Fix currency_digits for pay invoice
This commit is contained in:
1 parent
f7fc05d0fd
commit
f38bbb2ada
2 files changed
+36
-7
No files matched your search
+27
-2
@@ -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']
|
||||
|
||||
+9
-5
@@ -760,6 +760,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="journal"/>
|
||||
<label name="date"/>
|
||||
<field name="date"/>
|
||||
<field name="currency_digits" colspan="4" invisible="1"/>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
@@ -789,13 +790,16 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="credit" sum="Credit"/>
|
||||
<field name="amount_second_currency" sum="Amount Second Currency"/>
|
||||
<field name="second_currency"/>
|
||||
<field name="currency_digits" tree_invisible="1"/>
|
||||
<field name="second_currency_digits" tree_invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="lines_to_pay" invisible="1"/>
|
||||
<field name="description" invisible="1"/>
|
||||
<field name="journal" invisible="1"/>
|
||||
<field name="date" invisible="1"/>
|
||||
<field name="company" invisible="1"/>
|
||||
<field name="lines_to_pay" colspan="4" invisible="1"/>
|
||||
<field name="description" colspan="4" invisible="1"/>
|
||||
<field name="journal" colspan="4" invisible="1"/>
|
||||
<field name="date" colspan="4" invisible="1"/>
|
||||
<field name="company" colspan="4" invisible="1"/>
|
||||
<field name="currency_digits" colspan="4" invisible="1"/>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
|
||||
Reference in new issue
Block a user