Merge lp:~akretion-team/openobject-addons/trunk-addons-dont-access-product-template into lp:openobject-addons

Proposed by Alexis de Lattre on 2012-07-09
Status: Merged
Merged at revision: 7018
Proposed branch: lp:~akretion-team/openobject-addons/trunk-addons-dont-access-product-template
Merge into: lp:openobject-addons
Diff against target: 132 lines (+9/-26)
5 files modified
product/pricelist.py (+1/-2)
product_visible_discount/product_visible_discount.py (+2/-8)
stock/wizard/stock_change_product_qty.py (+4/-10)
stock_planning/wizard/stock_planning_createlines.py (+1/-3)
stock_planning/wizard/stock_planning_forecast.py (+1/-3)
To merge this branch: bzr merge lp:~akretion-team/openobject-addons/trunk-addons-dont-access-product-template
Reviewer Review Type Date Requested Status
qdp (OpenERP) 2012-07-10 Pending
OpenERP Core Team 2012-07-09 Pending
Review via email: mp+114001@code.launchpad.net

Description of the change

When we use the ORM, we should always use product.product ; we should never use product.template.

With this merge proposal, we will be able to "move" some fields from product.template to product.product in a custom module by just defining the field on product.product.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'product/pricelist.py'
2--- product/pricelist.py 2012-02-13 15:27:55 +0000
3+++ product/pricelist.py 2012-07-09 16:30:28 +0000
4@@ -155,7 +155,6 @@
5
6 currency_obj = self.pool.get('res.currency')
7 product_obj = self.pool.get('product.product')
8- product_template_obj = self.pool.get('product.template')
9 product_category_obj = self.pool.get('product.category')
10 product_uom_obj = self.pool.get('product.uom')
11 supplierinfo_obj = self.pool.get('product.supplierinfo')
12@@ -246,7 +245,7 @@
13 price = 0.0
14 if sinfo:
15 qty_in_product_uom = qty
16- product_default_uom = product_template_obj.read(cr, uid, [tmpl_id], ['uom_id'])[0]['uom_id'][0]
17+ product_default_uom = product_obj.read(cr, uid, [product_id], ['uom_id'])[0]['uom_id'][0]
18 supplier = supplierinfo_obj.browse(cr, uid, sinfo, context=context)[0]
19 seller_uom = supplier.product_uom and supplier.product_uom.id or False
20 if seller_uom and product_default_uom and product_default_uom != seller_uom:
21
22=== modified file 'product_visible_discount/product_visible_discount.py'
23--- product_visible_discount/product_visible_discount.py 2012-03-20 05:22:58 +0000
24+++ product_visible_discount/product_visible_discount.py 2012-07-09 16:30:28 +0000
25@@ -47,7 +47,6 @@
26 item_obj = self.pool.get('product.pricelist.item')
27 price_type_obj = self.pool.get('product.price.type')
28 product_obj = self.pool.get('product.product')
29- template_obj = self.pool.get('product.template')
30 field_name = 'list_price'
31
32 if res_dict.get('item_id',False) and res_dict['item_id'].get(pricelist,False):
33@@ -57,9 +56,7 @@
34 field_name = price_type_obj.browse(cr, uid, item_base).field
35
36 product = product_obj.browse(cr, uid, product_id, context)
37- product_tmpl_id = product.product_tmpl_id.id
38-
39- product_read = template_obj.read(cr, uid, product_tmpl_id, [field_name], context)
40+ product_read = product_obj.read(cr, uid, product_id, [field_name], context)
41
42 factor = 1.0
43 if uom and uom != product.uom_id.id:
44@@ -110,7 +107,6 @@
45 item_obj = self.pool.get('product.pricelist.item')
46 price_type_obj = self.pool.get('product.price.type')
47 product_obj = self.pool.get('product.product')
48- template_obj = self.pool.get('product.template')
49 field_name = 'list_price'
50
51 if res_dict.get('item_id',False) and res_dict['item_id'].get(pricelist,False):
52@@ -120,9 +116,7 @@
53 field_name = price_type_obj.browse(cr, uid, item_base).field
54
55 product = product_obj.browse(cr, uid, product_id, context)
56- product_tmpl_id = product.product_tmpl_id.id
57-
58- product_read = template_obj.read(cr, uid, product_tmpl_id, [field_name], context)
59+ product_read = product_obj.read(cr, uid, product_id, [field_name], context)
60
61 factor = 1.0
62 if uom and uom != product.uom_id.id:
63
64=== modified file 'stock/wizard/stock_change_product_qty.py'
65--- stock/wizard/stock_change_product_qty.py 2012-06-05 11:12:29 +0000
66+++ stock/wizard/stock_change_product_qty.py 2012-07-09 16:30:28 +0000
67@@ -103,20 +103,14 @@
68 self.change_product_qty_send_note(cr, uid, [data.id], context)
69 return {}
70
71- def change_product_qty_send_note (self, cr, uid, ids, context=None):
72+ def change_product_qty_send_note(self, cr, uid, ids, context=None):
73 prod_obj = self.pool.get('product.product')
74 location_obj = self.pool.get('stock.location')
75- prod_temp_obj = self.pool.get('product.template')
76- uom_obj = self.pool.get('product.uom')
77
78 for data in self.browse(cr, uid, ids, context=context):
79- for location in location_obj.browse(cr, uid, [data.location_id.id], context=context):
80- location_name = location.name
81- for prod in prod_obj.browse(cr, uid, [data.product_id.id], context=context):
82- for prod_temp in prod_temp_obj.browse(cr, uid, [prod.product_tmpl_id.id], context=context):
83- for uom in uom_obj.browse(cr, uid, [prod_temp.uom_id.id], context=context):
84- message = _("<b>Quantity has been changed</b> to <em>%s %s </em> for <em>%s</em> location.") % (data.new_quantity,uom.name,location_name)
85- prod_obj.message_append_note(cr, uid, [prod.id], body=message, context=context)
86+ location_name = location_obj.browse(cr, uid, data.location_id.id, context=context).name
87+ message = _("<b>Quantity has been changed</b> to <em>%s %s </em> for <em>%s</em> location.") % (data.new_quantity, data.product_id.uom_id.name, location_name)
88+ prod_obj.message_append_note(cr, uid, [data.product_id.id], body=message, context=context)
89
90 stock_change_product_qty()
91
92
93=== modified file 'stock_planning/wizard/stock_planning_createlines.py'
94--- stock_planning/wizard/stock_planning_createlines.py 2011-09-21 07:37:15 +0000
95+++ stock_planning/wizard/stock_planning_createlines.py 2012-07-09 16:30:28 +0000
96@@ -56,7 +56,6 @@
97 planning_obj = self.pool.get('stock.planning')
98 mod_obj = self.pool.get('ir.model.data')
99 prod_categ_obj = self.pool.get('product.category')
100- template_obj = self.pool.get('product.template')
101 planning_lines = []
102 for f in self.browse(cr, uid, ids, context=context):
103 if f.forecasted_products:
104@@ -67,8 +66,7 @@
105 else:
106 categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or []
107 prod_categ_ids = prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)])
108- templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)])
109- products_id1 = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)])
110+ products_id1 = product_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)])
111 if len(products_id1)==0:
112 raise osv.except_osv(_('Error !'), _('No forecasts for selected period or no products in selected category !'))
113
114
115=== modified file 'stock_planning/wizard/stock_planning_forecast.py'
116--- stock_planning/wizard/stock_planning_forecast.py 2011-09-21 07:37:15 +0000
117+++ stock_planning/wizard/stock_planning_forecast.py 2012-07-09 16:30:28 +0000
118@@ -49,13 +49,11 @@
119 forecast_obj = self.pool.get('stock.sale.forecast')
120 mod_obj = self.pool.get('ir.model.data')
121 prod_categ_obj = self.pool.get('product.category')
122- template_obj = self.pool.get('product.template')
123 forecast_lines = []
124 for f in self.browse(cr, uid, ids, context=context):
125 categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or []
126 prod_categ_ids = prod_categ_obj.search(cr, uid, [('parent_id','child_of', categ_ids)])
127- templates_ids = template_obj.search(cr, uid, [('categ_id','in',prod_categ_ids)])
128- products_ids = product_obj.search(cr, uid, [('product_tmpl_id','in',templates_ids)])
129+ products_ids = product_obj.search(cr, uid, [('categ_id','in',prod_categ_ids)])
130 if len(products_ids) == 0:
131 raise osv.except_osv(_('Error !'), _('No products in selected category !'))
132 copy = f.copy_forecast

Subscribers

People subscribed via source and target branches

to all changes: