Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
f695d853 by Cédric Krier at 2023-07-22T18:53:50+02:00
Copy pattern of production lead time before modification
We should not modify the caller mutable structure.
- - - - -
0b0d4d11 by Cédric Krier at 2023-07-22T18:55:46+02:00
Replace on_change_with_planned_start_date of production
Since 74c33f2fe011, the method has been replaced by set_planned_start_date,
the pattern has been remove to stay only on compute_lead_time.
Closes #12423
- - - - -
4 changed files:
- modules/production/production.py
- modules/production_routing/production.py
- modules/sale_supply_production/sale.py
- modules/stock_supply_production/production.py
Changes:
=====================================
modules/production/production.py
=====================================
@@ -305,8 +305,7 @@
@fields.depends('product', 'bom')
def compute_lead_time(self, pattern=None):
- if pattern is None:
- pattern = {}
+ pattern = pattern.copy() if pattern is not None else {}
if self.product:
pattern.setdefault('bom', self.bom.id if self.bom else None)
for line in self.product.production_lead_times:
=====================================
modules/production_routing/production.py
=====================================
@@ -27,8 +27,7 @@
self.routing = None
@fields.depends('routing')
- def on_change_with_planned_start_date(self, pattern=None):
- if pattern is None:
- pattern = {}
+ def compute_lead_time(self, pattern=None):
+ pattern = pattern.copy() if pattern is not None else {}
pattern.setdefault(
'routing', self.routing.id if self.routing else None)
@@ -33,7 +32,6 @@
pattern.setdefault(
'routing', self.routing.id if self.routing else None)
- return super(Production, self).on_change_with_planned_start_date(
- pattern=pattern)
+ return super().compute_lead_time(pattern=pattern)
@classmethod
def compute_request(
=====================================
modules/sale_supply_production/sale.py
=====================================
@@ -28,8 +28,7 @@
production = line.get_production(product_quantities)
if not production:
continue
- production.planned_start_date = (
- production.on_change_with_planned_start_date())
+ production.set_planned_start_date()
productions.append(production)
assert not line.productions
return productions
=====================================
modules/stock_supply_production/production.py
=====================================
@@ -142,8 +142,7 @@
(warehouse.id, product.id))
req = cls.compute_request(product, warehouse,
quantity, date, company, order_point)
- req.planned_start_date = (
- req.on_change_with_planned_start_date())
+ req.set_planned_start_date()
requests.append(req)
cls.save(requests)
cls.set_moves(requests)
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/compare/5c48c3defc0b23589ed993ab27874d5271c64d10...0b0d4d1106f00f83583c3c75cb16b73ad5e8451d
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/compare/5c48c3defc0b23589ed993ab27874d5271c64d10...0b0d4d1106f00f83583c3c75cb16b73ad5e8451d
You're receiving this email because of your account on foss.heptapod.net.