Show production on stock move form
issue11254 review384391002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Show production on stock move form
|
||||
* Add support for Python 3.10
|
||||
* Remove support for Python 3.6
|
||||
|
||||
|
||||
@@ -9,5 +9,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.message" id="msg_missing_product_list_price">
|
||||
<field name="text">The product "%(product)s" on production "%(production)s" does not have any list price defined.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_move_production_single">
|
||||
<field name="text">Move can not be used for production input and output.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from sql import Null
|
||||
|
||||
from trytond.model import Check, fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
||||
@@ -47,11 +49,23 @@ class Move(metaclass=PoolMeta):
|
||||
production_input = fields.Many2One('production', 'Production Input',
|
||||
readonly=True, select=True, ondelete='CASCADE',
|
||||
domain=[('company', '=', Eval('company'))],
|
||||
states={
|
||||
'invisible': ~Eval('production_input'),
|
||||
},
|
||||
depends=['company'])
|
||||
production_output = fields.Many2One('production', 'Production Output',
|
||||
readonly=True, select=True, ondelete='CASCADE',
|
||||
domain=[('company', '=', Eval('company'))],
|
||||
states={
|
||||
'invisible': ~Eval('production_output'),
|
||||
},
|
||||
depends=['company'])
|
||||
production = fields.Function(fields.Many2One(
|
||||
'production', "Production",
|
||||
states={
|
||||
'invisible': ~Eval('production'),
|
||||
}),
|
||||
'on_change_with_production')
|
||||
production_cost_price_updated = fields.Boolean(
|
||||
"Cost Price Updated", readonly=True,
|
||||
states={
|
||||
@@ -59,6 +73,26 @@ class Move(metaclass=PoolMeta):
|
||||
},
|
||||
depends=['production_input', 'state'])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
t = cls.__table__()
|
||||
cls._sql_constraints += [
|
||||
('production_single', Check(t, (
|
||||
(t.production_input == Null)
|
||||
| (t.production_output == Null))),
|
||||
'production.msg_stock_move_production_single'),
|
||||
]
|
||||
|
||||
@fields.depends(
|
||||
'production_input', '_parent_production_input.id',
|
||||
'production_output', '_parent_production_output.id')
|
||||
def on_change_with_production(self, name=None):
|
||||
if self.production_input:
|
||||
return self.production_input.id
|
||||
elif self.production_output:
|
||||
return self.production_output.id
|
||||
|
||||
def set_effective_date(self):
|
||||
if not self.effective_date and self.production_input:
|
||||
self.effective_date = self.production_input.effective_start_date
|
||||
|
||||
@@ -25,6 +25,12 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="action" ref="stock.wizard_open_product_quantities_by_warehouse"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="stock_move_view_form">
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit" ref="stock.move_view_form"/>
|
||||
<field name="name">stock_move_form</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
<data noupdate="1">
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="//field[@name='shipment']" position="after">
|
||||
<label name="production"/>
|
||||
<field name="production" colspan="3"/>
|
||||
</xpath>
|
||||
</data>
|
||||
Reference in New Issue
Block a user