Actualización de las pruebas del modulo

This commit is contained in:
root
2024-01-03 16:20:28 +00:00
parent 90f641766a
commit 554bf84e53
6 changed files with 73 additions and 65 deletions

26
sale.py
View File

@@ -1,10 +1,9 @@
# 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.pool import PoolMeta
from trytond.model import fields
from trytond.model.exceptions import ValidationError
from trytond.exceptions import UserError
class Sale(metaclass=PoolMeta):
'Sale Analytic Operation'
@@ -16,11 +15,10 @@ class Sale(metaclass=PoolMeta):
('type', '=', 'normal'),
])
class SaleLine(metaclass=PoolMeta):
'Sale Line Analytic Operation'
__name__ = 'sale.line'
__name__ = 'sale.line'
@fields.depends('product', 'unit', 'sale',
'_parent_sale.party', '_parent_sale.invoice_party',
@@ -30,7 +28,7 @@ class SaleLine(metaclass=PoolMeta):
def on_change_product(self):
if not self.product:
return
party = None
if self.sale:
party = self.sale.invoice_party or self.sale.party
@@ -44,13 +42,13 @@ class SaleLine(metaclass=PoolMeta):
self.unit_price = self.compute_unit_price()
self.type = 'line'
self.amount = self.on_change_with_amount()
self.analytic_accounts = tuple()
try:
self.analytic_accounts += ({'root': self.sale.account_analytic.root,
'account': self.sale.account_analytic},)
except:
pass
self.analytic_accounts += (
{'root': self.sale.account_analytic.root,
'account': self.sale.account_analytic},)
except Exception as e:
raise ValidationError(f"Se produjo un error: {e}")