This commit is contained in:
2026-05-25 11:15:50 +02:00
parent 55f342f106
commit 7a39754a63
6 changed files with 21 additions and 10 deletions

View File

@@ -1247,10 +1247,14 @@ class LotQt(
getattr(line, 'quantity_theorical', None)
or getattr(line, 'quantity', None)
or 0))
targeted = getattr(line, 'targeted_qt', None)
if targeted in (None, ''):
targeted = theoretical
tol_min = cls._matching_line_tolerance_percent(line, 'tol_min')
tol_max = cls._matching_line_tolerance_percent(line, 'tol_max')
return {
'lot_theoretical_qt': theoretical,
'lot_targeted_qt': Decimal(str(targeted or 0)),
'lot_tol_min': tol_min,
'lot_tol_max': tol_max,
'lot_tolerance_min': -tol_min,
@@ -3157,6 +3161,7 @@ class LotMatchingLot(ModelView):
lot_product = fields.Many2One('product.product',"Product",readonly=True)
lot_quantity = fields.Numeric("Qt",readonly=True)
lot_theoretical_qt = fields.Numeric("Theoretical Qt", readonly=True)
lot_targeted_qt = fields.Numeric("Targeted Qt", readonly=True)
lot_already_matched_qt = fields.Numeric("Already matched", readonly=True)
lot_qt_min = fields.Numeric("Qt min", readonly=True)
lot_qt_max = fields.Numeric("Qt max", readonly=True)

View File

@@ -280,7 +280,7 @@ class Purchase(metaclass=PoolMeta):
tolerance_used = fields.Function(
fields.Numeric("Tolerance used"), 'get_tolerance_used')
tolerance_option = fields.Selection([
('no_option', "No option"),
('', ''),
('buyer_option', "Buyer's option"),
('seller_option', "Seller's option"),
], "Tolerance option")
@@ -408,7 +408,7 @@ class Purchase(metaclass=PoolMeta):
@classmethod
def default_tolerance_option(cls):
return 'no_option'
return ''
def _line_quantity_in_unit(self, quantity, from_unit, to_unit):
if not from_unit or not to_unit or from_unit == to_unit:

View File

@@ -252,7 +252,7 @@ class Sale(metaclass=PoolMeta):
tolerance_used = fields.Function(
fields.Numeric("Tolerance used"), 'get_tolerance_used')
tolerance_option = fields.Selection([
('no_option', "No option"),
('', ''),
('buyer_option', "Buyer's option"),
('seller_option', "Seller's option"),
], "Tolerance option")
@@ -372,7 +372,7 @@ class Sale(metaclass=PoolMeta):
@classmethod
def default_tolerance_option(cls):
return 'no_option'
return ''
def _line_quantity_in_unit(self, quantity, from_unit, to_unit):
if not from_unit or not to_unit or from_unit == to_unit:

View File

@@ -1776,13 +1776,13 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual(
Purchase.operator.domain, [('categories.name', '=', 'OPERATOR')])
def test_sale_and_purchase_tolerance_option_defaults_to_no_option(self):
'sale and purchase tolerance option defaults to no option'
def test_sale_and_purchase_tolerance_option_defaults_to_empty(self):
'sale and purchase tolerance option defaults to empty'
Sale = Pool().get('sale.sale')
Purchase = Pool().get('purchase.purchase')
self.assertEqual(Sale.default_tolerance_option(), 'no_option')
self.assertEqual(Purchase.default_tolerance_option(), 'no_option')
self.assertEqual(Sale.default_tolerance_option(), '')
self.assertEqual(Purchase.default_tolerance_option(), '')
def test_sale_line_basis_price_and_progress_use_manual_summary_without_component(self):
'sale line basis values use manual summary rows even without a component'
@@ -3219,14 +3219,16 @@ class PurchaseTradeTestCase(ModuleTestCase):
id=101,
line=Mock(
purchase=purchase, inherit_tol=False,
quantity_theorical=Decimal('100'), tol_min=0, tol_max=0),
quantity_theorical=Decimal('100'),
targeted_qt=Decimal('96'), tol_min=0, tol_max=0),
sale_line=None,
lot_type='virtual', lot_product=product)
sale_lot = Mock(
id=102, line=None,
sale_line=Mock(
sale=sale, inherit_tol=False,
quantity_theorical=Decimal('80'), tol_min=0, tol_max=0),
quantity_theorical=Decimal('80'),
targeted_qt=Decimal('84'), tol_min=0, tol_max=0),
lot_type='virtual', lot_product=product)
matched_sale_lot = Mock(
id=103, line=None,
@@ -3274,11 +3276,13 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual(len(result['lot_s']), 1)
self.assertEqual(result['lot_p'][0]['lot_r_id'], 1)
self.assertEqual(result['lot_p'][0]['lot_quantity'], Decimal('100'))
self.assertEqual(result['lot_p'][0]['lot_targeted_qt'], Decimal('96'))
self.assertEqual(result['lot_p'][0]['lot_qt_min'], Decimal('100.00000'))
self.assertEqual(result['lot_p'][0]['lot_qt_max'], Decimal('100.00000'))
self.assertEqual(result['lot_p'][0]['lot_cp'], 20)
self.assertEqual(result['lot_s'][0]['lot_r_id'], 2)
self.assertEqual(result['lot_s'][0]['lot_quantity'], Decimal('80'))
self.assertEqual(result['lot_s'][0]['lot_targeted_qt'], Decimal('84'))
self.assertEqual(result['lot_s'][0]['lot_qt_min'], Decimal('80.00000'))
self.assertEqual(result['lot_s'][0]['lot_qt_max'], Decimal('80.00000'))
self.assertEqual(result['lot_s'][0]['lot_cp'], 40)

View File

@@ -5,6 +5,7 @@
<field name="lot_cp"/>
<field name="lot_product"/>
<field name="lot_quantity"/>
<field name="lot_targeted_qt"/>
<field name="lot_qt_min"/>
<field name="lot_qt_max"/>
<field name="lot_theoretical_qt" tree_invisible="1"/>

View File

@@ -5,6 +5,7 @@
<field name="lot_cp"/>
<field name="lot_product"/>
<field name="lot_quantity"/>
<field name="lot_targeted_qt"/>
<field name="lot_qt_min"/>
<field name="lot_qt_max"/>
<field name="lot_theoretical_qt" tree_invisible="1"/>