Ila Rana(Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.0-opw-5967-ira 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-5967-ira/+merge/63332

Hello,

When we add a job for a partner with the module base_contact, We get wrong 
contact for the partner.To overcome this issue, I have made changes in 
on_change_name() function, also the on_change function put in form view, and 
deleting on_change calling function from tree view.    

Thanks,
Ila Rana.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-5967-ira/+merge/63332
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-opw-5967-ira.
=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py	2011-05-20 10:29:05 +0000
+++ account_voucher/account_voucher.py	2011-06-03 06:51:31 +0000
@@ -705,6 +705,10 @@
                 line_total = line_total + currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency)
 
             for line in inv.line_ids:
+                if company_currency <> current_currency:
+                    final_curr=line.move_line_id.currency_id.id
+                else:
+                    final_curr= current_currency
                 #create one move line per voucher line where amount is not 0.0
                 if not line.amount:
                     continue
@@ -712,7 +716,7 @@
                 if line.amount == line.amount_unreconciled:
                     amount = line.move_line_id.amount_residual #residual amount in company currency
                 else:
-                    amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
+                    amount = currency_pool.compute(cr, uid, final_curr, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
                 move_line = {
                     'journal_id': inv.journal_id.id,
                     'period_id': inv.period_id.id,
@@ -720,7 +724,7 @@
                     'account_id': line.account_id.id,
                     'move_id': move_id,
                     'partner_id': inv.partner_id.id,
-                    'currency_id': company_currency <> current_currency and current_currency or False,
+                    'currency_id': final_curr,
                     'analytic_account_id': line.account_analytic_id and line.account_analytic_id.id or False,
                     'quantity': 1,
                     'credit': 0.0,
@@ -750,7 +754,7 @@
                     if not (tax_data.base_code_id and tax_data.tax_code_id):
                         raise osv.except_osv(_('No Account Base Code and Account Tax Code!'),_("You have to configure account base code and account tax code on the '%s' tax!") % (tax_data.name))
                 sign = (move_line['debit'] - move_line['credit']) < 0 and -1 or 1
-                move_line['amount_currency'] = company_currency <> current_currency and sign * line.amount or 0.0
+                move_line['amount_currency'] = final_curr and sign * line.amount or 0.0
                 voucher_line = move_line_pool.create(cr, uid, move_line)
                 if line.move_line_id.id:
                     rec_ids = [voucher_line, line.move_line_id.id]
@@ -773,8 +777,8 @@
                     'date': inv.date,
                     'credit': diff > 0 and diff or 0.0,
                     'debit': diff < 0 and -diff or 0.0,
-                    #'amount_currency': company_currency <> current_currency and currency_pool.compute(cr, uid, company_currency, current_currency, diff * -1, context=context_multi_currency) or 0.0,
-                    #'currency_id': company_currency <> current_currency and current_currency or False,
+                    'amount_currency': final_curr and currency_pool.compute(cr, uid, final_curr, company_currency, diff * -1, context=context_multi_currency) or 0.0,
+                    'currency_id': final_curr,
                 }
                 move_line_pool.create(cr, uid, move_line)
             self.write(cr, uid, [inv.id], {

=== modified file 'base_contact/base_contact.py'
--- base_contact/base_contact.py	2011-04-14 05:53:21 +0000
+++ base_contact/base_contact.py	2011-06-03 06:51:31 +0000
@@ -214,7 +214,10 @@
         'state': lambda *a: 'current',
     }
     
-    def onchange_name(self, cr, uid, ids, address_id='', name='', context=None):    
+    def onchange_name(self, cr, uid, ids, address_id='', name='', context=None):
+        if name:
+            adrs = self.pool.get('res.partner').address_get(cr, uid, [name],['default'])
+            address_id = adrs and adrs['default'] or False
         return {'value': {'address_id': address_id}, 'domain':{'partner_id':'name'}}     
     
     def onchange_partner(self, cr, uid, _, partner_id, context=None):

=== modified file 'base_contact/base_contact_view.xml'
--- base_contact/base_contact_view.xml	2011-01-14 00:11:01 +0000
+++ base_contact/base_contact_view.xml	2011-06-03 06:51:31 +0000
@@ -53,8 +53,8 @@
                                <group colspan="4" col="4">
                                    <field name="sequence_contact" />
                                    <field name="function"/>
-                                   <field name="name" on_change="onchange_name(name,address_id)"/> 
-                                   <field name="address_id"/>                                   
+				   <field name="name" on_change="onchange_name(address_id,name)"/>
+                                   <field name="address_id" attrs="{'required': [('name', '!=', False)]}" on_change="onchange_address(address_id)"/>                                   
                                    <field name="date_start" />
                                    <field name="date_stop" />
                                    <field name="state" />
@@ -72,8 +72,8 @@
                             <tree string="Functions and Addresses">
                                 <field name="sequence_contact" string="Seq."/>
                                 <field name="function"/>
-                                <field name="name" on_change="onchange_partner(name)"/> 
-								<field name="address_id" attrs="{'required': [('name', '!=', False)]}" on_change="onchange_address(address_id)"/>
+                                <field name="name"/>
+				<field name="address_id"/>
                                 <field name="phone"/>
                                 <field name="fax"/>
                                 <field name="extension"/>

_______________________________________________
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