Merge lp:~camptocamp/product-kitting/7.0-fix_1293582-afe into lp:product-kitting

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Approved by: Yannick Vaucher @ Camptocamp
Approved revision: 7
Merged at revision: 7
Proposed branch: lp:~camptocamp/product-kitting/7.0-fix_1293582-afe
Merge into: lp:product-kitting
Diff against target: 258 lines (+117/-17)
11 files modified
bom_split/__init__.py (+1/-1)
bom_split/__openerp__.py (+2/-3)
bom_split/bom_split_demo.yml (+43/-0)
bom_split/mrp.py (+5/-1)
purchase_bom_split/__init__.py (+1/-1)
purchase_bom_split/__openerp__.py (+3/-3)
purchase_bom_split/purchase.py (+3/-3)
purchase_bom_split/tests/test_purchase_bom_split.yml (+26/-0)
sale_bom_split/__openerp__.py (+4/-3)
sale_bom_split/sale.py (+4/-2)
sale_bom_split/tests/test_sale_bom_split.yml (+25/-0)
To merge this branch: bzr merge lp:~camptocamp/product-kitting/7.0-fix_1293582-afe
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp Approve
Romain Deheele - Camptocamp (community) code review, tests Approve
Pedro Manuel Baeza code review Approve
Review via email: mp+211358@code.launchpad.net

Description of the change

[FIX] inverted conversion for the final qty when calling bom_split in purchase_bom_split and sale_bom_split

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Seems OK. Good to see self.pool[] convention instead of self.pool.get()!

Regards.

review: Approve (code review)
Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

LGTM

