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.

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