[MIG] quality_control_mrp: Migration to 10.0

This commit is contained in:
Simone Rubino
2018-06-27 09:25:00 +02:00
parent 23c4dbd45f
commit 035b87ed28
13 changed files with 263 additions and 216 deletions

View File

@@ -1,52 +1,77 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
=================================
MRP extension for quality control
=================================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/10.0/quality_control_mrp
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/10.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4|
This module defines a trigger that creates quality control inspections when a
production order is finished.
It also adds the shortcuts related to these inspections on production orders.
**Table of contents**
Usage
=====
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/129/8.0
.. contents::
:local:
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/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/OCA/manufacture/issues/new?body=module:%20quality_control%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Contributors
------------
* Pedro M. Baeza <pedro.baeza@serviciobaeza.com>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
Authors
~~~~~~~
Maintainer
----------
* OdooMRP team
* AvanzOSC
* Serv. Tecnol. Avanzados - Pedro M. Baeza
* Agile Business Group
Contributors
~~~~~~~~~~~~
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Simone Rubino <simone.rubino@agilebg.com>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/10.0/quality_control_mrp>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# (c) 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models

View File

@@ -1,26 +1,24 @@
# -*- coding: utf-8 -*-
# (c) 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# (c) 2014 Oihane Crucelaegui - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Quality control - MRP",
"version": "8.0.1.0.0",
"name": "MRP extension for quality control",
"version": "10.0.1.0.0",
"category": "Quality control",
"license": "AGPL-3",
"author": "OdooMRP team, "
"AvanzOSC, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Agile Business Group, "
"Odoo Community Association (OCA)",
"website": "http://www.odoomrp.com",
"contributors": [
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>",
],
"website": "https://github.com/OCA/manufacture/tree/10.0/"
"quality_control_mrp",
"depends": [
"quality_control",
"quality_control_stock",
"mrp",
"mrp"
],
"data": [
'data/quality_control_mrp_data.xml',

View File

@@ -1,16 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- Copyright 2018 Simone Rubino - Agile Business Group
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="qc.trigger" id="qc_trigger_mrp">
<field name="name">Production done</field>
<field name="company_id"/>
</record>
<record model="qc.trigger" id="qc_trigger_mrp">
<field name="name">Production done</field>
<field name="company_id"></field>
</record>
<record id="req_link_mrp_production" model="res.request.link">
<field name="name">Manufacturing Order</field>
<field name="object">mrp.production</field>
</record>
</data>
</openerp>
<record id="req_link_mrp_production" model="res.request.link">
<field name="name">Manufacturing Order</field>
<field name="object">mrp.production</field>
</record>
</odoo>

View File

@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# (c) 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import qc_inspection
from . import mrp_production

View File

@@ -1,19 +1,21 @@
# -*- coding: utf-8 -*-
# (c) 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2018 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import models, fields, api
from openerp.addons.quality_control.models.qc_trigger_line import\
from odoo import api, fields, models
from odoo.addons.quality_control.models.qc_trigger_line import \
_filter_trigger_lines
class MrpProduction(models.Model):
_inherit = 'mrp.production'
@api.one
@api.multi
@api.depends('qc_inspections')
def _count_inspections(self):
self.created_inspections = len(self.qc_inspections)
for production in self:
production.created_inspections = len(production.qc_inspections)
qc_inspections = fields.One2many(
comodel_name='qc.inspection', inverse_name='production', copy=False,
@@ -21,26 +23,24 @@ class MrpProduction(models.Model):
created_inspections = fields.Integer(
compute="_count_inspections", string="Created inspections")
@api.model
def action_produce(self, production_id, production_qty, production_mode,
wiz=False):
production = self.browse(production_id)
done_moves = production.move_created_ids2.filtered(
@api.multi
def post_inventory(self):
done_moves = self.mapped('move_finished_ids').filtered(
lambda r: r.state == 'done')
res = super(MrpProduction, self).action_produce(
production_id, production_qty, production_mode, wiz=wiz)
if production_mode == 'consume_produce':
inspection_model = self.env['qc.inspection']
for move in production.move_created_ids2.filtered(
lambda r: r.state == 'done') - done_moves:
qc_trigger = self.env.ref('quality_control_mrp.qc_trigger_mrp')
trigger_lines = set()
for model in ['qc.trigger.product_category_line',
'qc.trigger.product_template_line',
'qc.trigger.product_line']:
trigger_lines = trigger_lines.union(
self.env[model].get_trigger_line_for_product(
qc_trigger, move.product_id))
for trigger_line in _filter_trigger_lines(trigger_lines):
inspection_model._make_inspection(move, trigger_line)
res = super(MrpProduction, self).post_inventory()
inspection_model = self.env['qc.inspection']
new_done_moves = self.mapped('move_finished_ids').filtered(
lambda r: r.state == 'done') - done_moves
if new_done_moves:
qc_trigger = self.env.ref('quality_control_mrp.qc_trigger_mrp')
for move in new_done_moves:
trigger_lines = set()
for model in ['qc.trigger.product_category_line',
'qc.trigger.product_template_line',
'qc.trigger.product_line']:
trigger_lines = trigger_lines.union(
self.env[model].get_trigger_line_for_product(
qc_trigger, move.product_id))
for trigger_line in _filter_trigger_lines(trigger_lines):
inspection_model._make_inspection(move, trigger_line)
return res

View File

@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# (c) 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
# Copyright 2018 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import models, fields, api
from odoo import api, fields, models
class QcInspection(models.Model):

View File

@@ -0,0 +1,3 @@
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Simone Rubino <simone.rubino@agilebg.com>

View File

@@ -0,0 +1,4 @@
This module defines a trigger that creates quality control inspections when a
production order is finished.
It also adds the shortcuts related to these inspections on production orders.

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# (c) 2015 Oihane Crucelaegui - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import test_quality_control_mrp

View File

@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# (c) 2015 Oihane Crucelaegui - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# Copyright 2015 Oihane Crucelaegui - AvanzOSC
# Copyright 2018 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp.tests.common import TransactionCase
from odoo.tests.common import TransactionCase
class TestQualityControlMrp(TransactionCase):
@@ -12,15 +13,16 @@ class TestQualityControlMrp(TransactionCase):
self.production_model = self.env['mrp.production']
self.inspection_model = self.env['qc.inspection']
self.qc_trigger_model = self.env['qc.trigger']
self.product = self.env.ref('product.product_product_4')
self.product = self.env.ref('mrp.product_product_computer_desk')
self.test = self.env.ref('quality_control.qc_test_1')
self.trigger = self.env.ref('quality_control_mrp.qc_trigger_mrp')
self.bom = self.env['mrp.bom']._bom_find(product=self.product)
self.production1 = self.production_model.create({
'product_id': self.product.id,
'product_qty': 2.0,
'product_uom': self.product.uom_id.id,
'product_uom_id': self.product.uom_id.id,
'bom_id': self.bom.id
})
self.production1.action_confirm()
self.production1.action_assign()
inspection_lines = (
self.inspection_model._prepare_inspection_lines(self.test))
@@ -36,9 +38,14 @@ class TestQualityControlMrp(TransactionCase):
'test': self.test.id,
}
)]
self.production1.action_produce(
self.production1.id, self.production1.product_qty,
'consume_produce')
produce_wizard = self.env['mrp.product.produce'].with_context({
'active_id': self.production1.id,
'active_ids': [self.production1.id],
}).create({
'product_qty': self.production1.product_qty
})
produce_wizard.do_produce()
self.production1.post_inventory()
self.assertEqual(self.production1.created_inspections, 1,
'Only one inspection must be created')
@@ -49,9 +56,14 @@ class TestQualityControlMrp(TransactionCase):
'test': self.test.id,
}
)]
self.production1.action_produce(
self.production1.id, self.production1.product_qty,
'consume_produce')
produce_wizard = self.env['mrp.product.produce'].with_context({
'active_id': self.production1.id,
'active_ids': [self.production1.id]
}).create({
'product_qty': self.production1.product_qty
})
produce_wizard.do_produce()
self.production1.post_inventory()
self.assertEqual(self.production1.created_inspections, 1,
'Only one inspection must be created')
@@ -62,9 +74,14 @@ class TestQualityControlMrp(TransactionCase):
'test': self.test.id,
}
)]
self.production1.action_produce(
self.production1.id, self.production1.product_qty,
'consume_produce')
produce_wizard = self.env['mrp.product.produce'].with_context({
'active_id': self.production1.id,
'active_ids': [self.production1.id],
}).create({
'product_qty': self.production1.product_qty
})
produce_wizard.do_produce()
self.production1.post_inventory()
self.assertEqual(self.production1.created_inspections, 1,
'Only one inspection must be created')
@@ -81,9 +98,14 @@ class TestQualityControlMrp(TransactionCase):
'test': self.test.id,
}
)]
self.production1.action_produce(
self.production1.id, self.production1.product_qty,
'consume_produce')
produce_wizard = self.env['mrp.product.produce'].with_context({
'active_id': self.production1.id,
'active_ids': [self.production1.id]
}).create({
'product_qty': self.production1.product_qty
})
produce_wizard.do_produce()
self.production1.post_inventory()
self.assertEqual(self.production1.created_inspections, 1,
'Only one inspection must be created')
@@ -94,18 +116,30 @@ class TestQualityControlMrp(TransactionCase):
'test': self.test.id,
}
)]
self.production1.action_produce(
self.production1.id, 1.0, 'consume_produce')
produce_wizard = self.env['mrp.product.produce'].with_context({
'active_id': self.production1.id,
'active_ids': [self.production1.id],
}).create({
'product_qty': 1.0
})
produce_wizard.do_produce()
self.production1.post_inventory()
self.assertEqual(self.production1.created_inspections, 1,
'Only one inspection must be created.')
self.production1.action_produce(
self.production1.id, 1.0, 'consume_produce')
produce_wizard = self.env['mrp.product.produce'].with_context({
'active_id': self.production1.id,
'active_ids': [self.production1.id],
}).create({
'product_qty': 1.0
})
produce_wizard.do_produce()
self.production1.post_inventory()
self.assertEqual(self.production1.created_inspections, 2,
'There must be only 2 inspections.')
def test_qc_inspection_mo(self):
self.inspection1.write({
'object_id': '%s,%d' % (self.production1._model,
'object_id': '%s,%d' % (self.production1._name,
self.production1.id),
})
self.assertEquals(self.inspection1.production,

View File

@@ -1,44 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="action_qc_inspection_per_production" model="ir.actions.act_window">
<field name="name">Quality inspections from production order</field>
<field name="res_model">qc.inspection</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('production', '=', active_id)]</field>
</record>
<!-- Copyright 2018 Simone Rubino - Agile Business Group
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="action_qc_inspection_per_production" model="ir.actions.act_window">
<field name="name">Quality inspections from production order</field>
<field name="res_model">qc.inspection</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('production', '=', active_id)]</field>
</record>
<record model="ir.ui.view" id="mrp.mrp_production_buttons">
<field name="name">mrp.production.buttons</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="arch" type="xml">
<div class="oe_title" position="after">
<div class="oe_right oe_button_box" name="buttons">
</div>
</div>
</field>
</record>
<record model="ir.ui.view" id="mrp_production_qc_view">
<field name="name">mrp.production.form.qc</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_buttons" />
<field name="groups_id"
eval="[(4, ref('quality_control.group_quality_control_user'))]" />
<field name="arch" type="xml">
<div name="buttons" position="inside">
<button class="oe_inline oe_stat_button"
type="action"
name="%(action_qc_inspection_per_production)d"
icon="fa-bookmark-o">
<field name="created_inspections"
widget="statinfo"
string="inspections" />
</button>
</div>
</field>
</record>
</data>
</openerp>
<record model="ir.ui.view" id="mrp_production_qc_view">
<field name="name">mrp.production.form.qc</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="groups_id"
eval="[(4, ref('quality_control.group_quality_control_user'))]" />
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button class="oe_inline oe_stat_button"
type="action"
name="%(action_qc_inspection_per_production)d"
icon="fa-bookmark-o">
<field name="created_inspections"
widget="statinfo"
string="inspections" />
</button>
</div>
</field>
</record>
</odoo>

