[MERGE] less direct call to product template objects: it's better to access them via product.product in case that field is moved there to manage variants. Courtesy of Alexis de Lattre, Akretion
bzr revid: qdp-launchpad@openerp.com-20120711084935-pnay2fm9wc0h3dwq
This commit is contained in:
commit
3f698109a5
|
@ -155,7 +155,6 @@ class product_pricelist(osv.osv):
|
|||
|
||||
currency_obj = self.pool.get('res.currency')
|
||||
product_obj = self.pool.get('product.product')
|
||||
product_template_obj = self.pool.get('product.template')
|
||||
product_category_obj = self.pool.get('product.category')
|
||||
product_uom_obj = self.pool.get('product.uom')
|
||||
supplierinfo_obj = self.pool.get('product.supplierinfo')
|
||||
|
@ -246,7 +245,7 @@ class product_pricelist(osv.osv):
|
|||
price = 0.0
|
||||
if sinfo:
|
||||
qty_in_product_uom = qty
|
||||
product_default_uom = product_template_obj.read(cr, uid, [tmpl_id], ['uom_id'])[0]['uom_id'][0]
|
||||
product_default_uom = product_obj.read(cr, uid, [product_id], ['uom_id'])[0]['uom_id'][0]
|
||||
supplier = supplierinfo_obj.browse(cr, uid, sinfo, context=context)[0]
|
||||
seller_uom = supplier.product_uom and supplier.product_uom.id or False
|
||||
if seller_uom and product_default_uom and product_default_uom != seller_uom:
|
||||
|
|
|
@ -47,7 +47,6 @@ class sale_order_line(osv.osv):
|
|||
item_obj = self.pool.get('product.pricelist.item')
|
||||
price_type_obj = self.pool.get('product.price.type')
|
||||
product_obj = self.pool.get('product.product')
|
||||
template_obj = self.pool.get('product.template')
|
||||
field_name = 'list_price'
|
||||
|
||||
if res_dict.get('item_id',False) and res_dict['item_id'].get(pricelist,False):
|
||||
|
@ -57,9 +56,7 @@ class sale_order_line(osv.osv):
|
|||
field_name = price_type_obj.browse(cr, uid, item_base).field
|
||||
|
||||
product = product_obj.browse(cr, uid, product_id, context)
|
||||
product_tmpl_id = product.product_tmpl_id.id
|
||||
|
||||
product_read = template_obj.read(cr, uid, product_tmpl_id, [field_name], context)
|
||||
product_read = product_obj.read(cr, uid, product_id, [field_name], context=context)
|
||||
|
||||
factor = 1.0
|
||||
if uom and uom != product.uom_id.id:
|
||||
|
@ -110,7 +107,6 @@ class account_invoice_line(osv.osv):
|
|||
item_obj = self.pool.get('product.pricelist.item')
|
||||
price_type_obj = self.pool.get('product.price.type')
|
||||
product_obj = self.pool.get('product.product')
|
||||
template_obj = self.pool.get('product.template')
|
||||
field_name = 'list_price'
|
||||
|
||||
if res_dict.get('item_id',False) and res_dict['item_id'].get(pricelist,False):
|
||||
|
@ -120,9 +116,7 @@ class account_invoice_line(osv.osv):
|
|||
field_name = price_type_obj.browse(cr, uid, item_base).field
|
||||
|
||||
product = product_obj.browse(cr, uid, product_id, context)
|
||||
product_tmpl_id = product.product_tmpl_id.id
|
||||
|
||||
product_read = template_obj.read(cr, uid, product_tmpl_id, [field_name], context)
|
||||
product_read = product_obj.read(cr, uid, product_id, [field_name], context=context)
|
||||
|
||||
factor = 1.0
|
||||
if uom and uom != product.uom_id.id:
|
||||
|
|
|
@ -103,20 +103,14 @@ class stock_change_product_qty(osv.osv_memory):
|
|||
self.change_product_qty_send_note(cr, uid, [data.id], context)
|
||||
return {}
|
||||
|
||||
def change_product_qty_send_note (self, cr, uid, ids, context=None):
|
||||
def change_product_qty_send_note(self, cr, uid, ids, context=None):
|
||||
prod_obj = self.pool.get('product.product')
|
||||
location_obj = self.pool.get('stock.location')
|
||||
prod_temp_obj = self.pool.get('product.template')
|
||||
uom_obj = self.pool.get('product.uom')
|
||||
|
||||
for data in self.browse(cr, uid, ids, context=context):
|
||||
for location in location_obj.browse(cr, uid, [data.location_id.id], context=context):
|
||||
location_name = location.name
|
||||
for prod in prod_obj.browse(cr, uid, [data.product_id.id], context=context):
|
||||
for prod_temp in prod_temp_obj.browse(cr, uid, [prod.product_tmpl_id.id], context=context):
|
||||
for uom in uom_obj.browse(cr, uid, [prod_temp.uom_id.id], context=context):
|
||||
message = _("<b>Quantity has been changed</b> to <em>%s %s </em> for <em>%s</em> location.") % (data.new_quantity,uom.name,location_name)
|
||||
prod_obj.message_append_note(cr, uid, [prod.id], body=message, context=context)
|
||||
location_name = location_obj.browse(cr, uid, data.location_id.id, context=context).name
|
||||
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)
|
||||
prod_obj.message_append_note(cr, uid, [data.product_id.id], body=message, context=context)
|
||||
|
||||
stock_change_product_qty()
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ class stock_planning_createlines(osv.osv_memory):
|
|||
planning_obj = self.pool.get('stock.planning')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
prod_categ_obj = self.pool.get('product.category')
|
||||
template_obj = self.pool.get('product.template')
|
||||
planning_lines = []
|
||||
for f in self.browse(cr, uid, ids, context=context):
|
||||
if f.forecasted_products:
|
||||
|
@ -67,8 +66,7 @@ class stock_planning_createlines(osv.osv_memory):
|
|||
else:
|
||||
categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or []
|
||||
prod_categ_ids = prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)])
|
||||
templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)])
|
||||
products_id1 = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)])
|
||||
products_id1 = product_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)])
|
||||
if len(products_id1)==0:
|
||||
raise osv.except_osv(_('Error !'), _('No forecasts for selected period or no products in selected category !'))
|
||||
|
||||
|
|
|
@ -49,13 +49,11 @@ class stock_sale_forecast_createlines(osv.osv_memory):
|
|||
forecast_obj = self.pool.get('stock.sale.forecast')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
prod_categ_obj = self.pool.get('product.category')
|
||||
template_obj = self.pool.get('product.template')
|
||||
forecast_lines = []
|
||||
for f in self.browse(cr, uid, ids, context=context):
|
||||
categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or []
|
||||
prod_categ_ids = prod_categ_obj.search(cr, uid, [('parent_id','child_of', categ_ids)])
|
||||
templates_ids = template_obj.search(cr, uid, [('categ_id','in',prod_categ_ids)])
|
||||
products_ids = product_obj.search(cr, uid, [('product_tmpl_id','in',templates_ids)])
|
||||
products_ids = product_obj.search(cr, uid, [('categ_id','in',prod_categ_ids)])
|
||||
if len(products_ids) == 0:
|
||||
raise osv.except_osv(_('Error !'), _('No products in selected category !'))
|
||||
copy = f.copy_forecast
|
||||
|
|
Loading…
Reference in New Issue