From 7f600c164610adb352e3b9d30b60157fad7189e8 Mon Sep 17 00:00:00 2001 From: rhe-mastercore Date: Mon, 25 Jul 2022 00:00:45 -0400 Subject: [PATCH 1/6] [FIX]commented function to generate multi-currency payment reconciliation --- .../models/account_partial_reconcile.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/account_ux/models/account_partial_reconcile.py b/account_ux/models/account_partial_reconcile.py index 7fc357569..c1738b4ed 100644 --- a/account_ux/models/account_partial_reconcile.py +++ b/account_ux/models/account_partial_reconcile.py @@ -4,15 +4,16 @@ class AccountPartialReconcile(models.Model): _inherit = "account.partial.reconcile" - @api.model - def create(self, vals): - """ ademas de mandar en el contexto en el metodo reconcile, hacemos - que el partial reconcile que crea el metodo auto_reconcile_lines - no tenga moneda en la misma situación (podriamos ). - Va de la mano de la modificacion de "def reconcile" en aml - """ - if vals.get('currency_id'): - account = self.env['account.move.line'].browse(vals.get('debit_move_id')).account_id - if account.company_id.country_id == self.env.ref('base.ar') and not account.currency_id: - vals.update({'currency_id': False, 'amount_currency': 0.0}) - return super().create(vals) + #TODO revisar la compatibilidad de esta funcion con el diferencial de cambio + # @API.MODEL + # DEF CREATE(SELF, VALS): + # """ ADEMAS DE MANDAR EN EL CONTEXTO EN EL METODO RECONCILE, HACEMOS + # QUE EL PARTIAL RECONCILE QUE CREA EL METODO AUTO_RECONCILE_LINES + # NO TENGA MONEDA EN LA MISMA SITUACIÓN (PODRIAMOS ). + # VA DE LA MANO DE LA MODIFICACION DE "DEF RECONCILE" EN AML + # """ + # IF VALS.GET('CURRENCY_ID'): + # ACCOUNT = SELF.ENV['ACCOUNT.MOVE.LINE'].BROWSE(VALS.GET('DEBIT_MOVE_ID')).ACCOUNT_ID + # IF ACCOUNT.COMPANY_ID.COUNTRY_ID == SELF.ENV.REF('BASE.AR') AND NOT ACCOUNT.CURRENCY_ID: + # VALS.UPDATE({'CURRENCY_ID': FALSE, 'AMOUNT_CURRENCY': 0.0}) + # RETURN SUPER().CREATE(VALS) From 0adbc2a950001dae2bc789d59b00c529f4288473 Mon Sep 17 00:00:00 2001 From: rhe-mastercore Date: Mon, 25 Jul 2022 01:02:28 -0400 Subject: [PATCH 2/6] [FIX]commented function to generate multi-currency payment reconciliation --- account_ux/models/account_move_line.py | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/account_ux/models/account_move_line.py b/account_ux/models/account_move_line.py index aa7ff8b89..05d6f0009 100644 --- a/account_ux/models/account_move_line.py +++ b/account_ux/models/account_move_line.py @@ -41,23 +41,23 @@ def action_open_related_document(self): 'res_id': res_id, } - def _reconcile_lines(self, debit_moves, credit_moves, field): - """ Modificamos contexto para que odoo solo concilie el metodo - auto_reconcile_lines teniendo en cuenta la moneda de cia si la cuenta - no tiene moneda. - Va de la mano de la modificación de "create" en - account.partial.reconcile - Para que este cambio funcione bien es ademas importante este parche en odoo - https://github.com/odoo/odoo/pull/63390 - """ - if self and self[0].company_id.country_id == self.env.ref('base.ar') and not self[0].account_id.currency_id: - field = 'amount_residual' - return super()._reconcile_lines(debit_moves, credit_moves, field) - - def reconcile(self, writeoff_acc_id=False, writeoff_journal_id=False): - """ This is needed if you reconcile, for eg, 1 USD to 1 USD but in an ARS account, by default - odoo make a full reconcile and exchange - """ - if self and self[0].company_id.country_id == self.env.ref('base.ar') and not self[0].account_id.currency_id: - self = self.with_context(no_exchange_difference=True) - return super().reconcile(writeoff_acc_id=writeoff_acc_id, writeoff_journal_id=writeoff_journal_id) + # def _reconcile_lines(self, debit_moves, credit_moves, field): + # """ Modificamos contexto para que odoo solo concilie el metodo + # auto_reconcile_lines teniendo en cuenta la moneda de cia si la cuenta + # no tiene moneda. + # Va de la mano de la modificación de "create" en + # account.partial.reconcile + # Para que este cambio funcione bien es ademas importante este parche en odoo + # https://github.com/odoo/odoo/pull/63390 + # """ + # if self and self[0].company_id.country_id == self.env.ref('base.ar') and not self[0].account_id.currency_id: + # field = 'amount_residual' + # return super()._reconcile_lines(debit_moves, credit_moves, field) + + # def reconcile(self, writeoff_acc_id=False, writeoff_journal_id=False): + # """ This is needed if you reconcile, for eg, 1 USD to 1 USD but in an ARS account, by default + # odoo make a full reconcile and exchange + # """ + # if self and self[0].company_id.country_id == self.env.ref('base.ar') and not self[0].account_id.currency_id: + # self = self.with_context(no_exchange_difference=True) + # return super().reconcile(writeoff_acc_id=writeoff_acc_id, writeoff_journal_id=writeoff_journal_id) From af62b39578f0326a4e1f3cce1332926c62a7ab27 Mon Sep 17 00:00:00 2001 From: rhe-mastercore Date: Mon, 25 Jul 2022 10:00:58 -0400 Subject: [PATCH 3/6] [FIX] date in financial amount --- account_financial_amount/models/account_move_line.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/account_financial_amount/models/account_move_line.py b/account_financial_amount/models/account_move_line.py index 786ecbf78..2432c7533 100644 --- a/account_financial_amount/models/account_move_line.py +++ b/account_financial_amount/models/account_move_line.py @@ -22,6 +22,8 @@ class AccountMoveLine(models.Model): @api.depends('debit', 'credit') def _compute_financial_amounts(self): date = fields.Date.today() + if self._context.get('date_account', False): + date = self._context.get('date_account') for line in self: financial_amount = ( line.currency_id and line.currency_id._convert( From f033228cbfb470599566bff60c2fd62b637c9e54 Mon Sep 17 00:00:00 2001 From: rhe-mastercore Date: Mon, 25 Jul 2022 23:40:49 -0400 Subject: [PATCH 4/6] [ADD]included fields for amounts in foreign currency --- account_ux/__manifest__.py | 1 + account_ux/models/__init__.py | 1 + account_ux/models/account_payment_group.py | 64 +++++++++++++++++++ .../views/account_payment_group_views.xml | 25 ++++++++ 4 files changed, 91 insertions(+) create mode 100644 account_ux/models/account_payment_group.py create mode 100644 account_ux/views/account_payment_group_views.xml diff --git a/account_ux/__manifest__.py b/account_ux/__manifest__.py index c7550440f..1e6f27e55 100644 --- a/account_ux/__manifest__.py +++ b/account_ux/__manifest__.py @@ -49,6 +49,7 @@ 'views/account_account_views.xml', 'views/account_type_views.xml', 'views/account_move_views.xml', + 'views/account_payment_group_views.xml', 'data/account_payment_method_data.xml', 'data/mail_data.xml', 'data/ir_parameters_data.xml', diff --git a/account_ux/models/__init__.py b/account_ux/models/__init__.py index 33d07e55f..a8036e14c 100644 --- a/account_ux/models/__init__.py +++ b/account_ux/models/__init__.py @@ -7,6 +7,7 @@ from . import account_account from . import account_journal from . import account_payment +from . import account_payment_group from . import account_bank_statements from . import account_partial_reconcile from . import account_move_line diff --git a/account_ux/models/account_payment_group.py b/account_ux/models/account_payment_group.py new file mode 100644 index 000000000..86622cf98 --- /dev/null +++ b/account_ux/models/account_payment_group.py @@ -0,0 +1,64 @@ +# © 2022 ADHOC SA - MASTERCORE SAS +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, fields +import datetime + + +class AccountPaymentGroup(models.Model): + _inherit = "account.payment.group" + + #This field is to be used by invoice in multicurrency + selected_finacial_debt_currency = fields.Monetary( + string='Selected Financial Debt in foreign currency', + compute='_compute_selected_debt', + ) + debt_multicurrency = fields.Boolean( + string='debt is in foreign currency?', default=False, + ) + selected_debt_currency_id = fields.Many2one("res.currency", + string='Selected Debt in foreign currency', + ) + + @api.depends( + 'to_pay_move_line_ids.amount_residual', + 'to_pay_move_line_ids.amount_residual_currency', + 'to_pay_move_line_ids.currency_id', + 'to_pay_move_line_ids.move_id', + 'payment_date', + 'currency_id', + ) + def _compute_selected_debt(self): + for rec in self: + selected_finacial_debt = 0.0 + selected_debt = 0.0 + selected_debt_untaxed = 0.0 + selected_debt_taxed = 0.0 + selected_finacial_debt_currency = 0.0 + for line in rec.to_pay_move_line_ids._origin: + #this is conditional used to vat retention + for abg in line.move_id.amount_by_group: + if str(abg[0]).find('IVA') > -1: + selected_debt_taxed += abg[1] + selected_finacial_debt += line.financial_amount_residual + # factor for total_untaxed + invoice = line.move_id + if line.currency_id != rec.company_id.currency_id: + selected_finacial_debt_currency += line.amount_residual_currency + rec.debt_multicurrency = True + rec.selected_debt_currency_id = line.move_id.currency_id.id + elif line.currency_id != rec.company_id.currency_id and rec.debt_multicurrency: + selected_finacial_debt_currency += line.amount_residual_currency + rec.debt_multicurrency = True + else: + rec.debt_multicurrency = False + #selected_debt += line.move_id.amount_residual + selected_debt += line.amount_residual + factor = invoice and invoice._get_tax_factor() or 1.0 + selected_debt_untaxed += line.amount_residual * factor + sign = rec.partner_type == 'supplier' and -1.0 or 1.0 + rec.selected_finacial_debt = selected_finacial_debt * sign + rec.selected_debt = selected_debt * sign + rec.selected_finacial_debt_currency = selected_finacial_debt_currency * sign + rec.selected_debt_untaxed = selected_debt_untaxed * sign + rec.selected_debt_taxed = selected_debt_taxed diff --git a/account_ux/views/account_payment_group_views.xml b/account_ux/views/account_payment_group_views.xml new file mode 100644 index 000000000..b171938b2 --- /dev/null +++ b/account_ux/views/account_payment_group_views.xml @@ -0,0 +1,25 @@ + + + + + account.payment.group.inherit.financial.form + account.payment.group + + + + + + + + + + + + + \ No newline at end of file From e457e304a7dc7de1e04e2251cb9753a1465b465a Mon Sep 17 00:00:00 2001 From: rhe-mastercore Date: Sun, 7 Aug 2022 22:42:18 -0400 Subject: [PATCH 5/6] [FIX]depends error --- account_ux/models/account_payment_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_ux/models/account_payment_group.py b/account_ux/models/account_payment_group.py index 86622cf98..c908cdf18 100644 --- a/account_ux/models/account_payment_group.py +++ b/account_ux/models/account_payment_group.py @@ -1,7 +1,7 @@ # © 2022 ADHOC SA - MASTERCORE SAS # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields +from odoo import models, fields, api import datetime From 198c269899fed0d97c293cfd272b32f0ed819048 Mon Sep 17 00:00:00 2001 From: rhe-mastercore Date: Sun, 7 Aug 2022 22:59:50 -0400 Subject: [PATCH 6/6] [REV]fields for amounts in foreing currency --- account_ux/__manifest__.py | 1 - account_ux/models/__init__.py | 1 - account_ux/models/account_payment_group.py | 64 ------------------- .../views/account_payment_group_views.xml | 25 -------- 4 files changed, 91 deletions(-) delete mode 100644 account_ux/models/account_payment_group.py delete mode 100644 account_ux/views/account_payment_group_views.xml diff --git a/account_ux/__manifest__.py b/account_ux/__manifest__.py index 1e6f27e55..c7550440f 100644 --- a/account_ux/__manifest__.py +++ b/account_ux/__manifest__.py @@ -49,7 +49,6 @@ 'views/account_account_views.xml', 'views/account_type_views.xml', 'views/account_move_views.xml', - 'views/account_payment_group_views.xml', 'data/account_payment_method_data.xml', 'data/mail_data.xml', 'data/ir_parameters_data.xml', diff --git a/account_ux/models/__init__.py b/account_ux/models/__init__.py index a8036e14c..33d07e55f 100644 --- a/account_ux/models/__init__.py +++ b/account_ux/models/__init__.py @@ -7,7 +7,6 @@ from . import account_account from . import account_journal from . import account_payment -from . import account_payment_group from . import account_bank_statements from . import account_partial_reconcile from . import account_move_line diff --git a/account_ux/models/account_payment_group.py b/account_ux/models/account_payment_group.py deleted file mode 100644 index c908cdf18..000000000 --- a/account_ux/models/account_payment_group.py +++ /dev/null @@ -1,64 +0,0 @@ -# © 2022 ADHOC SA - MASTERCORE SAS -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models, fields, api -import datetime - - -class AccountPaymentGroup(models.Model): - _inherit = "account.payment.group" - - #This field is to be used by invoice in multicurrency - selected_finacial_debt_currency = fields.Monetary( - string='Selected Financial Debt in foreign currency', - compute='_compute_selected_debt', - ) - debt_multicurrency = fields.Boolean( - string='debt is in foreign currency?', default=False, - ) - selected_debt_currency_id = fields.Many2one("res.currency", - string='Selected Debt in foreign currency', - ) - - @api.depends( - 'to_pay_move_line_ids.amount_residual', - 'to_pay_move_line_ids.amount_residual_currency', - 'to_pay_move_line_ids.currency_id', - 'to_pay_move_line_ids.move_id', - 'payment_date', - 'currency_id', - ) - def _compute_selected_debt(self): - for rec in self: - selected_finacial_debt = 0.0 - selected_debt = 0.0 - selected_debt_untaxed = 0.0 - selected_debt_taxed = 0.0 - selected_finacial_debt_currency = 0.0 - for line in rec.to_pay_move_line_ids._origin: - #this is conditional used to vat retention - for abg in line.move_id.amount_by_group: - if str(abg[0]).find('IVA') > -1: - selected_debt_taxed += abg[1] - selected_finacial_debt += line.financial_amount_residual - # factor for total_untaxed - invoice = line.move_id - if line.currency_id != rec.company_id.currency_id: - selected_finacial_debt_currency += line.amount_residual_currency - rec.debt_multicurrency = True - rec.selected_debt_currency_id = line.move_id.currency_id.id - elif line.currency_id != rec.company_id.currency_id and rec.debt_multicurrency: - selected_finacial_debt_currency += line.amount_residual_currency - rec.debt_multicurrency = True - else: - rec.debt_multicurrency = False - #selected_debt += line.move_id.amount_residual - selected_debt += line.amount_residual - factor = invoice and invoice._get_tax_factor() or 1.0 - selected_debt_untaxed += line.amount_residual * factor - sign = rec.partner_type == 'supplier' and -1.0 or 1.0 - rec.selected_finacial_debt = selected_finacial_debt * sign - rec.selected_debt = selected_debt * sign - rec.selected_finacial_debt_currency = selected_finacial_debt_currency * sign - rec.selected_debt_untaxed = selected_debt_untaxed * sign - rec.selected_debt_taxed = selected_debt_taxed diff --git a/account_ux/views/account_payment_group_views.xml b/account_ux/views/account_payment_group_views.xml deleted file mode 100644 index b171938b2..000000000 --- a/account_ux/views/account_payment_group_views.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - account.payment.group.inherit.financial.form - account.payment.group - - - - - - - - - - - - - \ No newline at end of file