# This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. from trytond.pool import Pool, PoolMeta from trytond.model import ModelView, ModelSQL, fields from trytond.pyson import Eval from trytond.exceptions import UserError class Invoice(metaclass=PoolMeta): 'Account Invoice' __name__ = 'account.invoice' _states = { 'readonly': Eval('state') != 'draft', } account_analytic = fields.Many2One('analytic_account.account', 'Analytic Account', required=True, domain=[('type', '=', 'normal')], states=_states) class InvoiceLine(metaclass=PoolMeta): 'Invoice Line' __name__ = 'account.invoice.line' @fields.depends('product', 'unit', '_parent_invoice.type', 'analytic_accounts', '_parent_invoice.party', 'party', 'invoice', 'invoice_type', '_parent_invoice.account_analytic', '_parent_invoice.invoice_date', '_parent_invoice.accounting_date','company', methods=['_get_tax_rule_pattern']) def on_change_product(self): super(InvoiceLine, self).on_change_product() self.analytic_accounts = tuple() try: self.analytic_accounts += ({'root': self.invoice.account_analytic.root, 'account': self.invoice.account_analytic},) except: pass