[MERGE] Access inherited product fields on the product directly rather than template, courtesy of Alexis de Lattre (Akretion)

It makes the code a little more straightforward and does not hurt.

bzr revid: odo@openerp.com-20121218225015-6r9ydxjlh147m3z1
This commit is contained in:
Olivier Dony 2012-12-18 23:50:15 +01:00
commit 03b6acd13d
21 changed files with 34 additions and 36 deletions

View File

@ -82,7 +82,7 @@ class account_analytic_line(osv.osv):
if j_id.type == 'purchase':
unit = prod.uom_po_id.id
if j_id.type <> 'sale':
a = prod.product_tmpl_id.property_account_expense.id
a = prod.property_account_expense.id
if not a:
a = prod.categ_id.property_account_expense_categ.id
if not a:
@ -91,7 +91,7 @@ class account_analytic_line(osv.osv):
'for this product: "%s" (id:%d).') % \
(prod.name, prod.id,))
else:
a = prod.product_tmpl_id.property_account_income.id
a = prod.property_account_income.id
if not a:
a = prod.categ_id.property_account_income_categ.id
if not a:

View File

@ -1476,11 +1476,11 @@ class account_invoice_line(osv.osv):
res = self.pool.get('product.product').browse(cr, uid, product, context=context)
if type in ('out_invoice','out_refund'):
a = res.product_tmpl_id.property_account_income.id
a = res.property_account_income.id
if not a:
a = res.categ_id.property_account_income_categ.id
else:
a = res.product_tmpl_id.property_account_expense.id
a = res.property_account_expense.id
if not a:
a = res.categ_id.property_account_expense_categ.id
a = fpos_obj.map_account(cr, uid, fpos, a)

View File

@ -36,7 +36,7 @@ class stock_picking(osv.osv):
for inv in self.pool.get('account.invoice').browse(cr, uid, res.values(), context=context):
for ol in inv.invoice_line:
if ol.product_id:
oa = ol.product_id.product_tmpl_id.property_stock_account_output and ol.product_id.product_tmpl_id.property_stock_account_output.id
oa = ol.product_id.property_stock_account_output and ol.product_id.property_stock_account_output.id
if not oa:
oa = ol.product_id.categ_id.property_stock_account_output_categ and ol.product_id.categ_id.property_stock_account_output_categ.id
if oa:
@ -48,7 +48,7 @@ class stock_picking(osv.osv):
for inv in self.pool.get('account.invoice').browse(cr, uid, res.values(), context=context):
for ol in inv.invoice_line:
if ol.product_id:
oa = ol.product_id.product_tmpl_id.property_stock_account_input and ol.product_id.product_tmpl_id.property_stock_account_input.id
oa = ol.product_id.property_stock_account_input and ol.product_id.property_stock_account_input.id
if not oa:
oa = ol.product_id.categ_id.property_stock_account_input_categ and ol.product_id.categ_id.property_stock_account_input_categ.id
if oa:

View File

@ -96,10 +96,10 @@ class hr_analytic_timesheet(osv.osv):
res.setdefault('value',{})
res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id)['value']
res['value']['product_id'] = r.product_id.id
res['value']['product_uom_id'] = r.product_id.product_tmpl_id.uom_id.id
res['value']['product_uom_id'] = r.product_id.uom_id.id
#the change of product has to impact the amount, uom and general_account_id
a = r.product_id.product_tmpl_id.property_account_expense.id
a = r.product_id.property_account_expense.id
if not a:
a = r.product_id.categ_id.property_account_expense_categ.id
if not a:
@ -128,7 +128,7 @@ class hr_analytic_timesheet(osv.osv):
res['value']['product_id'] = r.product_id.id
#the change of product has to impact the amount, uom and general_account_id
a = r.product_id.product_tmpl_id.property_account_expense.id
a = r.product_id.property_account_expense.id
if not a:
a = r.product_id.categ_id.property_account_expense_categ.id
if not a:

View File

@ -171,7 +171,7 @@ class hr_expense_expense(osv.osv):
journal = account_journal.browse(cr, uid, journal_id, context=context)
for line in exp.line_ids:
if line.product_id:
acc = line.product_id.product_tmpl_id.property_account_expense
acc = line.product_id.property_account_expense
if not acc:
acc = line.product_id.categ_id.property_account_expense_categ
else:

View File

@ -125,7 +125,7 @@ class hr_analytic_timesheet(osv.osv):
if emp_id:
emp = emp_obj.browse(cr, uid, emp_id[0], context=context)
if bool(emp.product_id):
a = emp.product_id.product_tmpl_id.property_account_expense.id
a = emp.product_id.property_account_expense.id
if not a:
a = emp.product_id.categ_id.property_account_expense_categ.id
if a:

