Fix: Correccion Tests

This commit is contained in:
Rodia 2025-01-25 22:14:29 -05:00
parent b3b74c1f69
commit 05bcb54779
4 changed files with 37 additions and 13 deletions

View File

@ -1,9 +1,10 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of # This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms. # this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields from trytond.model import ModelView, ModelSQL, fields
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.modules.currency.fields import Monetary from trytond.modules.currency.fields import Monetary
from trytond.modules.product import price_digits from trytond.modules.product import price_digits
from trytond.pyson import Eval
from decimal import Decimal from decimal import Decimal
@ -27,19 +28,18 @@ class OrderLine(ModelView, ModelSQL):
"Order Line" "Order Line"
__name__ = 'order.line' __name__ = 'order.line'
company = fields.Many2One(
'company.company', "Company", required=True)
order = fields.Many2One( order = fields.Many2One(
'sale.order', "Sale" 'sale.order', "Sale"
) )
currency = fields.Many2One(
'currency.currency', 'Currency', required=True)
product = fields.Many2One( product = fields.Many2One(
'product.product', 'Product', required=True 'product.product', 'Product', required=True
) )
unit = fields.Many2One( unit = fields.Many2One(
'product.uom', 'Unit', 'product.uom', 'Unit')
domain=[
('category', '=', Eval('product_uom_category')),
],
depends=['product_uom_category']
)
product_uom_category = fields.Function( product_uom_category = fields.Function(
fields.Many2One('product.uom.category', 'Product UOM Category'), fields.Many2One('product.uom.category', 'Product UOM Category'),
'on_change_with_product_uom_category' 'on_change_with_product_uom_category'
@ -52,9 +52,23 @@ class OrderLine(ModelView, ModelSQL):
) )
total_amount = fields.Function( total_amount = fields.Function(
Monetary("Total Amount", currency='currency', digits='currency'), Monetary("Total Amount", currency='currency', digits='currency'),
'get_total_amount' 'on_change_with_total_amount'
) )
@staticmethod
def default_company():
return Transaction().context.get('company')
@classmethod
def default_currency(cls, **pattern):
pool = Pool()
Company = pool.get('company.company')
company = pattern.get('company')
if not company:
company = cls.default_company()
if company:
return Company(company).currency.id
@fields.depends('product') @fields.depends('product')
def on_change_with_product_uom_category(self, name=None): def on_change_with_product_uom_category(self, name=None):
if self.product: if self.product:
@ -62,9 +76,8 @@ class OrderLine(ModelView, ModelSQL):
return None return None
@fields.depends('quantity', 'unitprice') @fields.depends('quantity', 'unitprice')
def on_change_with_total_amount(self): def on_change_with_total_amount(self, name=None):
total_amount = self.unitprice * Decimal(self.quantity) if self.unitprice and self.quantity:
return total_amount total_amount = self.unitprice * Decimal(self.quantity)
def get_total_amount(self): return total_amount
return self.on_change_with_total_amount()

View File

@ -5,3 +5,4 @@ depends:
party party
product product
xml: xml:
sale_order.xml

5
view/line_form.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
</form>

5
view/line_tree.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
</tree>