Skip to content

Commit

Permalink
[13.0] [FIX] account_payment_group: Adapt the changes in odoo save & …
Browse files Browse the repository at this point in the history
…new button for old context.

Ticket 43417
  • Loading branch information
nicomacr committed Aug 31, 2021
1 parent 8d56570 commit 6044d28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion account_payment_group/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Account Payment with Multiple methods",
"version": "13.0.1.6.0",
"version": "13.0.1.7.0",
"category": "Accounting",
"website": "www.adhoc.com.ar",
"author": "ADHOC SA, AITIC S.A.S",
Expand Down
21 changes: 18 additions & 3 deletions account_payment_group/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,23 @@ def _compute_other_currency(self):

@api.onchange('payment_group_id')
def onchange_payment_group_id(self):
if self.payment_group_id.payment_difference:
self.amount = self.payment_group_id.payment_difference
# now we change this according when use save & new the context from the payment was erased and we need to use some data.
# this change is due this odoo change https://github.com/odoo/odoo/commit/c14b17c4855fd296fd804a45eab02b6d3566bb7a
if self.payment_group_id:
self.payment_group_company_id = self.payment_group_id.company_id
self.payment_date = self.payment_group_id.payment_date
self.partner_type = self.payment_group_id.partner_type
self.partner_id = self.payment_group_id.partner_id
payment_difference = self.payment_group_id.payment_difference
if self.payment_group_id.payment_difference < 0.0 and self.payment_group_id.partner_type == 'customer':
self.amount = abs(payment_difference)
self.payment_type = 'outbound'
elif self.payment_group_id.payment_difference < 0.0 and self.payment_group_id.partner_type == 'supplier':
self.amount = abs(payment_difference)
self.payment_type = 'inbound'
else:
self.payment_type = 'inbound' if self.payment_group_id.partner_type == 'customer' else 'outbound'
self.amount = payment_difference

@api.depends('amount', 'other_currency', 'amount_company_currency')
def _compute_exchange_rate(self):
Expand Down Expand Up @@ -168,7 +183,7 @@ def _onchange_payment_type(self):
we disable change of partner_type if we came from a payment_group
but we still reset the journal
"""
if not self._context.get('payment_group'):
if not self.payment_group_id:
return super(AccountPayment, self)._onchange_payment_type()
self.journal_id = False

Expand Down
2 changes: 1 addition & 1 deletion account_payment_group/views/account_payment_group_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<page string="Payment Lines" attrs="{'invisible': [('payment_subtype', '=', 'double_validation'), ('state', '=', 'draft')]}">
<!-- <page string="Payment Lines" autofocus="autofocus"> -->
<!-- no pudimos hacer que payment_difference se actualice cuando ponemos save and new. La unica que se me ocurre es si está guardado, podemos mandar el active_id y que sea un default en payments el que obtiene el valor -->
<field name="payment_ids" context="{'default_payment_group_company_id': company_id, 'default_payment_type': partner_type == 'supplier' and 'outbound' or 'inbound', 'default_payment_date': payment_date, 'default_partner_id': partner_id, 'default_partner_type': partner_type, 'payment_group': True, 'tree_view_ref': 'account_payment_group.view_account_payment_from_group_tree'}" attrs="{'readonly': [('state', 'not in', ['draft', 'confirmed'])]}"/>
<field name="payment_ids" context="{'payment_group': True, 'tree_view_ref': 'account_payment_group.view_account_payment_from_group_tree'}" attrs="{'readonly': [('state', 'not in', ['draft', 'confirmed'])]}"/>
</page>
<page string="Debts" attrs="{'invisible': ['|', '|', ('pop_up', '=', True), ('payment_subtype', '!=', 'simple'), ('state', '!=', 'draft')]}">
<p>
Expand Down

0 comments on commit 6044d28

Please sign in to comment.