diff --git a/addons/account_payment/payment.py b/addons/account_payment/payment.py
index ca1f52f5ebb..c56116aaeab 100644
--- a/addons/account_payment/payment.py
+++ b/addons/account_payment/payment.py
@@ -430,12 +430,15 @@ class payment_line(osv.osv):
('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'),
]
- def onchange_move_line(self,cr,uid,ids,move_line_id,payment_type,date_prefered,date_planned,context=None):
+ def onchange_move_line(self,cr,uid,ids,move_line_id,payment_type,date_prefered,date_planned,currency=False,company_currency=False,context=None):
data={}
- data['amount_currency']=data['currency']=data['communication']=data['partner_id']=data['reference']=data['date_created']=data['bank_id']=False
+ data['amount_currency']=data['currency']=data['communication']=data['partner_id']=data['reference']=data['date_created']=data['bank_id']=data['amount']=False
if move_line_id:
line = self.pool.get('account.move.line').browse(cr,uid,move_line_id)
data['amount_currency']=line.amount_to_pay
+ res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency, company_currency, context)
+ if res:
+ data['amount'] = res['value']['amount']
data['partner_id']=line.partner_id.id
data['currency']=line.currency_id and line.currency_id.id or False
if not data['currency']:
@@ -458,6 +461,15 @@ class payment_line(osv.osv):
return {'value': data}
+ def onchange_amount(self,cr,uid,ids,amount,currency,cmpny_currency,context=None):
+ if not amount:
+ return {}
+ res = {}
+ currency_obj = self.pool.get('res.currency')
+ company_amount = currency_obj.compute(cr, uid, currency, cmpny_currency,amount)
+ res['amount'] = company_amount
+ return {'value': res}
+
def onchange_partner(self,cr,uid,ids,partner_id,payment_type,context=None):
data={}
data['info_partner']=data['bank_id']=False
diff --git a/addons/account_payment/payment_view.xml b/addons/account_payment/payment_view.xml
index 102b4eccd10..d77c454a90c 100644
--- a/addons/account_payment/payment_view.xml
+++ b/addons/account_payment/payment_view.xml
@@ -24,7 +24,7 @@
-
+
payment.type.form
payment.type
@@ -38,7 +38,7 @@
-
+
payment.mode.tree
payment.mode
@@ -69,9 +69,9 @@
form
tree,form
-
+
-
+
payment.order.form
payment.order
@@ -88,12 +88,12 @@
-
+
payment.order.tree
payment.order
@@ -176,7 +176,7 @@
-
+
Payment order
payment.order
@@ -184,7 +184,7 @@
form,tree
-
+
Draft payment order
payment.order
@@ -193,7 +193,7 @@
[('state','=','draft')]
-
+
Payment orders to validate
payment.order
@@ -202,7 +202,7 @@
[('state','=','open')]
-
+
Payment Line
payment.line
@@ -213,12 +213,12 @@
-
+
-
+
@@ -227,14 +227,14 @@
-
+
-
+
@@ -268,7 +268,7 @@
-
+
-
+
@@ -294,7 +294,7 @@
tree
form,tree
-
+
account.bank.statement.form.inherit
account.bank.statement
@@ -306,8 +306,8 @@
-
+
-
+