mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] add a server action to massively assign MOs.
This commit is contained in:
@@ -15,5 +15,8 @@
|
||||
"application": False,
|
||||
"installable": True,
|
||||
"depends": ["mrp"],
|
||||
"data": ['views/product_template_view.xml'],
|
||||
"data": [
|
||||
"views/product_template_view.xml",
|
||||
"views/mrp_production_view.xml",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
# Copyright 2015 John Walsh
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import api, models
|
||||
from openerp import api, models, _
|
||||
from openerp.exceptions import UserError
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -11,6 +12,13 @@ _logger = logging.getLogger(__name__)
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = 'mrp.production'
|
||||
|
||||
@api.multi
|
||||
def action_mass_assign(self):
|
||||
if any([x != 'confirmed' for x in self.mapped('state')]):
|
||||
raise UserError(_(
|
||||
"All Manufacturing Orders must be confirmed."))
|
||||
return self.action_assign()
|
||||
|
||||
@api.one
|
||||
def action_assign(self):
|
||||
"""Reserves available products to the production order but also creates
|
||||
|
||||
28
mrp_mto_with_stock/views/mrp_production_view.xml
Normal file
28
mrp_mto_with_stock/views/mrp_production_view.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="action_server_mrp_production_mass_assign"
|
||||
model="ir.actions.server">
|
||||
<field name="name">Reserve MO</field>
|
||||
<field name="condition">True</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="model_mrp_production" />
|
||||
<field name="state">code</field>
|
||||
<field name="code">self.action_mass_assign(cr, uid, context.get('active_ids', []), context=context)</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_mrp_production_mass_assign">
|
||||
<field name="name">mrp.production.action - mass assign</field>
|
||||
<field name="action_id"
|
||||
ref="action_server_mrp_production_mass_assign" />
|
||||
<field name="value" eval="'ir.actions.server,' + str(ref('action_server_mrp_production_mass_assign'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model_id" ref="model_mrp_production" />
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user