Actualización de las pruebas del modulo
This commit is contained in:
51
invoice.py
51
invoice.py
@@ -1,10 +1,10 @@
|
||||
# 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.pool import PoolMeta
|
||||
from trytond.model import fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.model.exceptions import ValidationError
|
||||
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
class Invoice(metaclass=PoolMeta):
|
||||
'Account Invoice'
|
||||
@@ -12,28 +12,31 @@ class Invoice(metaclass=PoolMeta):
|
||||
|
||||
_states = {
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}
|
||||
}
|
||||
|
||||
account_analytic = fields.Many2One(
|
||||
'analytic_account.account', 'Analytic Account',
|
||||
domain=[('type', '=', 'normal')],
|
||||
states=_states)
|
||||
|
||||
|
||||
account_analytic = fields.Many2One('analytic_account.account', 'Analytic Account',
|
||||
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
|
||||
'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:
|
||||
if self.invoice and self.invoice.account_analytic:
|
||||
self.analytic_accounts += (
|
||||
{'root': self.invoice.account_analytic.root,
|
||||
'account': self.invoice.account_analytic},)
|
||||
except Exception as e:
|
||||
raise ValidationError(f"Se produjo un error: {e}")
|
||||
|
||||
Reference in New Issue
Block a user