mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[MIG] quality_control_mrp:
Migration to 12.0
This commit is contained in:
committed by
Ignacio José Alés López
parent
e3f871dd17
commit
aa98f6f022
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import models
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# 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": "MRP extension for quality control",
|
||||
"version": "10.0.1.0.0",
|
||||
"version": "12.0.1.0.0",
|
||||
"category": "Quality control",
|
||||
"license": "AGPL-3",
|
||||
"author": "OdooMRP team, "
|
||||
@@ -13,7 +12,7 @@
|
||||
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
|
||||
"Agile Business Group, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/manufacture/tree/10.0/"
|
||||
"website": "https://github.com/OCA/manufacture/tree/12.0/"
|
||||
"quality_control_mrp",
|
||||
"depends": [
|
||||
"quality_control",
|
||||
@@ -23,7 +22,7 @@
|
||||
"data": [
|
||||
'data/quality_control_mrp_data.xml',
|
||||
'views/qc_inspection_view.xml',
|
||||
'views/mrp_production_view.xml',
|
||||
'views/mrp_production_view.xml'
|
||||
],
|
||||
"installable": True,
|
||||
"auto_install": True,
|
||||
|
||||
@@ -6,9 +6,4 @@
|
||||
<field name="name">Production done</field>
|
||||
<field name="company_id"/>
|
||||
</record>
|
||||
|
||||
<record id="req_link_mrp_production" model="res.request.link">
|
||||
<field name="name">Manufacturing Order</field>
|
||||
<field name="object">mrp.production</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
13
quality_control_mrp/migrations/12.0.1.0.0/pre-migration.py
Normal file
13
quality_control_mrp/migrations/12.0.1.0.0/pre-migration.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from openupgradelib import openupgrade
|
||||
|
||||
field_renames = [
|
||||
("mrp.production", "mrp_production", "qc_inspections",
|
||||
"qc_inspections_ids"),
|
||||
("qc.inspection", "qc_inspection", "production", "production_id"),
|
||||
("qc.inspection.line", "qc_inspection_line", "production", "production_id")
|
||||
]
|
||||
|
||||
|
||||
@openupgrade.migrate(use_env=True)
|
||||
def migrate(env, version):
|
||||
openupgrade.rename_fields(env, field_renames)
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import qc_inspection
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# 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).
|
||||
@@ -12,13 +11,13 @@ class MrpProduction(models.Model):
|
||||
_inherit = 'mrp.production'
|
||||
|
||||
@api.multi
|
||||
@api.depends('qc_inspections')
|
||||
@api.depends('qc_inspections_ids')
|
||||
def _count_inspections(self):
|
||||
for production in self:
|
||||
production.created_inspections = len(production.qc_inspections)
|
||||
production.created_inspections = len(production.qc_inspections_ids)
|
||||
|
||||
qc_inspections = fields.One2many(
|
||||
comodel_name='qc.inspection', inverse_name='production', copy=False,
|
||||
qc_inspections_ids = fields.One2many(
|
||||
comodel_name='qc.inspection', inverse_name='production_id', copy=False,
|
||||
string='Inspections', help="Inspections related to this production.")
|
||||
created_inspections = fields.Integer(
|
||||
compute="_count_inspections", string="Created inspections")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# 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).
|
||||
@@ -23,26 +22,32 @@ class QcInspection(models.Model):
|
||||
for inspection in self:
|
||||
if inspection.object_id:
|
||||
if inspection.object_id._name == 'stock.move':
|
||||
inspection.production = inspection.object_id.production_id
|
||||
inspection.production_id = inspection.object_id.production_id
|
||||
elif inspection.object_id._name == 'mrp.production':
|
||||
inspection.production = inspection.object_id
|
||||
inspection.production_id = inspection.object_id
|
||||
|
||||
@api.depends('object_id')
|
||||
def _get_product(self):
|
||||
def _compute_product_id(self):
|
||||
"""Overriden for getting the product from a manufacturing order."""
|
||||
for inspection in self:
|
||||
super(QcInspection, inspection)._get_product()
|
||||
super(QcInspection, inspection)._compute_product_id()
|
||||
if inspection.object_id and\
|
||||
inspection.object_id._name == 'mrp.production':
|
||||
inspection.product = inspection.object_id.product_id
|
||||
inspection.product_id = inspection.object_id.product_id
|
||||
|
||||
production = fields.Many2one(
|
||||
@api.multi
|
||||
def object_selection_values(self):
|
||||
objects = super(QcInspection, self).object_selection_values()
|
||||
objects.append(('mrp.production', 'Manufacturing Order'))
|
||||
return objects
|
||||
|
||||
production_id = 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",
|
||||
production_id = fields.Many2one(
|
||||
comodel_name="mrp.production", related="inspection_id.production_id",
|
||||
store=True, string="Production order")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_quality_control_mrp
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2015 Oihane Crucelaegui - AvanzOSC
|
||||
# Copyright 2018 Simone Rubino - Agile Business Group
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
@@ -13,7 +12,7 @@ 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('mrp.product_product_computer_desk')
|
||||
self.product = self.env.ref('mrp.product_product_wood_panel')
|
||||
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)
|
||||
@@ -142,5 +141,5 @@ class TestQualityControlMrp(TransactionCase):
|
||||
'object_id': '%s,%d' % (self.production1._name,
|
||||
self.production1.id),
|
||||
})
|
||||
self.assertEquals(self.inspection1.production,
|
||||
self.assertEquals(self.inspection1.production_id,
|
||||
self.production1)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<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>
|
||||
<field name="domain">[('production_id', '=', active_id)]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="mrp_production_qc_view">
|
||||
@@ -28,4 +28,4 @@
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
</odoo>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<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 name="product_id" position="after">
|
||||
<field name="production_id" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -22,8 +22,8 @@
|
||||
<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 name="product_id" position="after">
|
||||
<field name="production_id" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -35,13 +35,14 @@
|
||||
<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 name="product_id" position="after">
|
||||
<field name="production_id" />
|
||||
</field>
|
||||
<group expand="0" position="inside">
|
||||
<filter string="Production"
|
||||
name="groupby_productions"
|
||||
domain="[]"
|
||||
context="{'group_by': 'production'}" />
|
||||
context="{'group_by': 'production_id'}" />
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
@@ -53,8 +54,8 @@
|
||||
<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 name="product_id" position="after">
|
||||
<field name="production_id" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -66,13 +67,14 @@
|
||||
<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 name="product_id" position="after">
|
||||
<field name="production_id" />
|
||||
</field>
|
||||
<group expand="0" position="inside">
|
||||
<filter string="Production order"
|
||||
name="groupby_productions"
|
||||
domain="[]"
|
||||
context="{'group_by': 'production'}" />
|
||||
context="{'group_by': 'production_id'}" />
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user