@@ -1,3 +1,4 @@
|
||||
* Fill secondary unit from product customer
|
||||
* Remove support for Python 3.8
|
||||
* Add support for Python 3.13
|
||||
|
||||
|
||||
@@ -140,16 +140,19 @@ class Line(metaclass=PoolMeta):
|
||||
def set_secondary(cls, lines, name, value):
|
||||
pass
|
||||
|
||||
@fields.depends('secondary_unit',
|
||||
@fields.depends(
|
||||
'secondary_unit', 'product',
|
||||
methods=['on_change_with_secondary_quantity', '_secondary_record'])
|
||||
def on_change_product(self):
|
||||
super().on_change_product()
|
||||
secondary_record = self._secondary_record()
|
||||
if secondary_record and self.secondary_unit:
|
||||
if secondary_record:
|
||||
secondary_uom = secondary_record.sale_secondary_uom
|
||||
if secondary_uom:
|
||||
if self.secondary_unit and secondary_uom:
|
||||
if self.secondary_unit.category != secondary_uom.category:
|
||||
self.secondary_unit = None
|
||||
if not self.secondary_unit and secondary_record != self.product:
|
||||
self.secondary_unit = secondary_uom
|
||||
|
||||
if secondary_record:
|
||||
self.secondary_uom_factor = (
|
||||
|
||||
@@ -15,6 +15,7 @@ Activate modules::
|
||||
|
||||
>>> config = activate_modules([
|
||||
... 'sale_amendment',
|
||||
... 'sale_product_customer',
|
||||
... 'sale_secondary_unit',
|
||||
... 'account_invoice_secondary_unit',
|
||||
... 'stock_secondary_unit'],
|
||||
@@ -53,13 +54,20 @@ Create product::
|
||||
>>> template.type = 'goods'
|
||||
>>> template.salable = True
|
||||
>>> template.sale_secondary_uom = gr
|
||||
>>> template.sale_secondary_uom_factor = 200
|
||||
>>> template.sale_secondary_uom_factor = 100
|
||||
>>> template.sale_secondary_uom_rate
|
||||
0.005
|
||||
0.01
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
>>> product_customer = product.product_customers.new()
|
||||
>>> product_customer.party = customer
|
||||
>>> product_customer.sale_secondary_uom = gr
|
||||
>>> product_customer.sale_secondary_uom_factor = 200
|
||||
>>> product_customer.sale_secondary_uom_rate
|
||||
0.005
|
||||
>>> product.save()
|
||||
|
||||
Sale product::
|
||||
|
||||
@@ -75,6 +83,10 @@ Sale product::
|
||||
|
||||
Check secondary unit::
|
||||
|
||||
>>> assertEqual(line.secondary_unit, gr)
|
||||
>>> line.secondary_quantity
|
||||
2000.0
|
||||
>>> line.secondary_quantity = None
|
||||
>>> line.secondary_unit = kg
|
||||
>>> line.secondary_quantity
|
||||
2.0
|
||||
|
||||
Reference in New Issue
Block a user