← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/trunk-bug-778487-ara into lp:openobject-addons

 

Ashvin Rathod (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-bug-778487-ara into lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #778487 in OpenERP Addons: "account_anglo_saxon - field positioning and  code simplification"
  https://bugs.launchpad.net/openobject-addons/+bug/778487

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-778487-ara/+merge/60580

Hello,

Fix: account_anglo_saxon - field positioning and code simplification

Thanks,
ara
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-778487-ara/+merge/60580
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-778487-ara.
=== modified file 'account_anglo_saxon/invoice.py'
--- account_anglo_saxon/invoice.py	2011-01-14 00:11:01 +0000
+++ account_anglo_saxon/invoice.py	2011-05-11 05:53:30 +0000
@@ -25,7 +25,7 @@
 
 class account_invoice_line(osv.osv):
     _inherit = "account.invoice.line"
-    
+
     def move_line_get(self, cr, uid, invoice_id, context=None):
         res = super(account_invoice_line,self).move_line_get(cr, uid, invoice_id, context=context)
         inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context)
@@ -33,9 +33,9 @@
         def get_price(cr, uid, inv, company_currency,i_line):
             cur_obj = self.pool.get('res.currency')
             if inv.currency_id.id != company_currency:
-                price = cur_obj.compute(cr, uid, company_currency, inv.currency_id.id, i_line.product_id.product_tmpl_id.standard_price * i_line.quantity, context={'date': inv.date_invoice})
+                price = cur_obj.compute(cr, uid, company_currency, inv.currency_id.id, i_line.product_id.standard_price * i_line.quantity, context={'date': inv.date_invoice})
             else:
-                price = i_line.product_id.product_tmpl_id.standard_price * i_line.quantity
+                price = i_line.product_id.standard_price * i_line.quantity
             return price
 
         if inv.type in ('out_invoice','out_refund'):
@@ -43,27 +43,27 @@
                 if i_line.product_id:
                     if inv.type == 'out_invoice':
                         # debit account dacc will be the output account
-                        # first check the product, if empty check the category                        
-                        dacc = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id
+                        # first check the product, if empty check the category
+                        dacc = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id
                         if not dacc:
                             dacc = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id
                     else:
                         # = out_refund
                         # debit account dacc will be the input account
-                        # first check the product, if empty check the category                        
-                        dacc = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id
+                        # first check the product, if empty check the category
+                        dacc = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id
                         if not dacc:
                             dacc = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id
                     # in both cases the credit account cacc will be the expense account
-                    # first check the product, if empty check the category                                    
-                    cacc = i_line.product_id.product_tmpl_id.property_account_expense and i_line.product_id.product_tmpl_id.property_account_expense.id
+                    # first check the product, if empty check the category
+                    cacc = i_line.product_id.property_account_expense and i_line.product_id.property_account_expense.id
                     if not cacc:
                         cacc = i_line.product_id.categ_id.property_account_expense_categ and i_line.product_id.categ_id.property_account_expense_categ.id
                     if dacc and cacc:
                         res.append({
                             'type':'src',
                             'name': i_line.name[:64],
-                            'price_unit':i_line.product_id.product_tmpl_id.standard_price,
+                            'price_unit':i_line.product_id.standard_price,
                             'quantity':i_line.quantity,
                             'price':get_price(cr, uid, inv, company_currency, i_line),
                             'account_id':dacc,
@@ -72,11 +72,11 @@
                             'account_analytic_id':i_line.account_analytic_id.id,
                             'taxes':i_line.invoice_line_tax_id,
                             })
