From cf0b580618b38f2731e3266d32a59573fefba260 Mon Sep 17 00:00:00 2001 From: filoquin Date: Thu, 3 Nov 2022 17:02:46 -0300 Subject: [PATCH] [MIG] Account payment group: Migration to 16 --- account_payment_group/models/account_move.py | 9 +++++---- account_payment_group/models/account_move_line.py | 3 +-- account_payment_group/models/account_payment.py | 3 +++ account_payment_group/models/account_payment_group.py | 6 +++--- .../views/account_payment_group_view.xml | 6 +++--- .../__manifest__.py | 2 +- account_withholding/__manifest__.py | 2 +- account_withholding_automatic/__manifest__.py | 2 +- card_installment/__manifest__.py | 2 +- 9 files changed, 19 insertions(+), 16 deletions(-) diff --git a/account_payment_group/models/account_move.py b/account_payment_group/models/account_move.py index 8aef8abac..81080b625 100644 --- a/account_payment_group/models/account_move.py +++ b/account_payment_group/models/account_move.py @@ -51,12 +51,13 @@ def _compute_payment_groups(self): for rec in self: rec.payment_group_ids = rec._get_reconciled_payments().mapped('payment_group_id') - @api.depends('line_ids.account_id.internal_type', 'line_ids.reconciled') + + @api.depends('line_ids.account_id.account_type', 'line_ids.reconciled') def _compute_open_move_lines(self): for rec in self: rec.open_move_line_ids = rec.line_ids.filtered( - lambda r: not r.reconciled and r.account_id.internal_type in ( - 'payable', 'receivable')) + lambda r: not r.reconciled and r.account_id.account_type in ['asset_receivable','liability_payable']) + def action_register_payment_group(self): to_pay_move_lines = self.open_move_line_ids @@ -73,7 +74,7 @@ def action_register_payment_group(self): 'target': 'current', 'type': 'ir.actions.act_window', 'context': { - 'default_partner_type': 'customer' if to_pay_move_lines[0].account_id.internal_type == 'receivable' else 'supplier', + 'default_partner_type': 'customer' if to_pay_move_lines[0].account_id.account_type == 'asset_receivable' else 'supplier', 'default_partner_id': to_pay_partners.id, 'default_to_pay_move_line_ids': to_pay_move_lines.ids, # We set this because if became from other view and in the context has 'create=False' diff --git a/account_payment_group/models/account_move_line.py b/account_payment_group/models/account_move_line.py index 33cec8aee..34320e57e 100644 --- a/account_payment_group/models/account_move_line.py +++ b/account_payment_group/models/account_move_line.py @@ -31,8 +31,7 @@ def _compute_payment_group_matched_amount(self): self.payment_group_matched_amount = 0.0 return False payments = self.env['account.payment.group'].browse(payment_group_id).payment_ids - payment_lines = payments.mapped('line_ids').filtered(lambda x: x.account_internal_type in ['receivable', 'payable']) - + payment_lines = payments.mapped('line_ids').filtered(lambda x: x.account_type in ['asset_receivable', 'liability_payable']) for rec in self: debit_move_amount = sum(payment_lines.mapped('matched_debit_ids').filtered(lambda x: x.debit_move_id == rec).mapped('amount')) credit_move_amount = sum(payment_lines.mapped('matched_credit_ids').filtered(lambda x: x.credit_move_id == rec).mapped('amount')) diff --git a/account_payment_group/models/account_payment.py b/account_payment_group/models/account_payment.py index 87c636f03..a68f2ff66 100644 --- a/account_payment_group/models/account_payment.py +++ b/account_payment_group/models/account_payment.py @@ -72,6 +72,8 @@ def _compute_available_journal_ids(self): filtered_domain.append(('company_id', '=', pay.payment_group_id.company_id.id)) pay.available_journal_ids = journals.filtered_domain(filtered_domain) + + @api.depends('payment_method_id') def _compute_payment_method_description(self): for rec in self: @@ -125,6 +127,7 @@ def _compute_exchange_rate(self): # rouding odoo believes amount has changed) @api.onchange('amount_company_currency') def _inverse_amount_company_currency(self): + for rec in self: if rec.other_currency and rec.amount_company_currency != \ rec.currency_id._convert( diff --git a/account_payment_group/models/account_payment_group.py b/account_payment_group/models/account_payment_group.py index eea970c62..5c819e5dc 100644 --- a/account_payment_group/models/account_payment_group.py +++ b/account_payment_group/models/account_payment_group.py @@ -319,7 +319,7 @@ def _compute_matched_move_line_ids(self): al revz (debit_move_id vs credit_move_id) """ for rec in self: - payment_lines = rec.payment_ids.mapped('line_ids').filtered(lambda x: x.account_internal_type in ['receivable', 'payable']) + payment_lines = rec.payment_ids.mapped('line_ids').filtered(lambda x: x.account_type in ['asset_receivable', 'liability_payable']) rec.matched_move_line_ids = (payment_lines.mapped('matched_debit_ids.debit_move_id') | payment_lines.mapped('matched_credit_ids.credit_move_id')) - payment_lines @api.depends('payment_ids.line_ids') @@ -368,7 +368,7 @@ def _get_to_pay_move_lines_domain(self): ('partner_id.commercial_partner_id', '=', self.commercial_partner_id.id), ('company_id', '=', self.company_id.id), ('move_id.state', '=', 'posted'), ('account_id.reconcile', '=', True), ('reconciled', '=', False), ('full_reconcile_id', '=', False), - ('account_id.internal_type', '=', 'receivable' if self.partner_type == 'customer' else 'payable'), + ('account_id.account_type', '=', 'asset_receivable' if self.partner_type == 'customer' else 'liability_payable'), ] def add_all(self): @@ -482,7 +482,7 @@ def post(self): if not created_automatically: counterpart_aml = rec.payment_ids.mapped('line_ids').filtered( - lambda r: not r.reconciled and r.account_id.internal_type in ('payable', 'receivable')) + lambda r: not r.reconciled and r.account_id.account_type in ('liability_payable', 'asset_receivable')) if counterpart_aml and rec.to_pay_move_line_ids: (counterpart_aml + (rec.to_pay_move_line_ids)).reconcile() diff --git a/account_payment_group/views/account_payment_group_view.xml b/account_payment_group/views/account_payment_group_view.xml index 51b7eb42c..618aed870 100644 --- a/account_payment_group/views/account_payment_group_view.xml +++ b/account_payment_group/views/account_payment_group_view.xml @@ -91,7 +91,7 @@ - + + domain="[('partner_id.commercial_partner_id', '=', commercial_partner_id),('account_id.reconcile', '=', True),('reconciled', '=', False), ('full_reconcile_id', '=', False), ('company_id', '=', company_id), ('move_id.state', '=', 'posted'), ('account_id.account_type', '=', 'asset_receivable' if partner_type == 'customer' else 'liability_payable')]"/> @@ -148,7 +148,7 @@ + domain="[('partner_id.commercial_partner_id', '=', commercial_partner_id),('account_id.reconcile', '=', True),('reconciled', '=', False), ('full_reconcile_id', '=', False), ('company_id', '=', company_id), ('move_id.state', '=', 'posted'), ('account_id.account_type', '=', 'asset_receivable' if partner_type == 'customer' else 'liability_payable')]" help="Payment will be automatically matched with the oldest lines of this list (by maturity date). You can remove any line you dont want to be matched."/> diff --git a/account_payment_group_financial_surcharge/__manifest__.py b/account_payment_group_financial_surcharge/__manifest__.py index 4ef9e1222..fd008c0e6 100644 --- a/account_payment_group_financial_surcharge/__manifest__.py +++ b/account_payment_group_financial_surcharge/__manifest__.py @@ -20,6 +20,6 @@ ], 'images': [ ], - 'installable': True, + 'installable': False, 'auto_install': False, } diff --git a/account_withholding/__manifest__.py b/account_withholding/__manifest__.py index 1f6244c51..d9033d946 100644 --- a/account_withholding/__manifest__.py +++ b/account_withholding/__manifest__.py @@ -31,7 +31,7 @@ 'depends': [ 'account', ], - 'installable': True, + 'installable': False, 'name': 'Withholdings on Payments', 'test': [], 'version': "15.0.1.0.0", diff --git a/account_withholding_automatic/__manifest__.py b/account_withholding_automatic/__manifest__.py index d91f1dadb..88c9a1386 100644 --- a/account_withholding_automatic/__manifest__.py +++ b/account_withholding_automatic/__manifest__.py @@ -36,7 +36,7 @@ 'account_payment_group', 'account_withholding', ], - 'installable': True, + 'installable': False, 'name': 'Automatic Withholdings on Payments', 'test': [], 'version': "15.0.1.0.0", diff --git a/card_installment/__manifest__.py b/card_installment/__manifest__.py index 7a1ab9bec..eb134759e 100644 --- a/card_installment/__manifest__.py +++ b/card_installment/__manifest__.py @@ -11,7 +11,7 @@ 'license': 'LGPL-3', 'images': [ ], - 'installable': True, + 'installable': False, 'data': [ 'security/ir.model.access.csv', 'security/ir_rule.xml',