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.

44 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 fields, models, api, _
  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 '
  17. 'purpose',
  18. )
  19. name = fields.Char(
  20. required=True,
  21. default='/',
  22. )
  23. balance = fields.Float(
  24. required=True,
  25. )
  26. company_id = fields.Many2one(
  27. 'res.company',
  28. string='Company',
  29. required=True,
  30. default=lambda self: self.env.user.company_id.id,
  31. index=True,
  32. )
  33. @api.multi
  34. @api.constrains('company_id', 'account_id')
  35. def _check_company_id_account_id(self):
  36. if self.filtered(lambda x: x.company_id != x.account_id.company_id):
  37. raise ValidationError(_(
  38. 'The Company and the Company of the Account must be the '
  39. 'same.'))