[9.0][IMP] add a new field to show done qty.

This commit is contained in:
lreficent
2017-07-18 13:16:33 +02:00
committed by Chandresh Thakkar
parent 171279f01e
commit 774d28df42
3 changed files with 16 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L. # Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "MRP Request", "name": "MRP Production Request",
"summary": "Allows you to use Manufacturing Request as a previous " "summary": "Allows you to use Manufacturing Request as a previous "
"step to Manufacturing Orders for better manufacture " "step to Manufacturing Orders for better manufacture "
"planification.", "planification.",

View File

@@ -65,6 +65,9 @@ class MrpProductionRequest(models.Model):
def _compute_manufactured_qty(self): def _compute_manufactured_qty(self):
valid_states = self._get_mo_valid_states() valid_states = self._get_mo_valid_states()
for req in self: for req in self:
done_mo = req.mrp_production_ids.filtered(
lambda mo: mo.state in 'done').mapped('product_qty')
req.done_qty = sum(done_mo)
valid_mo = req.mrp_production_ids.filtered( valid_mo = req.mrp_production_ids.filtered(
lambda mo: mo.state in valid_states).mapped('product_qty') lambda mo: mo.state in valid_states).mapped('product_qty')
req.manufactured_qty = sum(valid_mo) req.manufactured_qty = sum(valid_mo)
@@ -118,7 +121,7 @@ class MrpProductionRequest(models.Model):
comodel_name='product.template', string='Product Template', comodel_name='product.template', string='Product Template',
related='product_id.product_tmpl_id') related='product_id.product_tmpl_id')
product_qty = fields.Float( product_qty = fields.Float(
required=True, track_visibility='onchange', string="Required Quantity", required=True, track_visibility='onchange',
digits_compute=dp.get_precision('Product Unit of Measure'), digits_compute=dp.get_precision('Product Unit of Measure'),
readonly=True, states={'draft': [('readonly', False)]}) readonly=True, states={'draft': [('readonly', False)]})
product_uom = fields.Many2one( product_uom = fields.Many2one(
@@ -128,13 +131,20 @@ class MrpProductionRequest(models.Model):
category_uom_id = fields.Many2one(related="product_uom.category_id") category_uom_id = fields.Many2one(related="product_uom.category_id")
manufactured_qty = fields.Float( manufactured_qty = fields.Float(
string="Quantity in Manufacturing Orders", string="Quantity in Manufacturing Orders",
compute=_compute_manufactured_qty, store=True, compute=_compute_manufactured_qty, store=True, readonly=True,
digits_compute=dp.get_precision('Product Unit of Measure'), digits_compute=dp.get_precision('Product Unit of Measure'),
readonly=True) help="Sum of the quantities in Manufacturing Orders (in any state).")
done_qty = fields.Float(
string="Quantity Done", store=True, readonly=True,
compute=_compute_manufactured_qty,
digits_compute=dp.get_precision('Product Unit of Measure'),
help="Sum of the quantities in all done Manufacturing Orders.")
pending_qty = fields.Float( pending_qty = fields.Float(
string="Pending Quantity", compute=_compute_manufactured_qty, string="Pending Quantity", compute=_compute_manufactured_qty,
store=True, digits_compute=dp.get_precision('Product Unit of Measure'), store=True, digits_compute=dp.get_precision('Product Unit of Measure'),
readonly=True) readonly=True,
help="Quantity pending to add to Manufacturing Orders "
"to fulfill the Manufacturing Request requirement.")
bom_id = fields.Many2one( bom_id = fields.Many2one(
comodel_name="mrp.bom", string="Bill of Materials", required=True, comodel_name="mrp.bom", string="Bill of Materials", required=True,
readonly=True, states={'draft': [('readonly', False)]}) readonly=True, states={'draft': [('readonly', False)]})

View File

@@ -50,6 +50,7 @@
</group> </group>
<group> <group>
<field name="product_qty"/> <field name="product_qty"/>
<field name="done_qty"/>
<field name="manufactured_qty"/> <field name="manufactured_qty"/>
<field name="pending_qty"/> <field name="pending_qty"/>
<field name="product_uom" groups="product.group_uom"/> <field name="product_uom" groups="product.group_uom"/>