From 8e8c70b30a90454920cf153ca05b38826d9f0437 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Sun, 28 Feb 2021 14:58:46 +0100 Subject: [PATCH] l10n_be_coa_multilang - fix vat decl (POS) --- l10n_be_coa_multilang/__manifest__.py | 4 +- .../models/account_chart_template.py | 4 +- .../wizards/l10n_be_vat_declaration.py | 42 +++++++++++++++---- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/l10n_be_coa_multilang/__manifest__.py b/l10n_be_coa_multilang/__manifest__.py index 29bc6434..376a7349 100644 --- a/l10n_be_coa_multilang/__manifest__.py +++ b/l10n_be_coa_multilang/__manifest__.py @@ -1,9 +1,9 @@ -# Copyright 2009-2020 Noviat +# Copyright 2009-2021 Noviat # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Belgium - Multilingual Chart of Accounts (en/nl/fr)', - 'version': '11.0.1.2.4', + 'version': '11.0.1.2.5', 'license': 'AGPL-3', 'author': "Noviat", 'website': 'http://www.noviat.com', diff --git a/l10n_be_coa_multilang/models/account_chart_template.py b/l10n_be_coa_multilang/models/account_chart_template.py index 8a152290..6b644403 100644 --- a/l10n_be_coa_multilang/models/account_chart_template.py +++ b/l10n_be_coa_multilang/models/account_chart_template.py @@ -1,7 +1,7 @@ -# Copyright 2009-2017 Noviat +# Copyright 2009-2020 Noviat # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import fields, models +from odoo import fields, models class account_chart_template(models.Model): diff --git a/l10n_be_coa_multilang/wizards/l10n_be_vat_declaration.py b/l10n_be_coa_multilang/wizards/l10n_be_vat_declaration.py index 8cf35952..af42f44a 100644 --- a/l10n_be_coa_multilang/wizards/l10n_be_vat_declaration.py +++ b/l10n_be_coa_multilang/wizards/l10n_be_vat_declaration.py @@ -1,4 +1,4 @@ -# Copyright 2009-2020 Noviat +# Copyright 2009-2021 Noviat # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import base64 @@ -300,10 +300,24 @@ def _get_case_domain(self, case_code, get_domain=True): self._tax_debt_in_refund_cases()): inv_type = 'in_refund' if inv_type: - if inv_type in ['out_refund']: - # filter out refund cases when the Journal Item - # has no originating invoice, e.g. - # POS Orders, misc. operations + # filter out invoice or refund cases based on + # transaction sign when the Journal Item + # has no originating invoice, e.g. + # POS Orders, misc. operations + if inv_type == 'out_invoice': + inv_type_args = [ + '|', + ('invoice_id.type', '=', inv_type), + '&', + ('invoice_id', '=', False), + ('credit', '>', 0) + ] + inv_check = ( + "({aml}.invoice_id.type == '%s'" + " or " + "(not {aml}.invoice_id and ({aml}.credit > 0)))" + ) % inv_type + elif inv_type == 'out_refund': inv_type_args = [ '|', ('invoice_id.type', '=', inv_type), @@ -316,10 +330,20 @@ def _get_case_domain(self, case_code, get_domain=True): " or " "(not {aml}.invoice_id and ({aml}.debit > 0)))" ) % inv_type - elif inv_type in ['in_refund']: - # filter out refund cases when the Journal Item - # has no originating invoice, e.g. - # bank costs, expense notes, misc. operations + elif inv_type == 'in_invoice': + inv_type_args = [ + '|', + ('invoice_id.type', '=', inv_type), + '&', + ('invoice_id', '=', False), + ('debit', '>', 0), + ] + inv_check = ( + "({aml}.invoice_id.type == '%s'" + " or " + "(not {aml}.invoice_id and ({aml}.debit > 0)))" + ) % inv_type + elif inv_type == 'in_refund': inv_type_args = [ '|', ('invoice_id.type', '=', inv_type),