View File

@@ -1,79 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="qc_inspection_form_view_production">
<field name="name">qc.inspection.form.view.production</field>
<field name="model">qc.inspection</field>
<field name="inherit_id" ref="quality_control.qc_inspection_form_view" />
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
<!-- Copyright 2018 Simone Rubino - Agile Business Group
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.ui.view" id="qc_inspection_form_view_production">
<field name="name">qc.inspection.form.view.production</field>
<field name="model">qc.inspection</field>
<field name="inherit_id" ref="quality_control.qc_inspection_form_view" />
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
</record>
</field>
</record>
<record model="ir.ui.view" id="qc_inspection_tree_view_production">
<field name="name">qc.inspection.tree.view.production</field>
<field name="model">qc.inspection</field>
<field name="inherit_id" ref="quality_control.qc_inspection_tree_view" />
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
<record model="ir.ui.view" id="qc_inspection_tree_view_production">
<field name="name">qc.inspection.tree.view.production</field>
<field name="model">qc.inspection</field>
<field name="inherit_id" ref="quality_control.qc_inspection_tree_view" />
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
</record>
</field>
</record>
<record model="ir.ui.view" id="qc_inspection_search_view_production">
<field name="name">qc.inspection.search.view.production</field>
<field name="model">qc.inspection</field>
<field name="inherit_id" ref="quality_control.qc_inspection_search_view" />
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
<filter string="Product" position="after">
<filter string="Production" domain="[]"
context="{'group_by': 'production'}" />
</filter>
<record model="ir.ui.view" id="qc_inspection_search_view_production">
<field name="name">qc.inspection.search.view.production</field>
<field name="model">qc.inspection</field>
<field name="inherit_id" ref="quality_control.qc_inspection_search_view" />
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
</record>
<group expand="0" position="inside">
<filter string="Production"
domain="[]"
context="{'group_by': 'production'}" />
</group>
</field>
</record>
<record model="ir.ui.view" id="qc_inspection_line_tree_production_view">
<field name="name">qc.inspection.line.tree.production</field>
<field name="model">qc.inspection.line</field>
<field name="inherit_id" ref="quality_control.qc_inspection_line_tree_view"/>
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
<record model="ir.ui.view" id="qc_inspection_line_tree_production_view">
<field name="name">qc.inspection.line.tree.production</field>
<field name="model">qc.inspection.line</field>
<field name="inherit_id" ref="quality_control.qc_inspection_line_tree_view"/>
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
</record>
</field>
</record>
<record model="ir.ui.view" id="qc_inspection_line_search_production_view">
<field name="name">qc.inspection.line.search.production</field>
<field name="model">qc.inspection.line</field>
<field name="inherit_id" ref="quality_control.qc_inspection_line_search_view" />
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
<filter string="Product" position="after">
<filter string="Production order" domain="[]"
context="{'group_by': 'production'}" />
</filter>
<record model="ir.ui.view" id="qc_inspection_line_search_production_view">
<field name="name">qc.inspection.line.search.production</field>
<field name="model">qc.inspection.line</field>
<field name="inherit_id" ref="quality_control.qc_inspection_line_search_view" />
<field name="groups_id"
eval="[(4, ref('mrp.group_mrp_user'))]" />
<field name="arch" type="xml">
<field name="product" position="after">
<field name="production" />
</field>
</record>
</data>
</openerp>
<group expand="0" position="inside">
<filter string="Production order"
domain="[]"
context="{'group_by': 'production'}" />
</group>
</field>
</record>
</odoo>