diff --git a/quality_control_mrp_oca/__manifest__.py b/quality_control_mrp_oca/__manifest__.py
index 2497f2085..504565d80 100644
--- a/quality_control_mrp_oca/__manifest__.py
+++ b/quality_control_mrp_oca/__manifest__.py
@@ -8,21 +8,16 @@
"category": "Quality control",
"license": "AGPL-3",
"author": "OdooMRP team, "
- "AvanzOSC, "
- "Serv. Tecnol. Avanzados - Pedro M. Baeza, "
- "Agile Business Group, "
- "Odoo Community Association (OCA)",
- "website": "https://github.com/OCA/manufacture/tree/12.0/"
- "quality_control_mrp",
- "depends": [
- "quality_control",
- "quality_control_stock",
- "mrp"
- ],
+ "AvanzOSC, "
+ "Serv. Tecnol. Avanzados - Pedro M. Baeza, "
+ "Agile Business Group, "
+ "Odoo Community Association (OCA)",
+ "website": "https://github.com/OCA/manufacture/tree/12.0/" "quality_control_mrp",
+ "depends": ["quality_control", "quality_control_stock", "mrp"],
"data": [
- 'data/quality_control_mrp_data.xml',
- 'views/qc_inspection_view.xml',
- 'views/mrp_production_view.xml'
+ "data/quality_control_mrp_data.xml",
+ "views/qc_inspection_view.xml",
+ "views/mrp_production_view.xml",
],
"installable": True,
"auto_install": True,
diff --git a/quality_control_mrp_oca/data/quality_control_mrp_data.xml b/quality_control_mrp_oca/data/quality_control_mrp_data.xml
index 529f58076..65dceeef6 100644
--- a/quality_control_mrp_oca/data/quality_control_mrp_data.xml
+++ b/quality_control_mrp_oca/data/quality_control_mrp_data.xml
@@ -1,9 +1,9 @@
-
+
Production done
-
+
diff --git a/quality_control_mrp_oca/migrations/12.0.1.0.0/pre-migration.py b/quality_control_mrp_oca/migrations/12.0.1.0.0/pre-migration.py
index 3514ef33d..16675c5d1 100644
--- a/quality_control_mrp_oca/migrations/12.0.1.0.0/pre-migration.py
+++ b/quality_control_mrp_oca/migrations/12.0.1.0.0/pre-migration.py
@@ -1,10 +1,9 @@
from openupgradelib import openupgrade
field_renames = [
- ("mrp.production", "mrp_production", "qc_inspections",
- "qc_inspections_ids"),
+ ("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")
+ ("qc.inspection.line", "qc_inspection_line", "production", "production_id"),
]
diff --git a/quality_control_mrp_oca/models/mrp_production.py b/quality_control_mrp_oca/models/mrp_production.py
index 93b3e5675..eae8402aa 100644
--- a/quality_control_mrp_oca/models/mrp_production.py
+++ b/quality_control_mrp_oca/models/mrp_production.py
@@ -3,43 +3,55 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
-from odoo.addons.quality_control.models.qc_trigger_line import \
- _filter_trigger_lines
+
+from odoo.addons.quality_control.models.qc_trigger_line import _filter_trigger_lines
class MrpProduction(models.Model):
- _inherit = 'mrp.production'
+ _inherit = "mrp.production"
@api.multi
- @api.depends('qc_inspections_ids')
+ @api.depends("qc_inspections_ids")
def _count_inspections(self):
for production in self:
production.created_inspections = len(production.qc_inspections_ids)
qc_inspections_ids = fields.One2many(
- comodel_name='qc.inspection', inverse_name='production_id', copy=False,
- string='Inspections', help="Inspections related to this production.")
+ 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")
+ compute="_count_inspections", string="Created inspections"
+ )
@api.multi
def post_inventory(self):
- done_moves = self.mapped('move_finished_ids').filtered(
- lambda r: r.state == 'done')
+ done_moves = self.mapped("move_finished_ids").filtered(
+ lambda r: r.state == "done"
+ )
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
+ 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')
+ 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']:
+ 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))
+ qc_trigger, move.product_id
+ )
+ )
for trigger_line in _filter_trigger_lines(trigger_lines):
inspection_model._make_inspection(move, trigger_line)
return res
diff --git a/quality_control_mrp_oca/models/qc_inspection.py b/quality_control_mrp_oca/models/qc_inspection.py
index 7604d321f..77b06aab8 100644
--- a/quality_control_mrp_oca/models/qc_inspection.py
+++ b/quality_control_mrp_oca/models/qc_inspection.py
@@ -6,48 +6,52 @@ from odoo import api, fields, models
class QcInspection(models.Model):
- _inherit = 'qc.inspection'
+ _inherit = "qc.inspection"
@api.multi
def _prepare_inspection_header(self, object_ref, trigger_line):
res = super(QcInspection, self)._prepare_inspection_header(
- object_ref, trigger_line)
+ object_ref, trigger_line
+ )
# Fill qty when coming from pack operations
- if object_ref and object_ref._name == 'mrp.production':
- res['qty'] = object_ref.product_qty
+ if object_ref and object_ref._name == "mrp.production":
+ res["qty"] = object_ref.product_qty
return res
- @api.depends('object_id')
+ @api.depends("object_id")
def get_production(self):
for inspection in self:
if inspection.object_id:
- if inspection.object_id._name == 'stock.move':
+ if inspection.object_id._name == "stock.move":
inspection.production_id = inspection.object_id.production_id
- elif inspection.object_id._name == 'mrp.production':
+ elif inspection.object_id._name == "mrp.production":
inspection.production_id = inspection.object_id
- @api.depends('object_id')
+ @api.depends("object_id")
def _compute_product_id(self):
"""Overriden for getting the product from a manufacturing order."""
for inspection in self:
super(QcInspection, inspection)._compute_product_id()
- if inspection.object_id and\
- inspection.object_id._name == 'mrp.production':
+ if inspection.object_id and inspection.object_id._name == "mrp.production":
inspection.product_id = inspection.object_id.product_id
@api.multi
def object_selection_values(self):
objects = super(QcInspection, self).object_selection_values()
- objects.append(('mrp.production', 'Manufacturing Order'))
+ objects.append(("mrp.production", "Manufacturing Order"))
return objects
production_id = fields.Many2one(
- comodel_name="mrp.production", compute="get_production", store=True)
+ comodel_name="mrp.production", compute="get_production", store=True
+ )
class QcInspectionLine(models.Model):
- _inherit = 'qc.inspection.line'
+ _inherit = "qc.inspection.line"
production_id = fields.Many2one(
- comodel_name="mrp.production", related="inspection_id.production_id",
- store=True, string="Production order")
+ comodel_name="mrp.production",
+ related="inspection_id.production_id",
+ store=True,
+ string="Production order",
+ )
diff --git a/quality_control_mrp_oca/tests/test_quality_control_mrp.py b/quality_control_mrp_oca/tests/test_quality_control_mrp.py
index b1f9196ec..55d2c62e6 100644
--- a/quality_control_mrp_oca/tests/test_quality_control_mrp.py
+++ b/quality_control_mrp_oca/tests/test_quality_control_mrp.py
@@ -6,140 +6,141 @@ from odoo.tests.common import TransactionCase
class TestQualityControlMrp(TransactionCase):
-
def setUp(self):
super(TestQualityControlMrp, self).setUp()
- 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_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)
- self.production1 = self.production_model.create({
- 'product_id': self.product.id,
- 'product_qty': 2.0,
- 'product_uom_id': self.product.uom_id.id,
- 'bom_id': self.bom.id
- })
+ 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_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)
+ self.production1 = self.production_model.create(
+ {
+ "product_id": self.product.id,
+ "product_qty": 2.0,
+ "product_uom_id": self.product.uom_id.id,
+ "bom_id": self.bom.id,
+ }
+ )
self.production1.action_assign()
- inspection_lines = (
- self.inspection_model._prepare_inspection_lines(self.test))
- self.inspection1 = self.inspection_model.create({
- 'name': 'Test Inspection',
- 'inspection_lines': inspection_lines,
- })
+ inspection_lines = self.inspection_model._prepare_inspection_lines(self.test)
+ self.inspection1 = self.inspection_model.create(
+ {"name": "Test Inspection", "inspection_lines": inspection_lines,}
+ )
def test_inspection_create_for_product(self):
- self.product.qc_triggers = [(
- 0, 0, {
- 'trigger': self.trigger.id,
- 'test': self.test.id,
- }
- )]
- 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
- })
+ self.product.qc_triggers = [
+ (0, 0, {"trigger": self.trigger.id, "test": self.test.id,})
+ ]
+ 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')
+ self.assertEqual(
+ self.production1.created_inspections,
+ 1,
+ "Only one inspection must be created",
+ )
def test_inspection_create_for_template(self):
- self.product.product_tmpl_id.qc_triggers = [(
- 0, 0, {
- 'trigger': self.trigger.id,
- 'test': self.test.id,
- }
- )]
- 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
- })
+ self.product.product_tmpl_id.qc_triggers = [
+ (0, 0, {"trigger": self.trigger.id, "test": self.test.id,})
+ ]
+ 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')
+ self.assertEqual(
+ self.production1.created_inspections,
+ 1,
+ "Only one inspection must be created",
+ )
def test_inspection_create_for_category(self):
- self.product.categ_id.qc_triggers = [(
- 0, 0, {
- 'trigger': self.trigger.id,
- 'test': self.test.id,
- }
- )]
- 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
- })
+ self.product.categ_id.qc_triggers = [
+ (0, 0, {"trigger": self.trigger.id, "test": self.test.id,})
+ ]
+ 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')
+ self.assertEqual(
+ self.production1.created_inspections,
+ 1,
+ "Only one inspection must be created",
+ )
def test_inspection_create_only_one(self):
- self.product.qc_triggers = [(
- 0, 0, {
- 'trigger': self.trigger.id,
- 'test': self.test.id,
- }
- )]
- self.product.categ_id.qc_triggers = [(
- 0, 0, {
- 'trigger': self.trigger.id,
- 'test': self.test.id,
- }
- )]
- 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
- })
+ self.product.qc_triggers = [
+ (0, 0, {"trigger": self.trigger.id, "test": self.test.id,})
+ ]
+ self.product.categ_id.qc_triggers = [
+ (0, 0, {"trigger": self.trigger.id, "test": self.test.id,})
+ ]
+ 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')
+ self.assertEqual(
+ self.production1.created_inspections,
+ 1,
+ "Only one inspection must be created",
+ )
def test_inspection_with_partial_fabrication(self):
- self.product.qc_triggers = [(
- 0, 0, {
- 'trigger': self.trigger.id,
- 'test': self.test.id,
- }
- )]
- produce_wizard = self.env['mrp.product.produce'].with_context({
- 'active_id': self.production1.id,
- 'active_ids': [self.production1.id],
- }).create({
- 'product_qty': 1.0
- })
+ self.product.qc_triggers = [
+ (0, 0, {"trigger": self.trigger.id, "test": self.test.id,})
+ ]
+ 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.')
- produce_wizard = self.env['mrp.product.produce'].with_context({
- 'active_id': self.production1.id,
- 'active_ids': [self.production1.id],
- }).create({
- 'product_qty': 1.0
- })
+ self.assertEqual(
+ self.production1.created_inspections,
+ 1,
+ "Only one inspection must be created.",
+ )
+ 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.')
+ 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._name,
- self.production1.id),
- })
- self.assertEquals(self.inspection1.production_id,
- self.production1)
+ self.inspection1.write(
+ {"object_id": "%s,%d" % (self.production1._name, self.production1.id),}
+ )
+ self.assertEquals(self.inspection1.production_id, self.production1)
diff --git a/quality_control_mrp_oca/views/mrp_production_view.xml b/quality_control_mrp_oca/views/mrp_production_view.xml
index bb91afcba..82dff685b 100644
--- a/quality_control_mrp_oca/views/mrp_production_view.xml
+++ b/quality_control_mrp_oca/views/mrp_production_view.xml
@@ -1,4 +1,4 @@
-
+
@@ -8,22 +8,27 @@
tree,form
[('production_id', '=', active_id)]
-
mrp.production.form.qc
mrp.production
-
+
-
diff --git a/quality_control_mrp_oca/views/qc_inspection_view.xml b/quality_control_mrp_oca/views/qc_inspection_view.xml
index fe2857af1..5a3402534 100644
--- a/quality_control_mrp_oca/views/qc_inspection_view.xml
+++ b/quality_control_mrp_oca/views/qc_inspection_view.xml
@@ -1,4 +1,4 @@
-
+
@@ -6,75 +6,70 @@
qc.inspection.form.view.production
qc.inspection
-
+
-
qc.inspection.tree.view.production
qc.inspection
-
+
-
qc.inspection.search.view.production
qc.inspection
-
+
-
+
-
qc.inspection.line.tree.production
qc.inspection.line
-
-
+
+
-
qc.inspection.line.search.production
qc.inspection.line
-
+
-
+
diff --git a/setup/quality_control_mrp/odoo/addons/quality_control_mrp b/setup/quality_control_mrp/odoo/addons/quality_control_mrp
new file mode 120000
index 000000000..0e59bd91a
--- /dev/null
+++ b/setup/quality_control_mrp/odoo/addons/quality_control_mrp
@@ -0,0 +1 @@
+../../../../quality_control_mrp
\ No newline at end of file
diff --git a/setup/quality_control_mrp/setup.py b/setup/quality_control_mrp/setup.py
new file mode 100644
index 000000000..28c57bb64
--- /dev/null
+++ b/setup/quality_control_mrp/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+ setup_requires=['setuptools-odoo'],
+ odoo_addon=True,
+)