mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] quality_control_stock: if lot in reference, get its info
quality_control_mrp: tests extended [IMP] quality_control_mrp: take product from manufacturing order [IMP] quality_control_mrp: removed not required code [FIX] quality_control_mrp: expected singleton error [FIX] quality_control_mrp: partial fabrications where creating more inspections than required
This commit is contained in:
@@ -24,13 +24,15 @@ class MrpProduction(models.Model):
|
||||
@api.model
|
||||
def action_produce(self, production_id, production_qty, production_mode,
|
||||
wiz=False):
|
||||
production = self.browse(production_id)
|
||||
done_moves = production.move_created_ids2.filtered(
|
||||
lambda r: r.state == 'done')
|
||||
res = super(MrpProduction, self).action_produce(
|
||||
production_id, production_qty, production_mode, wiz=wiz)
|
||||
if production_mode == 'consume_produce':
|
||||
inspection_model = self.env['qc.inspection']
|
||||
production = self.browse(production_id)
|
||||
for move in production.move_created_ids2.filtered(
|
||||
lambda r: r.state == 'done'):
|
||||
lambda r: r.state == 'done') - done_moves:
|
||||
qc_trigger = self.env.ref('quality_control_mrp.qc_trigger_mrp')
|
||||
trigger_lines = set()
|
||||
for model in ['qc.trigger.product_category_line',
|
||||
|
||||
@@ -8,15 +8,23 @@ from openerp import models, fields, api
|
||||
class QcInspection(models.Model):
|
||||
_inherit = 'qc.inspection'
|
||||
|
||||
@api.one
|
||||
@api.depends('object_id')
|
||||
def get_production(self):
|
||||
self.production = False
|
||||
if self.object_id:
|
||||
if self.object_id._name == 'stock.move':
|
||||
self.production = self.object_id.production_id
|
||||
elif self.object_id._name == 'mrp.production':
|
||||
self.production = self.object_id
|
||||
for inspection in self:
|
||||
if inspection.object_id:
|
||||
if inspection.object_id._name == 'stock.move':
|
||||
inspection.production = inspection.object_id.production_id
|
||||
elif inspection.object_id._name == 'mrp.production':
|
||||
inspection.production = inspection.object_id
|
||||
|
||||
@api.depends('object_id')
|
||||
def _get_product(self):
|
||||
"""Overriden for getting the product from a manufacturing order."""
|
||||
for inspection in self:
|
||||
super(QcInspection, inspection)._get_product()
|
||||
if inspection.object_id and\
|
||||
inspection.object_id._name == 'mrp.production':
|
||||
inspection.product = inspection.object_id.product_id
|
||||
|
||||
production = fields.Many2one(
|
||||
comodel_name="mrp.production", compute="get_production", store=True)
|
||||
|
||||
@@ -10,16 +10,24 @@ 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('product.product_product_4')
|
||||
self.test = self.env.ref('quality_control.qc_test_1')
|
||||
self.trigger = self.env.ref('quality_control_mrp.qc_trigger_mrp')
|
||||
self.production1 = self.production_model.create({
|
||||
'product_id': self.product.id,
|
||||
'product_qty': 2.0,
|
||||
'product_uom': self.product.uom_id.id,
|
||||
})
|
||||
self.production1.action_confirm()
|
||||
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,
|
||||
})
|
||||
|
||||
def test_inspection_create_for_product(self):
|
||||
self.product.qc_triggers = [(
|
||||
@@ -78,3 +86,27 @@ class TestQualityControlMrp(TransactionCase):
|
||||
'consume_produce')
|
||||
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,
|
||||
}
|
||||
)]
|
||||
self.production1.action_produce(
|
||||
self.production1.id, 1.0, 'consume_produce')
|
||||
self.assertEqual(self.production1.created_inspections, 1,
|
||||
'Only one inspection must be created.')
|
||||
self.production1.action_produce(
|
||||
self.production1.id, 1.0, 'consume_produce')
|
||||
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._model,
|
||||
self.production1.id),
|
||||
})
|
||||
self.assertEquals(self.inspection1.production,
|
||||
self.production1)
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
<field name="groups_id"
|
||||
eval="[(4, ref('mrp.group_mrp_user'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product" position="after">
|
||||
<field name="production" />
|
||||
</field>
|
||||
<filter string="Product" position="after">
|
||||
<filter string="Production" domain="[]"
|
||||
context="{'group_by': 'production'}" />
|
||||
|
||||
Reference in New Issue
Block a user