Remplace all occurences of my_browse_rec.product_id.product_tmpl_id.field to my_brows...
authorAlexis de Lattre <alexis@via.ecp.fr>
Fri, 27 Jul 2012 01:52:02 +0000 (03:52 +0200)
committerAlexis de Lattre <alexis@via.ecp.fr>
Fri, 27 Jul 2012 01:52:02 +0000 (03:52 +0200)
bzr revid: alexis@via.ecp.fr-20120727015202-7fylff5jr26sgxez

23 files changed:
addons/account/account_analytic_line.py
addons/account/account_invoice.py
addons/account_anglo_saxon/sale.py
addons/account_anglo_saxon/stock.py
addons/analytic_user_function/analytic_user_function.py
addons/hr_expense/hr_expense.py
addons/hr_timesheet/hr_timesheet.py
addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
addons/mrp/mrp.py
addons/mrp/procurement.py
addons/mrp/test/order_process.yml
addons/mrp_subproduct/mrp_subproduct.py
addons/procurement/procurement.py
addons/project_timesheet/project_timesheet.py
addons/purchase/purchase.py
addons/purchase/wizard/purchase_line_invoice.py
addons/sale/sale.py
addons/sale/stock.py
addons/sale/test/picking_order_policy.yml
addons/stock/product.py
addons/stock/stock.py
addons/stock/test/opening_stock.yml
addons/stock_planning/stock_planning.py

index 06de5a3..893acde 100644 (file)
@@ -83,7 +83,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:
@@ -92,7 +92,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:
index 6a0a29c..33ef8ad 100644 (file)
@@ -1404,11 +1404,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)
index e2cfa7b..0faf30c 100644 (file)
@@ -31,7 +31,7 @@ from osv import fields, osv
 #        invoice_line_obj = self.pool.get('account.invoice.line')
 #        for line in invoice_line_obj.browse(cr, uid, line_ids):
 #            if line.product_id:
-#                    a =  line.product_id.product_tmpl_id.property_stock_account_output and line.product_id.product_tmpl_id.property_stock_account_output.id
+#                    a =  line.product_id.property_stock_account_output and line.product_id.property_stock_account_output.id
 #                    if not a:
 #                        a = line.product_id.categ_id.property_stock_account_output_categ and line.product_id.categ_id.property_stock_account_output_categ.id
 #                    if a:
index 9ddfab8..e877499 100644 (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:
index cfb1aba..e446afc 100644 (file)
@@ -85,10 +85,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:
@@ -123,7 +123,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:
index b119270..fd5db8d 100644 (file)
@@ -164,7 +164,7 @@ class hr_expense_expense(osv.osv):
             for l in exp.line_ids:
                 tax_id = []
                 if l.product_id:
-                    acc = l.product_id.product_tmpl_id.property_account_expense
+                    acc = l.product_id.property_account_expense
                     if not acc:
                         acc = l.product_id.categ_id.property_account_expense_categ
                     tax_id = [x.id for x in l.product_id.supplier_taxes_id]
index 5311985..f959b85 100644 (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:
index c9b2439..bf5fc1b 100644 (file)
@@ -117,7 +117,7 @@ class account_analytic_line(osv.osv):
 
                 taxes = product.taxes_id
                 tax = fiscal_pos_obj.map_tax(cr, uid, account.partner_id.property_account_position, taxes)
-                account_id = product.product_tmpl_id.property_account_income.id or product.categ_id.property_account_income_categ.id
+                account_id = product.property_account_income.id or product.categ_id.property_account_income_categ.id
                 if not account_id:
                     raise osv.except_osv(_("Configuration Error"), _("No income account defined for product '%s'") % product.name)
                 curr_line = {
index ea21962..061dfe5 100644 (file)
@@ -957,7 +957,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
         move_name = _('PROD: %s') + production.name
         data = {
@@ -985,7 +985,7 @@ class mrp_production(osv.osv):
         if production_line.product_id.type not in ('product', 'consu'):
             return False
         move_name = _('PROD: %s') % production.name
-        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, {
index 363f98e..2b37f2a 100644 (file)
@@ -79,7 +79,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,
index ee78e03..102f6a0 100644 (file)
@@ -94,7 +94,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."
index bacdeb2..2a99577 100644 (file)
@@ -75,7 +75,7 @@ class mrp_production(osv.osv):
         """
         picking_id = super(mrp_production,self).action_confirm(cr, uid, ids)
         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:
index 1c83711..0d2388e 100644 (file)
@@ -285,7 +285,7 @@ class procurement_order(osv.osv):
         user = self.pool.get('res.users').browse(cr, uid, uid)
         partner_obj = self.pool.get('res.partner')
         for procurement in self.browse(cr, uid, ids):
-            if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
+            if procurement.product_id.supply_method <> 'buy':
                 return False
             if not procurement.product_id.seller_ids:
                 message = _('No supplier defined for this product !')
@@ -333,7 +333,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,
index 565710f..56f6e55 100644 (file)
@@ -88,7 +88,7 @@ class project_work(osv.osv):
             raise osv.except_osv(_('Bad Configuration !'),
                  _('No journal defined on the related employee.\nFill in the timesheet tab of the employee form.'))
 
-        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 not a:
index afdca95..32eedc4 100644 (file)
@@ -434,7 +434,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:
@@ -485,7 +485,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
 
@@ -1048,7 +1048,7 @@ class procurement_order(osv.osv):
             context.update({'lang': partner.lang, 'partner_id': partner_id})
 
             product = prod_obj.browse(cr, uid, procurement.product_id.id, context=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
index d43f617..f12477a 100644 (file)
@@ -102,7 +102,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:
index f920b34..34697a0 100644 (file)
@@ -950,7 +950,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))
@@ -1014,7 +1014,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
 
@@ -1188,7 +1188,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:
index c4e505a..2287385 100644 (file)
@@ -161,13 +161,13 @@ class stock_picking(osv.osv):
                     else:
                         name = sale_line.name
                     if type in ('out_invoice', 'out_refund'):
-                        account_id = sale_line.product_id.product_tmpl_id.\
+                        account_id = sale_line.product_id.\
                                 property_account_income.id
                         if not account_id:
                             account_id = sale_line.product_id.categ_id.\
                                     property_account_income_categ.id
                     else:
-                        account_id = sale_line.product_id.product_tmpl_id.\
+                        account_id = sale_line.product_id.\
                                 property_account_expense.id
                         if not account_id:
                             account_id = sale_line.product_id.categ_id.\
index 16caefd..8d5cdcb 100644 (file)
         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."
index e4164ef..0279807 100644 (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.\
index 6d8f6bb..c43fb07 100644 (file)
@@ -1029,14 +1029,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
@@ -2729,7 +2727,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:' + str(line.inventory_id.id) + ':' + line.inventory_id.name,
                         'product_id': line.product_id.id,
index 0cb6c0b..2e3eaea 100644 (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."
index e6f3b8d..bd973c6 100644 (file)
@@ -191,7 +191,7 @@ class stock_sale_forecast(osv.osv):
             coeff_def2uom = 1
             if (product_uom != product.uom_id.id):
                 coeff_def2uom, round_value = self._from_default_uom_factor(cr, uid, product_id, product_uom, {})
-            qty = rounding(coeff_def2uom * product_amt/(product.product_tmpl_id.list_price), round_value)
+            qty = rounding(coeff_def2uom * product_amt/(product.list_price), round_value)
         res = {'value': {'product_qty': qty}}
         return res