[FIX] quality_control_mrp: partial fabrications where creating more inspections than required

This commit is contained in:
oihane
2016-05-25 10:47:31 +02:00
parent 8886f3d638
commit 36987f5da8
2 changed files with 21 additions and 2 deletions

View File

@@ -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',

View File

@@ -17,6 +17,7 @@ class TestQualityControlMrp(TransactionCase):
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()
@@ -86,6 +87,22 @@ class TestQualityControlMrp(TransactionCase):
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,