Priyesh (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.0-opw-8274-pso into 
lp:openobject-addons/6.0.

Requested reviews:
  Jay Vora (OpenERP) (jvo-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-8274-pso/+merge/65968

Hello,

Improved the usability code in analytic line
Fixed KeyError:'amount' coming on selection of Analytic account in Working hours
Improved definition of on_change_account_id in Analytic timesheet in 
analytic_user_function module.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-8274-pso/+merge/65968
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-opw-8274-pso.
=== modified file 'account/account_analytic_line.py'
--- account/account_analytic_line.py	2011-01-14 00:11:01 +0000
+++ account/account_analytic_line.py	2011-06-27 11:46:06 +0000
@@ -67,13 +67,13 @@
     # property_valuation_price_type property
     def on_change_unit_amount(self, cr, uid, id, prod_id, quantity, company_id,
             unit=False, journal_id=False, context=None):
-        if context==None:
-            context={}
+        if context is None:
+            context = {}
         if not journal_id:
             j_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=','purchase')])
             journal_id = j_ids and j_ids[0] or False
         if not journal_id or not prod_id:
-            return {}
+            return {'value': {}}
         product_obj = self.pool.get('product.product')
         analytic_journal_obj =self.pool.get('account.analytic.journal')
         product_price_type_obj = self.pool.get('product.price.type')

=== modified file 'analytic_user_function/analytic_user_function.py'
--- analytic_user_function/analytic_user_function.py	2011-01-14 00:11:01 +0000
+++ analytic_user_function/analytic_user_function.py	2011-06-27 11:46:06 +0000
@@ -66,7 +66,7 @@
                 return False
 
 
-    def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0):
+    def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0, journal_id=False):
         res = {}
         if not (account_id):
             #avoid a useless call to super
@@ -99,9 +99,9 @@
                                 (r.product_id.name, r.product_id.id,))
             # Compute based on pricetype
             amount_unit = self.on_change_unit_amount(cr, uid, ids,
-                r.product_id.id, unit_amount, False, r.product_id.uom_id.id)['value']['amount']
+                r.product_id.id, unit_amount, False, r.product_id.uom_id.id)['value']
 
-            amount = unit_amount *  amount_unit
+            amount = amount_unit.has_key('amount') and (unit_amount *  amount_unit['amount']) or unit_amount
             res ['value']['amount']= - round(amount, 2)
             res ['value']['general_account_id']= a
         return res

=== modified file 'analytic_user_function/analytic_user_function_view.xml'
--- analytic_user_function/analytic_user_function_view.xml	2011-01-14 00:11:01 +0000
+++ analytic_user_function/analytic_user_function_view.xml	2011-06-27 11:46:06 +0000
@@ -51,11 +51,11 @@
             <field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/>
             <field name="arch" type="xml">
                 <xpath expr="/form/notebook/page/field[@name='timesheet_ids']/tree/field[@name='account_id']" position="replace">
-                    <field name="account_id" domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount)"/>
+                    <field name="account_id" domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount, journal_id)"/>
                 </xpath>
             </field>
         </record>
-        
+
         <!-- hr_timesheet_sheet.sheet inherited view -->
         <record model="ir.ui.view" id="hr_timesheet_sheet_form_inherit1">
             <field name="name">hr.timesheet.sheet.form.form</field>
@@ -65,7 +65,7 @@
             <field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/>
             <field name="arch" type="xml">
                 <xpath expr="/form/notebook/page/field[@name='timesheet_ids']/form/field[@name='account_id']" position="replace">
-                    <field name="account_id" domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount)"/>
+                    <field name="account_id" domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount, journal_id)"/>
                 </xpath>
             </field>
         </record>
@@ -78,7 +78,7 @@
             <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form"/>
             <field name="arch" type="xml">
                 <xpath expr="/form/notebook/page[@string='Information']/group/field[@name='account_id']" position="replace">
-                    <field name="account_id" domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount)" select="1"/>
+                    <field name="account_id" domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount, journal_id)" select="1"/>
                 </xpath>
             </field>
         </record>
@@ -102,7 +102,7 @@
             <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree"/>
             <field name="arch" type="xml">
                 <xpath expr="/tree/field[@name='account_id']" position="replace">
-                    <field name="account_id" domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount)" select="1"/>
+                    <field name="account_id" domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount, journal_id)" select="1"/>
                 </xpath>
             </field>
         </record>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to