mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_bom_version: Some improvements
* When passing back to draft mantain active according to company definition * SQL sentence for state update in post-init-hook. * _bom_find with context state so that only those in state=active are taken into account * Tests * api.one deprecated [IMP] <mrp_bom_version> Little required changes [IMP] <mrp_bom_version> from api.one to api.multi [IMP] <mrp_bom_version> New tests added
This commit is contained in:
@@ -1,20 +1,9 @@
|
|||||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
|
|
||||||
Module name
|
=================
|
||||||
===========
|
MRP - BoM Version
|
||||||
|
=================
|
||||||
mrp_bom_version, MRP - BoM version
|
|
||||||
|
|
||||||
Short Description
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
This module is intended to add a version control to BoM (Bill of Materials) and to allow to control his life cycle.
|
|
||||||
|
|
||||||
[es_ES] Este módulo tiene como objetivo el añadir el control de versiones a la LdM (Lista de Materiales) y permitir el control de su ciclo de vida.
|
|
||||||
|
|
||||||
Long Description
|
|
||||||
----------------
|
|
||||||
|
|
||||||
This module provides a state in the BoM whether to allow their use in
|
This module provides a state in the BoM whether to allow their use in
|
||||||
manufacturing, to do the following states are defined:
|
manufacturing, to do the following states are defined:
|
||||||
@@ -26,7 +15,8 @@ manufacturing, to do the following states are defined:
|
|||||||
lines, and the new field Active, for false default when you create a new BoM.
|
lines, and the new field Active, for false default when you create a new BoM.
|
||||||
The "active" state may be passed back to state "draft", if we mark the new
|
The "active" state may be passed back to state "draft", if we mark the new
|
||||||
field "Allow re-edit the BoM list", this new field is defined in
|
field "Allow re-edit the BoM list", this new field is defined in
|
||||||
*Configuration > Configuration > Manufacturing*.
|
*Configuration > Configuration > Manufacturing*. You can configure there also
|
||||||
|
if those BoM will continue with active check marked as True or not.
|
||||||
The active state may move to state "Historical".
|
The active state may move to state "Historical".
|
||||||
* **Historical**:
|
* **Historical**:
|
||||||
This is the last state of the LdM, you can not change any field on the form.
|
This is the last state of the LdM, you can not change any field on the form.
|
||||||
@@ -40,46 +30,30 @@ to be unique.
|
|||||||
and a new BOM is creating based on this but with version number +1 and
|
and a new BOM is creating based on this but with version number +1 and
|
||||||
changing state to draft
|
changing state to draft
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
To install this module, you need to:
|
|
||||||
** to do **
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
=============
|
|
||||||
|
|
||||||
To configure this module, you need to:
|
|
||||||
** to do **
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
** to do **
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
|
:alt: Try me on Runbot
|
||||||
|
:target: https://runbot.odoo-community.org/runbot/188/8.0
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
** to do **
|
Bug Tracker
|
||||||
|
===========
|
||||||
|
|
||||||
Configuration
|
Bugs are tracked on `GitHub Issues <https://github.com/odoomrp/odoomrp-wip/issues>`_.
|
||||||
=============
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
|
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
|
||||||
|
`here <https://github.com/odoomrp/odoomrp-wip/issues/new?body=module:%20mrp_bom_version%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
To configure this module, you need to:
|
|
||||||
** to do **
|
|
||||||
|
|
||||||
Usage
|
|
||||||
=====
|
|
||||||
|
|
||||||
To use this module, you need to:
|
|
||||||
** to do **
|
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
=======
|
=======
|
||||||
|
|
||||||
* odooMRP Project, www.odoomrp.com
|
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||||
** to do **
|
* Ana Juaristi <anajuaristi@avanzosc.es>
|
||||||
|
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es>
|
||||||
|
* Oihane Crucelaegui <oihanecrucelaegui@avanzosc.es>
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# (c) 2015 Oihane Crucelaegui - AvanzOSC
|
||||||
# For copyright and license notices, see __openerp__.py file in root directory
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
from openerp import SUPERUSER_ID
|
|
||||||
|
|
||||||
|
|
||||||
def set_bom_inactive(cr, registry):
|
def set_active_bom_active_state(cr, registry):
|
||||||
"""Set all draft or historical state BoMs inactive."""
|
"""Set those active BoMs to state 'active'"""
|
||||||
mrp_bom_obj = registry['mrp.bom']
|
cr.execute("""UPDATE mrp_bom
|
||||||
mrp_bom_ids = mrp_bom_obj.search(cr, SUPERUSER_ID,
|
SET state = 'active'
|
||||||
[('active', '=', True)])
|
WHERE active = True""")
|
||||||
for mrp_bom in mrp_bom_obj.browse(cr, SUPERUSER_ID, mrp_bom_ids):
|
|
||||||
mrp_bom_obj.write(cr, SUPERUSER_ID, mrp_bom.id, {'state': 'active'})
|
|
||||||
|
|||||||
@@ -1,35 +1,22 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# (c) 2015 Alfredo de la Fuente - AvanzOSC
|
||||||
#
|
# (c) 2015 Oihane Crucelaegui - AvanzOSC
|
||||||
# Copyright (c)
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
# 2015 Serv. Tec. Avanzados - Pedro M. Baeza (http://www.serviciosbaeza.com)
|
|
||||||
# 2015 AvanzOsc (http://www.avanzosc.es)
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as published
|
|
||||||
# by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
{
|
{
|
||||||
"name": "MRP - BoM version",
|
"name": "MRP - BoM version",
|
||||||
"version": "1.0",
|
"summary": "BoM versioning",
|
||||||
|
"version": "8.0.1.0.0",
|
||||||
|
"license": "AGPL-3",
|
||||||
"author": "OdooMRP team,"
|
"author": "OdooMRP team,"
|
||||||
"AvanzOSC,"
|
"AvanzOSC,"
|
||||||
"Serv. Tecnol. Avanzados - Pedro M. Baeza",
|
"Serv. Tecnol. Avanzados - Pedro M. Baeza",
|
||||||
"website": "http://www.odoomrp.com",
|
"website": "http://www.odoomrp.com",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com",
|
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
|
||||||
"Ana Juaristi <anajuaristi@avanzosc.es>",
|
"Ana Juaristi <anajuaristi@avanzosc.es>",
|
||||||
"Alfredo de la Fuente <alfredodelafuente@avanzosc.es>",
|
"Alfredo de la Fuente <alfredodelafuente@avanzosc.es>",
|
||||||
|
"Oihane Crucelaegui <oihanecrucelaegui@avanzosc.es>",
|
||||||
],
|
],
|
||||||
"category": "Manufacturing",
|
"category": "Manufacturing",
|
||||||
"depends": [
|
"depends": [
|
||||||
@@ -42,5 +29,5 @@
|
|||||||
"views/mrp_bom_view.xml",
|
"views/mrp_bom_view.xml",
|
||||||
],
|
],
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"post_init_hook": "set_bom_inactive",
|
"post_init_hook": "set_active_bom_active_state",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ msgstr "Estado"
|
|||||||
#. module: mrp_bom_version
|
#. module: mrp_bom_version
|
||||||
#: field:mrp.bom,state:0
|
#: field:mrp.bom,state:0
|
||||||
msgid "Status"
|
msgid "Status"
|
||||||
msgstr "Estatus"
|
msgstr "Estado"
|
||||||
|
|
||||||
#. module: mrp_bom_version
|
#. module: mrp_bom_version
|
||||||
#: help:mrp.config.settings,group_mrp_bom_state:0
|
#: help:mrp.config.settings,group_mrp_bom_state:0
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# (c) 2015 Oihane Crucelaegui - AvanzOSC
|
||||||
# For copyright and license notices, see __openerp__.py file in root directory
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
from . import mrp_bom
|
from . import mrp_bom
|
||||||
|
from . import res_company
|
||||||
from . import res_config
|
from . import res_config
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# (c) 2015 Oihane Crucelaegui - AvanzOSC
|
||||||
# For copyright and license notices, see __openerp__.py file in root directory
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
##############################################################################
|
|
||||||
from openerp import models, fields, api
|
from openerp import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
@@ -78,85 +78,75 @@ class MrpBom(models.Model):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def button_draft(self):
|
def button_draft(self):
|
||||||
|
self.ensure_one()
|
||||||
|
self.active = (self.company_id.active_draft if self.company_id else
|
||||||
|
self.env.user.company_id.active_draft)
|
||||||
self.state = 'draft'
|
self.state = 'draft'
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def button_new_version(self):
|
def button_new_version(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
new_bom = self._copy_bom()
|
new_bom = self._copy_bom()
|
||||||
self._update_bom_state_after_copy()
|
self.button_historical()
|
||||||
return {
|
return {
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'view_type': 'form, tree',
|
'view_type': 'form, tree',
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'res_model': 'mrp.bom',
|
'res_model': 'mrp.bom',
|
||||||
'res_id': new_bom.id,
|
'res_id': new_bom.id,
|
||||||
'target': 'new',
|
'target': 'current',
|
||||||
}
|
}
|
||||||
|
|
||||||
def _copy_bom(self):
|
def _copy_bom(self):
|
||||||
new_bom = self.copy({
|
new_bom = self.copy({
|
||||||
'version': self.version + 1,
|
'version': self.version + 1,
|
||||||
'active': True,
|
'active': (self.company_id.active_draft if self.company_id else
|
||||||
|
self.env.user.company_id.active_draft),
|
||||||
'parent_bom': self.id,
|
'parent_bom': self.id,
|
||||||
})
|
})
|
||||||
return new_bom
|
return new_bom
|
||||||
|
|
||||||
def _update_bom_state_after_copy(self):
|
@api.multi
|
||||||
self.write({
|
|
||||||
'active': False,
|
|
||||||
'state': 'historical',
|
|
||||||
'historical_date': fields.Date.today(),
|
|
||||||
})
|
|
||||||
|
|
||||||
@api.one
|
|
||||||
def button_activate(self):
|
def button_activate(self):
|
||||||
|
self.ensure_one()
|
||||||
self.write({
|
self.write({
|
||||||
'active': True,
|
'active': True,
|
||||||
'state': 'active'
|
'state': 'active'
|
||||||
})
|
})
|
||||||
|
|
||||||
@api.one
|
@api.multi
|
||||||
def button_historical(self):
|
def button_historical(self):
|
||||||
|
self.ensure_one()
|
||||||
self.write({
|
self.write({
|
||||||
'active': False,
|
'active': False,
|
||||||
'state': 'historical',
|
'state': 'historical',
|
||||||
'historical_date': fields.Date.today()
|
'historical_date': fields.Date.today()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||||
|
context=None, count=False):
|
||||||
|
"""Add search argument for field type if the context says so. This
|
||||||
|
should be in old API because context argument is not the last one.
|
||||||
|
"""
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
|
search_state = context.get('state', False)
|
||||||
|
if search_state:
|
||||||
|
args += [('state', '=', search_state)]
|
||||||
|
return super(MrpBom, self).search(
|
||||||
|
cr, uid, args, offset=offset, limit=limit, order=order,
|
||||||
|
context=context, count=count)
|
||||||
|
|
||||||
class MrpProduction(models.Model):
|
@api.model
|
||||||
_inherit = 'mrp.production'
|
def _bom_find(
|
||||||
|
self, product_tmpl_id=None, product_id=None, properties=None):
|
||||||
def product_id_change(self, cr, uid, ids, product_id, product_qty=0,
|
""" Finds BoM for particular product and product uom.
|
||||||
context=None):
|
@param product_tmpl_id: Selected product.
|
||||||
bom_obj = self.pool['mrp.bom']
|
@param product_uom: Unit of measure of a product.
|
||||||
product_obj = self.pool['product.product']
|
@param properties: List of related properties.
|
||||||
res = super(MrpProduction, self).product_id_change(
|
@return: False or BoM id.
|
||||||
cr, uid, ids, product_id=product_id, product_qty=product_qty,
|
"""
|
||||||
context=context)
|
bom_id = super(MrpBom, self.with_context(state='active'))._bom_find(
|
||||||
if product_id:
|
product_tmpl_id=product_tmpl_id, product_id=product_id,
|
||||||
res['value'].update({'bom_id': False})
|
properties=properties)
|
||||||
product_tmpl_id = product_obj.browse(
|
return bom_id
|
||||||
cr, uid, product_id, context=context).product_tmpl_id.id
|
|
||||||
domain = [('state', '=', 'active'),
|
|
||||||
'|',
|
|
||||||
('product_id', '=', product_id),
|
|
||||||
'&',
|
|
||||||
('product_id', '=', False),
|
|
||||||
('product_tmpl_id', '=', product_tmpl_id)
|
|
||||||
]
|
|
||||||
domain = domain + ['|', ('date_start', '=', False),
|
|
||||||
('date_start', '<=', fields.Datetime.now()),
|
|
||||||
'|', ('date_stop', '=', False),
|
|
||||||
('date_stop', '>=', fields.Datetime.now())]
|
|
||||||
bom_ids = bom_obj.search(cr, uid, domain, context=context)
|
|
||||||
bom_id = 0
|
|
||||||
min_seq = 0
|
|
||||||
for bom in bom_obj.browse(cr, uid, bom_ids, context=context):
|
|
||||||
if min_seq == 0 or bom.sequence < min_seq:
|
|
||||||
min_seq = bom.sequence
|
|
||||||
bom_id = bom.id
|
|
||||||
if bom_id > 0:
|
|
||||||
res['value'].update({'bom_id': bom_id})
|
|
||||||
return res
|
|
||||||
|
|||||||
14
mrp_bom_version/models/res_company.py
Normal file
14
mrp_bom_version/models/res_company.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# (c) 2015 Oihane Crucelaegui - AvanzOSC
|
||||||
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
|
|
||||||
|
from openerp import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResCompany(models.Model):
|
||||||
|
_inherit = 'res.company'
|
||||||
|
|
||||||
|
active_draft = fields.Boolean(
|
||||||
|
string='Keep re-editing BoM active',
|
||||||
|
help='This will allow you to define if those BoM passed back to draft'
|
||||||
|
' are still activated or not', default=False)
|
||||||
@@ -1,14 +1,31 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# (c) 2015 Oihane Crucelaegui - AvanzOSC
|
||||||
# For copyright and license notices, see __openerp__.py file in root directory
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
##############################################################################
|
|
||||||
from openerp import models, fields
|
from openerp import fields, models
|
||||||
|
|
||||||
|
|
||||||
class MrpConfigSettings(models.TransientModel):
|
class MrpConfigSettings(models.TransientModel):
|
||||||
_inherit = 'mrp.config.settings'
|
_inherit = 'mrp.config.settings'
|
||||||
|
|
||||||
|
def _default_company_id(self):
|
||||||
|
return self.env.user.company_id
|
||||||
|
|
||||||
|
def _default_has_default_company(self):
|
||||||
|
count = self.env['res.company'].search_count([])
|
||||||
|
return bool(count == 1)
|
||||||
|
|
||||||
|
company_id = fields.Many2one(
|
||||||
|
comodel_name='res.company', string='Company', required=True,
|
||||||
|
default=_default_company_id)
|
||||||
|
has_default_company = fields.Boolean(
|
||||||
|
string='Has default company', readonly=True,
|
||||||
|
default=_default_has_default_company)
|
||||||
group_mrp_bom_version = fields.Boolean(
|
group_mrp_bom_version = fields.Boolean(
|
||||||
string='Allow to re-edit BoMs',
|
string='Allow to re-edit BoMs',
|
||||||
implied_group='mrp_bom_version.group_mrp_bom_version',
|
implied_group='mrp_bom_version.group_mrp_bom_version',
|
||||||
help='The active state may be passed back to state draft')
|
help='The active state may be passed back to state draft')
|
||||||
|
active_draft = fields.Boolean(
|
||||||
|
string='Keep re-editing BoM active',
|
||||||
|
help='This will allow you to define if those BoM passed back to draft'
|
||||||
|
' are still activated or not', related='company_id.active_draft')
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# (c) 2015 Oihane Crucelaegui - AvanzOSC
|
||||||
# For copyright and license notices, see __openerp__.py file in root directory
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
##############################################################################
|
|
||||||
from . import test_mrp_bom_version
|
from . import test_mrp_bom_version
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# (c) 2015 Alfredo de la Fuente - AvanzOSC
|
||||||
# For copyright and license notices, see __openerp__.py file in root directory
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
##############################################################################
|
|
||||||
import openerp.tests.common as common
|
import openerp.tests.common as common
|
||||||
|
|
||||||
|
|
||||||
@@ -9,33 +9,71 @@ class TestMrpBomVersion(common.TransactionCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestMrpBomVersion, self).setUp()
|
super(TestMrpBomVersion, self).setUp()
|
||||||
self.mrp_bom_model = self.env['mrp.bom']
|
self.bom_model = self.env['mrp.bom']
|
||||||
vals = {"product_tmpl_id":
|
self.company = self.env.ref('base.main_company')
|
||||||
|
vals = {
|
||||||
|
'company_id': self.company.id,
|
||||||
|
'product_tmpl_id':
|
||||||
self.env.ref('product.product_product_11_product_template').id,
|
self.env.ref('product.product_product_11_product_template').id,
|
||||||
"active": True,
|
'bom_line_ids':
|
||||||
"bom_line_ids":
|
|
||||||
[(0, 0, {'product_id':
|
[(0, 0, {'product_id':
|
||||||
self.env.ref('product.product_product_5').id}),
|
self.env.ref('product.product_product_5').id}),
|
||||||
(0, 0, {'product_id':
|
(0, 0, {'product_id':
|
||||||
self.env.ref('product.product_product_6').id})],
|
self.env.ref('product.product_product_6').id})],
|
||||||
}
|
}
|
||||||
self.new_mrp_bom = self.mrp_bom_model.create(vals)
|
self.mrp_bom = self.bom_model.create(vals)
|
||||||
|
|
||||||
def test_mrp_bom_version(self):
|
def test_mrp_bom(self):
|
||||||
self.assertEqual(self.new_mrp_bom.state, 'draft',
|
self.assertEqual(
|
||||||
"No 'draft' state for MRP new BoM")
|
self.mrp_bom.state, 'draft', "New BoM must be in state 'draft'")
|
||||||
self.assertEqual(self.new_mrp_bom.version, 1,
|
self.assertEqual(
|
||||||
"Incorrect version for MRP new BoM")
|
self.mrp_bom.version, 1, 'Incorrect version for new BoM')
|
||||||
self.new_mrp_bom.button_activate()
|
self.assertFalse(
|
||||||
self.assertEqual(self.new_mrp_bom.active, True,
|
self.mrp_bom.active, 'New BoMs must be created inactive')
|
||||||
"Incorrect active field for MRP new BoM, after"
|
self.mrp_bom.button_activate()
|
||||||
" activation")
|
self.assertTrue(
|
||||||
self.assertEqual(self.new_mrp_bom.state, 'active',
|
self.mrp_bom.active, 'Incorrect activation, check must be True')
|
||||||
"No 'active' state for MRP new BoM, after activation")
|
self.assertEqual(
|
||||||
self.new_mrp_bom.button_historical()
|
self.mrp_bom.state, 'active',
|
||||||
self.assertEqual(self.new_mrp_bom.active, False,
|
"Incorrect state, it should be 'active'")
|
||||||
"Incorrect active field for MRP new BoM, after"
|
self.mrp_bom.button_historical()
|
||||||
" historification")
|
self.assertFalse(
|
||||||
self.assertEqual(self.new_mrp_bom.state, 'historical',
|
self.mrp_bom.active, 'Check must be False, after historification')
|
||||||
"No 'historical' state for MRP new BoM, after"
|
self.assertEqual(
|
||||||
" activation")
|
self.mrp_bom.state, 'historical',
|
||||||
|
"Incorrect state, it should be 'historical'")
|
||||||
|
|
||||||
|
def test_mrp_bom_back2draft_default(self):
|
||||||
|
self.mrp_bom.button_activate()
|
||||||
|
self.mrp_bom.button_draft()
|
||||||
|
self.assertFalse(
|
||||||
|
self.mrp_bom.active, 'Check must be False, default in company')
|
||||||
|
|
||||||
|
def test_mrp_bom_back2draft_active(self):
|
||||||
|
self.company.active_draft = True
|
||||||
|
self.mrp_bom.button_activate()
|
||||||
|
self.mrp_bom.button_draft()
|
||||||
|
self.assertTrue(
|
||||||
|
self.mrp_bom.active, 'Check must be True, as set in company')
|
||||||
|
|
||||||
|
def test_mrp_bom_versioning(self):
|
||||||
|
self.mrp_bom.button_activate()
|
||||||
|
self.mrp_bom.button_new_version()
|
||||||
|
self.assertFalse(
|
||||||
|
self.mrp_bom.active,
|
||||||
|
'Check must be False, it must have been historified')
|
||||||
|
self.assertEqual(
|
||||||
|
self.mrp_bom.state, 'historical',
|
||||||
|
'Incorrect state, it must have been historified')
|
||||||
|
new_boms = self.bom_model.search(
|
||||||
|
[('parent_bom', '=', self.mrp_bom.id)])
|
||||||
|
for new_bom in new_boms:
|
||||||
|
self.assertEqual(
|
||||||
|
new_bom.version, self.mrp_bom.version + 1,
|
||||||
|
'New BoM version must be +1 from origin BoM version')
|
||||||
|
self.assertEqual(
|
||||||
|
new_bom.active, self.company.active_draft,
|
||||||
|
'It does not match active draft check state set in company')
|
||||||
|
self.assertEqual(
|
||||||
|
new_bom.state, 'draft',
|
||||||
|
"New version must be created in 'draft' state")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<field name="domain">['|',('active','=',True),('active','=',False)]</field>
|
<field name="domain">['|',('active','=',True),('active','=',False)]</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="mrp.mrp_bom_tree_parent_view" model="ir.ui.view">
|
<record model="ir.ui.view" id="mrp.mrp_bom_tree_parent_view">
|
||||||
<field name="name">mrp.bom.tree.parent.view</field>
|
<field name="name">mrp.bom.tree.parent.view</field>
|
||||||
<field name="model">mrp.bom</field>
|
<field name="model">mrp.bom</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="mrp_bom_state_tree_view" model="ir.ui.view">
|
<record model="ir.ui.view" id="mrp_bom_version_tree_view">
|
||||||
<field name="name">mrp.bom.state.tree.view</field>
|
<field name="name">mrp.bom.version.tree</field>
|
||||||
<field name="model">mrp.bom</field>
|
<field name="model">mrp.bom</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_bom_tree_parent_view"/>
|
<field name="inherit_id" ref="mrp.mrp_bom_tree_parent_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
@@ -26,26 +26,19 @@
|
|||||||
<field name="version" />
|
<field name="version" />
|
||||||
<field name="state" />
|
<field name="state" />
|
||||||
<field name="historical_date"/>
|
<field name="historical_date"/>
|
||||||
<button name="button_draft"
|
<button name="button_draft" type="object" string="Draft"
|
||||||
type="object"
|
|
||||||
string="Draft"
|
|
||||||
groups="mrp_bom_version.group_mrp_bom_version"
|
groups="mrp_bom_version.group_mrp_bom_version"
|
||||||
attrs="{'invisible':[('state','!=','active')]}"
|
attrs="{'invisible':[('state','!=','active')]}"
|
||||||
icon="terp-document-new" />
|
icon="terp-document-new" />
|
||||||
<button name="button_activate"
|
<button name="button_activate" type="object" string="Activate"
|
||||||
type="object" string="Activate"
|
|
||||||
attrs="{'invisible':[('state','not in',(False, 'draft'))]}"
|
attrs="{'invisible':[('state','not in',(False, 'draft'))]}"
|
||||||
icon="terp-camera_test"
|
icon="terp-camera_test"
|
||||||
confirm="You will activate the BoM. If you haven't set a route yet, then you won't be able to do it after this. Are you sure you want to proceed?"/>
|
confirm="You will activate the BoM. If you haven't set a route yet, then you won't be able to do it after this. Are you sure you want to proceed?"/>
|
||||||
<button name="button_new_version"
|
<button name="button_new_version" type="object" string="New version"
|
||||||
type="object"
|
|
||||||
string="New version"
|
|
||||||
attrs="{'invisible':[('state','==','historical')]}"
|
attrs="{'invisible':[('state','==','historical')]}"
|
||||||
icon="gtk-execute"
|
icon="gtk-execute"
|
||||||
confirm="You are going to create a new version of this BoM. Are you sure?"/>
|
confirm="You are going to create a new version of this BoM. Are you sure?"/>
|
||||||
<button name="button_historical"
|
<button name="button_historical" type="object" string="Historical"
|
||||||
type="object"
|
|
||||||
string="Historical"
|
|
||||||
attrs="{'invisible':[('state','!=','active')]}"
|
attrs="{'invisible':[('state','!=','active')]}"
|
||||||
icon="gtk-convert"
|
icon="gtk-convert"
|
||||||
confirm="You are going to historize an BoM. Doing, not be able to unlock it unless you make a copy. Are you sure you want to proceed?"/>
|
confirm="You are going to historize an BoM. Doing, not be able to unlock it unless you make a copy. Are you sure you want to proceed?"/>
|
||||||
@@ -53,33 +46,26 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="mrp_bom_form_view_inh_state" model="ir.ui.view">
|
<record model="ir.ui.view" id="mrp_bom_version_form_view">
|
||||||
<field name="name">mrp.bom.form.view.inh.state</field>
|
<field name="name">mrp.bom.version.form</field>
|
||||||
<field name="model">mrp.bom</field>
|
<field name="model">mrp.bom</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
|
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//form/group" position="before">
|
<xpath expr="//form/group" position="before">
|
||||||
<header>
|
<header>
|
||||||
<button name="button_draft"
|
<button name="button_draft" type="object" string="Draft"
|
||||||
type="object"
|
|
||||||
string="Draft"
|
|
||||||
groups="mrp_bom_version.group_mrp_bom_version"
|
groups="mrp_bom_version.group_mrp_bom_version"
|
||||||
attrs="{'invisible':[('state','!=','active')]}"
|
attrs="{'invisible':[('state','!=','active')]}"
|
||||||
class="oe_highlight" />
|
class="oe_highlight" />
|
||||||
<button name="button_activate"
|
<button name="button_activate" type="object" string="Activate"
|
||||||
type="object" string="Activate"
|
|
||||||
attrs="{'invisible':[('state','not in',(False, 'draft'))]}"
|
attrs="{'invisible':[('state','not in',(False, 'draft'))]}"
|
||||||
class="oe_highlight"
|
class="oe_highlight"
|
||||||
confirm="You will activate the BoM. If you haven't set a route yet, then you won't be able to do it after this. Are you sure you want to proceed?"/>
|
confirm="You will activate the BoM. If you haven't set a route yet, then you won't be able to do it after this. Are you sure you want to proceed?"/>
|
||||||
<button name="button_new_version"
|
<button name="button_new_version" type="object" string="New version"
|
||||||
type="object"
|
|
||||||
string="New version"
|
|
||||||
attrs="{'invisible':[('state','==','historical')]}"
|
attrs="{'invisible':[('state','==','historical')]}"
|
||||||
class="oe_highlight"
|
class="oe_highlight"
|
||||||
confirm="You are going to create a new version of this BoM. Are you sure?"/>
|
confirm="You are going to create a new version of this BoM. Are you sure?"/>
|
||||||
<button name="button_historical"
|
<button name="button_historical" type="object" string="Historical"
|
||||||
type="object"
|
|
||||||
string="Historical"
|
|
||||||
attrs="{'invisible':[('state','!=','active')]}"
|
attrs="{'invisible':[('state','!=','active')]}"
|
||||||
class="oe_highlight"
|
class="oe_highlight"
|
||||||
confirm="You are going to historize an BoM. Doing, not be able to unlock it unless you make a copy. Are you sure you want to proceed?"/>
|
confirm="You are going to historize an BoM. Doing, not be able to unlock it unless you make a copy. Are you sure you want to proceed?"/>
|
||||||
@@ -98,8 +84,8 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_mrp_bom_filter_inh_state" model="ir.ui.view">
|
<record model="ir.ui.view" id="mrp_bom_version_search_view">
|
||||||
<field name="name">view.mrp.bom.filter.inh.state</field>
|
<field name="name">mrp.bom.version.search</field>
|
||||||
<field name="model">mrp.bom</field>
|
<field name="model">mrp.bom</field>
|
||||||
<field name="inherit_id" ref="mrp.view_mrp_bom_filter"/>
|
<field name="inherit_id" ref="mrp.view_mrp_bom_filter"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
|||||||
@@ -1,16 +1,33 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<openerp>
|
<openerp>
|
||||||
<data>
|
<data>
|
||||||
<record model="ir.ui.view" id="view_mrp_config_inh_bomstate">
|
<record model="ir.ui.view" id="mrp_config_settings_versioning">
|
||||||
<field name="name">view.mrp.config.inh.bomstate</field>
|
<field name="name">mrp.config.settings.versioning</field>
|
||||||
<field name="model">mrp.config.settings</field>
|
<field name="model">mrp.config.settings</field>
|
||||||
<field name="inherit_id" ref="mrp.view_mrp_config" />
|
<field name="inherit_id" ref="mrp.view_mrp_config" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<separator string="Master Data" position="after">
|
||||||
|
<field name="has_default_company" invisible="1" />
|
||||||
|
<group groups="base.group_multi_company">
|
||||||
|
<label for="id" string="Company"/>
|
||||||
|
<div>
|
||||||
|
<div attrs="{'invisible': [('has_default_company', '=', True)]}">
|
||||||
|
<label for="company_id" string="Select Company"/>
|
||||||
|
<field name="company_id" widget="selection"
|
||||||
|
class="oe_inline"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</group>
|
||||||
|
</separator>
|
||||||
<xpath expr="//field[@name='module_mrp_repair']/.." position="after">
|
<xpath expr="//field[@name='module_mrp_repair']/.." position="after">
|
||||||
<div>
|
<div>
|
||||||
<field name="group_mrp_bom_version" class="oe_inline"/>
|
<field name="group_mrp_bom_version" class="oe_inline"/>
|
||||||
<label for="group_mrp_bom_version"/>
|
<label for="group_mrp_bom_version"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div attrs="{'invisible': [('group_mrp_bom_version', '=', False)]}">
|
||||||
|
<field name="active_draft" class="oe_inline"/>
|
||||||
|
<label for="active_draft"/>
|
||||||
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user