mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] quality_control_*: Make use of qty field
Making it a regular field, you can put any manual quantity in inspections
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
{
|
||||
"name": "Quality control",
|
||||
"version": "8.0.1.0.0",
|
||||
"version": "8.0.1.1.0",
|
||||
"category": "Quality control",
|
||||
"license": "AGPL-3",
|
||||
"author": "OdooMRP team, "
|
||||
|
||||
@@ -28,11 +28,6 @@ class QcInspection(models.Model):
|
||||
else:
|
||||
self.product = False
|
||||
|
||||
@api.one
|
||||
@api.depends('object_id')
|
||||
def _get_qty(self):
|
||||
self.qty = 1.0
|
||||
|
||||
name = fields.Char(
|
||||
string='Inspection number', required=True, default='/', select=True,
|
||||
readonly=True, states={'draft': [('readonly', False)]}, copy=False)
|
||||
@@ -46,7 +41,7 @@ class QcInspection(models.Model):
|
||||
product = fields.Many2one(
|
||||
comodel_name="product.product", compute="_get_product", store=True,
|
||||
help="Product associated with the inspection")
|
||||
qty = fields.Float(string="Quantity", compute="_get_qty", store=True)
|
||||
qty = fields.Float(string="Quantity", default=1.0)
|
||||
test = fields.Many2one(
|
||||
comodel_name='qc.test', string='Test', readonly=True, select=True)
|
||||
inspection_lines = fields.One2many(
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<field name="test" />
|
||||
<field name="user" />
|
||||
<field name="object_id" />
|
||||
<field name="qty" />
|
||||
<field name="product" />
|
||||
</group>
|
||||
<group>
|
||||
@@ -112,6 +113,7 @@
|
||||
<field name="name" />
|
||||
<field name="user" />
|
||||
<field name="test" />
|
||||
<field name="qty" />
|
||||
<field name="product" />
|
||||
<field name="success" />
|
||||
<field name="state" />
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
"name": "Quality control - Stock",
|
||||
"version": "8.0.1.0.0",
|
||||
"version": "8.0.1.0.1",
|
||||
"category": "Quality control",
|
||||
"license": "AGPL-3",
|
||||
"author": "OdooMRP team, "
|
||||
|
||||
@@ -41,16 +41,23 @@ class QcInspection(models.Model):
|
||||
elif self.object_id._name == 'stock.pack.operation':
|
||||
self.product = self.object_id.product_id
|
||||
|
||||
@api.one
|
||||
@api.depends('object_id')
|
||||
def _get_qty(self):
|
||||
super(QcInspection, self)._get_qty()
|
||||
@api.onchange('object_id')
|
||||
def onchange_object_id(self):
|
||||
if self.object_id:
|
||||
if self.object_id._name == 'stock.move':
|
||||
self.qty = self.object_id.product_qty
|
||||
elif self.object_id._name == 'stock.pack.operation':
|
||||
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)
|
||||
# Fill qty when coming from pack operations
|
||||
if object_ref and object_ref._name == 'stock.pack.operation':
|
||||
res['qty'] = object_ref.product_qty
|
||||
return res
|
||||
|
||||
picking = fields.Many2one(
|
||||
comodel_name="stock.picking", compute="get_picking", store=True)
|
||||
lot = fields.Many2one(
|
||||
|
||||
@@ -35,6 +35,7 @@ class TestQualityControl(TransactionCase):
|
||||
'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.picking_type.default_location_dest_id.id,
|
||||
}
|
||||
@@ -60,8 +61,14 @@ class TestQualityControl(TransactionCase):
|
||||
self.picking1.do_transfer()
|
||||
self.assertEqual(self.picking1.created_inspections, 1,
|
||||
'Only one inspection must be created')
|
||||
self.assertEqual(self.picking1.qc_inspections[:1].test, self.test,
|
||||
inspection = self.picking1.qc_inspections[:1]
|
||||
self.assertEqual(inspection.qty, 2.0)
|
||||
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 = [(
|
||||
@@ -221,6 +228,7 @@ class TestQualityControl(TransactionCase):
|
||||
'object_id': '%s,%d' % (self.picking1.move_lines[:1]._model,
|
||||
self.picking1.move_lines[:1].id),
|
||||
})
|
||||
self.inspection1.onchange_object_id()
|
||||
self.assertEquals(self.inspection1.picking,
|
||||
self.picking1)
|
||||
self.assertEquals(self.inspection1.lot,
|
||||
|
||||
Reference in New Issue
Block a user