mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] Total refactorization of quality control modules with new API, README files, and new concepts. WIP of quality_control_tolerance
[FIX] quality_control: Triggers for product category
This commit is contained in:
11
quality_control_mrp/README.rst
Normal file
11
quality_control_mrp/README.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
MRP extension for quality control
|
||||
=================================
|
||||
|
||||
This module defines a trigger that creates inspections when a production order
|
||||
is made.
|
||||
|
||||
It also adds some shortcuts on production orders to these inspections.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
* Pedro M. Baeza <pedro.baeza@serviciobaeza.com>
|
||||
6
quality_control_mrp/__init__.py
Normal file
6
quality_control_mrp/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
# For copyright and license notices, see __openerp__.py file in root directory
|
||||
##############################################################################
|
||||
|
||||
from . import models
|
||||
42
quality_control_mrp/__openerp__.py
Normal file
42
quality_control_mrp/__openerp__.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2014 Serv. Tec. Avanzados - Pedro M. Baeza (http://www.serviciosbaeza.com)
|
||||
# 2014 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": "Quality control - MRP",
|
||||
"version": "1.0",
|
||||
"author": "OdooMRP team",
|
||||
"website": "http://www.odoomrp.com",
|
||||
"contributors": [
|
||||
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com",
|
||||
],
|
||||
"category": "Quality control",
|
||||
"depends": [
|
||||
'quality_control',
|
||||
'mrp',
|
||||
],
|
||||
"data": [
|
||||
'data/quality_control_mrp_data.xml',
|
||||
'views/qc_inspection_view.xml',
|
||||
],
|
||||
"installable": True,
|
||||
"auto_install": True,
|
||||
}
|
||||
16
quality_control_mrp/data/quality_control_mrp_data.xml
Normal file
16
quality_control_mrp/data/quality_control_mrp_data.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<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>
|
||||
39
quality_control_mrp/i18n/es.po
Normal file
39
quality_control_mrp/i18n/es.po
Normal file
@@ -0,0 +1,39 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * quality_control_mrp
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-12-10 17:45+0000\n"
|
||||
"PO-Revision-Date: 2014-12-10 17:45+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: help:mrp.production,qc_inspections:0
|
||||
msgid "Inspections related to this production."
|
||||
msgstr "Inspecciones relativas a esta producción."
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: view:qc.inspection:quality_control_mrp.qc_inspection_search_view_production
|
||||
#: field:qc.inspection,production:0
|
||||
msgid "Production"
|
||||
msgstr "Producción"
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: model:qc.trigger,name:quality_control_mrp.qc_trigger_mrp
|
||||
msgid "Production done"
|
||||
msgstr "Producción realizada"
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: view:qc.inspection.line:quality_control_mrp.qc_inspection_line_search_production_view
|
||||
#: field:qc.inspection.line,production:0
|
||||
msgid "Production order"
|
||||
msgstr "Orden de producción"
|
||||
|
||||
39
quality_control_mrp/i18n/quality_control_mrp.pot
Normal file
39
quality_control_mrp/i18n/quality_control_mrp.pot
Normal file
@@ -0,0 +1,39 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * quality_control_mrp
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-12-10 17:45+0000\n"
|
||||
"PO-Revision-Date: 2014-12-10 17:45+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: help:mrp.production,qc_inspections:0
|
||||
msgid "Inspections related to this production."
|
||||
msgstr ""
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: view:qc.inspection:quality_control_mrp.qc_inspection_search_view_production
|
||||
#: field:qc.inspection,production:0
|
||||
msgid "Production"
|
||||
msgstr ""
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: model:qc.trigger,name:quality_control_mrp.qc_trigger_mrp
|
||||
msgid "Production done"
|
||||
msgstr ""
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: view:qc.inspection.line:quality_control_mrp.qc_inspection_line_search_production_view
|
||||
#: field:qc.inspection.line,production:0
|
||||
msgid "Production order"
|
||||
msgstr ""
|
||||
|
||||
7
quality_control_mrp/models/__init__.py
Normal file
7
quality_control_mrp/models/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
# For copyright and license notices, see __openerp__.py file in root directory
|
||||
##############################################################################
|
||||
|
||||
from . import qc_inspection
|
||||
from . import mrp_production
|
||||
58
quality_control_mrp/models/mrp_production.py
Normal file
58
quality_control_mrp/models/mrp_production.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
# For copyright and license notices, see __openerp__.py file in root directory
|
||||
##############################################################################
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = 'mrp.production'
|
||||
|
||||
@api.one
|
||||
@api.depends('qc_inspections', 'qc_inspections.state')
|
||||
def _count_inspections(self):
|
||||
self.created_inspections = len(self.qc_inspections)
|
||||
self.passed_inspections = len([x for x in self.qc_inspections if
|
||||
x.state == 'success'])
|
||||
self.failed_inspections = len([x for x in self.qc_inspections if
|
||||
x.state == 'failed'])
|
||||
self.done_inspections = (self.passed_inspections +
|
||||
self.failed_inspections)
|
||||
|
||||
qc_inspections = fields.One2many(
|
||||
comodel_name='qc.inspection', inverse_name='picking', copy=False,
|
||||
string='Inspections', help="Inspections related to this production.")
|
||||
created_inspections = fields.Integer(
|
||||
compute="_count_inspections", string="Created inspections")
|
||||
done_inspections = fields.Integer(
|
||||
compute="_count_inspections", string="Done inspections")
|
||||
passed_inspections = fields.Integer(
|
||||
compute="_count_inspections", string="Inspections OK")
|
||||
failed_inspections = fields.Integer(
|
||||
compute="_count_inspections", string="Inspections failed")
|
||||
|
||||
@api.v7
|
||||
def action_produce(self, cr, uid, production_id, production_qty,
|
||||
production_mode, wiz=False, context=None):
|
||||
production = self.browse(cr, uid, production_id, context=context)
|
||||
production.action_produce(
|
||||
production_id, production_qty, production_mode, wiz=wiz)
|
||||
|
||||
@api.v8
|
||||
def action_produce(self, production_id, production_qty, production_mode,
|
||||
wiz=False):
|
||||
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 self.move_created_ids2:
|
||||
qc_trigger = self.env.ref('quality_control_mrp.qc_trigger_mrp')
|
||||
tests = set()
|
||||
for model in ['qc.trigger.product_category_line',
|
||||
'qc.trigger.product_template_line',
|
||||
'qc.trigger.product_line']:
|
||||
tests = tests.union(self.env[model].get_test_for_product(
|
||||
qc_trigger, move.product_id))
|
||||
for test in tests:
|
||||
inspection_model._make_inspection(move, test)
|
||||
return res
|
||||
45
quality_control_mrp/models/qc_inspection.py
Normal file
45
quality_control_mrp/models/qc_inspection.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
# For copyright and license notices, see __openerp__.py file in root directory
|
||||
##############################################################################
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class QcInspection(models.Model):
|
||||
_inherit = 'qc.inspection'
|
||||
|
||||
@api.one
|
||||
@api.depends('object_id')
|
||||
def get_production(self):
|
||||
self.production = False
|
||||
if self.object_id:
|
||||
if self.object_id._name == 'mrp.production':
|
||||
self.production = self.object_id
|
||||
|
||||
@api.one
|
||||
@api.depends('object_id')
|
||||
def _get_product(self):
|
||||
"""Overriden for getting the product from a mrp.production."""
|
||||
super(QcInspection, self)._get_product()
|
||||
if self.object_id:
|
||||
if self.object_id._name == 'mrp.production':
|
||||
self.product = self.object_id.product_id
|
||||
|
||||
@api.one
|
||||
@api.depends('object_id')
|
||||
def _get_qty(self):
|
||||
super(QcInspection, self)._get_qty()
|
||||
if self.object_id:
|
||||
if self.object_id._name == 'mrp.production':
|
||||
self.qty = self.object_id.product_qty
|
||||
|
||||
production = fields.Many2one(
|
||||
comodel_name="mrp.production", compute="get_production", store=True)
|
||||
|
||||
|
||||
class QcInspectionLine(models.Model):
|
||||
_inherit = 'qc.inspection.line'
|
||||
|
||||
production = fields.Many2one(
|
||||
comodel_name="mrp.production", related="inspection_id.production",
|
||||
store=True, string="Production order")
|
||||
BIN
quality_control_mrp/static/description/icon.png
Normal file
BIN
quality_control_mrp/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
68
quality_control_mrp/views/qc_inspection_view.xml
Normal file
68
quality_control_mrp/views/qc_inspection_view.xml
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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="arch" type="xml">
|
||||
<field name="product" position="after">
|
||||
<field name="production" />
|
||||
</field>
|
||||
</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="arch" type="xml">
|
||||
<field name="product" position="after">
|
||||
<field name="production" />
|
||||
</field>
|
||||
</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="arch" type="xml">
|
||||
<filter string="Product" position="after">
|
||||
<filter string="Production"
|
||||
domain="[]"
|
||||
context="{'group_by': 'production'}" />
|
||||
</filter>
|
||||
</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="arch" type="xml">
|
||||
<field name="product" position="after">
|
||||
<field name="production" />
|
||||
</field>
|
||||
</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="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>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user