Merge pull request #123 from oihane/8.0-quality

[IMP] quality_control_stock: if lot in reference, get its info
This commit is contained in:
Pedro M. Baeza
2016-05-11 12:43:42 +02:00
3 changed files with 30 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ 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')
@@ -20,6 +21,12 @@ class TestQualityControlMrp(TransactionCase):
})
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 +85,11 @@ class TestQualityControlMrp(TransactionCase):
'consume_produce')
self.assertEqual(self.production1.created_inspections, 1,
'Only one inspection must be created')
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)

View File

@@ -29,6 +29,8 @@ class QcInspection(models.Model):
self.lot = self.object_id.lot_id
elif self.object_id._name == 'stock.move':
self.lot = self.object_id.lot_ids[:1]
elif self.object_id._name == 'stock.production.lot':
self.lot = self.object_id
@api.one
@api.depends('object_id')
@@ -40,6 +42,8 @@ class QcInspection(models.Model):
self.product = self.object_id.product_id
elif self.object_id._name == 'stock.pack.operation':
self.product = self.object_id.product_id
elif self.object_id._name == 'stock.production.lot':
self.product = self.object_id.product_id
@api.onchange('object_id')
def onchange_object_id(self):

View File

@@ -237,3 +237,14 @@ class TestQualityControl(TransactionCase):
self.picking1.move_lines[:1].product_id)
self.assertEquals(self.inspection1.qty,
self.picking1.move_lines[:1].product_qty)
def test_qc_inspection_lot(self):
self.inspection1.write({
'object_id': '%s,%d' % (self.lot._model,
self.lot.id),
})
self.inspection1.onchange_object_id()
self.assertEquals(self.inspection1.lot,
self.lot)
self.assertEquals(self.inspection1.product,
self.lot.product_id)