[FIX] quality_control_mrp: Some problems

[IMP] quality_control_mrp: Smartbutton to inspections
This commit is contained in:
Pedro M. Baeza
2015-01-05 05:18:56 +01:00
committed by Carlos Roca
parent f9b4b95280
commit cc047aa8e4
6 changed files with 46 additions and 33 deletions

View File

@@ -9,27 +9,15 @@ class MrpProduction(models.Model):
_inherit = 'mrp.production'
@api.one
@api.depends('qc_inspections', 'qc_inspections.state')
@api.depends('qc_inspections')
def _count_inspections(self):
self.created_inspections = len(self.qc_inspections)
self.passed_inspections = len([x for x in self.qc_inspections if
x.state == 'success'])
self.failed_inspections = len([x for x in self.qc_inspections if
x.state == 'failed'])
self.done_inspections = (self.passed_inspections +
self.failed_inspections)
qc_inspections = fields.One2many(
comodel_name='qc.inspection', inverse_name='picking', copy=False,
comodel_name='qc.inspection', inverse_name='production', copy=False,
string='Inspections', help="Inspections related to this production.")
created_inspections = fields.Integer(
compute="_count_inspections", string="Created inspections")
done_inspections = fields.Integer(
compute="_count_inspections", string="Done inspections")
passed_inspections = fields.Integer(
compute="_count_inspections", string="Inspections OK")
failed_inspections = fields.Integer(
compute="_count_inspections", string="Inspections failed")
@api.v7
def action_produce(self, cr, uid, production_id, production_qty,

View File

@@ -13,25 +13,8 @@ class QcInspection(models.Model):
def get_production(self):
self.production = False
if self.object_id:
if self.object_id._name == 'mrp.production':
self.production = self.object_id
@api.one
@api.depends('object_id')
def _get_product(self):
"""Overriden for getting the product from a mrp.production."""
super(QcInspection, self)._get_product()
if self.object_id:
if self.object_id._name == 'mrp.production':
self.product = self.object_id.product_id
@api.one
@api.depends('object_id')
def _get_qty(self):
super(QcInspection, self)._get_qty()
if self.object_id:
if self.object_id._name == 'mrp.production':
self.qty = self.object_id.product_qty
if self.object_id._name == 'stock.move':
self.production = self.object_id.production_id
production = fields.Many2one(
comodel_name="mrp.production", compute="get_production", store=True)