details: https://code.tryton.org/tryton/commit/42cf694cdab3
branch: default
user: Cédric Krier <[email protected]>
date: Tue Mar 10 14:54:48 2026 +0100
description:
Set the default locations for stock move when production is set
Closes #14665
diffstat:
modules/production/stock.py | 30 ++++++++++--
modules/production/tests/scenario_production_lot_number.rst | 2 -
modules/production/tests/scenario_production_lot_trace.rst | 4 -
modules/production/tests/scenario_production_set_cost.rst | 2 -
modules/production/tests/scenario_production_waste.rst | 5 --
5 files changed, 25 insertions(+), 18 deletions(-)
diffs (126 lines):
diff -r aa59b09a8b92 -r 42cf694cdab3 modules/production/stock.py
--- a/modules/production/stock.py Fri Mar 27 18:15:43 2026 +0100
+++ b/modules/production/stock.py Tue Mar 10 14:54:48 2026 +0100
@@ -71,7 +71,8 @@
'production', "Production",
states={
'invisible': ~Eval('production'),
- }),
+ },
+ depends=['production_input', 'production_output']),
'on_change_with_production', searcher='search_production')
production_cost_price_updated = fields.Boolean(
"Cost Price Updated", readonly=True,
@@ -92,10 +93,29 @@
cls._allow_modify_closed_period.add('production_cost_price_updated')
@fields.depends(
- 'production_output', '_parent_production_output.company',
- 'to_location')
+ 'production_input',
+ '_parent_production_input.warehouse',
+ '_parent_production_input.location',
+ 'from_location', 'to_location')
+ def on_change_production_input(self):
+ if self.production_input:
+ if not self.from_location:
+ self.from_location = self.production_input.picking_location
+ if not self.to_location:
+ self.to_location = self.production_input.location
+
+ @fields.depends(
+ 'production_output',
+ '_parent_production_output.company',
+ '_parent_production_output.warehouse',
+ '_parent_production_output.location',
+ 'from_location', 'to_location')
def on_change_production_output(self):
if self.production_output:
+ if not self.from_location:
+ self.from_location = self.production_output.location
+ if not self.to_location:
+ self.to_location = self.production_output.output_location
if self.production_output.company:
self.currency = self.production_output.company.currency
if self.to_location and self.to_location.type == 'lost_found':
@@ -117,9 +137,9 @@
'production_input', '_parent_production_input.id',
'production_output', '_parent_production_output.id')
def on_change_with_production(self, name=None):
- if self.production_input:
+ if self.production_input and self.production_input.id >= 0:
return self.production_input
- elif self.production_output:
+ elif self.production_output and self.production_output.id >= 0:
return self.production_output
@classmethod
diff -r aa59b09a8b92 -r 42cf694cdab3
modules/production/tests/scenario_production_lot_number.rst
--- a/modules/production/tests/scenario_production_lot_number.rst Fri Mar
27 18:15:43 2026 +0100
+++ b/modules/production/tests/scenario_production_lot_number.rst Tue Mar
10 14:54:48 2026 +0100
@@ -46,8 +46,6 @@
>>> production = Production()
>>> output = production.outputs.new()
- >>> output.from_location = production.location
- >>> output.to_location = production.warehouse.storage_location
>>> output.product = product
>>> output.quantity = 1
>>> output.unit_price = Decimal(0)
diff -r aa59b09a8b92 -r 42cf694cdab3
modules/production/tests/scenario_production_lot_trace.rst
--- a/modules/production/tests/scenario_production_lot_trace.rst Fri Mar
27 18:15:43 2026 +0100
+++ b/modules/production/tests/scenario_production_lot_trace.rst Tue Mar
10 14:54:48 2026 +0100
@@ -51,14 +51,10 @@
>>> production = Production()
>>> input = production.inputs.new()
- >>> input.from_location = production.warehouse.storage_location
- >>> input.to_location = production.location
>>> input.product = component
>>> input.lot = component_lot
>>> input.quantity = 1
>>> output = production.outputs.new()
- >>> output.from_location = production.location
- >>> output.to_location = production.warehouse.storage_location
>>> output.product = product
>>> output.lot = product_lot
>>> output.quantity = 1
diff -r aa59b09a8b92 -r 42cf694cdab3
modules/production/tests/scenario_production_set_cost.rst
--- a/modules/production/tests/scenario_production_set_cost.rst Fri Mar 27
18:15:43 2026 +0100
+++ b/modules/production/tests/scenario_production_set_cost.rst Tue Mar 10
14:54:48 2026 +0100
@@ -68,8 +68,6 @@
>>> output.quantity = 2
>>> output.unit_price = Decimal(0)
>>> output.currency = get_currency()
- >>> output.from_location = production.location
- >>> output.to_location = production.warehouse.storage_location
>>> production.click('do')
Check output price::
diff -r aa59b09a8b92 -r 42cf694cdab3
modules/production/tests/scenario_production_waste.rst
--- a/modules/production/tests/scenario_production_waste.rst Fri Mar 27
18:15:43 2026 +0100
+++ b/modules/production/tests/scenario_production_waste.rst Tue Mar 10
14:54:48 2026 +0100
@@ -56,8 +56,6 @@
>>> input = production.inputs.new()
>>> input.quantity = 20.0
>>> input.product = component
- >>> input.from_location = warehouse_loc.storage_location
- >>> input.to_location = production.location
>>> production.click('wait')
>>> production.click('assign_force')
>>> production.click('run')
@@ -67,14 +65,11 @@
>>> output = production.outputs.new()
>>> output.quantity = 1.0
>>> output.product = product
- >>> output.from_location = production.location
- >>> output.to_location = warehouse_loc.storage_location
>>> output.unit_price = Decimal('0')
>>> output.currency = production.company.currency
>>> waste_output = production.outputs.new()
>>> waste_output.quantity = 1.0
>>> waste_output.product = product
- >>> waste_output.from_location = production.location
>>> waste_output.to_location = lost_found_loc
>>> production.click('do')
>>> production.cost