openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #05032
[Merge] lp:~camptocamp/product-kitting/7.0-fix_1293582-afe into lp:product-kitting
Alexandre Fayolle - camptocamp has proposed merging lp:~camptocamp/product-kitting/7.0-fix_1293582-afe into lp:product-kitting.
Requested reviews:
Product Core Editors (product-core-editors)
Related bugs:
Bug #1293582 in Product - Kitting Management: "bom_split, sale_bom_split, purchase_bom_split: wrong uom management"
https://bugs.launchpad.net/product-kitting/+bug/1293582
For more details, see:
https://code.launchpad.net/~camptocamp/product-kitting/7.0-fix_1293582-afe/+merge/211358
[FIX] inverted conversion for the final qty when calling bom_split in purchase_bom_split and sale_bom_split
--
https://code.launchpad.net/~camptocamp/product-kitting/7.0-fix_1293582-afe/+merge/211358
Your team Product Core Editors is requested to review the proposed merge of lp:~camptocamp/product-kitting/7.0-fix_1293582-afe into lp:product-kitting.
=== modified file 'bom_split/__init__.py'
--- bom_split/__init__.py 2012-07-24 12:27:35 +0000
+++ bom_split/__init__.py 2014-03-17 16:25:52 +0000
@@ -19,6 +19,6 @@
#
##############################################################################
-import mrp
+from . import mrp
=== modified file 'bom_split/__openerp__.py'
--- bom_split/__openerp__.py 2012-07-24 12:27:35 +0000
+++ bom_split/__openerp__.py 2014-03-17 16:25:52 +0000
@@ -30,9 +30,8 @@
'author': 'Camptocamp',
'website': 'http://www.camptocamp.com',
'depends': ['mrp'],
- 'init_xml': [],
- 'update_xml': [],
- 'demo_xml': [],
+ 'data': [],
+ 'demo': ['bom_split_demo.yml'],
'installable': True,
'autoinstall': False,
}
=== added file 'bom_split/bom_split_demo.yml'
--- bom_split/bom_split_demo.yml 1970-01-01 00:00:00 +0000
+++ bom_split/bom_split_demo.yml 2014-03-17 16:25:52 +0000
@@ -0,0 +1,43 @@
+-
+ I create a product "Drilling Kit"
+-
+ !record {model: product.product, id: product1}:
+ name: Drilling Kit
+ type: product
+ procure_method: make_to_order
+ supply_method: produce
+ uom_id: product.product_uom_unit
+-
+ I create a product "Driller"
+-
+ !record {model: product.product, id: product2}:
+ name: Driller
+ type: product
+ procure_method: make_to_order
+ supply_method: buy
+ uom_id: product.product_uom_unit
+-
+ I create a product "Drill bit"
+-
+ !record {model: product.product, id: product3}:
+ name: Drill bit
+ type: product
+ procure_method: make_to_order
+ supply_method: buy
+ uom_id: product.product_uom_unit
+-
+ I explain how to build Driller Kits
+-
+ !record {model: mrp.bom, id: bom_prod1}:
+ name: half pipe
+ product_id: product1
+ product_qty: 1
+ product_uom: product.product_uom_dozen
+ type: phantom
+ bom_lines:
+ - product_id: product2
+ product_qty: 1
+ product_uom: product.product_uom_dozen
+ - product_id: product3
+ product_qty: 48
+ product_uom: product.product_uom_unit
=== modified file 'bom_split/mrp.py'
--- bom_split/mrp.py 2012-07-24 12:27:35 +0000
+++ bom_split/mrp.py 2014-03-17 16:25:52 +0000
@@ -28,7 +28,7 @@
_inherit = 'mrp.bom'
def _bom_split_vals(self, cr, uid, bom, factor, context=None):
- product_obj = self.pool.get('product.product')
+ product_obj = self.pool['product.product']
return {
'name': product_obj.name_get(cr, uid, [bom.product_id.id])[0][1],
'product_id': bom.product_id.id,
@@ -39,6 +39,10 @@
}
def bom_split(self, cr, uid, bom, factor, addthis=False, level=0):
+ """
+ split the bom into components.
+ factor is the quantity to produce expressed in bom product_uom
+ """
factor = factor / (bom.product_efficiency or 1.0)
factor = rounding(factor, bom.product_rounding)
if factor < bom.product_rounding:
=== modified file 'purchase_bom_split/__init__.py'
--- purchase_bom_split/__init__.py 2012-07-24 12:27:35 +0000
+++ purchase_bom_split/__init__.py 2014-03-17 16:25:52 +0000
@@ -19,5 +19,5 @@
#
##############################################################################
-import purchase
+from . import purchase
=== modified file 'purchase_bom_split/__openerp__.py'
--- purchase_bom_split/__openerp__.py 2012-07-24 12:27:35 +0000
+++ purchase_bom_split/__openerp__.py 2014-03-17 16:25:52 +0000
@@ -50,9 +50,9 @@
'author': 'Camptocamp',
'website': 'http://www.camptocamp.com',
'depends': ['bom_split', 'purchase'],
- 'init_xml': [],
- 'update_xml': [],
- 'demo_xml': [],
+ 'data': [],
+ 'demo': [],
+ 'test': ['tests/test_purchase_bom_split.yml'],
'installable': True,
'auto_install': False,
}
=== modified file 'purchase_bom_split/purchase.py'
--- purchase_bom_split/purchase.py 2012-07-24 12:27:35 +0000
+++ purchase_bom_split/purchase.py 2014-03-17 16:25:52 +0000
@@ -64,7 +64,7 @@
bom_obj = self.pool.get('mrp.bom')
picking_obj = self.pool.get('stock.picking')
product_obj = self.pool.get('product.product')
-
+ uom_obj = self.pool['product.uom']
bom_order_lines = []
normal_order_lines = order_lines[:]
for line in order_lines:
@@ -92,9 +92,9 @@
new_move_ids = []
for line, bom in bom_order_lines:
- factor = line.product_qty * line.product_uom.factor / bom.product_uom.factor
+ factor = uom_obj._compute_qty_obj(cr, uid, line.product_uom, line.product_qty, bom.product_uom)
bom_components = bom_obj.bom_split(
- cr, uid, bom, factor / bom.product_qty)
+ cr, uid, bom, factor)
move_dest_id = None
for component in bom_components:
=== added directory 'purchase_bom_split/tests'
=== added file 'purchase_bom_split/tests/test_purchase_bom_split.yml'
--- purchase_bom_split/tests/test_purchase_bom_split.yml 1970-01-01 00:00:00 +0000
+++ purchase_bom_split/tests/test_purchase_bom_split.yml 2014-03-17 16:25:52 +0000
@@ -0,0 +1,26 @@
+-
+ I create a purchase order for 24 bom_split.product1
+-
+ !record {model: purchase.order, id: purchase_order_test1}:
+ partner_id: base.res_partner_2
+ order_line:
+ - product_id: bom_split.product1
+ price_unit: 11
+ product_qty: 24
+ product_uom: product.product_uom_unit
+-
+ I confirm the purchase order
+-
+ !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_test1}
+-
+ I check the picking created for the purchase order
+-
+ !assert {model: purchase.order, id: purchase_order_test1}:
+ - len(picking_ids) == 1
+ - len(picking_ids[0].move_lines) == 2
+ - picking_ids[0].move_lines[0].product_id.id == ref('bom_split.product2')
+ - picking_ids[0].move_lines[0].product_uom.id == ref('product.product_uom_dozen')
+ - picking_ids[0].move_lines[0].product_qty == 2
+ - picking_ids[0].move_lines[1].product_id.id == ref('bom_split.product3')
+ - picking_ids[0].move_lines[1].product_uom.id == ref('product.product_uom_unit')
+ - picking_ids[0].move_lines[1].product_qty == 96
=== modified file 'sale_bom_split/__openerp__.py'
--- sale_bom_split/__openerp__.py 2012-07-24 12:27:35 +0000
+++ sale_bom_split/__openerp__.py 2014-03-17 16:25:52 +0000
@@ -51,9 +51,10 @@
'author': 'Camptocamp',
'website': 'http://www.camptocamp.com',
'depends': ['sale', 'bom_split'],
- 'init_xml': [],
- 'update_xml': [],
- 'demo_xml': [],
+ 'data': [],
+ 'demo': [],
+ 'test': ['tests/test_sale_bom_split.yml',
+ ],
'installable': True,
'auto_install': False,
}
=== modified file 'sale_bom_split/sale.py'
--- sale_bom_split/sale.py 2012-07-24 12:27:35 +0000
+++ sale_bom_split/sale.py 2014-03-17 16:25:52 +0000
@@ -80,6 +80,7 @@
picking_obj = self.pool.get('stock.picking')
product_obj = self.pool.get('product.product')
procurement_obj = self.pool.get('procurement.order')
+ uom_obj = self.pool['product.uom']
bom_order_lines = []
normal_order_lines = order_lines[:]
@@ -110,9 +111,10 @@
proc_ids = []
for line, bom in bom_order_lines:
- factor = line.product_uom_qty * line.product_uom.factor / bom.product_uom.factor
+ factor = uom_obj._compute_qty_obj(cr, uid, line.product_uom, line.product_uom_qty, bom.product_uom)
bom_components = bom_obj.bom_split(
- cr, uid, bom, factor / bom.product_qty)
+ cr, uid, bom, factor)
+
date_planned = self._get_date_planned(
cr, uid, order, line, order.date_order, context=context)
=== added directory 'sale_bom_split/tests'
=== added file 'sale_bom_split/tests/test_sale_bom_split.yml'
--- sale_bom_split/tests/test_sale_bom_split.yml 1970-01-01 00:00:00 +0000
+++ sale_bom_split/tests/test_sale_bom_split.yml 2014-03-17 16:25:52 +0000
@@ -0,0 +1,25 @@
+-
+ I create a sale order for 24 bom_split.product1
+-
+ !record {model: sale.order, id: sale_order_test1}:
+ partner_id: base.res_partner_2
+ order_line:
+ - product_id: bom_split.product1
+ product_uom_qty: 24
+ product_uom: product.product_uom_unit
+-
+ I confirm the sale order
+-
+ !workflow {model: sale.order, action: order_confirm, ref: sale_order_test1}
+-
+ I check the picking created for the sale order
+-
+ !assert {model: sale.order, id: sale_order_test1}:
+ - len(picking_ids) == 1
+ - len(picking_ids[0].move_lines) == 2
+ - picking_ids[0].move_lines[0].product_id.id == ref('bom_split.product2')
+ - picking_ids[0].move_lines[0].product_uom.id == ref('product.product_uom_dozen')
+ - picking_ids[0].move_lines[0].product_qty == 2
+ - picking_ids[0].move_lines[1].product_id.id == ref('bom_split.product3')
+ - picking_ids[0].move_lines[1].product_uom.id == ref('product.product_uom_unit')
+ - picking_ids[0].move_lines[1].product_qty == 96
Follow ups