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.

35 lines
1.2 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(required=True, index=True,)
  9. account_id = fields.Many2one(
  10. comodel_name="account.account",
  11. string="Account",
  12. required=True,
  13. help="The account of the forecast line is only for informative purpose",
  14. )
  15. partner_id = fields.Many2one(comodel_name="res.partner", string="Partner",)
  16. name = fields.Char(required=True, default="/",)
  17. balance = fields.Float(required=True,)
  18. company_id = fields.Many2one(
  19. "res.company",
  20. string="Company",
  21. required=True,
  22. default=lambda self: self.env.user.company_id.id,
  23. index=True,
  24. )
  25. @api.constrains("company_id", "account_id")
  26. def _check_company_id_account_id(self):
  27. if self.filtered(lambda x: x.company_id != x.account_id.company_id):
  28. raise ValidationError(
  29. _("The Company and the Company of the Account must be the same.")
  30. )