review: Approve (code review, tests)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bom_split/__init__.py'
2--- bom_split/__init__.py 2012-07-24 12:27:35 +0000
3+++ bom_split/__init__.py 2014-03-17 16:25:52 +0000
4@@ -19,6 +19,6 @@
5 #
6 ##############################################################################
7
8-import mrp
9+from . import mrp
10
11
12
13=== modified file 'bom_split/__openerp__.py'
14--- bom_split/__openerp__.py 2012-07-24 12:27:35 +0000
15+++ bom_split/__openerp__.py 2014-03-17 16:25:52 +0000
16@@ -30,9 +30,8 @@
17 'author': 'Camptocamp',
18 'website': 'http://www.camptocamp.com',
19 'depends': ['mrp'],
20- 'init_xml': [],
21- 'update_xml': [],
22- 'demo_xml': [],
23+ 'data': [],
24+ 'demo': ['bom_split_demo.yml'],
25 'installable': True,
26 'autoinstall': False,
27 }
28
29=== added file 'bom_split/bom_split_demo.yml'
30--- bom_split/bom_split_demo.yml 1970-01-01 00:00:00 +0000
31+++ bom_split/bom_split_demo.yml 2014-03-17 16:25:52 +0000
32@@ -0,0 +1,43 @@
33+-
34+ I create a product "Drilling Kit"
35+-
36+ !record {model: product.product, id: product1}:
37+ name: Drilling Kit
38+ type: product
39+ procure_method: make_to_order
40+ supply_method: produce
41+ uom_id: product.product_uom_unit
42+-
43+ I create a product "Driller"
44+-
45+ !record {model: product.product, id: product2}:
46+ name: Driller
47+ type: product
48+ procure_method: make_to_order
49+ supply_method: buy
50+ uom_id: product.product_uom_unit
51+-
52+ I create a product "Drill bit"
53+-
54+ !record {model: product.product, id: product3}:
55+ name: Drill bit
56+ type: product
57+ procure_method: make_to_order
58+ supply_method: buy
59+ uom_id: product.product_uom_unit
60+-
61+ I explain how to build Driller Kits
62+-
63+ !record {model: mrp.bom, id: bom_prod1}:
64+ name: half pipe
65+ product_id: product1
66+ product_qty: 1
67+ product_uom: product.product_uom_dozen
68+ type: phantom
69+ bom_lines:
70+ - product_id: product2
71+ product_qty: 1
72+ product_uom: product.product_uom_dozen
73+ - product_id: product3
74+ product_qty: 48
75+ product_uom: product.product_uom_unit
76
77=== modified file 'bom_split/mrp.py'
78--- bom_split/mrp.py 2012-07-24 12:27:35 +0000
79+++ bom_split/mrp.py 2014-03-17 16:25:52 +0000
80@@ -28,7 +28,7 @@
81 _inherit = 'mrp.bom'
82
83 def _bom_split_vals(self, cr, uid, bom, factor, context=None):
84- product_obj = self.pool.get('product.product')
85+ product_obj = self.pool['product.product']
86 return {
87 'name': product_obj.name_get(cr, uid, [bom.product_id.id])[0][1],
88 'product_id': bom.product_id.id,
89@@ -39,6 +39,10 @@
90 }
91
92 def bom_split(self, cr, uid, bom, factor, addthis=False, level=0):
93+ """
94+ split the bom into components.
95+ factor is the quantity to produce expressed in bom product_uom
96+ """
97 factor = factor / (bom.product_efficiency or 1.0)
98 factor = rounding(factor, bom.product_rounding)
99 if factor < bom.product_rounding:
100
101=== modified file 'purchase_bom_split/__init__.py'
102--- purchase_bom_split/__init__.py 2012-07-24 12:27:35 +0000
103+++ purchase_bom_split/__init__.py 2014-03-17 16:25:52 +0000
104@@ -19,5 +19,5 @@
105 #
106 ##############################################################################
107
108-import purchase
109+from . import purchase
110
111
112=== modified file 'purchase_bom_split/__openerp__.py'
113--- purchase_bom_split/__openerp__.py 2012-07-24 12:27:35 +0000
114+++ purchase_bom_split/__openerp__.py 2014-03-17 16:25:52 +0000
115@@ -50,9 +50,9 @@
116 'author': 'Camptocamp',
117 'website': 'http://www.camptocamp.com',
118 'depends': ['bom_split', 'purchase'],
119- 'init_xml': [],
120- 'update_xml': [],
121- 'demo_xml': [],
122+ 'data': [],
123+ 'demo': [],
124+ 'test': ['tests/test_purchase_bom_split.yml'],
125 'installable': True,
126 'auto_install': False,
127 }
128
129=== modified file 'purchase_bom_split/purchase.py'
130--- purchase_bom_split/purchase.py 2012-07-24 12:27:35 +0000
131+++ purchase_bom_split/purchase.py 2014-03-17 16:25:52 +0000
132@@ -64,7 +64,7 @@
133 bom_obj = self.pool.get('mrp.bom')
134 picking_obj = self.pool.get('stock.picking')
135 product_obj = self.pool.get('product.product')
136-
137+ uom_obj = self.pool['product.uom']
138 bom_order_lines = []
139 normal_order_lines = order_lines[:]
140 for line in order_lines:
141@@ -92,9 +92,9 @@
142
143 new_move_ids = []
144 for line, bom in bom_order_lines:
145- factor = line.product_qty * line.product_uom.factor / bom.product_uom.factor
146+ factor = uom_obj._compute_qty_obj(cr, uid, line.product_uom, line.product_qty, bom.product_uom)
147 bom_components = bom_obj.bom_split(
148- cr, uid, bom, factor / bom.product_qty)
149+ cr, uid, bom, factor)
150
151 move_dest_id = None
152 for component in bom_components:
153
154=== added directory 'purchase_bom_split/tests'
155=== added file 'purchase_bom_split/tests/test_purchase_bom_split.yml'
156--- purchase_bom_split/tests/test_purchase_bom_split.yml 1970-01-01 00:00:00 +0000
157+++ purchase_bom_split/tests/test_purchase_bom_split.yml 2014-03-17 16:25:52 +0000
158@@ -0,0 +1,26 @@
159+-
160+ I create a purchase order for 24 bom_split.product1
161+-
162+ !record {model: purchase.order, id: purchase_order_test1}:
163+ partner_id: base.res_partner_2
164+ order_line:
165+ - product_id: bom_split.product1
166+ price_unit: 11
167+ product_qty: 24
168+ product_uom: product.product_uom_unit
169+-
170+ I confirm the purchase order
171+-
172+ !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_test1}
173+-
174+ I check the picking created for the purchase order
175+-
176+ !assert {model: purchase.order, id: purchase_order_test1}:
177+ - len(picking_ids) == 1
178+ - len(picking_ids[0].move_lines) == 2
179+ - picking_ids[0].move_lines[0].product_id.id == ref('bom_split.product2')
180+ - picking_ids[0].move_lines[0].product_uom.id == ref('product.product_uom_dozen')
181+ - picking_ids[0].move_lines[0].product_qty == 2
182+ - picking_ids[0].move_lines[1].product_id.id == ref('bom_split.product3')
183+ - picking_ids[0].move_lines[1].product_uom.id == ref('product.product_uom_unit')
184+ - picking_ids[0].move_lines[1].product_qty == 96
185
186=== modified file 'sale_bom_split/__openerp__.py'
187--- sale_bom_split/__openerp__.py 2012-07-24 12:27:35 +0000
188+++ sale_bom_split/__openerp__.py 2014-03-17 16:25:52 +0000
189@@ -51,9 +51,10 @@
190 'author': 'Camptocamp',
191 'website': 'http://www.camptocamp.com',
192 'depends': ['sale', 'bom_split'],
193- 'init_xml': [],
194- 'update_xml': [],
195- 'demo_xml': [],
196+ 'data': [],
197+ 'demo': [],
198+ 'test': ['tests/test_sale_bom_split.yml',
199+ ],
200 'installable': True,
201 'auto_install': False,
202 }
203
204=== modified file 'sale_bom_split/sale.py'
205--- sale_bom_split/sale.py 2012-07-24 12:27:35 +0000
206+++ sale_bom_split/sale.py 2014-03-17 16:25:52 +0000
207@@ -80,6 +80,7 @@
208 picking_obj = self.pool.get('stock.picking')
209 product_obj = self.pool.get('product.product')
210 procurement_obj = self.pool.get('procurement.order')
211+ uom_obj = self.pool['product.uom']
212
213 bom_order_lines = []
214 normal_order_lines = order_lines[:]
215@@ -110,9 +111,10 @@
216
217 proc_ids = []
218 for line, bom in bom_order_lines:
219- factor = line.product_uom_qty * line.product_uom.factor / bom.product_uom.factor
220+ factor = uom_obj._compute_qty_obj(cr, uid, line.product_uom, line.product_uom_qty, bom.product_uom)
221 bom_components = bom_obj.bom_split(
222- cr, uid, bom, factor / bom.product_qty)
223+ cr, uid, bom, factor)
224+
225
226 date_planned = self._get_date_planned(
227 cr, uid, order, line, order.date_order, context=context)
228
229=== added directory 'sale_bom_split/tests'
230=== added file 'sale_bom_split/tests/test_sale_bom_split.yml'
231--- sale_bom_split/tests/test_sale_bom_split.yml 1970-01-01 00:00:00 +0000
232+++ sale_bom_split/tests/test_sale_bom_split.yml 2014-03-17 16:25:52 +0000
233@@ -0,0 +1,25 @@
234+-
235+ I create a sale order for 24 bom_split.product1
236+-
237+ !record {model: sale.order, id: sale_order_test1}:
238+ partner_id: base.res_partner_2
239+ order_line:
240+ - product_id: bom_split.product1
241+ product_uom_qty: 24
242+ product_uom: product.product_uom_unit
243+-
244+ I confirm the sale order
245+-
246+ !workflow {model: sale.order, action: order_confirm, ref: sale_order_test1}
247+-
248+ I check the picking created for the sale order
249+-
250+ !assert {model: sale.order, id: sale_order_test1}:
251+ - len(picking_ids) == 1
252+ - len(picking_ids[0].move_lines) == 2
253+ - picking_ids[0].move_lines[0].product_id.id == ref('bom_split.product2')
254+ - picking_ids[0].move_lines[0].product_uom.id == ref('product.product_uom_dozen')
255+ - picking_ids[0].move_lines[0].product_qty == 2
256+ - picking_ids[0].move_lines[1].product_id.id == ref('bom_split.product3')
257+ - picking_ids[0].move_lines[1].product_uom.id == ref('product.product_uom_unit')
258+ - picking_ids[0].move_lines[1].product_qty == 96

Subscribers

People subscribed via source and target branches