mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[FIX] quality_control_mrp: Some problems
[IMP] quality_control_mrp: Smartbutton to inspections
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
"data": [
|
||||
'data/quality_control_mrp_data.xml',
|
||||
'views/qc_inspection_view.xml',
|
||||
'views/mrp_production_view.xml',
|
||||
],
|
||||
"installable": True,
|
||||
"auto_install": True,
|
||||
|
||||
@@ -37,3 +37,7 @@ msgstr "Producción realizada"
|
||||
msgid "Production order"
|
||||
msgstr "Orden de producción"
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: view:mrp.production:quality_control_mrp.mrp_production_qc_view
|
||||
msgid "inspections"
|
||||
msgstr "inspecciones"
|
||||
|
||||
@@ -37,3 +37,8 @@ msgstr ""
|
||||
msgid "Production order"
|
||||
msgstr ""
|
||||
|
||||
#. module: quality_control_mrp
|
||||
#: view:mrp.production:quality_control_mrp.mrp_production_qc_view
|
||||
msgid "inspections"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
32
quality_control_mrp/views/mrp_production_view.xml
Normal file
32
quality_control_mrp/views/mrp_production_view.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="action_qc_inspection_per_production" model="ir.actions.act_window">
|
||||
<field name="name">Quality inspections from production order</field>
|
||||
<field name="res_model">qc.inspection</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('production', '=', active_id)]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="mrp_production_qc_view">
|
||||
<field name="name">mrp.production.form.qc</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<div class="oe_title" position="after">
|
||||
<div class="oe_right oe_button_box">
|
||||
<button class="oe_inline oe_stat_button"
|
||||
type="action"
|
||||
name="%(action_qc_inspection_per_production)d"
|
||||
icon="fa-bookmark-o">
|
||||
<field name="created_inspections"
|
||||
widget="statinfo"
|
||||
string="inspections" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user