Skip to content

Commit

Permalink
[IMP] account_payment_group: Mejora transferencias
Browse files Browse the repository at this point in the history
Task: 28369
  • Loading branch information
pablohmontenegro committed Feb 1, 2023
1 parent 61619ce commit 439a459
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
18 changes: 18 additions & 0 deletions account_payment_group/models/account_payment.py
Expand Up @@ -51,6 +51,14 @@ class AccountPayment(models.Model):
compute='_compute_available_journal_ids'
)

label_journal_id = fields.Char(
compute='_compute_label'
)

label_destination_journal_id = fields.Char(
compute='_compute_label'
)

@api.depends('payment_type', 'payment_group_id')
def _compute_available_journal_ids(self):
"""
Expand Down Expand Up @@ -248,3 +256,13 @@ def _create_paired_internal_transfer_payment(self):
super(AccountPayment, rec.with_context(
default_force_amount_company_currency=rec.force_amount_company_currency
))._create_paired_internal_transfer_payment()

@api.onchange("payment_type")
def _compute_label(self):
for rec in self:
if rec.payment_type == "outbound":
rec.label_journal_id = "Diario de origen"
rec.label_destination_journal_id = "Diario de destino"
else:
rec.label_journal_id = "Diario de destino"
rec.label_destination_journal_id = "Diario de origen"
34 changes: 33 additions & 1 deletion account_payment_group/views/account_payment_view.xml
Expand Up @@ -98,6 +98,38 @@
</field>
</record>

<record id="view_account_payment_form2" model="ir.ui.view">
<field name="name">account.payment.form</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<field name="journal_id" position="attributes">
<attribute name="nolabel">1</attribute>
<attribute name="class">oe_inline</attribute>
</field>
<field name="destination_journal_id" position="attributes">
<attribute name="nolabel">1</attribute>
<attribute name="class">oe_inline</attribute>
</field>
<xpath expr="//field[@name='journal_id']" position="before">
<!-- <label for="journal_id" class="oe_inline" string="Diario de origen" attrs="{'invisible': [('payment_type', 'not in', ('outbound'))]}"></label>
<label for="journal_id" class="oe_inline" string="Diario de destino" attrs="{'invisible': [('payment_type', 'not in', ('inbound'))]}"></label> -->
<div>
<field name="label_journal_id" nolabel="1" class="o_form_label"></field>
</div>
</xpath>

<xpath expr="//field[@name='destination_journal_id']" position="before">
<!-- <label for="destination_journal_id" class="oe_inline" string="Diario de destino" attrs="{'invisible': [('payment_type', 'not in', ('outbound'))]}"></label>
<label for="destination_journal_id" class="oe_inline" string="Diario de origen" attrs="{'invisible': [('payment_type', 'not in', ('inbound'))]}"></label> -->
<div>
<field name="label_destination_journal_id" nolabel="1" class="o_form_label"></field>
</div>
</xpath>
</field>
</record>

<record id="view_account_payment_from_group_form" model="ir.ui.view">
<field name="name">account.payment.from payment group.form</field>
<field name="model">account.payment</field>
Expand Down Expand Up @@ -131,7 +163,7 @@
<field name="name">Transfers</field>
<field name="res_model">account.payment</field>
<field name="view_mode">tree,form,graph</field>
<field name="context">{'default_is_internal_transfer': True, 'default_move_journal_types': ('bank', 'cash')}</field>
<field name="context">{'form_view_ref': 'account_payment_group.view_account_payment_form2', 'default_payment_type': 'outbound', 'default_is_internal_transfer': True, 'default_move_journal_types': ('bank', 'cash')}</field>
<field name="domain">[('is_internal_transfer', '=', 'transfer')]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Expand Down

0 comments on commit 439a459

Please sign in to comment.