Correction cron faircot
This commit is contained in:
@@ -1209,8 +1209,9 @@ class SaleLine(metaclass=PoolMeta):
|
||||
unit_factor = Decimal(1)
|
||||
if self.linked_unit:
|
||||
source_unit = getattr(self, 'unit', None)
|
||||
if not source_unit and self.product:
|
||||
source_unit = self.product.sale_uom
|
||||
product = getattr(self, 'product', None)
|
||||
if not source_unit and product:
|
||||
source_unit = product.sale_uom
|
||||
if not source_unit:
|
||||
return factor
|
||||
Uom = Pool().get('product.uom')
|
||||
|
||||
@@ -990,7 +990,6 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
sale_line.linked_currency = 1
|
||||
sale_line.linked_unit = Uom.get_by_name(sell_price_unit)
|
||||
sale_line.linked_price = round(sell_price,4)
|
||||
sale_line.unit_price = sale_line.get_price_linked_currency()
|
||||
else:
|
||||
sale.currency = Currency.get_by_name(sell_price_currency)
|
||||
sale_line.unit_price = round(sell_price,4)
|
||||
@@ -1003,6 +1002,8 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
sale_line.product = Product.get_by_name('BRAZIL COTTON')
|
||||
logger.info("PRODUCT:%s",sale_line.product)
|
||||
sale_line.unit = Uom.get_by_name(lot_unit)
|
||||
if sell_price_currency == 'USC':
|
||||
sale_line.unit_price = sale_line.get_price_linked_currency()
|
||||
sale_line.price_type = 'priced'
|
||||
sale_line.created_by_code = False
|
||||
sale_line.note = dec_key
|
||||
|
||||
@@ -258,6 +258,17 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
line.compute_unit_price(),
|
||||
Decimal('123.45'))
|
||||
|
||||
def test_sale_line_linked_unit_factor_keeps_currency_factor_without_product(self):
|
||||
'linked price conversion does not crash when automation builds a sale line before setting product'
|
||||
SaleLine = Pool().get('sale.line')
|
||||
line = SaleLine()
|
||||
line.enable_linked_currency = True
|
||||
line.linked_currency = Mock(factor=Decimal('2'))
|
||||
line.linked_unit = Mock()
|
||||
line.unit = None
|
||||
|
||||
self.assertEqual(line._get_linked_unit_factor(), Decimal('2'))
|
||||
|
||||
def test_purchase_line_default_pricing_rule_comes_from_configuration(self):
|
||||
'purchase line pricing_rule defaults to the purchase_trade singleton value'
|
||||
PurchaseLine = Pool().get('purchase.line')
|
||||
|
||||
Reference in New Issue
Block a user