Skip to content

Commit

Permalink
[FIX] not show manual currency when main currency
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 committed Jan 22, 2024
1 parent a1ddd5a commit 9b468ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 10 additions & 1 deletion account_manual_currency/wizard/account_payment_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
class AccountPaymentRegister(models.TransientModel):
_inherit = "account.payment.register"

currency_diff = fields.Boolean(
compute="_compute_currency_diff",
store=True,
)
manual_currency = fields.Boolean()
type_currency = fields.Selection(
selection=lambda self: self.line_ids.move_id._get_label_currency_name(),
Expand All @@ -19,6 +23,11 @@ class AccountPaymentRegister(models.TransientModel):
"currency on the purchase order and last currency",
)

@api.depends("currency_id")
def _compute_currency_diff(self):
for rec in self:
rec.currency_diff = rec.company_currency_id != rec.currency_id

@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
Expand All @@ -37,7 +46,7 @@ def default_get(self, fields_list):
"You can only register payments for moves with the same manual currency."
)
)
res["manual_currency"] = moves.mapped("manual_currency")
res["manual_currency"] = moves.mapped("manual_currency")[0]
if len(list(set(moves.mapped("manual_currency_rate")))) == 1:
res["manual_currency_rate"] = moves.mapped("manual_currency_rate")[0]
if len(list(set(moves.mapped("type_currency")))) == 1:
Expand Down
12 changes: 10 additions & 2 deletions account_manual_currency/wizard/account_payment_register_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@
<field name="inherit_id" ref="account.view_account_payment_register_form" />
<field name="arch" type="xml">
<xpath expr="//group[@name='group2']" position="inside">
<label for="manual_currency" groups="base.group_multi_currency" />
<div groups="base.group_multi_currency">
<field name="currency_diff" invisible="1" />
<label
for="manual_currency"
groups="base.group_multi_currency"
attrs="{'invisible': [('currency_diff', '!=', True)]}"
/>
<div
groups="base.group_multi_currency"
attrs="{'invisible': [('currency_diff', '!=', True)]}"
>
<field name="manual_currency" />
<label for="manual_currency_rate" invisible='1' />
<div
Expand Down

0 comments on commit 9b468ce

Please sign in to comment.