Set the default locations for stock move when production is set
Closes #14665
This commit is contained in:
@@ -71,7 +71,8 @@ class Move(metaclass=PoolMeta):
|
||||
'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 @@ class Move(metaclass=PoolMeta):
|
||||
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 @@ class Move(metaclass=PoolMeta):
|
||||
'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
|
||||
|
||||
@@ -46,8 +46,6 @@ Make a production::
|
||||
|
||||
>>> 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)
|
||||
|
||||
@@ -51,14 +51,10 @@ Make a production::
|
||||
|
||||
>>> 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
|
||||
|
||||
@@ -68,8 +68,6 @@ Make a production with 2 unused component::
|
||||
>>> 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::
|
||||
|
||||
@@ -56,8 +56,6 @@ Run the production::
|
||||
>>> 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 @@ Create outputs including waste products::
|
||||
>>> 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
|
||||
|
||||
Reference in New Issue
Block a user