Actualización de las pruebas del modulo
This commit is contained in:
38
purchase.py
38
purchase.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 Purchase(metaclass=PoolMeta):
|
||||
'Purchase Analytic Operation'
|
||||
@@ -12,20 +12,25 @@ class Purchase(metaclass=PoolMeta):
|
||||
|
||||
_states = {
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}
|
||||
}
|
||||
|
||||
account_analytic = fields.Many2One(
|
||||
'analytic_account.account', 'Analytic Account', required=True,
|
||||
domain=[('type', '=', 'normal')],
|
||||
states=_states)
|
||||
|
||||
|
||||
account_analytic = fields.Many2One('analytic_account.account', 'Analytic Account', required=True,
|
||||
domain=[('type', '=', 'normal')],
|
||||
states=_states)
|
||||
class PurchaseLine(metaclass=PoolMeta):
|
||||
'Purchase Line Analytic Operation'
|
||||
__name__ = 'purchase.line'
|
||||
__name__ = 'purchase.line'
|
||||
|
||||
@fields.depends('product', 'unit', 'purchase',
|
||||
@fields.depends(
|
||||
'product', 'unit', 'purchase',
|
||||
'_parent_purchase.party', '_parent_purchase.invoice_party',
|
||||
'_parent_purchase.account_analytic', 'product_supplier',
|
||||
'analytic_accounts', methods=['compute_taxes', 'compute_unit_price',
|
||||
'_get_product_supplier_pattern'])
|
||||
'analytic_accounts',
|
||||
methods=['compute_taxes', 'compute_unit_price',
|
||||
'_get_product_supplier_pattern'])
|
||||
def on_change_product(self):
|
||||
if not self.product:
|
||||
return
|
||||
@@ -43,7 +48,7 @@ class PurchaseLine(metaclass=PoolMeta):
|
||||
self.unit = self.product.purchase_uom
|
||||
|
||||
product_suppliers = list(self.product.product_suppliers_used(
|
||||
**self._get_product_supplier_pattern()))
|
||||
**self._get_product_supplier_pattern()))
|
||||
if len(product_suppliers) == 1:
|
||||
self.product_supplier, = product_suppliers
|
||||
elif (self.product_supplier
|
||||
@@ -57,7 +62,8 @@ class PurchaseLine(metaclass=PoolMeta):
|
||||
|
||||
self.analytic_accounts = tuple()
|
||||
try:
|
||||
self.analytic_accounts += ({'root': self.purchase.account_analytic.root,
|
||||
'account': self.purchase.account_analytic},)
|
||||
except:
|
||||
pass
|
||||
self.analytic_accounts += (
|
||||
{'root': self.purchase.account_analytic.root,
|
||||
'account': self.purchase.account_analytic},)
|
||||
except Exception as e:
|
||||
raise ValidationError(f"Se produjo un error: {e}")
|
||||
|
||||
Reference in New Issue
Block a user