mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] quality_control_stock: black, isort
This commit is contained in:
committed by
Enrique Martín
parent
2d16412cbb
commit
79e2cf45fb
@@ -9,6 +9,6 @@ from odoo import api, SUPERUSER_ID
|
||||
def post_init_hook(cr, registry):
|
||||
# Create QC triggers
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
picking_type_ids = env['stock.picking.type'].sudo().search([])
|
||||
picking_type_ids = env["stock.picking.type"].sudo().search([])
|
||||
for picking_type_id in picking_type_ids:
|
||||
picking_type_id.sudo()._create_qc_trigger()
|
||||
|
||||
@@ -5,20 +5,13 @@
|
||||
|
||||
{
|
||||
"name": "Quality control - Stock",
|
||||
"version": "12.0.1.0.0",
|
||||
"version": "13.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": "https://github.com/OCA/manufacture/tree/12.0/"
|
||||
"quality_control_stock",
|
||||
"depends": [
|
||||
"quality_control",
|
||||
"stock",
|
||||
],
|
||||
"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_stock",
|
||||
"depends": ["quality_control", "stock"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"views/qc_inspection_view.xml",
|
||||
|
||||
@@ -7,95 +7,97 @@ from odoo.fields import first
|
||||
|
||||
|
||||
class QcInspection(models.Model):
|
||||
_inherit = 'qc.inspection'
|
||||
_inherit = "qc.inspection"
|
||||
|
||||
picking_id = fields.Many2one(
|
||||
comodel_name="stock.picking", compute="_compute_picking", store=True)
|
||||
comodel_name="stock.picking", compute="_compute_picking", store=True
|
||||
)
|
||||
lot_id = fields.Many2one(
|
||||
comodel_name='stock.production.lot', compute="_compute_lot",
|
||||
store=True)
|
||||
comodel_name="stock.production.lot", compute="_compute_lot", store=True
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def object_selection_values(self):
|
||||
result = super().object_selection_values()
|
||||
result.extend([
|
||||
('stock.picking', "Picking List"), ('stock.move', "Stock Move")])
|
||||
result.extend([("stock.picking", "Picking List"), ("stock.move", "Stock Move")])
|
||||
return result
|
||||
|
||||
@api.multi
|
||||
@api.depends('object_id')
|
||||
@api.depends("object_id")
|
||||
def _compute_picking(self):
|
||||
for inspection in self:
|
||||
if inspection.object_id:
|
||||
if inspection.object_id._name == 'stock.move':
|
||||
if inspection.object_id._name == "stock.move":
|
||||
inspection.picking_id = inspection.object_id.picking_id
|
||||
elif inspection.object_id._name == 'stock.picking':
|
||||
elif inspection.object_id._name == "stock.picking":
|
||||
inspection.picking_id = inspection.object_id
|
||||
elif inspection.object_id._name == 'stock.move.line':
|
||||
elif inspection.object_id._name == "stock.move.line":
|
||||
inspection.picking_id = inspection.object_id.picking_id
|
||||
|
||||
@api.multi
|
||||
@api.depends('object_id')
|
||||
@api.depends("object_id")
|
||||
def _compute_lot(self):
|
||||
moves = self.filtered(
|
||||
lambda i: i.object_id and
|
||||
i.object_id._name == 'stock.move').mapped('object_id')
|
||||
move_lines = self.env['stock.move.line'].search([
|
||||
('lot_id', '!=', False),
|
||||
('move_id', 'in', [move.id for move in moves])])
|
||||
lambda i: i.object_id and i.object_id._name == "stock.move"
|
||||
).mapped("object_id")
|
||||
move_lines = self.env["stock.move.line"].search(
|
||||
[("lot_id", "!=", False), ("move_id", "in", [move.id for move in moves])]
|
||||
)
|
||||
|
||||
for inspection in self:
|
||||
if inspection.object_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_id = first(move_lines.filtered(
|
||||
lambda line: line.move_id == inspection.object_id
|
||||
)).lot_id
|
||||
elif inspection.object_id._name == 'stock.production.lot':
|
||||
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_id = first(
|
||||
move_lines.filtered(
|
||||
lambda line: line.move_id == inspection.object_id
|
||||
)
|
||||
).lot_id
|
||||
elif inspection.object_id._name == "stock.production.lot":
|
||||
inspection.lot_id = inspection.object_id
|
||||
|
||||
@api.multi
|
||||
@api.depends('object_id')
|
||||
@api.depends("object_id")
|
||||
def _compute_product_id(self):
|
||||
"""Overriden for getting the product from a stock move."""
|
||||
self.ensure_one()
|
||||
super(QcInspection, self)._compute_product_id()
|
||||
if self.object_id:
|
||||
if self.object_id._name == 'stock.move':
|
||||
if self.object_id._name == "stock.move":
|
||||
self.product_id = self.object_id.product_id
|
||||
elif self.object_id._name == 'stock.move.line':
|
||||
elif self.object_id._name == "stock.move.line":
|
||||
self.product_id = self.object_id.product_id
|
||||
elif self.object_id._name == 'stock.production.lot':
|
||||
elif self.object_id._name == "stock.production.lot":
|
||||
self.product_id = self.object_id.product_id
|
||||
|
||||
@api.onchange('object_id')
|
||||
@api.onchange("object_id")
|
||||
def onchange_object_id(self):
|
||||
if self.object_id:
|
||||
if self.object_id._name == 'stock.move':
|
||||
if self.object_id._name == "stock.move":
|
||||
self.qty = self.object_id.product_qty
|
||||
elif self.object_id._name == 'stock.move.line':
|
||||
elif self.object_id._name == "stock.move.line":
|
||||
self.qty = self.object_id.product_qty
|
||||
|
||||
@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 == '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
|
||||
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
|
||||
|
||||
|
||||
class QcInspectionLine(models.Model):
|
||||
_inherit = 'qc.inspection.line'
|
||||
_inherit = "qc.inspection.line"
|
||||
|
||||
picking_id = fields.Many2one(
|
||||
comodel_name="stock.picking", related="inspection_id.picking_id",
|
||||
store=True)
|
||||
comodel_name="stock.picking", related="inspection_id.picking_id", store=True
|
||||
)
|
||||
lot_id = fields.Many2one(
|
||||
comodel_name="stock.production.lot", related="inspection_id.lot_id",
|
||||
store=True)
|
||||
comodel_name="stock.production.lot", related="inspection_id.lot_id", store=True
|
||||
)
|
||||
|
||||
@@ -6,7 +6,8 @@ from odoo import fields, models
|
||||
|
||||
|
||||
class QcTrigger(models.Model):
|
||||
_inherit = 'qc.trigger'
|
||||
_inherit = "qc.trigger"
|
||||
|
||||
picking_type_id = fields.Many2one(
|
||||
comodel_name="stock.picking.type", readonly=True, ondelete="cascade")
|
||||
comodel_name="stock.picking.type", readonly=True, ondelete="cascade"
|
||||
)
|
||||
|
||||
@@ -4,59 +4,74 @@
|
||||
# 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 StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
_inherit = "stock.picking"
|
||||
|
||||
qc_inspections_ids = fields.One2many(
|
||||
comodel_name='qc.inspection', inverse_name='picking_id', copy=False,
|
||||
string='Inspections', help="Inspections related to this picking.")
|
||||
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")
|
||||
compute="_compute_count_inspections", string="Created inspections"
|
||||
)
|
||||
done_inspections = fields.Integer(
|
||||
compute="_compute_count_inspections", string="Done inspections")
|
||||
compute="_compute_count_inspections", string="Done inspections"
|
||||
)
|
||||
passed_inspections = fields.Integer(
|
||||
compute="_compute_count_inspections", string="Inspections OK")
|
||||
compute="_compute_count_inspections", string="Inspections OK"
|
||||
)
|
||||
failed_inspections = fields.Integer(
|
||||
compute="_compute_count_inspections", string="Inspections failed")
|
||||
compute="_compute_count_inspections", string="Inspections failed"
|
||||
)
|
||||
|
||||
@api.depends('qc_inspections_ids', 'qc_inspections_ids.state')
|
||||
@api.depends("qc_inspections_ids", "qc_inspections_ids.state")
|
||||
def _compute_count_inspections(self):
|
||||
data = self.env['qc.inspection'].read_group([
|
||||
('id', 'in', self.mapped('qc_inspections_ids').ids),
|
||||
], ['picking_id', 'state'], ['picking_id', 'state'], lazy=False)
|
||||
data = self.env["qc.inspection"].read_group(
|
||||
[("id", "in", self.mapped("qc_inspections_ids").ids)],
|
||||
["picking_id", "state"],
|
||||
["picking_id", "state"],
|
||||
lazy=False,
|
||||
)
|
||||
picking_data = {}
|
||||
for d in data:
|
||||
picking_data.setdefault(d['picking_id'][0], {})\
|
||||
.setdefault(d['state'], 0)
|
||||
picking_data[d['picking_id'][0]][d['state']] += d['__count']
|
||||
picking_data.setdefault(d["picking_id"][0], {}).setdefault(d["state"], 0)
|
||||
picking_data[d["picking_id"][0]][d["state"]] += d["__count"]
|
||||
for picking in self:
|
||||
count_data = picking_data.get(picking.id, {})
|
||||
picking.created_inspections = sum(count_data.values())
|
||||
picking.passed_inspections = count_data.get('success', 0)
|
||||
picking.failed_inspections = count_data.get('failed', 0)
|
||||
picking.done_inspections = \
|
||||
(picking.passed_inspections + picking.failed_inspections)
|
||||
picking.passed_inspections = count_data.get("success", 0)
|
||||
picking.failed_inspections = count_data.get("failed", 0)
|
||||
picking.done_inspections = (
|
||||
picking.passed_inspections + picking.failed_inspections
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def action_done(self):
|
||||
res = super(StockPicking, self).action_done()
|
||||
inspection_model = self.env['qc.inspection']
|
||||
qc_trigger = self.env['qc.trigger'].search(
|
||||
[('picking_type_id', '=', self.picking_type_id.id)])
|
||||
inspection_model = self.env["qc.inspection"]
|
||||
qc_trigger = self.env["qc.trigger"].search(
|
||||
[("picking_type_id", "=", self.picking_type_id.id)]
|
||||
)
|
||||
for operation in self.move_lines:
|
||||
trigger_lines = set()
|
||||
for model in ['qc.trigger.product_category_line',
|
||||
'qc.trigger.product_template_line',
|
||||
'qc.trigger.product_line']:
|
||||
partner = (self.partner_id
|
||||
if qc_trigger.partner_selectable else False)
|
||||
for model in [
|
||||
"qc.trigger.product_category_line",
|
||||
"qc.trigger.product_template_line",
|
||||
"qc.trigger.product_line",
|
||||
]:
|
||||
partner = self.partner_id if qc_trigger.partner_selectable else False
|
||||
trigger_lines = trigger_lines.union(
|
||||
self.env[model].get_trigger_line_for_product(
|
||||
qc_trigger, operation.product_id, partner=partner))
|
||||
qc_trigger, operation.product_id, partner=partner
|
||||
)
|
||||
)
|
||||
for trigger_line in _filter_trigger_lines(trigger_lines):
|
||||
inspection_model._make_inspection(operation, trigger_line)
|
||||
return res
|
||||
|
||||
@@ -6,18 +6,18 @@ from odoo import api, models
|
||||
|
||||
|
||||
class StockPickingType(models.Model):
|
||||
_inherit = 'stock.picking.type'
|
||||
_inherit = "stock.picking.type"
|
||||
|
||||
@api.multi
|
||||
def _create_qc_trigger(self):
|
||||
for picking_type in self:
|
||||
qc_trigger = {
|
||||
'name': picking_type.name,
|
||||
'company_id': picking_type.warehouse_id.company_id.id,
|
||||
'picking_type_id': picking_type.id,
|
||||
'partner_selectable': True
|
||||
"name": picking_type.name,
|
||||
"company_id": picking_type.warehouse_id.company_id.id,
|
||||
"picking_type_id": picking_type.id,
|
||||
"partner_selectable": True,
|
||||
}
|
||||
self.env['qc.trigger'].sudo().create(qc_trigger)
|
||||
self.env["qc.trigger"].sudo().create(qc_trigger)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, val_list):
|
||||
@@ -28,10 +28,11 @@ class StockPickingType(models.Model):
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
res = super(StockPickingType, self).write(vals)
|
||||
if vals.get('name') or vals.get('warehouse_id'):
|
||||
qc_trigger_model = self.env['qc.trigger'].sudo()
|
||||
if vals.get("name") or vals.get("warehouse_id"):
|
||||
qc_trigger_model = self.env["qc.trigger"].sudo()
|
||||
for rec in self:
|
||||
qc_triggers = qc_trigger_model.search(
|
||||
[('picking_type_id', '=', rec.id)])
|
||||
qc_triggers.write({'name': rec.name})
|
||||
[("picking_type_id", "=", rec.id)]
|
||||
)
|
||||
qc_triggers.write({"name": rec.name})
|
||||
return res
|
||||
|
||||
@@ -6,33 +6,43 @@ from odoo import api, fields, models
|
||||
|
||||
|
||||
class StockProductionLot(models.Model):
|
||||
_inherit = 'stock.production.lot'
|
||||
_inherit = "stock.production.lot"
|
||||
|
||||
qc_inspections_ids = fields.One2many(
|
||||
comodel_name='qc.inspection', inverse_name='lot_id', copy=False,
|
||||
string='Inspections', help="Inspections related to this lot.")
|
||||
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")
|
||||
compute="_compute_count_inspections", string="Created inspections"
|
||||
)
|
||||
done_inspections = fields.Integer(
|
||||
compute="_compute_count_inspections", string="Done inspections")
|
||||
compute="_compute_count_inspections", string="Done inspections"
|
||||
)
|
||||
passed_inspections = fields.Integer(
|
||||
compute="_compute_count_inspections", string="Inspections OK")
|
||||
compute="_compute_count_inspections", string="Inspections OK"
|
||||
)
|
||||
failed_inspections = fields.Integer(
|
||||
compute="_compute_count_inspections", string="Inspections failed")
|
||||
compute="_compute_count_inspections", string="Inspections failed"
|
||||
)
|
||||
|
||||
@api.depends('qc_inspections_ids', 'qc_inspections_ids.state')
|
||||
@api.depends("qc_inspections_ids", "qc_inspections_ids.state")
|
||||
def _compute_count_inspections(self):
|
||||
data = self.env['qc.inspection'].read_group([
|
||||
('id', 'in', self.mapped('qc_inspections_ids').ids),
|
||||
], ['lot_id', 'state'], ['lot_id', 'state'], lazy=False)
|
||||
data = self.env["qc.inspection"].read_group(
|
||||
[("id", "in", self.mapped("qc_inspections_ids").ids)],
|
||||
["lot_id", "state"],
|
||||
["lot_id", "state"],
|
||||
lazy=False,
|
||||
)
|
||||
lot_data = {}
|
||||
for d in data:
|
||||
lot_data.setdefault(d['lot_id'][0], {}).setdefault(d['state'], 0)
|
||||
lot_data[d['lot_id'][0]][d['state']] += d['__count']
|
||||
lot_data.setdefault(d["lot_id"][0], {}).setdefault(d["state"], 0)
|
||||
lot_data[d["lot_id"][0]][d["state"]] += d["__count"]
|
||||
for lot in self:
|
||||
count_data = lot_data.get(lot.id, {})
|
||||
lot.created_inspections = sum(count_data.values())
|
||||
lot.passed_inspections = count_data.get('success', 0)
|
||||
lot.failed_inspections = count_data.get('failed', 0)
|
||||
lot.done_inspections = \
|
||||
(lot.passed_inspections + lot.failed_inspections)
|
||||
lot.passed_inspections = count_data.get("success", 0)
|
||||
lot.failed_inspections = count_data.get("failed", 0)
|
||||
lot.done_inspections = lot.passed_inspections + lot.failed_inspections
|
||||
|
||||
@@ -6,287 +6,347 @@ from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestQualityControl(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestQualityControl, self).setUp()
|
||||
|
||||
self.users_model = self.env['res.users']
|
||||
self.picking_model = self.env['stock.picking']
|
||||
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_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')
|
||||
self.picking_type = self.env.ref('stock.picking_type_out')
|
||||
self.location_dest = self.env.ref('stock.stock_location_customers')
|
||||
self.sequence = self.env['ir.sequence'] \
|
||||
.search([('prefix', 'like', '/OUT/')], limit=1)
|
||||
inspection_lines = (
|
||||
self.inspection_model._prepare_inspection_lines(self.test))
|
||||
self.inspection1 = self.inspection_model.create({
|
||||
'name': 'Test Inspection',
|
||||
'inspection_lines': inspection_lines,
|
||||
})
|
||||
self.users_model = self.env["res.users"]
|
||||
self.picking_model = self.env["stock.picking"]
|
||||
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_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")
|
||||
self.picking_type = self.env.ref("stock.picking_type_out")
|
||||
self.location_dest = self.env.ref("stock.stock_location_customers")
|
||||
self.sequence = self.env["ir.sequence"].search(
|
||||
[("prefix", "like", "/OUT/")], limit=1
|
||||
)
|
||||
inspection_lines = self.inspection_model._prepare_inspection_lines(self.test)
|
||||
self.inspection1 = self.inspection_model.create(
|
||||
{"name": "Test Inspection", "inspection_lines": inspection_lines}
|
||||
)
|
||||
self.trigger = self.qc_trigger_model.search(
|
||||
[('picking_type_id', '=', self.picking_type.id)])
|
||||
self.lot = self.env['stock.production.lot'].create({
|
||||
'name': 'Lot for tests',
|
||||
'product_id': self.product.id,
|
||||
})
|
||||
self.group_stock_user = self.env.ref('stock.group_stock_user')
|
||||
self.company1 = self.env.ref('base.main_company')
|
||||
[("picking_type_id", "=", self.picking_type.id)]
|
||||
)
|
||||
self.lot = self.env["stock.production.lot"].create(
|
||||
{"name": "Lot for tests", "product_id": self.product.id}
|
||||
)
|
||||
self.group_stock_user = self.env.ref("stock.group_stock_user")
|
||||
self.company1 = self.env.ref("base.main_company")
|
||||
self.user1_id = self._create_user(
|
||||
'user_1', [self.group_stock_user], self.company1)
|
||||
"user_1", [self.group_stock_user], self.company1
|
||||
)
|
||||
|
||||
move_vals = {
|
||||
'name': self.product.name,
|
||||
'product_id': self.product.id,
|
||||
'product_uom': self.product.uom_id.id,
|
||||
'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
|
||||
"name": self.product.name,
|
||||
"product_id": self.product.id,
|
||||
"product_uom": self.product.uom_id.id,
|
||||
"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.sudo(self.user1_id) \
|
||||
.with_context(default_picking_type_id=self.picking_type.id) \
|
||||
.create({
|
||||
'partner_id': self.partner1.id,
|
||||
'picking_type_id': self.picking_type.id,
|
||||
'move_lines': [(0, 0, move_vals)],
|
||||
'location_dest_id': self.location_dest.id
|
||||
})
|
||||
self.picking1 = (
|
||||
self.picking_model.sudo(self.user1_id)
|
||||
.with_context(default_picking_type_id=self.picking_type.id)
|
||||
.create(
|
||||
{
|
||||
"partner_id": self.partner1.id,
|
||||
"picking_type_id": self.picking_type.id,
|
||||
"move_lines": [(0, 0, move_vals)],
|
||||
"location_dest_id": self.location_dest.id,
|
||||
}
|
||||
)
|
||||
)
|
||||
self.picking1.action_confirm()
|
||||
sequence = 10
|
||||
for line in self.picking1.move_lines.filtered(
|
||||
lambda r: r.product_id == self.product):
|
||||
line.write({
|
||||
'move_line_ids': [(0, 0, {
|
||||
'lot_id': self.lot.id,
|
||||
'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
|
||||
})
|
||||
lambda r: r.product_id == self.product
|
||||
):
|
||||
line.write(
|
||||
{
|
||||
"move_line_ids": [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"lot_id": self.lot.id,
|
||||
"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 _create_user(self, login, groups, company):
|
||||
""" Create a user."""
|
||||
group_ids = [group.id for group in groups]
|
||||
user = self.users_model.with_context({'no_reset_password': True}).\
|
||||
create({
|
||||
'name': 'Sale User',
|
||||
'login': login,
|
||||
'password': 'test',
|
||||
'email': 'test@yourcompany.com',
|
||||
'company_id': company.id,
|
||||
'company_ids': [(4, company.id)],
|
||||
'groups_id': [(6, 0, group_ids)]
|
||||
})
|
||||
user = self.users_model.with_context({"no_reset_password": True}).create(
|
||||
{
|
||||
"name": "Sale User",
|
||||
"login": login,
|
||||
"password": "test",
|
||||
"email": "test@yourcompany.com",
|
||||
"company_id": company.id,
|
||||
"company_ids": [(4, company.id)],
|
||||
"groups_id": [(6, 0, group_ids)],
|
||||
}
|
||||
)
|
||||
return user.id
|
||||
|
||||
def test_inspection_create_for_product(self):
|
||||
self.product.qc_triggers = [(
|
||||
0, 0, {
|
||||
'trigger': self.trigger.id,
|
||||
'test': self.test.id,
|
||||
}
|
||||
)]
|
||||
self.product.qc_triggers = [
|
||||
(0, 0, {"trigger": self.trigger.id, "test": self.test.id})
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 1, "Only one inspection must be created"
|
||||
)
|
||||
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.')
|
||||
self.assertEqual(
|
||||
inspection.test, self.test, "Wrong test picked when creating inspection."
|
||||
)
|
||||
# Try in this context if onchange with an stock.pack.operation works
|
||||
inspection.qty = 5
|
||||
inspection.onchange_object_id()
|
||||
self.assertEqual(inspection.qty, 2.0)
|
||||
|
||||
def test_inspection_create_for_template(self):
|
||||
self.product.product_tmpl_id.qc_triggers = [(
|
||||
0, 0, {
|
||||
'trigger': self.trigger.id,
|
||||
'test': self.test.id,
|
||||
}
|
||||
)]
|
||||
self.product.product_tmpl_id.qc_triggers = [
|
||||
(0, 0, {"trigger": self.trigger.id, "test": self.test.id})
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 1, "Only one inspection must be created"
|
||||
)
|
||||
self.assertEqual(
|
||||
self.picking1.qc_inspections_ids[:1].test,
|
||||
self.test,
|
||||
"Wrong test picked when creating inspection.",
|
||||
)
|
||||
|
||||
def test_inspection_create_for_category(self):
|
||||
self.product.categ_id.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})
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 1, "Only one inspection must be created"
|
||||
)
|
||||
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):
|
||||
self.product.qc_triggers = [(
|
||||
0, 0, {
|
||||
'trigger': self.trigger.id,
|
||||
'test': self.test.id,
|
||||
'partners': [(6, 0, self.partner1.ids)],
|
||||
}
|
||||
)]
|
||||
self.product.qc_triggers = [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"trigger": self.trigger.id,
|
||||
"test": self.test.id,
|
||||
"partners": [(6, 0, self.partner1.ids)],
|
||||
},
|
||||
)
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 1, "Only one inspection must be created"
|
||||
)
|
||||
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):
|
||||
self.product.product_tmpl_id.qc_triggers = [(
|
||||
0, 0, {
|
||||
'trigger': self.trigger.id,
|
||||
'test': self.test.id,
|
||||
'partners': [(6, 0, self.partner1.ids)],
|
||||
}
|
||||
)]
|
||||
self.product.product_tmpl_id.qc_triggers = [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"trigger": self.trigger.id,
|
||||
"test": self.test.id,
|
||||
"partners": [(6, 0, self.partner1.ids)],
|
||||
},
|
||||
)
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 1, "Only one inspection must be created"
|
||||
)
|
||||
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):
|
||||
self.product.categ_id.qc_triggers = [(
|
||||
0, 0, {
|
||||
'trigger': self.trigger.id,
|
||||
'test': self.test.id,
|
||||
'partners': [(6, 0, self.partner1.ids)],
|
||||
}
|
||||
)]
|
||||
self.product.categ_id.qc_triggers = [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"trigger": self.trigger.id,
|
||||
"test": self.test.id,
|
||||
"partners": [(6, 0, self.partner1.ids)],
|
||||
},
|
||||
)
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 1, "Only one inspection must be created"
|
||||
)
|
||||
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):
|
||||
self.product.qc_triggers = [(
|
||||
0, 0, {
|
||||
'trigger': self.trigger.id,
|
||||
'test': self.test.id,
|
||||
'partners': [(6, 0, self.partner2.ids)],
|
||||
}
|
||||
)]
|
||||
self.product.qc_triggers = [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"trigger": self.trigger.id,
|
||||
"test": self.test.id,
|
||||
"partners": [(6, 0, self.partner2.ids)],
|
||||
},
|
||||
)
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 0,
|
||||
'No inspection must be created')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 0, "No inspection must be created"
|
||||
)
|
||||
|
||||
def test_inspection_create_for_template_wrong_partner(self):
|
||||
self.product.product_tmpl_id.qc_triggers = [(
|
||||
0, 0, {
|
||||
'trigger': self.trigger.id,
|
||||
'test': self.test.id,
|
||||
'partners': [(6, 0, self.partner2.ids)],
|
||||
}
|
||||
)]
|
||||
self.product.product_tmpl_id.qc_triggers = [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"trigger": self.trigger.id,
|
||||
"test": self.test.id,
|
||||
"partners": [(6, 0, self.partner2.ids)],
|
||||
},
|
||||
)
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 0,
|
||||
'No inspection must be created')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 0, "No inspection must be created"
|
||||
)
|
||||
|
||||
def test_inspection_create_for_category_wrong_partner(self):
|
||||
self.product.categ_id.qc_triggers = [(
|
||||
0, 0, {
|
||||
'trigger': self.trigger.id,
|
||||
'test': self.test.id,
|
||||
'partners': [(6, 0, self.partner2.ids)],
|
||||
}
|
||||
)]
|
||||
self.product.categ_id.qc_triggers = [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"trigger": self.trigger.id,
|
||||
"test": self.test.id,
|
||||
"partners": [(6, 0, self.partner2.ids)],
|
||||
},
|
||||
)
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 0,
|
||||
'No inspection must be created')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 0, "No 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,
|
||||
}
|
||||
)]
|
||||
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})
|
||||
]
|
||||
self.picking1.action_done()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
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_ids[:1].test, self.test,
|
||||
'Wrong test picked when creating inspection.')
|
||||
self.assertEqual(
|
||||
self.picking1.created_inspections, 1, "Only one inspection must be created"
|
||||
)
|
||||
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_ids[:1].test,
|
||||
self.test,
|
||||
"Wrong test picked when creating inspection.",
|
||||
)
|
||||
|
||||
def test_picking_type(self):
|
||||
picking_type = self.picking_type_model.create({
|
||||
'name': 'Test Picking Type',
|
||||
'code': 'outgoing',
|
||||
'sequence_id': self.sequence.id
|
||||
})
|
||||
picking_type = self.picking_type_model.create(
|
||||
{
|
||||
"name": "Test Picking Type",
|
||||
"code": "outgoing",
|
||||
"sequence_id": self.sequence.id,
|
||||
}
|
||||
)
|
||||
trigger = self.qc_trigger_model.search(
|
||||
[('picking_type_id', '=', picking_type.id)])
|
||||
self.assertEqual(len(trigger), 1,
|
||||
'One trigger must have been created.')
|
||||
self.assertEqual(trigger.name, picking_type.name,
|
||||
'Trigger name must match picking type name.')
|
||||
picking_type.write({
|
||||
'name': 'Test Name Change',
|
||||
})
|
||||
self.assertEqual(trigger.name, picking_type.name,
|
||||
'Trigger name must match picking type name.')
|
||||
[("picking_type_id", "=", picking_type.id)]
|
||||
)
|
||||
self.assertEqual(len(trigger), 1, "One trigger must have been created.")
|
||||
self.assertEqual(
|
||||
trigger.name,
|
||||
picking_type.name,
|
||||
"Trigger name must match picking type name.",
|
||||
)
|
||||
picking_type.write({"name": "Test Name Change"})
|
||||
self.assertEqual(
|
||||
trigger.name,
|
||||
picking_type.name,
|
||||
"Trigger name must match picking type name.",
|
||||
)
|
||||
|
||||
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.assertEqual(self.inspection1.picking_id,
|
||||
self.picking1)
|
||||
self.inspection1.write(
|
||||
{
|
||||
"name": self.picking1.move_lines[:1]._name + "inspection",
|
||||
"object_id": "%s,%d" % (self.picking1._name, self.picking1.id),
|
||||
}
|
||||
)
|
||||
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.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.assertEqual(self.inspection1.picking_id,
|
||||
self.picking1)
|
||||
self.assertEqual(self.inspection1.lot_id,
|
||||
self.lot)
|
||||
self.assertEqual(self.inspection1.product_id,
|
||||
self.picking1.move_lines[:1].product_id)
|
||||
self.assertEqual(self.inspection1.qty,
|
||||
self.picking1.move_lines[:1].product_qty)
|
||||
self.assertEqual(self.inspection1.picking_id, self.picking1)
|
||||
self.assertEqual(self.inspection1.lot_id, self.lot)
|
||||
self.assertEqual(
|
||||
self.inspection1.product_id, self.picking1.move_lines[:1].product_id
|
||||
)
|
||||
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.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.assertEqual(self.inspection1.lot_id,
|
||||
self.lot)
|
||||
self.assertEqual(self.inspection1.product_id,
|
||||
self.lot.product_id)
|
||||
self.assertEqual(self.inspection1.lot_id, self.lot)
|
||||
self.assertEqual(self.inspection1.product_id, self.lot.product_id)
|
||||
|
||||
@@ -1,84 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!-- 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_picking">
|
||||
<field name="name">qc.inspection.form.view.picking</field>
|
||||
<field name="model">qc.inspection</field>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_form_view"/>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id" groups="stock.group_production_lot" />
|
||||
<field name="picking_id" />
|
||||
<field name="lot_id" groups="stock.group_production_lot" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="qc_inspection_tree_view_picking">
|
||||
<field name="name">qc.inspection.tree.view.picking</field>
|
||||
<field name="model">qc.inspection</field>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_tree_view"/>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_tree_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id" groups="stock.group_production_lot"/>
|
||||
<field name="picking_id" />
|
||||
<field name="lot_id" groups="stock.group_production_lot" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="qc_inspection_search_view_picking">
|
||||
<field name="name">qc.inspection.search.view.picking</field>
|
||||
<field name="model">qc.inspection</field>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_search_view"/>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_search_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id" groups="stock.group_production_lot"/>
|
||||
<field name="picking_id" />
|
||||
<field name="lot_id" groups="stock.group_production_lot" />
|
||||
</field>
|
||||
<group expand="0" position="inside">
|
||||
<filter string="Picking"
|
||||
domain="[]"
|
||||
name="group_by_picking_id"
|
||||
context="{'group_by': 'picking_id'}"/>
|
||||
<filter string="Lot"
|
||||
domain="[]"
|
||||
name="group_by_lot_id"
|
||||
groups="stock.group_production_lot"
|
||||
context="{'group_by': 'lot_id'}"/>
|
||||
<filter
|
||||
string="Picking"
|
||||
domain="[]"
|
||||
name="group_by_picking_id"
|
||||
context="{'group_by': 'picking_id'}"
|
||||
/>
|
||||
<filter
|
||||
string="Lot"
|
||||
domain="[]"
|
||||
name="group_by_lot_id"
|
||||
groups="stock.group_production_lot"
|
||||
context="{'group_by': 'lot_id'}"
|
||||
/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="qc_inspection_line_tree_stock_view">
|
||||
<field name="name">qc.inspection.line.tree.stock</field>
|
||||
<field name="model">qc.inspection.line</field>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_line_tree_view"/>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_line_tree_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id"/>
|
||||
<field name="picking_id" />
|
||||
<field name="lot_id" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="qc_inspection_line_search_stock_view">
|
||||
<field name="name">qc.inspection.line.search.stock</field>
|
||||
<field name="model">qc.inspection.line</field>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_line_search_view"/>
|
||||
<field name="inherit_id" ref="quality_control.qc_inspection_line_search_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="picking_id"/>
|
||||
<field name="lot_id"/>
|
||||
<field name="picking_id" />
|
||||
<field name="lot_id" />
|
||||
</field>
|
||||
<group expand="0" position="inside">
|
||||
<filter string="Picking"
|
||||
domain="[]"
|
||||
name="group_by_picking_id"
|
||||
context="{'group_by': 'picking_id'}"/>
|
||||
<filter string="Lot"
|
||||
domain="[]"
|
||||
name="group_by_lot_id"
|
||||
context="{'group_by': 'lot_id'}"/>
|
||||
<filter
|
||||
string="Picking"
|
||||
domain="[]"
|
||||
name="group_by_picking_id"
|
||||
context="{'group_by': 'picking_id'}"
|
||||
/>
|
||||
<filter
|
||||
string="Lot"
|
||||
domain="[]"
|
||||
name="group_by_lot_id"
|
||||
context="{'group_by': 'lot_id'}"
|
||||
/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!-- Copyright 2018 Simone Rubino - Agile Business Group
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
@@ -8,60 +8,74 @@
|
||||
<field name="view_mode">tree,form</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_id', '=', 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_id', '=', 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_id', '=', 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">
|
||||
<field name="name">stock.picking.qc.view</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form" />
|
||||
<field name="groups_id"
|
||||
eval="[(4, ref('quality_control.group_quality_control_user'))]" />
|
||||
<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_picking)d"
|
||||
icon="fa-list">
|
||||
<field name="created_inspections"
|
||||
widget="statinfo"
|
||||
string="inspections" />
|
||||
<button
|
||||
class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_picking)d"
|
||||
icon="fa-list"
|
||||
>
|
||||
<field
|
||||
name="created_inspections"
|
||||
widget="statinfo"
|
||||
string="inspections"
|
||||
/>
|
||||
</button>
|
||||
<button class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_picking_done)d"
|
||||
icon="fa-pencil">
|
||||
<button
|
||||
class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_picking_done)d"
|
||||
icon="fa-pencil"
|
||||
>
|
||||
<field name="done_inspections" widget="statinfo" />
|
||||
</button>
|
||||
<button class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_picking_passed)d"
|
||||
icon="fa-thumbs-o-up">
|
||||
<button
|
||||
class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_picking_passed)d"
|
||||
icon="fa-thumbs-o-up"
|
||||
>
|
||||
<field name="passed_inspections" widget="statinfo" />
|
||||
</button>
|
||||
<button class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_picking_failed)d"
|
||||
icon="fa-thumbs-o-down">
|
||||
<button
|
||||
class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_picking_failed)d"
|
||||
icon="fa-thumbs-o-down"
|
||||
>
|
||||
<field name="failed_inspections" widget="statinfo" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!-- Copyright 2018 Simone Rubino - Agile Business Group
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
@@ -8,60 +8,74 @@
|
||||
<field name="view_mode">tree,form</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_id', '=', 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_id', '=', 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_id', '=', 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">
|
||||
<field name="name">stock.production.lot.qc.view</field>
|
||||
<field name="model">stock.production.lot</field>
|
||||
<field name="inherit_id" ref="stock.view_production_lot_form" />
|
||||
<field name="groups_id"
|
||||
eval="[(4, ref('quality_control.group_quality_control_user'))]" />
|
||||
<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_lot)d"
|
||||
icon="fa-list">
|
||||
<field name="created_inspections"
|
||||
widget="statinfo"
|
||||
string="inspections" />
|
||||
<button
|
||||
class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_lot)d"
|
||||
icon="fa-list"
|
||||
>
|
||||
<field
|
||||
name="created_inspections"
|
||||
widget="statinfo"
|
||||
string="inspections"
|
||||
/>
|
||||
</button>
|
||||
<button class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_lot_done)d"
|
||||
icon="fa-pencil">
|
||||
<button
|
||||
class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_lot_done)d"
|
||||
icon="fa-pencil"
|
||||
>
|
||||
<field name="done_inspections" widget="statinfo" />
|
||||
</button>
|
||||
<button class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_lot_passed)d"
|
||||
icon="fa-thumbs-o-up">
|
||||
<button
|
||||
class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_lot_passed)d"
|
||||
icon="fa-thumbs-o-up"
|
||||
>
|
||||
<field name="passed_inspections" widget="statinfo" />
|
||||
</button>
|
||||
<button class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_lot_failed)d"
|
||||
icon="fa-thumbs-o-down">
|
||||
<button
|
||||
class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_lot_failed)d"
|
||||
icon="fa-thumbs-o-down"
|
||||
>
|
||||
<field name="failed_inspections" widget="statinfo" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user