View File

@ -255,7 +255,7 @@ class account_analytic_line(osv.osv):
price = self._get_invoice_price(cr, uid, account, product_id, user_id, qty, ctx)
general_account = product.product_tmpl_id.property_account_income or product.categ_id.property_account_income_categ
general_account = product.property_account_income or product.categ_id.property_account_income_categ
if not general_account:
raise osv.except_osv(_("Configuration Error!"), _("Please define income account for product '%s'.") % product.name)
taxes = product.taxes_id or general_account.tax_ids

View File

@ -948,7 +948,7 @@ class mrp_production(osv.osv):
def _make_production_produce_line(self, cr, uid, production, context=None):
stock_move = self.pool.get('stock.move')
source_location_id = production.product_id.product_tmpl_id.property_stock_production.id
source_location_id = production.product_id.property_stock_production.id
destination_location_id = production.location_dest_id.id
data = {
'name': production.name,
@ -974,7 +974,7 @@ class mrp_production(osv.osv):
# Internal shipment is created for Stockable and Consumer Products
if production_line.product_id.type not in ('product', 'consu'):
return False
destination_location_id = production.product_id.product_tmpl_id.property_stock_production.id
destination_location_id = production.product_id.property_stock_production.id
if not source_location_id:
source_location_id = production.location_src_id.id
move_id = stock_move.create(cr, uid, {

View File

@ -91,7 +91,7 @@ class procurement_order(osv.osv):
procurement_obj = self.pool.get('procurement.order')
for procurement in procurement_obj.browse(cr, uid, ids, context=context):
res_id = procurement.move_id.id
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)
newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - relativedelta(days=procurement.product_id.produce_delay or 0.0)
newdate = newdate - relativedelta(days=company.manufacturing_lead)
produce_id = production_obj.create(cr, uid, {
'origin': procurement.origin,

View File

@ -31,7 +31,7 @@
assert order.state == 'confirmed', "Production order should be confirmed."
assert order.move_created_ids, "Trace Record is not created for Final Product."
move = order.move_created_ids[0]
source_location_id = order.product_id.product_tmpl_id.property_stock_production.id
source_location_id = order.product_id.property_stock_production.id
assert move.date == order.date_planned, "Planned date is not correspond."
assert move.product_id.id == order.product_id.id, "Product is not correspond."
assert move.product_uom.id == order.product_uom.id, "UOM is not correspond."

View File

@ -89,7 +89,7 @@ class mrp_production(osv.osv):
picking_id = super(mrp_production,self).action_confirm(cr, uid, ids)
product_uom_obj = self.pool.get('product.uom')
for production in self.browse(cr, uid, ids):
source = production.product_id.product_tmpl_id.property_stock_production.id
source = production.product_id.property_stock_production.id
if not production.bom_id:
continue
for sub_product in production.bom_id.sub_products:

View File

@ -313,7 +313,7 @@ class procurement_order(osv.osv):
if not procurement.move_id:
source = procurement.location_id.id
if procurement.procure_method == 'make_to_order':
source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
source = procurement.product_id.property_stock_procurement.id
id = move_obj.create(cr, uid, {
'name': procurement.name,
'location_id': source,

View File

@ -92,7 +92,7 @@ class project_work(osv.osv):
raise osv.except_osv(_('Bad Configuration !'),
_('Please define journal on the related employee.\nFill in the timesheet tab of the employee form.'))
acc_id = emp.product_id.product_tmpl_id.property_account_expense.id
acc_id = emp.product_id.property_account_expense.id
if not acc_id:
acc_id = emp.product_id.categ_id.property_account_expense_categ.id
if not acc_id:

View File

@ -516,7 +516,7 @@ class purchase_order(osv.osv):
inv_lines = []
for po_line in order.order_line:
if po_line.product_id:
acc_id = po_line.product_id.product_tmpl_id.property_account_expense.id
acc_id = po_line.product_id.property_account_expense.id
if not acc_id:
acc_id = po_line.product_id.categ_id.property_account_expense_categ.id
if not acc_id:
@ -567,7 +567,7 @@ class purchase_order(osv.osv):
def has_stockable_product(self, cr, uid, ids, *args):
for order in self.browse(cr, uid, ids):
for order_line in order.order_line:
if order_line.product_id and order_line.product_id.product_tmpl_id.type in ('product', 'consu'):
if order_line.product_id and order_line.product_id.type in ('product', 'consu'):
return True
return False
@ -1046,7 +1046,7 @@ class procurement_order(osv.osv):
'''
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
if procurement.product_id.supply_method <> 'buy':
return False
return True
@ -1169,7 +1169,7 @@ class procurement_order(osv.osv):
new_context.update({'lang': partner.lang, 'partner_id': partner_id})
product = prod_obj.browse(cr, uid, procurement.product_id.id, context=new_context)
taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id
taxes_ids = procurement.product_id.supplier_taxes_id
taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids)
name = product.partner_ref

View File

@ -98,7 +98,7 @@ class purchase_line_invoice(osv.osv_memory):
if not line.partner_id.id in invoices:
invoices[line.partner_id.id] = []
if line.product_id:
a = line.product_id.product_tmpl_id.property_account_expense.id
a = line.product_id.property_account_expense.id
if not a:
a = line.product_id.categ_id.property_account_expense_categ.id
if not a:

View File

@ -781,7 +781,7 @@ class sale_order_line(osv.osv):
if not line.invoiced:
if not account_id:
if line.product_id:
account_id = line.product_id.product_tmpl_id.property_account_income.id
account_id = line.product_id.property_account_income.id
if not account_id:
account_id = line.product_id.categ_id.property_account_income_categ.id
if not account_id:

View File

@ -383,7 +383,7 @@ class sale_order(osv.osv):
date_planned = self._get_date_planned(cr, uid, order, line, order.date_order, context=context)
if line.product_id:
if line.product_id.product_tmpl_id.type in ('product', 'consu'):
if line.product_id.type in ('product', 'consu'):
if not picking_id:
picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context))
move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, context=context))
@ -447,7 +447,7 @@ class sale_order(osv.osv):
def has_stockable_products(self, cr, uid, ids, *args):
for order in self.browse(cr, uid, ids):
for order_line in order.order_line:
if order_line.product_id and order_line.product_id.product_tmpl_id.type in ('product', 'consu'):
if order_line.product_id and order_line.product_id.type in ('product', 'consu'):
return True
return False

View File

@ -121,7 +121,7 @@
assert invoice.payment_term.id == order.payment_term.id, "Payment term is not correspond."
for so_line in order.order_line:
inv_line = so_line.invoice_lines[0]
ac = so_line.product_id.product_tmpl_id.property_account_income.id or so_line.product_id.categ_id.property_account_income_categ.id
ac = so_line.product_id.property_account_income.id or so_line.product_id.categ_id.property_account_income_categ.id
assert inv_line.product_id.id == so_line.product_id.id or False,"Product is not correspond"
assert inv_line.account_id.id == ac,"Account of Invoice line is not corresponding."
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."

View File

@ -132,7 +132,7 @@ class product_product(osv.osv):
if diff > 0:
if not stock_input_acc:
stock_input_acc = product.product_tmpl_id.\
stock_input_acc = product.\
property_stock_account_input.id
if not stock_input_acc:
stock_input_acc = product.categ_id.\
@ -158,7 +158,7 @@ class product_product(osv.osv):
})
elif diff < 0:
if not stock_output_acc:
stock_output_acc = product.product_tmpl_id.\
stock_output_acc = product.\
property_stock_account_output.id
if not stock_output_acc:
stock_output_acc = product.categ_id.\

View File

@ -1067,14 +1067,12 @@ class stock_picking(osv.osv):
origin += ':' + move_line.picking_id.origin
if invoice_vals['type'] in ('out_invoice', 'out_refund'):
account_id = move_line.product_id.product_tmpl_id.\
property_account_income.id
account_id = move_line.product_id.property_account_income.id
if not account_id:
account_id = move_line.product_id.categ_id.\
property_account_income_categ.id
else:
account_id = move_line.product_id.product_tmpl_id.\
property_account_expense.id
account_id = move_line.product_id.property_account_expense.id
if not account_id:
account_id = move_line.product_id.categ_id.\
property_account_expense_categ.id
@ -2896,7 +2894,7 @@ class stock_inventory(osv.osv):
change = line.product_qty - amount
lot_id = line.prod_lot_id.id
if change:
location_id = line.product_id.product_tmpl_id.property_stock_inventory.id
location_id = line.product_id.property_stock_inventory.id
value = {
'name': _('INV:') + (line.inventory_id.name or ''),
'product_id': line.product_id.id,

View File

@ -66,7 +66,7 @@
for move_line in inventory.move_ids:
for line in inventory.inventory_line_id:
if move_line.product_id.id == line.product_id.id and move_line.prodlot_id.id == line.prod_lot_id.id:
location_id = line.product_id.product_tmpl_id.property_stock_inventory.id
location_id = line.product_id.property_stock_inventory.id
assert move_line.product_qty == line.product_qty, "Qty is not correspond."
assert move_line.product_uom.id == line.product_uom.id, "UOM is not correspond."
assert move_line.date == inventory.date, "Date is not correspond."