diff --git a/invoice.py b/invoice.py
index 6c2e47c57d..ea2d10bc36 100644
--- a/invoice.py
+++ b/invoice.py
@@ -2101,8 +2101,11 @@ Period()
class PayInvoiceInit(WizardOSV):
_name = 'account.invoice.pay_invoice.init'
- amount = fields.Numeric('Amount', digits=(16, 2), required=True)
+ amount = fields.Numeric('Amount', digits="(16, currency_digits)",
+ required=True)
currency = fields.Many2One('currency.currency', 'Currency', required=True)
+ currency_digits = fields.Integer('Currency Digits', readonly=True,
+ on_change_with=['currency'])
description = fields.Char('Description', size=None, required=True)
journal = fields.Many2One('account.journal', 'Journal', required=True,
domain=[('type', '=', 'cash')])
@@ -2112,6 +2115,15 @@ class PayInvoiceInit(WizardOSV):
date_obj = self.pool.get('ir.date')
return date_obj.today(cursor, user, context=context)
+ def on_change_with_currency_digits(self, cursor, user, ids, vals,
+ context=None):
+ currency_obj = self.pool.get('currency.currency')
+ if vals.get('currency'):
+ currency = currency_obj.browse(cursor, user, vals['currency'],
+ context=context)
+ return currency.digits
+ return 2
+
PayInvoiceInit()
@@ -2132,8 +2144,10 @@ class PayInvoiceAsk(WizardOSV):
'invisible': "type != 'writeoff'",
'required': "type == 'writeoff'",
})
- amount = fields.Numeric('Amount', digits=(16, 2), readonly=True)
+ amount = fields.Numeric('Amount', digits="(16, currency_digits)", readonly=True)
currency = fields.Many2One('currency.currency', 'Currency', readonly=True)
+ currency_digits = fields.Integer('Currency Digits', readonly=True,
+ on_change_with=['currency'])
lines_to_pay = fields.Char(string='Lines to Pay', size=None)
lines = fields.One2Many('account.move.line', 'ham', 'Lines',
domain="[('id', 'in', eval(lines_to_pay)), " \
@@ -2151,6 +2165,15 @@ class PayInvoiceAsk(WizardOSV):
def default_type(self, cursor, user, context=None):
return 'writeoff'
+ def on_change_with_currency_digits(self, cursor, user, ids, vals,
+ context=None):
+ currency_obj = self.pool.get('currency.currency')
+ if vals.get('currency'):
+ currency = currency_obj.browse(cursor, user, vals['currency'],
+ context=context)
+ return currency.digits
+ return 2
+
PayInvoiceAsk()
@@ -2200,6 +2223,7 @@ class PayInvoice(Wizard):
res = {}
invoice = invoice_obj.browse(cursor, user, data['id'], context=context)
res['currency'] = invoice.currency.id
+ res['currency_digits'] = invoice.currency.digits
res['amount'] = invoice.amount_to_pay_today
res['description'] = invoice.number
return res
@@ -2233,6 +2257,7 @@ class PayInvoice(Wizard):
res['amount'] = data['form']['amount']
res['currency'] = data['form']['currency']
+ res['currency_digits'] = data['form']['currency_digits']
res['description'] = data['form']['description']
res['journal'] = data['form']['journal']
res['date'] = data['form']['date']
diff --git a/invoice.xml b/invoice.xml
index 307363b4a7..48d84eca87 100644
--- a/invoice.xml
+++ b/invoice.xml
@@ -760,6 +760,7 @@ this repository contains the full copyright notices and license terms. -->
+
]]>
@@ -789,13 +790,16 @@ this repository contains the full copyright notices and license terms. -->
+
+
-
-
-
-
-
+
+
+
+
+
+
]]>