-                        
+
                         res.append({
                             'type':'src',
                             'name': i_line.name[:64],
-                            'price_unit':i_line.product_id.product_tmpl_id.standard_price,
+                            'price_unit':i_line.product_id.standard_price,
                             'quantity':i_line.quantity,
                             'price': -1 * get_price(cr, uid, inv, company_currency, i_line),
                             'account_id':cacc,
@@ -88,36 +88,36 @@
         elif inv.type in ('in_invoice','in_refund'):
             for i_line in inv.invoice_line:
                 if i_line.product_id:
-                    if i_line.product_id.product_tmpl_id.type != 'service':
-                        # get the price difference account at the product                        
-                        acc = i_line.product_id.product_tmpl_id.property_account_creditor_price_difference and i_line.product_id.product_tmpl_id.property_account_creditor_price_difference.id
+                    if i_line.product_id.type != 'service':
+                        # get the price difference account at the product
+                        acc = i_line.product_id.property_account_creditor_price_difference and i_line.product_id.property_account_creditor_price_difference.id
                         if not acc:
-                            # if not found on the product get the price difference account at the category                            
+                            # if not found on the product get the price difference account at the category
                             acc = i_line.product_id.categ_id.property_account_creditor_price_difference_categ and i_line.product_id.categ_id.property_account_creditor_price_difference_categ.id
                         a = None
                         if inv.type == 'in_invoice':
                             # oa will be the stock input account
-                            # first check the product, if empty check the category                             
-                            oa = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id
+                            # first check the product, if empty check the category
+                            oa = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id
                             if not oa:
                                 oa = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id
                         else:
                             # = in_refund
                             # oa will be the stock output account
-                            # first check the product, if empty check the category                            
-                            oa = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id
+                            # first check the product, if empty check the category
+                            oa = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id
                             if not oa:
                                 oa = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id
                         if oa:
-                            # get the fiscal position                            
+                            # get the fiscal position
                             fpos = i_line.invoice_id.fiscal_position or False
                             a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)
                         diff_res = []
-                        # calculate and write down the possible price difference between invoice price and product price                        
+                        # calculate and write down the possible price difference between invoice price and product price
                         for line in res:
                             if a == line['account_id'] and i_line.product_id.id == line['product_id']:
                                 uom = i_line.product_id.uos_id or i_line.product_id.uom_id
-                                standard_price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.product_tmpl_id.standard_price, i_line.uos_id.id)
+                                standard_price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.standard_price, i_line.uos_id.id)
                                 if standard_price != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc:
                                     price_diff = i_line.price_unit - standard_price
                                     line.update({'price':standard_price * line['quantity']})
@@ -134,8 +134,8 @@
                                         'taxes':line.get('taxes',[]),
                                         })
                         res += diff_res
-        return res   
-    
+        return res
+
     def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None):
         if not product:
             return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context)
@@ -145,19 +145,19 @@
         if type in ('in_invoice','in_refund'):
             product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context)
             if type == 'in_invoice':
-                oa = product_obj.product_tmpl_id.property_stock_account_input and product_obj.product_tmpl_id.property_stock_account_input.id
+                oa = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id
                 if not oa:
                     oa = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id
             else:
-                oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id
+                oa = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id
                 if not oa:
                     oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id
             if oa:
                 fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id, context=context) or False
                 a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)
-                res['value'].update({'account_id':a})            
+                res['value'].update({'account_id':a})
         return res
-         
+
 account_invoice_line()
 
 class account_invoice(osv.osv):
@@ -170,7 +170,7 @@
             if inv_obj.type == 'in_invoice':
                 if line.get('product_id',False):
                     product_obj = self.pool.get('product.product').browse(cr, uid, line['product_id'][0])
-                    oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id
+                    oa = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id
                     if not oa:
                         oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id
                     if oa:
@@ -180,6 +180,6 @@
                         line.update({'account_id': (account_data['id'],account_data['name'])})
         res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines)
         return res
-    
+
 account_invoice()
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'account_anglo_saxon/product_view.xml'
--- account_anglo_saxon/product_view.xml	2011-01-14 00:11:01 +0000
+++ account_anglo_saxon/product_view.xml	2011-05-11 05:53:30 +0000
@@ -8,6 +8,7 @@
             <field name="inherit_id" ref="account.product_normal_form_view"/>
             <field name="arch" type="xml">
                 <xpath expr="/form/notebook/page/group/field[@name='property_account_expense']" position="after">
+                    <label string="" colspan="2"/>
                     <field name="property_account_creditor_price_difference" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
                     <newline/>
                 </xpath>
@@ -36,7 +37,7 @@
                 <form position="inside">
                     <group col="2" colspan="2">
                         <separator string=" Accounting Property" colspan="2"/>
-                            <field name="property_account_creditor_price_difference_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />                        
+                            <field name="property_account_creditor_price_difference_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
                     </group>
                 </form>
             </field>

=== modified file 'account_anglo_saxon/purchase.py'
--- account_anglo_saxon/purchase.py	2011-01-14 00:11:01 +0000
+++ account_anglo_saxon/purchase.py	2011-05-11 05:53:30 +0000
@@ -29,7 +29,7 @@
     def inv_line_create(self, cr, uid, a, ol):
         line = super(purchase_order, self).inv_line_create(cr, uid, a, ol)
         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:


Follow ups