diff options
| author | Simon Lejeune <sle@openerp.com> | 2019-08-26 15:36:52 +0000 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2019-09-03 15:05:03 +0000 |
| commit | 96406dc2a9e06595961f6d4bec6b66f27b94e2ff (patch) | |
| tree | 4ba80b44ba48516836fdf36a48abaecc21069a82 /addons/mrp/wizard | |
| parent | 4a031781462d27bb35e1ad81c6d981da1b9f6f77 (diff) | |
[REF] mrp: multi company
Ensure proper domains are applied and enforced on relation fields thanks
to the `check_company` attributes.
Make sure unbuild have proper sequence for each companies.
The produce wizard and workorders company is the one of the production.
The BoM line company_id is the one of its bom_id.
Added some tests.
task-1985992
Diffstat (limited to 'addons/mrp/wizard')
| -rw-r--r-- | addons/mrp/wizard/mrp_product_produce.py | 7 | ||||
| -rw-r--r-- | addons/mrp/wizard/mrp_product_produce_views.xml | 13 | ||||
| -rw-r--r-- | addons/mrp/wizard/mrp_workcenter_block_view.xml | 1 | ||||
| -rw-r--r-- | addons/mrp/wizard/stock_warn_insufficient_qty.py | 5 |
4 files changed, 18 insertions, 8 deletions
diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py index c1a7dc1bba2..4e8947cb6b4 100644 --- a/addons/mrp/wizard/mrp_product_produce.py +++ b/addons/mrp/wizard/mrp_product_produce.py @@ -78,7 +78,8 @@ class MrpProductProduce(models.TransientModel): self.ensure_one() product_produce_wiz = self.env.ref('mrp.view_mrp_product_produce_wizard', False) self.finished_lot_id = self.env['stock.production.lot'].create({ - 'product_id': self.product_id.id + 'product_id': self.product_id.id, + 'company_id': self.production_id.company_id.id }) return { 'name': _('Produce'), @@ -94,6 +95,7 @@ class MrpProductProduce(models.TransientModel): """ Save the current wizard and go back to the MO. """ self.ensure_one() self._record_production() + self._check_company() return {'type': 'ir.actions.act_window_close'} def _get_todo(self, production): @@ -127,7 +129,8 @@ class MrpProductProduce(models.TransientModel): 'raw_material_production_id': self.production_id.id, 'group_id': self.production_id.procurement_group_id.id, 'origin': self.production_id.name, - 'state': 'confirmed' + 'state': 'confirmed', + 'company_id': self.production_id.company_id.id, } else: values = self.production_id._get_finished_move_value(line.product_id.id, 0, line.product_uom_id.id) diff --git a/addons/mrp/wizard/mrp_product_produce_views.xml b/addons/mrp/wizard/mrp_product_produce_views.xml index 00542f06747..f6c512727d3 100644 --- a/addons/mrp/wizard/mrp_product_produce_views.xml +++ b/addons/mrp/wizard/mrp_product_produce_views.xml @@ -9,6 +9,7 @@ <group> <group> <field name="serial" invisible="1"/> + <field name="company_id" invisible="1"/> <field name="production_id" invisible="1"/> <field name="product_id" readonly="1"/> <field name="is_pending_production" invisible="1"/> @@ -20,7 +21,7 @@ <field name="product_tracking" invisible="1"/> <label for="finished_lot_id" attrs="{'invisible': [('product_tracking', '=', 'none')]}"/> <div class="o_row"> - <field name="finished_lot_id" attrs="{'invisible': [('product_tracking', '=', 'none')], 'required': [('product_tracking', '!=', 'none'), ('finished_lot_id', '!=', False)]}" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}"/> + <field name="finished_lot_id" attrs="{'invisible': [('product_tracking', '=', 'none')], 'required': [('product_tracking', '!=', 'none'), ('finished_lot_id', '!=', False)]}" context="{'default_product_id': product_id, 'default_company_id': company_id}"/> <button name="action_generate_serial" type="object" class="btn btn-primary fa fa-plus-square-o" aria-label="Creates a new serial/lot number" title="Creates a new serial/lot number" role="img" attrs="{'invisible': ['|', ('product_tracking', '=', 'none'), ('finished_lot_id', '!=', False)]}"/> </div> </group> @@ -29,9 +30,10 @@ <group> <field name="raw_workorder_line_ids" attrs="{'invisible': [('raw_workorder_line_ids', '=', [])]}" nolabel="1" context="{'w_production': True, 'active_id': production_id, 'default_finished_lot_id': finished_lot_id}"> <tree editable="top" delete="0" decoration-danger="(qty_to_consume < qty_done)"> - <field name="product_id" attrs="{'readonly': [('move_id', '!=', False)]}" required="1" domain="[('id', '!=', parent.product_id)]" force_save="1"/> + <field name="company_id" invisible="1"/> + <field name="product_id" attrs="{'readonly': [('move_id', '!=', False)]}" required="1" domain="[('id', '!=', parent.product_id), ('type', 'in', ['product', 'consu']), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" force_save="1"/> <field name="product_tracking" invisible="1"/> - <field name="lot_id" attrs="{'readonly': [('product_tracking', '=', 'none')]}" context="{'default_product_id': product_id, 'active_mo_id': parent.production_id}" domain="[('product_id', '=', product_id)]" groups="stock.group_production_lot"/> + <field name="lot_id" attrs="{'readonly': [('product_tracking', '=', 'none')]}" context="{'default_product_id': product_id, 'active_mo_id': parent.production_id, 'default_company_id': company_id}" groups="stock.group_production_lot"/> <field name="qty_to_consume" readonly="1" force_save="1"/> <field name="qty_reserved" readonly="1" force_save="1" optional="show"/> <field name="qty_done"/> @@ -44,9 +46,10 @@ <group> <field name="finished_workorder_line_ids" attrs="{'invisible': [('finished_workorder_line_ids', '=', [])]}" nolabel="1" context="{'w_production': True, 'active_id': production_id, 'default_finished_lot_id': finished_lot_id}"> <tree editable="top" delete="0" decoration-danger="(qty_to_consume < qty_done)"> - <field name="product_id" attrs="{'readonly': [('move_id', '!=', False)]}" required="1" domain="[('id', '!=', parent.product_id)]" force_save="1"/> + <field name="company_id" invisible="1"/> + <field name="product_id" attrs="{'readonly': [('move_id', '!=', False)]}" required="1" domain="[('id', '!=', parent.product_id), ('type', 'in', ['product', 'consu']), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" force_save="1"/> <field name="product_tracking" invisible="1"/> - <field name="lot_id" attrs="{'readonly': [('product_tracking', '=', 'none')]}" context="{'default_product_id': product_id}" domain="[('product_id', '=', product_id)]" groups="stock.group_production_lot"/> + <field name="lot_id" attrs="{'readonly': [('product_tracking', '=', 'none')]}" context="{'default_product_id': product_id}" groups="stock.group_production_lot"/> <field name="qty_to_consume" string="To Produce" readonly="1" force_save="1"/> <field name="qty_done" string="Produced"/> <field name="product_uom_id" readonly="1" force_save="1" groups="uom.group_uom"/> diff --git a/addons/mrp/wizard/mrp_workcenter_block_view.xml b/addons/mrp/wizard/mrp_workcenter_block_view.xml index 3d151c1285b..8104b8ea5ec 100644 --- a/addons/mrp/wizard/mrp_workcenter_block_view.xml +++ b/addons/mrp/wizard/mrp_workcenter_block_view.xml @@ -10,6 +10,7 @@ <field name="loss_id" class="oe_inline" domain="[('manual','=',True)]"/> <field name="description" placeholder="Add a description..."/> <field name="workcenter_id" invisible="1"/> + <field name="company_id" invisible="1"/> </group> <footer> <button name="button_block" string="Block" type="object" class="btn-danger text-uppercase"/> diff --git a/addons/mrp/wizard/stock_warn_insufficient_qty.py b/addons/mrp/wizard/stock_warn_insufficient_qty.py index 192368e20c0..335c54249a4 100644 --- a/addons/mrp/wizard/stock_warn_insufficient_qty.py +++ b/addons/mrp/wizard/stock_warn_insufficient_qty.py @@ -11,6 +11,9 @@ class StockWarnInsufficientQtyUnbuild(models.TransientModel): unbuild_id = fields.Many2one('mrp.unbuild', 'Unbuild') + def _get_reference_document_company_id(self): + return self.unbuild_id.company_id + def action_done(self): self.ensure_one() - return self.unbuild_id.action_unbuild()
\ No newline at end of file + return self.unbuild_id.action_unbuild() |
