Add symbol widget

issue9059
review276871002
This commit is contained in:
Cédric Krier
2020-10-09 19:09:05 +02:00
parent fae94c5047
commit cdcbc861a8
7 changed files with 34 additions and 14 deletions
+23 -3
View File
@@ -86,6 +86,8 @@ class Statement(Workflow, ModelSQL, ModelView):
'readonly': (Eval('state') != 'draft') | Eval('lines', [0]),
},
depends=['state', 'company'])
currency = fields.Function(fields.Many2One(
'currency.currency', "Currency"), 'on_change_with_currency')
currency_digits = fields.Function(fields.Integer('Currency Digits'),
'on_change_with_currency_digits')
date = fields.Date('Date', required=True, select=True)
@@ -236,6 +238,11 @@ class Statement(Workflow, ModelSQL, ModelView):
statement, = statements
self.start_balance = statement.end_balance
@fields.depends('journal')
def on_change_with_currency(self, name=None):
if self.journal:
return self.journal.currency.id
@fields.depends('journal')
def on_change_with_currency_digits(self, name=None):
if self.journal:
@@ -667,9 +674,12 @@ def origin_mixin(_states, _depends):
"Date", required=True, states=_states, depends=_depends)
amount = fields.Numeric(
"Amount", required=True,
digits=(16, Eval('_parent_statement', {})
.get('currency_digits', 2)),
states=_states, depends=_depends)
digits=(16, Eval('currency_digits', 2)),
states=_states, depends=_depends + ['currency_digits'])
currency = fields.Function(fields.Many2One(
'currency.currency', "Currency"), 'on_change_with_currency')
currency_digits = fields.Function(fields.Integer(
"Currency Digits"), 'on_change_with_currency_digits')
party = fields.Many2One(
'party.party', "Party", states=_states, depends=_depends)
account = fields.Many2One(
@@ -706,6 +716,16 @@ def origin_mixin(_states, _depends):
def search_company(cls, name, clause):
return [('statement.' + clause[0],) + tuple(clause[1:])]
@fields.depends('statement', '_parent_statement.journal')
def on_change_with_currency(self, name=None):
if self.statement and self.statement.journal:
return self.statement.journal.currency.id
@fields.depends('statement', '_parent_statement.journal')
def on_change_with_currency_digits(self, name=None):
if self.statement and self.statement.journal:
return self.statement.journal.currency.digits
return Mixin
+4 -4
View File
@@ -10,14 +10,14 @@ this repository contains the full copyright notices and license terms. -->
<field name="date"/>
<label name="start_balance"/>
<group id="balances" col="-1">
<field name="start_balance"/>
<field name="start_balance" symbol="currency"/>
<label name="balance"/>
<field name="balance"/>
<field name="balance" symbol="currency"/>
</group>
<label name="end_balance"/>
<field name="end_balance"/>
<field name="end_balance" symbol="currency"/>
<label name="total_amount"/>
<field name="total_amount"/>
<field name="total_amount" symbol="currency"/>
<newline/>
<label name="number_of_lines"/>
<field name="number_of_lines"/>
+1 -1
View File
@@ -11,7 +11,7 @@ this repository contains the full copyright notices and license terms. -->
<label name="date"/>
<field name="date"/>
<label name="amount"/>
<field name="amount"/>
<field name="amount" symbol="currency"/>
<label name="party"/>
<field name="party"/>
<label name="account"/>
+1 -1
View File
@@ -5,7 +5,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="statement" expand="1"/>
<field name="number"/>
<field name="date"/>
<field name="amount"/>
<field name="amount" symbol="currency"/>
<field name="party" expand="1"/>
<field name="account" expand="1"/>
<field name="invoice" expand="1"/>
+1 -1
View File
@@ -5,7 +5,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="statement" expand="1"/>
<field name="number"/>
<field name="date"/>
<field name="amount" sum="Amount"/>
<field name="amount" sum="Amount" symbol="currency"/>
<field name="party" expand="1"/>
<field name="invoice" expand="1"/>
<field name="account" expand="1"/>
+2 -2
View File
@@ -11,9 +11,9 @@ this repository contains the full copyright notices and license terms. -->
<label name="date"/>
<field name="date"/>
<label name="amount"/>
<field name="amount"/>
<field name="amount" symbol="currency"/>
<label name="pending_amount"/>
<field name="pending_amount"/>
<field name="pending_amount" symbol="currency"/>
<label name="party"/>
<field name="party"/>
<label name="account"/>
+2 -2
View File
@@ -5,8 +5,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="statement" expand="1"/>
<field name="number"/>
<field name="date"/>
<field name="amount" sum="Amount"/>
<field name="pending_amount"/>
<field name="amount" sum="Amount" symbol="currency"/>
<field name="pending_amount" symbol="currency"/>
<field name="party" expand="1"/>
<field name="account" expand="1"/>
<field name="description" expand="1"/>