Merge lp:~akretion-team/openobject-addons/trunk-addons-do-not-jump-to-product-template into lp:openobject-addons

Proposed by Alexis de Lattre
Status: Merged
Merged at revision: 8396
Proposed branch: lp:~akretion-team/openobject-addons/trunk-addons-do-not-jump-to-product-template
Merge into: lp:openobject-addons
Diff against target: 420 lines (+38/-40)
23 files modified
account/account_analytic_line.py (+2/-2)
account/account_invoice.py (+2/-2)
account_anglo_saxon/sale.py (+1/-1)
account_anglo_saxon/stock.py (+2/-2)
analytic_user_function/analytic_user_function.py (+3/-3)
hr_expense/hr_expense.py (+1/-1)
hr_timesheet/hr_timesheet.py (+1/-1)
hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py (+1/-1)
mrp/mrp.py (+2/-2)
mrp/procurement.py (+1/-1)
mrp/test/order_process.yml (+1/-1)
mrp_subproduct/mrp_subproduct.py (+1/-1)
procurement/procurement.py (+2/-2)
project_timesheet/project_timesheet.py (+1/-1)
purchase/purchase.py (+3/-3)
purchase/wizard/purchase_line_invoice.py (+1/-1)
sale/sale.py (+3/-3)
sale/stock.py (+2/-2)
sale/test/picking_order_policy.yml (+1/-1)
stock/product.py (+2/-2)
stock/stock.py (+3/-5)
stock/test/opening_stock.yml (+1/-1)
stock_planning/stock_planning.py (+1/-1)
To merge this branch: bzr merge lp:~akretion-team/openobject-addons/trunk-addons-do-not-jump-to-product-template
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Approve
Review via email: mp+117089@code.launchpad.net

Description of the change

Remplace all occurences of :

my_browse_rec.product_id.product_tmpl_id.field

by

my_browse_rec.product_id.field

This is the continuity of the work started in this (accepted) merge proposal : https://code.launchpad.net/~akretion-team/openobject-addons/trunk-addons-dont-access-product-template/+merge/114001

This is important because we want to be able to move some fields from product.template to product.product in a custom module when needed, without patching the addons.

To post a comment you must log in.
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

The runbot is green on this branch.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Looks good to me, thanks! Even without the reason underlying your patch, it makes the code more straightforward.
I'll solve the new conflicts and merge.

