Merge lp:~vauxoo/openobject-addons/6.1-bug-1051367-moylop260_vauxoo into lp:openobject-addons/6.1

Proposed by Moisés López - http://www.vauxoo.com
Status: Needs review
Proposed branch: lp:~vauxoo/openobject-addons/6.1-bug-1051367-moylop260_vauxoo
Merge into: lp:openobject-addons/6.1
Diff against target: 97 lines (+28/-19)
2 files modified
mrp/mrp.py (+17/-5)
mrp_subproduct/mrp_subproduct.py (+11/-14)
To merge this branch: bzr merge lp:~vauxoo/openobject-addons/6.1-bug-1051367-moylop260_vauxoo
Reviewer Review Type Date Requested Status
Nhomar - Vauxoo (community) Needs Information
OpenERP Core Team Pending
Review via email: mp+124590@code.launchpad.net

Description of the change

Fix bom explode qty

To post a comment you must log in.
6993. By Moisés López - http://www.vauxoo.com

[FIX] [mrp_subproduct] Fix name variable

6994. By Moisés López - http://www.vauxoo.com

[FIX] [mrp] Fix mrp subproducts validation zero & fix calc

Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

Moy.

To avoid misunderstood, can we prepare a use-case for this MP or link the videos related to the bug please.

Just for information to openerp team.

all explanation is really here:

bug #1047680

If we can prepare some test yaml it can be great Moy,
Regards.

review: Needs Information

Unmerged revisions

6994. By Moisés López - http://www.vauxoo.com

[FIX] [mrp] Fix mrp subproducts validation zero & fix calc

6993. By Moisés López - http://www.vauxoo.com

[FIX] [mrp_subproduct] Fix name variable

6992. By Moisés López - http://www.vauxoo.com

[REF] [mrp & mrp_subproducts] BoM explode qty refactory

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py 2012-07-23 08:44:52 +0000
+++ mrp/mrp.py 2012-09-17 17:14:20 +0000
@@ -292,8 +292,8 @@
292 result = bom.id292 result = bom.id
293 max_prop = prop293 max_prop = prop
294 return result294 return result
295295
296 def _bom_explode(self, cr, uid, bom, factor, properties=[], addthis=False, level=0, routing_id=False):296 def _bom_explode(self, cr, uid, bom, factor, properties=[], addthis=False, level=0, routing_id=False, result_subproducts=False):
297 """ Finds Products and Work Centers for related BoM for manufacturing order.297 """ Finds Products and Work Centers for related BoM for manufacturing order.
298 @param bom: BoM of particular product.298 @param bom: BoM of particular product.
299 @param factor: Factor of product UoM.299 @param factor: Factor of product UoM.
@@ -303,6 +303,18 @@
303 @return: result: List of dictionaries containing product details.303 @return: result: List of dictionaries containing product details.
304 result2: List of dictionaries containing Work Center details.304 result2: List of dictionaries containing Work Center details.
305 """305 """
306 if result_subproducts is False:
307 result_subproducts = []
308 if self._columns.has_key('sub_products'):#if module mrp_subproduct is installed
309 for sub_product in bom.sub_products:
310 qty1 = sub_product.product_qty
311 if sub_product.subproduct_type == 'variable':
312 qty1 = factor*qty1/bom.product_uom.factor_inv
313 result_subproducts.append({
314 'product_id': sub_product.product_id.id,
315 'product_qty': qty1,
316 'product_uom': sub_product.product_uom.id,
317 })
306 routing_obj = self.pool.get('mrp.routing')318 routing_obj = self.pool.get('mrp.routing')
307 factor = factor / (bom.product_efficiency or 1.0)319 factor = factor / (bom.product_efficiency or 1.0)
308 factor = rounding(factor, bom.product_rounding)320 factor = rounding(factor, bom.product_rounding)
@@ -313,9 +325,9 @@
313 phantom = False325 phantom = False
314 if bom.type == 'phantom' and not bom.bom_lines:326 if bom.type == 'phantom' and not bom.bom_lines:
315 newbom = self._bom_find(cr, uid, bom.product_id.id, bom.product_uom.id, properties)327 newbom = self._bom_find(cr, uid, bom.product_id.id, bom.product_uom.id, properties)
316
317 if newbom:328 if newbom:
318 res = self._bom_explode(cr, uid, self.browse(cr, uid, [newbom])[0], factor*bom.product_qty, properties, addthis=True, level=level+10)329 newbom_pool = self.browse(cr, uid, newbom)
330 res = self._bom_explode(cr, uid, self.browse(cr, uid, [newbom])[0], factor*bom.product_qty/(newbom_pool.product_qty*newbom_pool.product_uom.factor_inv), properties, addthis=True, level=level+10, result_subproducts=result_subproducts)
319 result = result + res[0]331 result = result + res[0]
320 result2 = result2 + res[1]332 result2 = result2 + res[1]
321 phantom = True333 phantom = True
@@ -347,7 +359,7 @@
347 'hour': float(wc_use.hour_nbr*mult + ((wc.time_start or 0.0)+(wc.time_stop or 0.0)+cycle*(wc.time_cycle or 0.0)) * (wc.time_efficiency or 1.0)),359 'hour': float(wc_use.hour_nbr*mult + ((wc.time_start or 0.0)+(wc.time_stop or 0.0)+cycle*(wc.time_cycle or 0.0)) * (wc.time_efficiency or 1.0)),
348 })360 })
349 for bom2 in bom.bom_lines:361 for bom2 in bom.bom_lines:
350 res = self._bom_explode(cr, uid, bom2, factor, properties, addthis=True, level=level+10)362 res = self._bom_explode(cr, uid, bom2, factor, properties, addthis=True, level=level+10, result_subproducts=result_subproducts)
351 result = result + res[0]363 result = result + res[0]
352 result2 = result2 + res[1]364 result2 = result2 + res[1]
353 return result, result2365 return result, result2
354366
=== modified file 'mrp_subproduct/mrp_subproduct.py'
--- mrp_subproduct/mrp_subproduct.py 2012-02-14 15:57:46 +0000
+++ mrp_subproduct/mrp_subproduct.py 2012-09-17 17:14:20 +0000
@@ -73,27 +73,24 @@
73 """ Confirms production order and calculates quantity based on subproduct_type.73 """ Confirms production order and calculates quantity based on subproduct_type.
74 @return: Newly generated picking Id.74 @return: Newly generated picking Id.
75 """75 """
76 bom_obj = self.pool.get('mrp.bom')
77 uom_obj = self.pool.get('product.uom')
76 picking_id = super(mrp_production,self).action_confirm(cr, uid, ids)78 picking_id = super(mrp_production,self).action_confirm(cr, uid, ids)
77 for production in self.browse(cr, uid, ids):79 for production in self.browse(cr, uid, ids):
78 source = production.product_id.product_tmpl_id.property_stock_production.id80 source = production.product_id.product_tmpl_id.property_stock_production.id
79 if not production.bom_id:81 bom_id = production.bom_id
82 if not bom_id:
80 continue83 continue
81 for sub_product in production.bom_id.sub_products:84 factor = uom_obj._compute_qty(cr, uid, production.product_uom.id, production.product_qty, bom_id.product_uom.id)
82 qty1 = sub_product.product_qty85 result_subproducts =[]
83 qty2 = production.product_uos and production.product_uos_qty or False86 res = bom_obj._bom_explode(cr, uid, bom_id, factor / bom_id.product_qty, properties=False, routing_id=False, result_subproducts=result_subproducts)
84 if sub_product.subproduct_type == 'variable':87 for sub_product in result_subproducts:
85 if production.product_qty:
86 qty1 *= production.product_qty / (production.bom_id.product_qty or 1.0)
87 if production.product_uos_qty:
88 qty2 *= production.product_uos_qty / (production.bom_id.product_uos_qty or 1.0)
89 data = {88 data = {
90 'name': 'PROD:'+production.name,89 'name': 'PROD:'+production.name,
91 'date': production.date_planned,90 'date': production.date_planned,
92 'product_id': sub_product.product_id.id,91 'product_id': sub_product['product_id'],
93 'product_qty': qty1,92 'product_qty': sub_product['product_qty'],
94 'product_uom': sub_product.product_uom.id,93 'product_uom': sub_product['product_uom'],
95 'product_uos_qty': qty2,
96 'product_uos': production.product_uos and production.product_uos.id or False,
97 'location_id': source,94 'location_id': source,
98 'location_dest_id': production.location_dest_id.id,95 'location_dest_id': production.location_dest_id.id,
99 'move_dest_id': production.move_prod_id.id,96 'move_dest_id': production.move_prod_id.id,