You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

  1. # Copyright 2019 ADHOC SA
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import _, api, fields, models
  4. from odoo.exceptions import ValidationError
  5. class MisCashFlowForecastLine(models.Model):
  6. _name = "mis.cash_flow.forecast_line"
  7. _description = "MIS Cash Flow Forecast Line"
  8. date = fields.Date(
  9. required=True,
  10. index=True,
  11. )
  12. account_id = fields.Many2one(
  13. comodel_name="account.account",
  14. string="Account",
  15. required=True,
  16. help="The account of the forecast line is only for informative purpose",
  17. )
  18. partner_id = fields.Many2one(
  19. comodel_name="res.partner",
  20. string="Partner",
  21. )
  22. name = fields.Char(
  23. required=True,
  24. default="/",
  25. )
  26. balance = fields.Float(
  27. required=True,
  28. )
  29. company_id = fields.Many2one(
  30. "res.company",
  31. string="Company",
  32. required=True,
  33. default=lambda self: self.env.user.company_id.id,
  34. index=True,
  35. )
  36. @api.constrains("company_id", "account_id")
  37. def _check_company_id_account_id(self):
  38. if self.filtered(lambda x: x.company_id != x.account_id.company_id):
  39. raise ValidationError(
  40. _("The Company and the Company of the Account must be the same.")
  41. )