bug th qt
This commit is contained in:
@@ -139,10 +139,14 @@ class Component(metaclass=PoolMeta):
|
|||||||
if self.line:
|
if self.line:
|
||||||
return self.line.unit
|
return self.line.unit
|
||||||
|
|
||||||
def get_quota_purchase(self, name):
|
def get_quota_purchase(self, name):
|
||||||
if self.line:
|
if self.line:
|
||||||
if self.line.quantity:
|
quantity = getattr(self.line, 'quantity_theorical', None)
|
||||||
return round(self.line.quantity_theorical / (self.nbdays if self.nbdays > 0 else 1),5)
|
if quantity is None:
|
||||||
|
quantity = getattr(self.line, 'quantity', None)
|
||||||
|
if quantity is not None:
|
||||||
|
nbdays = self.nbdays if self.nbdays and self.nbdays > 0 else 1
|
||||||
|
return round(Decimal(quantity) / nbdays, 5)
|
||||||
|
|
||||||
class Pricing(metaclass=PoolMeta):
|
class Pricing(metaclass=PoolMeta):
|
||||||
"Pricing"
|
"Pricing"
|
||||||
|
|||||||
@@ -103,10 +103,14 @@ class Component(metaclass=PoolMeta):
|
|||||||
if self.sale_line:
|
if self.sale_line:
|
||||||
return self.sale_line.unit
|
return self.sale_line.unit
|
||||||
|
|
||||||
def get_quota_sale(self, name):
|
def get_quota_sale(self, name):
|
||||||
if self.sale_line:
|
if self.sale_line:
|
||||||
if self.sale_line.quantity:
|
quantity = getattr(self.sale_line, 'quantity_theorical', None)
|
||||||
return round(self.sale_line.quantity_theorical / (self.nbdays if self.nbdays > 0 else 1),4)
|
if quantity is None:
|
||||||
|
quantity = getattr(self.sale_line, 'quantity', None)
|
||||||
|
if quantity is not None:
|
||||||
|
nbdays = self.nbdays if self.nbdays and self.nbdays > 0 else 1
|
||||||
|
return round(Decimal(quantity) / nbdays, 4)
|
||||||
|
|
||||||
class Pricing(metaclass=PoolMeta):
|
class Pricing(metaclass=PoolMeta):
|
||||||
"Pricing"
|
"Pricing"
|
||||||
|
|||||||
@@ -184,6 +184,30 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
PurchaseLine.default_pricing_rule(), 'Default pricing rule')
|
PurchaseLine.default_pricing_rule(), 'Default pricing rule')
|
||||||
|
|
||||||
|
def test_component_quota_uses_quantity_fallback_when_theoretical_is_missing(self):
|
||||||
|
'component quota does not crash when theoretical quantity is still empty'
|
||||||
|
SaleComponent = Pool().get('pricing.component')
|
||||||
|
PurchaseComponent = Pool().get('pricing.component')
|
||||||
|
|
||||||
|
sale_component = SaleComponent()
|
||||||
|
sale_component.nbdays = None
|
||||||
|
sale_component.sale_line = Mock(
|
||||||
|
quantity=Decimal('12'),
|
||||||
|
quantity_theorical=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
purchase_component = PurchaseComponent()
|
||||||
|
purchase_component.nbdays = None
|
||||||
|
purchase_component.line = Mock(
|
||||||
|
quantity=Decimal('15'),
|
||||||
|
quantity_theorical=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(sale_component.get_quota_sale('quota_sale'), Decimal('12.0000'))
|
||||||
|
self.assertEqual(
|
||||||
|
purchase_component.get_quota_purchase('quota'),
|
||||||
|
Decimal('15.00000'))
|
||||||
|
|
||||||
def test_sale_and_purchase_trader_operator_domains_use_explicit_categories(self):
|
def test_sale_and_purchase_trader_operator_domains_use_explicit_categories(self):
|
||||||
'sale and purchase trader/operator fields are filtered by TRADER/OPERATOR categories'
|
'sale and purchase trader/operator fields are filtered by TRADER/OPERATOR categories'
|
||||||
Sale = Pool().get('sale.sale')
|
Sale = Pool().get('sale.sale')
|
||||||
|
|||||||
Reference in New Issue
Block a user