mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
Merge pull request #128 from oihane/8.0-quality_control_mrp
[FIX] quality_control_mrp: partial fabrications...
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',
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user