mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[MIG] quality_control_stock: Migration to 11.0
This commit is contained in:
committed by
Enrique Martín
parent
4190a02e39
commit
195448dc3a
@@ -14,13 +14,13 @@ Quality control - Stock
|
||||
: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_stock
|
||||
:target: https://github.com/OCA/manufacture/tree/11.0/quality_control_stock
|
||||
:alt: OCA/manufacture
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/manufacture-10-0/manufacture-10-0-quality_control_stock
|
||||
:target: https://translation.odoo-community.org/projects/manufacture-11-0/manufacture-11-0-quality_control_stock
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/129/10.0
|
||||
:target: https://runbot.odoo-community.org/runbot/129/11.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -66,6 +66,7 @@ Contributors
|
||||
* Pedro M. Baeza <pedro.baeza@serviciobaeza.com>
|
||||
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
|
||||
* Simone Rubino <simone.rubino@agilebg.com>
|
||||
* Ignacio Ales <ignacio.ales@guadaltech.es>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza
|
||||
# Copyright 2014 Oihane Crucelaegui - AvanzOSC
|
||||
# Copyright 2018 Simone Rubino - Agile Business Group
|
||||
@@ -6,7 +5,7 @@
|
||||
|
||||
{
|
||||
"name": "Quality control - Stock",
|
||||
"version": "10.0.1.0.2",
|
||||
"version": "11.0.1.0.0",
|
||||
"category": "Quality control",
|
||||
"license": "AGPL-3",
|
||||
"author": "OdooMRP team, "
|
||||
@@ -14,7 +13,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/11.0/"
|
||||
"quality_control_stock",
|
||||
"depends": [
|
||||
"quality_control",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<!-- Copyright 2018 Simone Rubino - Agile Business Group
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="req_link_stock_move" model="res.request.link">
|
||||
<field name="name">Stock Move</field>
|
||||
<field name="object">stock.move</field>
|
||||
@@ -11,9 +12,5 @@
|
||||
<field name="name">Picking List</field>
|
||||
<field name="object">stock.picking</field>
|
||||
</record>
|
||||
|
||||
<record id="req_link_stock_production_lot" model="res.request.link">
|
||||
<field name="name">Lot</field>
|
||||
<field name="object">stock.production.lot</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import qc_trigger
|
||||
|
||||
@@ -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).
|
||||
@@ -13,49 +12,53 @@ class QcInspection(models.Model):
|
||||
@api.depends('object_id')
|
||||
def _compute_picking(self):
|
||||
for inspection in self:
|
||||
inspection.picking = False
|
||||
inspection.picking_id = False
|
||||
if inspection.object_id:
|
||||
if inspection.object_id._name == 'stock.move':
|
||||
inspection.picking = inspection.object_id.picking_id
|
||||
inspection.picking_id = inspection.object_id.picking_id
|
||||
elif inspection.object_id._name == 'stock.picking':
|
||||
inspection.picking = inspection.object_id
|
||||
elif inspection.object_id._name == 'stock.pack.operation':
|
||||
inspection.picking = inspection.object_id.picking_id
|
||||
inspection.picking_id = inspection.object_id
|
||||
elif inspection.object_id._name == 'stock.move.line':
|
||||
inspection.picking_id = inspection.object_id.picking_id
|
||||
|
||||
@api.multi
|
||||
@api.depends('object_id')
|
||||
def _compute_lot(self):
|
||||
for inspection in self:
|
||||
inspection.lot = False
|
||||
inspection.lot_id = False
|
||||
if inspection.object_id:
|
||||
if inspection.object_id._name == 'stock.pack.operation':
|
||||
inspection.lot = \
|
||||
inspection.object_id.pack_lot_ids[:1].lot_id
|
||||
if inspection.object_id._name == 'stock.move.line':
|
||||
inspection.lot_id = \
|
||||
inspection.object_id.lot_id
|
||||
elif inspection.object_id._name == 'stock.move':
|
||||
inspection.lot = inspection.object_id.lot_ids[:1]
|
||||
inspection.lot_id = \
|
||||
self.env['stock.move.line'].search([
|
||||
('lot_id', '!=', False),
|
||||
('move_id', '=', inspection.object_id.id)
|
||||
])[:1].lot_id
|
||||
elif inspection.object_id._name == 'stock.production.lot':
|
||||
inspection.lot = inspection.object_id
|
||||
inspection.lot_id = inspection.object_id
|
||||
|
||||
@api.multi
|
||||
@api.depends('object_id')
|
||||
def _get_product(self):
|
||||
def _compute_product_id(self):
|
||||
"""Overriden for getting the product from a stock move."""
|
||||
self.ensure_one()
|
||||
super(QcInspection, self)._get_product()
|
||||
super(QcInspection, self)._compute_product_id()
|
||||
if self.object_id:
|
||||
if self.object_id._name == 'stock.move':
|
||||
self.product = self.object_id.product_id
|
||||
elif self.object_id._name == 'stock.pack.operation':
|
||||
self.product = self.object_id.product_id
|
||||
self.product_id = self.object_id.product_id
|
||||
elif self.object_id._name == 'stock.move.line':
|
||||
self.product_id = self.object_id.product_id
|
||||
elif self.object_id._name == 'stock.production.lot':
|
||||
self.product = self.object_id.product_id
|
||||
self.product_id = self.object_id.product_id
|
||||
|
||||
@api.onchange('object_id')
|
||||
def onchange_object_id(self):
|
||||
if self.object_id:
|
||||
if self.object_id._name == 'stock.move':
|
||||
self.qty = self.object_id.product_qty
|
||||
elif self.object_id._name == 'stock.pack.operation':
|
||||
elif self.object_id._name == 'stock.move.line':
|
||||
self.qty = self.object_id.product_qty
|
||||
|
||||
@api.multi
|
||||
@@ -63,15 +66,15 @@ class QcInspection(models.Model):
|
||||
res = super(QcInspection, self)._prepare_inspection_header(
|
||||
object_ref, trigger_line)
|
||||
# Fill qty when coming from pack operations
|
||||
if object_ref and object_ref._name == 'stock.pack.operation':
|
||||
if object_ref and object_ref._name == 'stock.move.line':
|
||||
res['qty'] = object_ref.product_qty
|
||||
if object_ref and object_ref._name == 'stock.move':
|
||||
res['qty'] = object_ref.product_uom_qty
|
||||
return res
|
||||
|
||||
picking = fields.Many2one(
|
||||
picking_id = fields.Many2one(
|
||||
comodel_name="stock.picking", compute="_compute_picking", store=True)
|
||||
lot = fields.Many2one(
|
||||
lot_id = fields.Many2one(
|
||||
comodel_name='stock.production.lot', compute="_compute_lot",
|
||||
store=True)
|
||||
|
||||
@@ -79,9 +82,9 @@ class QcInspection(models.Model):
|
||||
class QcInspectionLine(models.Model):
|
||||
_inherit = 'qc.inspection.line'
|
||||
|
||||
picking = fields.Many2one(
|
||||
comodel_name="stock.picking", related="inspection_id.picking",
|
||||
picking_id = fields.Many2one(
|
||||
comodel_name="stock.picking", related="inspection_id.picking_id",
|
||||
store=True)
|
||||
lot = fields.Many2one(
|
||||
comodel_name="stock.production.lot", related="inspection_id.lot",
|
||||
lot_id = fields.Many2one(
|
||||
comodel_name="stock.production.lot", related="inspection_id.lot_id",
|
||||
store=True)
|
||||
|
||||
@@ -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).
|
||||
@@ -9,5 +8,5 @@ from odoo import fields, models
|
||||
class QcTrigger(models.Model):
|
||||
_inherit = 'qc.trigger'
|
||||
|
||||
picking_type = fields.Many2one(
|
||||
picking_type_id = fields.Many2one(
|
||||
comodel_name="stock.picking.type", readonly=True, ondelete="cascade")
|
||||
|
||||
@@ -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,21 +11,21 @@ class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
@api.multi
|
||||
@api.depends('qc_inspections', 'qc_inspections.state')
|
||||
@api.depends('qc_inspections_ids', 'qc_inspections_ids.state')
|
||||
def _compute_count_inspections(self):
|
||||
for picking in self:
|
||||
picking.created_inspections = len(picking.qc_inspections)
|
||||
picking.created_inspections = len(picking.qc_inspections_ids)
|
||||
picking.passed_inspections = \
|
||||
len([x for x in picking.qc_inspections
|
||||
len([x for x in picking.qc_inspections_ids
|
||||
if x.state == 'success'])
|
||||
picking.failed_inspections = \
|
||||
len([x for x in picking.qc_inspections
|
||||
len([x for x in picking.qc_inspections_ids
|
||||
if x.state == 'failed'])
|
||||
picking.done_inspections = \
|
||||
(picking.passed_inspections + picking.failed_inspections)
|
||||
|
||||
qc_inspections = fields.One2many(
|
||||
comodel_name='qc.inspection', inverse_name='picking', copy=False,
|
||||
qc_inspections_ids = fields.One2many(
|
||||
comodel_name='qc.inspection', inverse_name='picking_id', copy=False,
|
||||
string='Inspections', help="Inspections related to this picking.")
|
||||
created_inspections = fields.Integer(
|
||||
compute="_compute_count_inspections", string="Created inspections")
|
||||
@@ -38,12 +37,12 @@ class StockPicking(models.Model):
|
||||
compute="_compute_count_inspections", string="Inspections failed")
|
||||
|
||||
@api.multi
|
||||
def do_transfer(self):
|
||||
res = super(StockPicking, self).do_transfer()
|
||||
def action_done(self):
|
||||
res = super(StockPicking, self).action_done()
|
||||
inspection_model = self.env['qc.inspection']
|
||||
for operation in self.pack_operation_ids:
|
||||
for operation in self.move_lines:
|
||||
qc_trigger = self.env['qc.trigger'].search(
|
||||
[('picking_type', '=', self.picking_type_id.id)])
|
||||
[('picking_type_id', '=', self.picking_type_id.id)])
|
||||
trigger_lines = set()
|
||||
for model in ['qc.trigger.product_category_line',
|
||||
'qc.trigger.product_template_line',
|
||||
|
||||
@@ -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).
|
||||
@@ -15,7 +14,7 @@ class StockPickingType(models.Model):
|
||||
qc_trigger = {
|
||||
'name': self.name,
|
||||
'company_id': self.warehouse_id.company_id.id,
|
||||
'picking_type': self.id,
|
||||
'picking_type_id': self.id,
|
||||
'partner_selectable': True,
|
||||
}
|
||||
return self.env['qc.trigger'].sudo().create(qc_trigger)
|
||||
@@ -31,7 +30,9 @@ class StockPickingType(models.Model):
|
||||
res = super(StockPickingType, self).write(vals)
|
||||
if vals.get('name') or vals.get('warehouse_id'):
|
||||
qc_trigger_model = self.env['qc.trigger'].sudo()
|
||||
for rec in self:
|
||||
qc_trigger = qc_trigger_model.search(
|
||||
[('picking_type', '=', self.id)])
|
||||
qc_trigger.name = self.name
|
||||
[('picking_type_id', '=', rec.id)])
|
||||
qc_trigger.name = rec.name
|
||||
|
||||
return res
|
||||
|
||||
@@ -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).
|
||||
@@ -10,19 +9,20 @@ class StockProductionLot(models.Model):
|
||||
_inherit = 'stock.production.lot'
|
||||
|
||||
@api.multi
|
||||
@api.depends('qc_inspections', 'qc_inspections.state')
|
||||
@api.depends('qc_inspections_ids', 'qc_inspections_ids.state')
|
||||
def _compute_count_inspections(self):
|
||||
for lot in self:
|
||||
lot.created_inspections = len(lot.qc_inspections)
|
||||
lot.created_inspections = len(lot.qc_inspections_ids)
|
||||
lot.passed_inspections = \
|
||||
len([x for x in lot.qc_inspections if x.state == 'success'])
|
||||
len([x for x in lot.qc_inspections_ids
|
||||
if x.state == 'success'])
|
||||
lot.failed_inspections = \
|
||||
len([x for x in lot.qc_inspections if x.state == 'failed'])
|
||||
len([x for x in lot.qc_inspections_ids if x.state == 'failed'])
|
||||
lot.done_inspections = \
|
||||
(lot.passed_inspections + lot.failed_inspections)
|
||||
|
||||
qc_inspections = fields.One2many(
|
||||
comodel_name='qc.inspection', inverse_name='lot', copy=False,
|
||||
qc_inspections_ids = fields.One2many(
|
||||
comodel_name='qc.inspection', inverse_name='lot_id', copy=False,
|
||||
string='Inspections', help="Inspections related to this lot.")
|
||||
created_inspections = fields.Integer(
|
||||
compute="_compute_count_inspections", string="Created inspections")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_quality_control_stock
|
||||
|
||||
@@ -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).
|
||||
@@ -14,7 +13,7 @@ class TestQualityControl(TransactionCase):
|
||||
self.inspection_model = self.env['qc.inspection']
|
||||
self.qc_trigger_model = self.env['qc.trigger']
|
||||
self.picking_type_model = self.env['stock.picking.type']
|
||||
self.product = self.env.ref('product.product_product_4')
|
||||
self.product = self.env.ref('product.product_product_2')
|
||||
self.partner1 = self.env.ref('base.res_partner_2')
|
||||
self.partner2 = self.env.ref('base.res_partner_4')
|
||||
self.test = self.env.ref('quality_control.qc_test_1')
|
||||
@@ -29,7 +28,7 @@ class TestQualityControl(TransactionCase):
|
||||
'inspection_lines': inspection_lines,
|
||||
})
|
||||
self.trigger = self.qc_trigger_model.search(
|
||||
[('picking_type', '=', self.picking_type.id)])
|
||||
[('picking_type_id', '=', self.picking_type.id)])
|
||||
self.lot = self.env['stock.production.lot'].create({
|
||||
'name': 'Lot for tests',
|
||||
'product_id': self.product.id,
|
||||
@@ -41,6 +40,7 @@ class TestQualityControl(TransactionCase):
|
||||
'product_uom_qty': 2.0,
|
||||
'location_id': self.picking_type.default_location_src_id.id,
|
||||
'location_dest_id': self.location_dest.id,
|
||||
'quantity_done': 1.0
|
||||
}
|
||||
self.picking1 = self.picking_model \
|
||||
.with_context(default_picking_type_id=self.picking_type.id) \
|
||||
@@ -52,15 +52,22 @@ class TestQualityControl(TransactionCase):
|
||||
})
|
||||
self.picking1.action_confirm()
|
||||
self.picking1.force_assign()
|
||||
self.picking1.do_prepare_partial()
|
||||
for line in self.picking1.pack_operation_ids.filtered(
|
||||
sequence = 10
|
||||
for line in self.picking1.move_lines.filtered(
|
||||
lambda r: r.product_id == self.product):
|
||||
line.write({
|
||||
'pack_lot_ids': [(0, 0, {
|
||||
'move_line_ids': [(0, 0, {
|
||||
'lot_id': self.lot.id,
|
||||
'qty': 2.0
|
||||
})]
|
||||
'product_uom_qty': 1.0,
|
||||
'qty_done': 1.0,
|
||||
'product_uom_id': line.product_uom.id,
|
||||
'product_id': line.product_id.id,
|
||||
'location_id': line.location_id.id,
|
||||
'location_dest_id': line.location_dest_id.id,
|
||||
})],
|
||||
'sequence': sequence
|
||||
})
|
||||
sequence += 10
|
||||
|
||||
def test_inspection_create_for_product(self):
|
||||
self.product.qc_triggers = [(
|
||||
@@ -72,7 +79,7 @@ class TestQualityControl(TransactionCase):
|
||||
self.picking1.do_transfer()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
inspection = self.picking1.qc_inspections[:1]
|
||||
inspection = self.picking1.qc_inspections_ids[:1]
|
||||
self.assertEqual(inspection.qty, 2.0)
|
||||
self.assertEqual(inspection.test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
@@ -91,7 +98,7 @@ class TestQualityControl(TransactionCase):
|
||||
self.picking1.do_transfer()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections[:1].test, self.test,
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
|
||||
def test_inspection_create_for_category(self):
|
||||
@@ -104,7 +111,7 @@ class TestQualityControl(TransactionCase):
|
||||
self.picking1.do_transfer()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections[:1].test, self.test,
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
|
||||
def test_inspection_create_for_product_partner(self):
|
||||
@@ -118,7 +125,7 @@ class TestQualityControl(TransactionCase):
|
||||
self.picking1.do_transfer()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections[:1].test, self.test,
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
|
||||
def test_inspection_create_for_template_partner(self):
|
||||
@@ -132,7 +139,7 @@ class TestQualityControl(TransactionCase):
|
||||
self.picking1.do_transfer()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections[:1].test, self.test,
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
|
||||
def test_inspection_create_for_category_partner(self):
|
||||
@@ -146,7 +153,7 @@ class TestQualityControl(TransactionCase):
|
||||
self.picking1.do_transfer()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections[:1].test, self.test,
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
|
||||
def test_inspection_create_for_product_wrong_partner(self):
|
||||
@@ -201,11 +208,11 @@ class TestQualityControl(TransactionCase):
|
||||
self.picking1.do_transfer()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections[:1].test, self.test,
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
self.assertEqual(self.lot.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.lot.qc_inspections[:1].test, self.test,
|
||||
self.assertEqual(self.lot.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
|
||||
def test_picking_type(self):
|
||||
@@ -215,7 +222,7 @@ class TestQualityControl(TransactionCase):
|
||||
'sequence_id': self.sequence.id
|
||||
})
|
||||
trigger = self.qc_trigger_model.search(
|
||||
[('picking_type', '=', picking_type.id)])
|
||||
[('picking_type_id', '=', picking_type.id)])
|
||||
self.assertEqual(len(trigger), 1,
|
||||
'One trigger must have been created.')
|
||||
self.assertEqual(trigger.name, picking_type.name,
|
||||
@@ -228,34 +235,37 @@ class TestQualityControl(TransactionCase):
|
||||
|
||||
def test_qc_inspection_picking(self):
|
||||
self.inspection1.write({
|
||||
'name': self.picking1.move_lines[:1]._name + "inspection",
|
||||
'object_id': '%s,%d' % (self.picking1._name,
|
||||
self.picking1.id),
|
||||
})
|
||||
self.assertEquals(self.inspection1.picking,
|
||||
self.assertEqual(self.inspection1.picking_id,
|
||||
self.picking1)
|
||||
|
||||
def test_qc_inspection_stock_move(self):
|
||||
self.inspection1.write({
|
||||
'name': self.picking1.move_lines[:1]._name + "inspection",
|
||||
'object_id': '%s,%d' % (self.picking1.move_lines[:1]._name,
|
||||
self.picking1.move_lines[:1].id),
|
||||
})
|
||||
self.inspection1.onchange_object_id()
|
||||
self.assertEquals(self.inspection1.picking,
|
||||
self.assertEqual(self.inspection1.picking_id,
|
||||
self.picking1)
|
||||
self.assertEquals(self.inspection1.lot,
|
||||
self.picking1.move_lines[:1].lot_ids[:1])
|
||||
self.assertEquals(self.inspection1.product,
|
||||
self.assertEqual(self.inspection1.lot_id,
|
||||
self.lot)
|
||||
self.assertEqual(self.inspection1.product_id,
|
||||
self.picking1.move_lines[:1].product_id)
|
||||
self.assertEquals(self.inspection1.qty,
|
||||
self.assertEqual(self.inspection1.qty,
|
||||
self.picking1.move_lines[:1].product_qty)
|
||||
|
||||
def test_qc_inspection_lot(self):
|
||||
self.inspection1.write({
|
||||
'name': self.picking1.move_lines[:1]._name + "inspection",
|
||||
'object_id': '%s,%d' % (self.lot._name,
|
||||
self.lot.id),
|
||||
})
|
||||
self.inspection1.onchange_object_id()
|
||||
self.assertEquals(self.inspection1.lot,
|
||||
self.assertEqual(self.inspection1.lot_id,
|
||||
self.lot)
|
||||
self.assertEquals(self.inspection1.product,
|
||||
self.assertEqual(self.inspection1.product_id,
|
||||
self.lot.product_id)
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
<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="picking"/>
|
||||
<field name="lot" groups="stock.group_production_lot"/>
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id" groups="stock.group_production_lot" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -19,9 +19,9 @@
|
||||
<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="picking"/>
|
||||
<field name="lot" groups="stock.group_production_lot"/>
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id" groups="stock.group_production_lot"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -31,18 +31,18 @@
|
||||
<field name="model">qc.inspection</field>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_search_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product" position="after">
|
||||
<field name="picking"/>
|
||||
<field name="lot" groups="stock.group_production_lot"/>
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id" groups="stock.group_production_lot"/>
|
||||
</field>
|
||||
<group expand="0" position="inside">
|
||||
<filter string="Picking"
|
||||
domain="[]"
|
||||
context="{'group_by': 'picking'}"/>
|
||||
context="{'group_by': 'picking_id'}"/>
|
||||
<filter string="Lot"
|
||||
domain="[]"
|
||||
groups="stock.group_production_lot"
|
||||
context="{'group_by': 'lot'}"/>
|
||||
context="{'group_by': 'lot_id'}"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
@@ -52,9 +52,9 @@
|
||||
<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="picking"/>
|
||||
<field name="lot"/>
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -64,9 +64,9 @@
|
||||
<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="picking"/>
|
||||
<field name="lot"/>
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id"/>
|
||||
</field>
|
||||
<group expand="0" position="inside">
|
||||
<filter string="Picking"
|
||||
|
||||
@@ -6,28 +6,28 @@
|
||||
<field name="name">Quality inspections from picking</field>
|
||||
<field name="res_model">qc.inspection</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('picking', '=', active_id)]</field>
|
||||
<field name="domain">[('picking_id', '=', active_id)]</field>
|
||||
</record>
|
||||
|
||||
<record id="action_qc_inspection_per_picking_done" model="ir.actions.act_window">
|
||||
<field name="name">Quality inspection from picking done</field>
|
||||
<field name="res_model">qc.inspection</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('picking', '=', active_id), ('state', 'not in', ['draft', 'waiting'])]</field>
|
||||
<field name="domain">[('picking_id', '=', active_id), ('state', 'not in', ['draft', 'waiting'])]</field>
|
||||
</record>
|
||||
|
||||
<record id="action_qc_inspection_per_picking_passed" model="ir.actions.act_window">
|
||||
<field name="name">Quality inspection from picking passed</field>
|
||||
<field name="res_model">qc.inspection</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('picking', '=', active_id), ('state', '=', 'success')]</field>
|
||||
<field name="domain">[('picking_id', '=', active_id), ('state', '=', 'success')]</field>
|
||||
</record>
|
||||
|
||||
<record id="action_qc_inspection_per_picking_failed" model="ir.actions.act_window">
|
||||
<field name="name">Quality inspections from picking failed</field>
|
||||
<field name="res_model">qc.inspection</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('picking', '=', active_id), ('state', '=', 'failed')]</field>
|
||||
<field name="domain">[('picking_id', '=', active_id), ('state', '=', 'failed')]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="stock_picking_qc_view">
|
||||
|
||||
@@ -6,28 +6,28 @@
|
||||
<field name="name">Quality inspections from lot</field>
|
||||
<field name="res_model">qc.inspection</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('lot', '=', active_id)]</field>
|
||||
<field name="domain">[('lot_id', '=', active_id)]</field>
|
||||
</record>
|
||||
|
||||
<record id="action_qc_inspection_per_lot_done" model="ir.actions.act_window">
|
||||
<field name="name">Quality inspection from lot done</field>
|
||||
<field name="res_model">qc.inspection</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('lot', '=', active_id), ('state', 'not in', ['draft', 'waiting'])]</field>
|
||||
<field name="domain">[('lot_id', '=', active_id), ('state', 'not in', ['draft', 'waiting'])]</field>
|
||||
</record>
|
||||
|
||||
<record id="action_qc_inspection_per_lot_passed" model="ir.actions.act_window">
|
||||
<field name="name">Quality inspection from lot passed</field>
|
||||
<field name="res_model">qc.inspection</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('lot', '=', active_id), ('state', '=', 'success')]</field>
|
||||
<field name="domain">[('lot_id', '=', active_id), ('state', '=', 'success')]</field>
|
||||
</record>
|
||||
|
||||
<record id="action_qc_inspection_per_lot_failed" model="ir.actions.act_window">
|
||||
<field name="name">Quality inspections from lot failed</field>
|
||||
<field name="res_model">qc.inspection</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('lot', '=', active_id), ('state', '=', 'failed')]</field>
|
||||
<field name="domain">[('lot_id', '=', active_id), ('state', '=', 'failed')]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="stock_lot_qc_view">
|
||||
|
||||
Reference in New Issue
Block a user