bug th qt
This commit is contained in:
@@ -141,8 +141,12 @@ class Component(metaclass=PoolMeta):
|
||||
|
||||
def get_quota_purchase(self, name):
|
||||
if self.line:
|
||||
if self.line.quantity:
|
||||
return round(self.line.quantity_theorical / (self.nbdays if self.nbdays > 0 else 1),5)
|
||||
quantity = getattr(self.line, 'quantity_theorical', None)
|
||||
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):
|
||||
"Pricing"
|
||||
|
||||
@@ -105,8 +105,12 @@ class Component(metaclass=PoolMeta):
|
||||
|
||||
def get_quota_sale(self, name):
|
||||
if self.sale_line:
|
||||
if self.sale_line.quantity:
|
||||
return round(self.sale_line.quantity_theorical / (self.nbdays if self.nbdays > 0 else 1),4)
|
||||
quantity = getattr(self.sale_line, 'quantity_theorical', None)
|
||||
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):
|
||||
"Pricing"
|
||||
|
||||
@@ -184,6 +184,30 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(
|
||||
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):
|
||||
'sale and purchase trader/operator fields are filtered by TRADER/OPERATOR categories'
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
Reference in New Issue
Block a user