From a6d13535916bb2f02daad64b87ed96a665d78c1f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 12 Dec 2018 11:44:48 +0000 Subject: [PATCH] [FIX] l10n_be_intrastat, report_intrastat: date The reference date for Intrastat should be the accounting date, not the invoice date. opw-1890240 closes odoo/odoo#29466 --- addons/l10n_be_intrastat/wizard/xml_decl.py | 4 ++-- addons/report_intrastat/report/report_intrastat_report.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/l10n_be_intrastat/wizard/xml_decl.py b/addons/l10n_be_intrastat/wizard/xml_decl.py index f5b9bdcf6b6..b7c6e04f713 100644 --- a/addons/l10n_be_intrastat/wizard/xml_decl.py +++ b/addons/l10n_be_intrastat/wizard/xml_decl.py @@ -155,8 +155,8 @@ class XmlDeclaration(models.TransientModel): OR (res_country.code is NULL AND countrypartner.code IS NOT NULL AND not countrypartner.code=%s)) AND inv.type IN (%s, %s) - AND to_char(inv.date_invoice, 'YYYY')=%s - AND to_char(inv.date_invoice, 'MM')=%s + AND to_char(COALESCE(inv.date, inv.date_invoice), 'YYYY')=%s + AND to_char(COALESCE(inv.date, inv.date_invoice), 'MM')=%s """ self.env.cr.execute(query, (company.id, company.partner_id.country_id.code, diff --git a/addons/report_intrastat/report/report_intrastat_report.py b/addons/report_intrastat/report/report_intrastat_report.py index 1ca5dfb4bec..518534d0a92 100644 --- a/addons/report_intrastat/report/report_intrastat_report.py +++ b/addons/report_intrastat/report/report_intrastat_report.py @@ -30,8 +30,8 @@ class ReportIntrastat(models.Model): self.env.cr.execute(""" create or replace view report_intrastat as ( select - to_char(inv.date_invoice, 'YYYY') as name, - to_char(inv.date_invoice, 'MM') as month, + to_char(coalesce(inv.date, inv.date_invoice), 'YYYY') as name, + to_char(coalesce(inv.date, inv.date_invoice), 'MM') as month, min(inv_line.id) as id, intrastat.id as intrastat_id, upper(inv_country.code) as code, @@ -71,5 +71,5 @@ class ReportIntrastat(models.Model): inv.state in ('open','paid') and inv_line.product_id is not null and inv_country.intrastat=true - group by to_char(inv.date_invoice, 'YYYY'), to_char(inv.date_invoice, 'MM'),intrastat.id,inv.type,pt.intrastat_id, inv_country.code,inv.number, inv.currency_id, inv.company_id + group by to_char(coalesce(inv.date, inv.date_invoice), 'YYYY'), to_char(coalesce(inv.date, inv.date_invoice), 'MM'),intrastat.id,inv.type,pt.intrastat_id, inv_country.code,inv.number, inv.currency_id, inv.company_id )""")