From f59f9e7bf827cc79b54ccf1222d3be3ad29e99c4 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 1 Jul 2015 13:45:01 +0200 Subject: [PATCH] [FIX] report_intrastat: multi-company rules. The intrastat report did not take care about the multi-company concept. In an multi-company environment, lines issued from invoices in different company (without a parent-children relationship) were all displayed in this report. opw-643685 --- addons/report_intrastat/__openerp__.py | 1 + addons/report_intrastat/report_intrastat.py | 6 ++++-- .../security/report_intrastat_security.xml | 11 +++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 addons/report_intrastat/security/report_intrastat_security.xml diff --git a/addons/report_intrastat/__openerp__.py b/addons/report_intrastat/__openerp__.py index ad49d30f210..b9f431d2685 100644 --- a/addons/report_intrastat/__openerp__.py +++ b/addons/report_intrastat/__openerp__.py @@ -16,6 +16,7 @@ European Union.""", 'depends': ['base', 'product', 'stock', 'sale', 'purchase'], 'data': [ 'security/ir.model.access.csv', + 'security/report_intrastat_security.xml', 'report_intrastat_view.xml', 'intrastat_report.xml', 'report_intrastat_data.xml', diff --git a/addons/report_intrastat/report_intrastat.py b/addons/report_intrastat/report_intrastat.py index 0536f1f243e..20b79f0c978 100644 --- a/addons/report_intrastat/report_intrastat.py +++ b/addons/report_intrastat/report_intrastat.py @@ -53,6 +53,7 @@ class report_intrastat(osv.osv): 'value': fields.float('Value', readonly=True, digits=0), 'type': fields.selection([('import', 'Import'), ('export', 'Export')], 'Type'), 'currency_id': fields.many2one('res.currency', "Currency", readonly=True), + 'company_id': fields.many2one('res.company', "Company", readonly=True), } def init(self, cr): drop_view_if_exists(cr, 'report_intrastat') @@ -82,7 +83,8 @@ class report_intrastat(osv.osv): case when inv.type in ('out_invoice','in_refund') then 'export' else 'import' - end as type + end as type, + inv.company_id as company_id from account_invoice inv left join account_invoice_line inv_line on inv_line.invoice_id=inv.id @@ -99,5 +101,5 @@ class report_intrastat(osv.osv): inv.state in ('open','paid') and inv_line.product_id is not null and inv_country.intrastat=true - group by to_char(inv.create_date, 'YYYY'), to_char(inv.create_date, 'MM'),intrastat.id,inv.type,pt.intrastat_id, inv_country.code,inv.number, inv.currency_id + group by to_char(inv.create_date, 'YYYY'), to_char(inv.create_date, 'MM'),intrastat.id,inv.type,pt.intrastat_id, inv_country.code,inv.number, inv.currency_id, inv.company_id )""") diff --git a/addons/report_intrastat/security/report_intrastat_security.xml b/addons/report_intrastat/security/report_intrastat_security.xml new file mode 100644 index 00000000000..0415b53642b --- /dev/null +++ b/addons/report_intrastat/security/report_intrastat_security.xml @@ -0,0 +1,11 @@ + + + + + Intrastat multi-company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + +