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

# Copyright 2019 ADHOC SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models, api, _
from odoo.exceptions import ValidationError
class MisCashFlowForecastLine(models.Model):
_name = 'mis.cash_flow.forecast_line'
_description = 'MIS Cash Flow Forecast Line'
date = fields.Date(
required=True,
index=True,
)
account_id = fields.Many2one(
comodel_name='account.account',
string='Account',
required=True,
help='The account of the forecast line is only for informative '
'purpose',
)
name = fields.Char(
required=True,
default='/',
)
balance = fields.Float(
required=True,
)
company_id = fields.Many2one(
'res.company',
string='Company',
required=True,
default=lambda self: self.env.user.company_id.id,
index=True,
)
@api.multi
@api.constrains('company_id', 'account_id')
def _check_company_id_account_id(self):
if self.filtered(lambda x: x.company_id != x.account_id.company_id):
raise ValidationError(_(
'The Company and the Company of the Account must be the '
'same.'))