Thanks for your patience!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account_analytic_line.py'
2--- account/account_analytic_line.py 2012-07-06 07:42:15 +0000
3+++ account/account_analytic_line.py 2012-07-27 16:07:26 +0000
4@@ -83,7 +83,7 @@
5 if j_id.type == 'purchase':
6 unit = prod.uom_po_id.id
7 if j_id.type <> 'sale':
8- a = prod.product_tmpl_id.property_account_expense.id
9+ a = prod.property_account_expense.id
10 if not a:
11 a = prod.categ_id.property_account_expense_categ.id
12 if not a:
13@@ -92,7 +92,7 @@
14 'for this product: "%s" (id:%d)') % \
15 (prod.name, prod.id,))
16 else:
17- a = prod.product_tmpl_id.property_account_income.id
18+ a = prod.property_account_income.id
19 if not a:
20 a = prod.categ_id.property_account_income_categ.id
21 if not a:
22
23=== modified file 'account/account_invoice.py'
24--- account/account_invoice.py 2012-07-14 23:18:43 +0000
25+++ account/account_invoice.py 2012-07-27 16:07:26 +0000
26@@ -1404,11 +1404,11 @@
27 res = self.pool.get('product.product').browse(cr, uid, product, context=context)
28
29 if type in ('out_invoice','out_refund'):
30- a = res.product_tmpl_id.property_account_income.id
31+ a = res.property_account_income.id
32 if not a:
33 a = res.categ_id.property_account_income_categ.id
34 else:
35- a = res.product_tmpl_id.property_account_expense.id
36+ a = res.property_account_expense.id
37 if not a:
38 a = res.categ_id.property_account_expense_categ.id
39 a = fpos_obj.map_account(cr, uid, fpos, a)
40
41=== modified file 'account_anglo_saxon/sale.py'
42--- account_anglo_saxon/sale.py 2011-01-14 00:11:01 +0000
43+++ account_anglo_saxon/sale.py 2012-07-27 16:07:26 +0000
44@@ -31,7 +31,7 @@
45 # invoice_line_obj = self.pool.get('account.invoice.line')
46 # for line in invoice_line_obj.browse(cr, uid, line_ids):
47 # if line.product_id:
48-# a = line.product_id.product_tmpl_id.property_stock_account_output and line.product_id.product_tmpl_id.property_stock_account_output.id
49+# a = line.product_id.property_stock_account_output and line.product_id.property_stock_account_output.id
50 # if not a:
51 # a = line.product_id.categ_id.property_stock_account_output_categ and line.product_id.categ_id.property_stock_account_output_categ.id
52 # if a:
53
54=== modified file 'account_anglo_saxon/stock.py'
55--- account_anglo_saxon/stock.py 2011-02-08 06:58:24 +0000
56+++ account_anglo_saxon/stock.py 2012-07-27 16:07:26 +0000
57@@ -36,7 +36,7 @@
58 for inv in self.pool.get('account.invoice').browse(cr, uid, res.values(), context=context):
59 for ol in inv.invoice_line:
60 if ol.product_id:
61- oa = ol.product_id.product_tmpl_id.property_stock_account_output and ol.product_id.product_tmpl_id.property_stock_account_output.id
62+ oa = ol.product_id.property_stock_account_output and ol.product_id.property_stock_account_output.id
63 if not oa:
64 oa = ol.product_id.categ_id.property_stock_account_output_categ and ol.product_id.categ_id.property_stock_account_output_categ.id
65 if oa:
66@@ -48,7 +48,7 @@
67 for inv in self.pool.get('account.invoice').browse(cr, uid, res.values(), context=context):
68 for ol in inv.invoice_line:
69 if ol.product_id:
70- oa = ol.product_id.product_tmpl_id.property_stock_account_input and ol.product_id.product_tmpl_id.property_stock_account_input.id
71+ oa = ol.product_id.property_stock_account_input and ol.product_id.property_stock_account_input.id
72 if not oa:
73 oa = ol.product_id.categ_id.property_stock_account_input_categ and ol.product_id.categ_id.property_stock_account_input_categ.id
74 if oa:
75
76=== modified file 'analytic_user_function/analytic_user_function.py'
77--- analytic_user_function/analytic_user_function.py 2011-12-19 16:54:40 +0000
78+++ analytic_user_function/analytic_user_function.py 2012-07-27 16:07:26 +0000
79@@ -85,10 +85,10 @@
80 res.setdefault('value',{})
81 res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id)['value']
82 res['value']['product_id'] = r.product_id.id
83- res['value']['product_uom_id'] = r.product_id.product_tmpl_id.uom_id.id
84+ res['value']['product_uom_id'] = r.product_id.uom_id.id
85
86 #the change of product has to impact the amount, uom and general_account_id
87- a = r.product_id.product_tmpl_id.property_account_expense.id
88+ a = r.product_id.property_account_expense.id
89 if not a:
90 a = r.product_id.categ_id.property_account_expense_categ.id
91 if not a:
92@@ -123,7 +123,7 @@
93 res['value']['product_id'] = r.product_id.id
94
95 #the change of product has to impact the amount, uom and general_account_id
96- a = r.product_id.product_tmpl_id.property_account_expense.id
97+ a = r.product_id.property_account_expense.id
98 if not a:
99 a = r.product_id.categ_id.property_account_expense_categ.id
100 if not a:
101
102=== modified file 'hr_expense/hr_expense.py'
103--- hr_expense/hr_expense.py 2012-07-05 09:29:21 +0000
104+++ hr_expense/hr_expense.py 2012-07-27 16:07:26 +0000
105@@ -164,7 +164,7 @@
106 for l in exp.line_ids:
107 tax_id = []
108 if l.product_id:
109- acc = l.product_id.product_tmpl_id.property_account_expense
110+ acc = l.product_id.property_account_expense
111 if not acc:
112 acc = l.product_id.categ_id.property_account_expense_categ
113 tax_id = [x.id for x in l.product_id.supplier_taxes_id]
114
115=== modified file 'hr_timesheet/hr_timesheet.py'
116--- hr_timesheet/hr_timesheet.py 2012-07-23 12:10:29 +0000
117+++ hr_timesheet/hr_timesheet.py 2012-07-27 16:07:26 +0000
118@@ -125,7 +125,7 @@
119 if emp_id:
120 emp = emp_obj.browse(cr, uid, emp_id[0], context=context)
121 if bool(emp.product_id):
122- a = emp.product_id.product_tmpl_id.property_account_expense.id
123+ a = emp.product_id.property_account_expense.id
124 if not a:
125 a = emp.product_id.categ_id.property_account_expense_categ.id
126 if a:
127
128=== modified file 'hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py'
129--- hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2012-07-26 12:31:58 +0000
130+++ hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2012-07-27 16:07:26 +0000
131@@ -117,7 +117,7 @@
132
133 taxes = product.taxes_id
134 tax = fiscal_pos_obj.map_tax(cr, uid, account.partner_id.property_account_position, taxes)
135- account_id = product.product_tmpl_id.property_account_income.id or product.categ_id.property_account_income_categ.id
136+ account_id = product.property_account_income.id or product.categ_id.property_account_income_categ.id
137 if not account_id:
138 raise osv.except_osv(_("Configuration Error"), _("No income account defined for product '%s'") % product.name)
139 curr_line = {
140
141=== modified file 'mrp/mrp.py'
142--- mrp/mrp.py 2012-07-25 16:15:21 +0000
143+++ mrp/mrp.py 2012-07-27 16:07:26 +0000
144@@ -957,7 +957,7 @@
145
146 def _make_production_produce_line(self, cr, uid, production, context=None):
147 stock_move = self.pool.get('stock.move')
148- source_location_id = production.product_id.product_tmpl_id.property_stock_production.id
149+ source_location_id = production.product_id.property_stock_production.id
150 destination_location_id = production.location_dest_id.id
151 move_name = _('PROD: %s') + production.name
152 data = {
153@@ -985,7 +985,7 @@
154 if production_line.product_id.type not in ('product', 'consu'):
155 return False
156 move_name = _('PROD: %s') % production.name
157- destination_location_id = production.product_id.product_tmpl_id.property_stock_production.id
158+ destination_location_id = production.product_id.property_stock_production.id
159 if not source_location_id:
160 source_location_id = production.location_src_id.id
161 move_id = stock_move.create(cr, uid, {
162
163=== modified file 'mrp/procurement.py'
164--- mrp/procurement.py 2012-06-01 14:40:59 +0000
165+++ mrp/procurement.py 2012-07-27 16:07:26 +0000
166@@ -79,7 +79,7 @@
167 procurement_obj = self.pool.get('procurement.order')
168 for procurement in procurement_obj.browse(cr, uid, ids, context=context):
169 res_id = procurement.move_id.id
170- newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - relativedelta(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0)
171+ newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - relativedelta(days=procurement.product_id.produce_delay or 0.0)
172 newdate = newdate - relativedelta(days=company.manufacturing_lead)
173 produce_id = production_obj.create(cr, uid, {
174 'origin': procurement.origin,
175
176=== modified file 'mrp/test/order_process.yml'
177--- mrp/test/order_process.yml 2012-04-03 08:27:56 +0000
178+++ mrp/test/order_process.yml 2012-07-27 16:07:26 +0000
179@@ -94,7 +94,7 @@
180 assert order.state == 'confirmed', "Production order should be confirmed."
181 assert order.move_created_ids, "Trace Record is not created for Final Product."
182 move = order.move_created_ids[0]
183- source_location_id = order.product_id.product_tmpl_id.property_stock_production.id
184+ source_location_id = order.product_id.property_stock_production.id
185 assert move.date == order.date_planned, "Planned date is not correspond."
186 assert move.product_id.id == order.product_id.id, "Product is not correspond."
187 assert move.product_uom.id == order.product_uom.id, "UOM is not correspond."
188
189=== modified file 'mrp_subproduct/mrp_subproduct.py'
190--- mrp_subproduct/mrp_subproduct.py 2012-05-22 16:10:55 +0000
191+++ mrp_subproduct/mrp_subproduct.py 2012-07-27 16:07:26 +0000
192@@ -75,7 +75,7 @@
193 """
194 picking_id = super(mrp_production,self).action_confirm(cr, uid, ids)
195 for production in self.browse(cr, uid, ids):
196- source = production.product_id.product_tmpl_id.property_stock_production.id
197+ source = production.product_id.property_stock_production.id
198 if not production.bom_id:
199 continue
200 for sub_product in production.bom_id.sub_products:
201
202=== modified file 'procurement/procurement.py'
203--- procurement/procurement.py 2012-06-11 09:59:14 +0000
204+++ procurement/procurement.py 2012-07-27 16:07:26 +0000
205@@ -285,7 +285,7 @@
206 user = self.pool.get('res.users').browse(cr, uid, uid)
207 partner_obj = self.pool.get('res.partner')
208 for procurement in self.browse(cr, uid, ids):
209- if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
210+ if procurement.product_id.supply_method <> 'buy':
211 return False
212 if not procurement.product_id.seller_ids:
213 message = _('No supplier defined for this product !')
214@@ -333,7 +333,7 @@
215 if not procurement.move_id:
216 source = procurement.location_id.id
217 if procurement.procure_method == 'make_to_order':
218- source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
219+ source = procurement.product_id.property_stock_procurement.id
220 id = move_obj.create(cr, uid, {
221 'name': procurement.name,
222 'location_id': source,
223
224=== modified file 'project_timesheet/project_timesheet.py'
225--- project_timesheet/project_timesheet.py 2012-06-27 13:54:25 +0000
226+++ project_timesheet/project_timesheet.py 2012-07-27 16:07:26 +0000
227@@ -88,7 +88,7 @@
228 raise osv.except_osv(_('Bad Configuration !'),
229 _('No journal defined on the related employee.\nFill in the timesheet tab of the employee form.'))
230
231- a = emp.product_id.product_tmpl_id.property_account_expense.id
232+ a = emp.product_id.property_account_expense.id
233 if not a:
234 a = emp.product_id.categ_id.property_account_expense_categ.id
235 if not a:
236
237=== modified file 'purchase/purchase.py'
238--- purchase/purchase.py 2012-07-25 12:07:19 +0000
239+++ purchase/purchase.py 2012-07-27 16:07:26 +0000
240@@ -434,7 +434,7 @@
241 inv_lines = []
242 for po_line in order.order_line:
243 if po_line.product_id:
244- acc_id = po_line.product_id.product_tmpl_id.property_account_expense.id
245+ acc_id = po_line.product_id.property_account_expense.id
246 if not acc_id:
247 acc_id = po_line.product_id.categ_id.property_account_expense_categ.id
248 if not acc_id:
249@@ -485,7 +485,7 @@
250 def has_stockable_product(self,cr, uid, ids, *args):
251 for order in self.browse(cr, uid, ids):
252 for order_line in order.order_line:
253- if order_line.product_id and order_line.product_id.product_tmpl_id.type in ('product', 'consu'):
254+ if order_line.product_id and order_line.product_id.type in ('product', 'consu'):
255 return True
256 return False
257
258@@ -1048,7 +1048,7 @@
259 context.update({'lang': partner.lang, 'partner_id': partner_id})
260
261 product = prod_obj.browse(cr, uid, procurement.product_id.id, context=context)
262- taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id
263+ taxes_ids = procurement.product_id.supplier_taxes_id
264 taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids)
265
266 name = product.partner_ref
267
268=== modified file 'purchase/wizard/purchase_line_invoice.py'
269--- purchase/wizard/purchase_line_invoice.py 2012-07-14 20:51:50 +0000
270+++ purchase/wizard/purchase_line_invoice.py 2012-07-27 16:07:26 +0000
271@@ -102,7 +102,7 @@
272 if not line.partner_id.id in invoices:
273 invoices[line.partner_id.id] = []
274 if line.product_id:
275- a = line.product_id.product_tmpl_id.property_account_expense.id
276+ a = line.product_id.property_account_expense.id
277 if not a:
278 a = line.product_id.categ_id.property_account_expense_categ.id
279 if not a:
280
281=== modified file 'sale/sale.py'
282--- sale/sale.py 2012-07-23 13:14:53 +0000
283+++ sale/sale.py 2012-07-27 16:07:26 +0000
284@@ -950,7 +950,7 @@
285 date_planned = self._get_date_planned(cr, uid, order, line, order.date_order, context=context)
286
287 if line.product_id:
288- if line.product_id.product_tmpl_id.type in ('product', 'consu'):
289+ if line.product_id.type in ('product', 'consu'):
290 if not picking_id:
291 picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context))
292 move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, context=context))
293@@ -1014,7 +1014,7 @@
294 def has_stockable_products(self, cr, uid, ids, *args):
295 for order in self.browse(cr, uid, ids):
296 for order_line in order.order_line:
297- if order_line.product_id and order_line.product_id.product_tmpl_id.type in ('product', 'consu'):
298+ if order_line.product_id and order_line.product_id.type in ('product', 'consu'):
299 return True
300 return False
301
302@@ -1188,7 +1188,7 @@
303 if not line.invoiced:
304 if not account_id:
305 if line.product_id:
306- account_id = line.product_id.product_tmpl_id.property_account_income.id
307+ account_id = line.product_id.property_account_income.id
308 if not account_id:
309 account_id = line.product_id.categ_id.property_account_income_categ.id
310 if not account_id:
311
312=== modified file 'sale/stock.py'
313--- sale/stock.py 2012-07-14 20:36:23 +0000
314+++ sale/stock.py 2012-07-27 16:07:26 +0000
315@@ -161,13 +161,13 @@
316 else:
317 name = sale_line.name
318 if type in ('out_invoice', 'out_refund'):
319- account_id = sale_line.product_id.product_tmpl_id.\
320+ account_id = sale_line.product_id.\
321 property_account_income.id
322 if not account_id:
323 account_id = sale_line.product_id.categ_id.\
324 property_account_income_categ.id
325 else:
326- account_id = sale_line.product_id.product_tmpl_id.\
327+ account_id = sale_line.product_id.\
328 property_account_expense.id
329 if not account_id:
330 account_id = sale_line.product_id.categ_id.\
331
332=== modified file 'sale/test/picking_order_policy.yml'
333--- sale/test/picking_order_policy.yml 2012-07-14 22:12:00 +0000
334+++ sale/test/picking_order_policy.yml 2012-07-27 16:07:26 +0000
335@@ -121,7 +121,7 @@
336 assert invoice.payment_term.id == order.payment_term.id, "Payment term is not correspond."
337 for so_line in order.order_line:
338 inv_line = so_line.invoice_lines[0]
339- ac = so_line.product_id.product_tmpl_id.property_account_income.id or so_line.product_id.categ_id.property_account_income_categ.id
340+ ac = so_line.product_id.property_account_income.id or so_line.product_id.categ_id.property_account_income_categ.id
341 assert inv_line.product_id.id == so_line.product_id.id or False,"Product is not correspond"
342 assert inv_line.account_id.id == ac,"Account of Invoice line is not corresponding."
343 assert inv_line.uos_id.id == (so_line.product_uos and so_line.product_uos.id) or so_line.product_uom.id, "Product UOS is not correspond."
344
345=== modified file 'stock/product.py'
346--- stock/product.py 2012-07-09 13:40:24 +0000
347+++ stock/product.py 2012-07-27 16:07:26 +0000
348@@ -132,7 +132,7 @@
349
350 if diff > 0:
351 if not stock_input_acc:
352- stock_input_acc = product.product_tmpl_id.\
353+ stock_input_acc = product.\
354 property_stock_account_input.id
355 if not stock_input_acc:
356 stock_input_acc = product.categ_id.\
357@@ -158,7 +158,7 @@
358 })
359 elif diff < 0:
360 if not stock_output_acc:
361- stock_output_acc = product.product_tmpl_id.\
362+ stock_output_acc = product.\
363 property_stock_account_output.id
364 if not stock_output_acc:
365 stock_output_acc = product.categ_id.\
366
367=== modified file 'stock/stock.py'
368--- stock/stock.py 2012-07-27 09:10:29 +0000
369+++ stock/stock.py 2012-07-27 16:07:26 +0000
370@@ -1029,14 +1029,12 @@
371 origin += ':' + move_line.picking_id.origin
372
373 if invoice_vals['type'] in ('out_invoice', 'out_refund'):
374- account_id = move_line.product_id.product_tmpl_id.\
375- property_account_income.id
376+ account_id = move_line.product_id.property_account_income.id
377 if not account_id:
378 account_id = move_line.product_id.categ_id.\
379 property_account_income_categ.id
380 else:
381- account_id = move_line.product_id.product_tmpl_id.\
382- property_account_expense.id
383+ account_id = move_line.product_id.property_account_expense.id
384 if not account_id:
385 account_id = move_line.product_id.categ_id.\
386 property_account_expense_categ.id
387@@ -2729,7 +2727,7 @@
388 change = line.product_qty - amount
389 lot_id = line.prod_lot_id.id
390 if change:
391- location_id = line.product_id.product_tmpl_id.property_stock_inventory.id
392+ location_id = line.product_id.property_stock_inventory.id
393 value = {
394 'name': 'INV:' + str(line.inventory_id.id) + ':' + line.inventory_id.name,
395 'product_id': line.product_id.id,
396
397=== modified file 'stock/test/opening_stock.yml'
398--- stock/test/opening_stock.yml 2011-12-23 11:06:43 +0000
399+++ stock/test/opening_stock.yml 2012-07-27 16:07:26 +0000
400@@ -66,7 +66,7 @@
401 for move_line in inventory.move_ids:
402 for line in inventory.inventory_line_id:
403 if move_line.product_id.id == line.product_id.id and move_line.prodlot_id.id == line.prod_lot_id.id:
404- location_id = line.product_id.product_tmpl_id.property_stock_inventory.id
405+ location_id = line.product_id.property_stock_inventory.id
406 assert move_line.product_qty == line.product_qty, "Qty is not correspond."
407 assert move_line.product_uom.id == line.product_uom.id, "UOM is not correspond."
408 assert move_line.date == inventory.date, "Date is not correspond."
409
410=== modified file 'stock_planning/stock_planning.py'
411--- stock_planning/stock_planning.py 2012-06-22 06:48:54 +0000
412+++ stock_planning/stock_planning.py 2012-07-27 16:07:26 +0000
413@@ -191,7 +191,7 @@
414 coeff_def2uom = 1
415 if (product_uom != product.uom_id.id):
416 coeff_def2uom, round_value = self._from_default_uom_factor(cr, uid, product_id, product_uom, {})
417- qty = rounding(coeff_def2uom * product_amt/(product.product_tmpl_id.list_price), round_value)
418+ qty = rounding(coeff_def2uom * product_amt/(product.list_price), round_value)
419 res = {'value': {'product_qty': qty}}
420 return res
421

Subscribers

People subscribed via source and target branches

to all changes: