From facd627f5e8dbc10dc497681e3cc21544ca34231 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Sun, 19 Jul 2026 19:30:28 +0200 Subject: [PATCH] Faircot cron --- ir/ui/tree.rng | 9 +++++++++ modules/automation/cron.py | 9 +++++++-- .../freight_booking_shipment_report_tree.xml | 3 ++- modules/purchase_trade/lot.py | 3 +++ modules/purchase_trade/tests/test_module.py | 20 +++++++++++++++++++ 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/ir/ui/tree.rng b/ir/ui/tree.rng index 4e15e90..bcd6ef9 100755 --- a/ir/ui/tree.rng +++ b/ir/ui/tree.rng @@ -117,6 +117,7 @@ widget binary + badge boolean callto char @@ -145,6 +146,14 @@ + + + + badge_colors + + + + diff --git a/modules/automation/cron.py b/modules/automation/cron.py index 262d731..1da468a 100644 --- a/modules/automation/cron.py +++ b/modules/automation/cron.py @@ -252,7 +252,10 @@ class AutomationCron(ModelSQL, ModelView): logger.info( "Shipment %s existe deja sans lots, verification freight_booking_lots", si_number) - inv_date, inv_nb = shipment._create_lots_from_fintrade() + with Transaction().set_context( + _purchase_trade_skip_physical_lot_tolerance_warning=True): + inv_date, inv_nb = ( + shipment._create_lots_from_fintrade()) shipment = ShipmentIn(shipment.id) if shipment.incoming_moves: shipment.controller = shipment.get_controller() @@ -342,7 +345,9 @@ class AutomationCron(ModelSQL, ModelView): shipment.etad = shipment.bl_date + timedelta(days=20) ShipmentIn.save([shipment]) - inv_date, inv_nb = shipment._create_lots_from_fintrade() + with Transaction().set_context( + _purchase_trade_skip_physical_lot_tolerance_warning=True): + inv_date, inv_nb = shipment._create_lots_from_fintrade() shipment.controller = shipment.get_controller() shipment.controller_target = controller shipment.create_fee(shipment.controller) diff --git a/modules/automation/view/freight_booking_shipment_report_tree.xml b/modules/automation/view/freight_booking_shipment_report_tree.xml index e1001cc..1a4714b 100644 --- a/modules/automation/view/freight_booking_shipment_report_tree.xml +++ b/modules/automation/view/freight_booking_shipment_report_tree.xml @@ -1,6 +1,7 @@ - + diff --git a/modules/purchase_trade/lot.py b/modules/purchase_trade/lot.py index 19a9ce8..1e182e5 100755 --- a/modules/purchase_trade/lot.py +++ b/modules/purchase_trade/lot.py @@ -1996,6 +1996,9 @@ class LotQt( @classmethod def _warn_physical_lot_tolerance(cls, lqt, vlots): + if Transaction().context.get( + '_purchase_trade_skip_physical_lot_tolerance_warning'): + return Warning = Pool().get('res.user.warning') for line in cls._affected_lines_for_lqt(lqt): theoretical = cls._line_theoretical_quantity(line) diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py index 7b909ec..c9b6ac0 100644 --- a/modules/purchase_trade/tests/test_module.py +++ b/modules/purchase_trade/tests/test_module.py @@ -9223,6 +9223,26 @@ description patch.object(lot_module.LotQt, 'search', return_value=[]): lot_module.LotQt.match_lots([purchase_lot], []) + def test_physical_lot_tolerance_warning_can_be_skipped_by_context(self): + 'physical lot tolerance warning can be skipped for automation cron' + line = Mock( + purchase=Mock(number='P-1'), + sale=None, + id=12, + quantity_theorical=Decimal('100'), + tol_max=Decimal('0'), + inherit_tol=False, + unit=None, + lots=[], + ) + lqt = Mock(lot_p=Mock(line=line), lot_s=None) + physical_lot = Mock(lot_quantity=Decimal('120'), lot_unit_line=None) + + with Transaction().set_context( + _purchase_trade_skip_physical_lot_tolerance_warning=True): + lot_module.LotQt._warn_physical_lot_tolerance( + lqt, [physical_lot]) + def test_lot_matching_gauge_uses_entered_quantity_to_match(self): 'go to matching gauge projects tolerance from qt to match' matching_lot = lot_module.LotMatchingLot()