01.04.26
This commit is contained in:
@@ -1225,9 +1225,14 @@ class Line(metaclass=PoolMeta):
|
|||||||
return None
|
return None
|
||||||
unit_factor = Decimal(1)
|
unit_factor = Decimal(1)
|
||||||
if self.linked_unit:
|
if self.linked_unit:
|
||||||
|
source_unit = getattr(self, 'unit', None)
|
||||||
|
if not source_unit and self.product:
|
||||||
|
source_unit = self.product.purchase_uom or self.product.default_uom
|
||||||
|
if not source_unit:
|
||||||
|
return factor
|
||||||
Uom = Pool().get('product.uom')
|
Uom = Pool().get('product.uom')
|
||||||
unit_factor = Decimal(str(
|
unit_factor = Decimal(str(
|
||||||
Uom.compute_qty(self.unit, float(1), self.linked_unit) or 0))
|
Uom.compute_qty(source_unit, float(1), self.linked_unit) or 0))
|
||||||
return factor * unit_factor
|
return factor * unit_factor
|
||||||
|
|
||||||
def _linked_to_line_price(self, price):
|
def _linked_to_line_price(self, price):
|
||||||
@@ -1304,7 +1309,8 @@ class Line(metaclass=PoolMeta):
|
|||||||
return self.get_price()
|
return self.get_price()
|
||||||
|
|
||||||
@fields.depends(
|
@fields.depends(
|
||||||
'type', 'quantity', 'unit_price', 'purchase', '_parent_purchase.currency',
|
'type', 'quantity', 'unit_price', 'unit', 'product',
|
||||||
|
'purchase', '_parent_purchase.currency',
|
||||||
'premium', 'enable_linked_currency', 'linked_currency', 'linked_unit')
|
'premium', 'enable_linked_currency', 'linked_currency', 'linked_unit')
|
||||||
def on_change_with_amount(self):
|
def on_change_with_amount(self):
|
||||||
if (self.type == 'line'
|
if (self.type == 'line'
|
||||||
@@ -1318,7 +1324,10 @@ class Line(metaclass=PoolMeta):
|
|||||||
return amount
|
return amount
|
||||||
return Decimal(0)
|
return Decimal(0)
|
||||||
|
|
||||||
@fields.depends(methods=['on_change_with_unit_price', 'on_change_with_amount'])
|
@fields.depends(
|
||||||
|
'unit', 'product', 'price_type', 'enable_linked_currency',
|
||||||
|
'linked_currency', 'linked_unit', 'linked_price', 'premium',
|
||||||
|
methods=['on_change_with_unit_price', 'on_change_with_amount'])
|
||||||
def _recompute_trade_price_fields(self):
|
def _recompute_trade_price_fields(self):
|
||||||
self.unit_price = self.on_change_with_unit_price()
|
self.unit_price = self.on_change_with_unit_price()
|
||||||
self.amount = self.on_change_with_amount()
|
self.amount = self.on_change_with_amount()
|
||||||
|
|||||||
@@ -778,9 +778,14 @@ class SaleLine(metaclass=PoolMeta):
|
|||||||
return None
|
return None
|
||||||
unit_factor = Decimal(1)
|
unit_factor = Decimal(1)
|
||||||
if self.linked_unit:
|
if self.linked_unit:
|
||||||
|
source_unit = getattr(self, 'unit', None)
|
||||||
|
if not source_unit and self.product:
|
||||||
|
source_unit = self.product.sale_uom
|
||||||
|
if not source_unit:
|
||||||
|
return factor
|
||||||
Uom = Pool().get('product.uom')
|
Uom = Pool().get('product.uom')
|
||||||
unit_factor = Decimal(str(
|
unit_factor = Decimal(str(
|
||||||
Uom.compute_qty(self.unit, float(1), self.linked_unit) or 0))
|
Uom.compute_qty(source_unit, float(1), self.linked_unit) or 0))
|
||||||
return factor * unit_factor
|
return factor * unit_factor
|
||||||
|
|
||||||
def _linked_to_line_price(self, price):
|
def _linked_to_line_price(self, price):
|
||||||
@@ -852,7 +857,8 @@ class SaleLine(metaclass=PoolMeta):
|
|||||||
return self.get_price()
|
return self.get_price()
|
||||||
|
|
||||||
@fields.depends(
|
@fields.depends(
|
||||||
'type', 'quantity', 'unit_price', 'sale', '_parent_sale.currency',
|
'type', 'quantity', 'unit_price', 'unit', 'product',
|
||||||
|
'sale', '_parent_sale.currency',
|
||||||
'premium', 'enable_linked_currency', 'linked_currency', 'linked_unit')
|
'premium', 'enable_linked_currency', 'linked_currency', 'linked_unit')
|
||||||
def on_change_with_amount(self):
|
def on_change_with_amount(self):
|
||||||
if self.type == 'line':
|
if self.type == 'line':
|
||||||
@@ -864,7 +870,10 @@ class SaleLine(metaclass=PoolMeta):
|
|||||||
return amount
|
return amount
|
||||||
return Decimal(0)
|
return Decimal(0)
|
||||||
|
|
||||||
@fields.depends(methods=['on_change_with_unit_price', 'on_change_with_amount'])
|
@fields.depends(
|
||||||
|
'unit', 'product', 'price_type', 'enable_linked_currency',
|
||||||
|
'linked_currency', 'linked_unit', 'linked_price', 'premium',
|
||||||
|
methods=['on_change_with_unit_price', 'on_change_with_amount'])
|
||||||
def _recompute_trade_price_fields(self):
|
def _recompute_trade_price_fields(self):
|
||||||
self.unit_price = self.on_change_with_unit_price()
|
self.unit_price = self.on_change_with_unit_price()
|
||||||
self.amount = self.on_change_with_amount()
|
self.amount = self.on_change_with_amount()
|
||||||
|
|||||||
Reference in New Issue
Block a user