From 81aa1d46b4d378e069effc99bd19fb21236d02ef Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 27 Mar 2011 22:59:53 +0200 Subject: [PATCH] Initial commit of the entirely new code for report_intrastat for France. --- l10n_fr_intrastat_base/__init__.py | 29 +++ l10n_fr_intrastat_base/__terp__.py | 52 ++++++ l10n_fr_intrastat_base/account_invoice.py | 47 +++++ .../account_invoice_view.xml | 173 ++++++++++++++++++ .../account_invoice_workflow.xml | 24 +++ l10n_fr_intrastat_base/company.py | 32 ++++ l10n_fr_intrastat_base/company_view.xml | 20 ++ l10n_fr_intrastat_base/country.py | 33 ++++ l10n_fr_intrastat_base/country_data.xml | 84 +++++++++ l10n_fr_intrastat_base/country_view.xml | 30 +++ l10n_fr_intrastat_base/intrastat_demo.xml | 24 +++ l10n_fr_intrastat_base/partner_address.py | 35 ++++ l10n_fr_intrastat_base/product.py | 35 ++++ l10n_fr_intrastat_base/product_view.xml | 36 ++++ l10n_fr_intrastat_base/report_intrastat.py | 65 +++++++ .../report_intrastat_view.xml | 92 ++++++++++ .../security/ir.model.access.csv | 2 + 17 files changed, 813 insertions(+) create mode 100644 l10n_fr_intrastat_base/__init__.py create mode 100644 l10n_fr_intrastat_base/__terp__.py create mode 100644 l10n_fr_intrastat_base/account_invoice.py create mode 100644 l10n_fr_intrastat_base/account_invoice_view.xml create mode 100644 l10n_fr_intrastat_base/account_invoice_workflow.xml create mode 100644 l10n_fr_intrastat_base/company.py create mode 100644 l10n_fr_intrastat_base/company_view.xml create mode 100644 l10n_fr_intrastat_base/country.py create mode 100644 l10n_fr_intrastat_base/country_data.xml create mode 100644 l10n_fr_intrastat_base/country_view.xml create mode 100644 l10n_fr_intrastat_base/intrastat_demo.xml create mode 100644 l10n_fr_intrastat_base/partner_address.py create mode 100644 l10n_fr_intrastat_base/product.py create mode 100644 l10n_fr_intrastat_base/product_view.xml create mode 100644 l10n_fr_intrastat_base/report_intrastat.py create mode 100644 l10n_fr_intrastat_base/report_intrastat_view.xml create mode 100644 l10n_fr_intrastat_base/security/ir.model.access.csv diff --git a/l10n_fr_intrastat_base/__init__.py b/l10n_fr_intrastat_base/__init__.py new file mode 100644 index 00000000..f85979af --- /dev/null +++ b/l10n_fr_intrastat_base/__init__.py @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (http://tiny.be). All Rights Reserved +# Copyright (C) 2010-2011 Akretion (http://www.akretion.com). All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import report_intrastat +import country +import product +import account_invoice +import partner_address +import company + diff --git a/l10n_fr_intrastat_base/__terp__.py b/l10n_fr_intrastat_base/__terp__.py new file mode 100644 index 00000000..60ff12fb --- /dev/null +++ b/l10n_fr_intrastat_base/__terp__.py @@ -0,0 +1,52 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (http://tiny.be). All Rights Reserved +# Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'Base module for Intrastat reporting (DEB + DES) for France', + 'version': '1.1', + 'category': 'Localisation/Report Intrastat', + 'license': 'AGPL-3', + 'description': """This module contains the common functions for 2 other modules : +- l10n_fr_intrastat_service : the module for the "Déclaration Européenne des Services" (DES) +- l10n_fr_intrastat_product : the module for the "Déclaration d'Echange de Biens" (DEB) +This module is not usefull if it's not used together with one of the other 2 modules. + +WARNING : this module conflicts with the module "report_intrastat" from the addons. If you have already installed the module "report_intrastat", you should uninstall it first before installing this module. + """, + 'author': 'Akretion and OpenERP S.A.', + 'website': 'http://www.akretion.com', + 'depends': ['account'], + 'init_xml': ['country_data.xml'], + 'update_xml': [ + 'security/ir.model.access.csv', + 'product_view.xml', + 'country_view.xml', + 'report_intrastat_view.xml', + 'company_view.xml', + 'account_invoice_view.xml', + 'account_invoice_workflow.xml', + ], + 'demo_xml': ['intrastat_demo.xml'], + 'installable': True, + 'active': False, +} diff --git a/l10n_fr_intrastat_base/account_invoice.py b/l10n_fr_intrastat_base/account_invoice.py new file mode 100644 index 00000000..35f2e0c6 --- /dev/null +++ b/l10n_fr_intrastat_base/account_invoice.py @@ -0,0 +1,47 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2009-2011 Akretion (http://www.akretion.com/) All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields +from tools.translate import _ + +class account_invoice(osv.osv): + _inherit = "account.invoice" + _columns = { + 'intrastat_type_id': fields.many2one('report.intrastat.type', 'Intrastat Type',select=True,readonly=True, states={'draft':[('readonly',False)]}), + 'state': fields.selection([ + ('draft','Draft'), + ('legal_intrastat','Legal Intrastat'), + ('proforma','Pro-forma'), + ('proforma2','Pro-forma'), + ('open','Open'), + ('paid','Done'), + ('cancel','Cancelled') + ],'State', select=True, readonly=True), + 'intrastat_only': fields.boolean('Intrastat Only'), + } + + def intrastat_type_id_change(self, cr, uid, ids, intrastat_type_id): + if intrastat_type_id: + intrastat_only = self.pool.get('report.intrastat.type').browse(cr, uid, intrastat_type_id).intrastat_only + return {'value': {'intrastat_only': intrastat_only}} + +account_invoice() + diff --git a/l10n_fr_intrastat_base/account_invoice_view.xml b/l10n_fr_intrastat_base/account_invoice_view.xml new file mode 100644 index 00000000..79b2b78c --- /dev/null +++ b/l10n_fr_intrastat_base/account_invoice_view.xml @@ -0,0 +1,173 @@ + + + + + report.intrastat.invoice.supplier + account.invoice + + + + + + + + + + + report.intrastat.invoice + account.invoice + + + + + + + + + + + report.intrastat.invoice.supplier.buttons + account.invoice + + + + + + + + report.intrastat.invoice.supplier.buttons + account.invoice + + + + + + + + report.intrastat.invoice.buttons + account.invoice + + + + + + + + report.intrastat.invoice.buttons + account.invoice + + + + + + + + Customer Intrastat Invoices + account.invoice + form + tree,form,calendar,graph + [('state','in',['legal_intrastat']),('type','=','out_invoice')] + {'type':'out_invoice'} + + + + tree + + + + + form + + + + + + + + + Supplier Intrastat Invoices + account.invoice + form + tree,form,calendar,graph + [('state','in',['legal_intrastat']),('type','=','in_invoice')] + {'type':'out_invoice'} + + + + tree + + + + + form + + + + + + + + + Customer Intrastat Refunds + account.invoice + form + tree,form,calendar,graph + [('state','in',['legal_intrastat']),('type','=','out_refund')] + {'type':'out_refund'} + + + + tree + + + + + form + + + + + + + + Supplier Intrastat Refunds + account.invoice + form + tree,form,calendar,graph + [('state','in',['legal_intrastat']),('type','=','in_refund')] + {'type':'in_refund'} + + + + tree + + + + + form + + + + + + + + \ No newline at end of file diff --git a/l10n_fr_intrastat_base/account_invoice_workflow.xml b/l10n_fr_intrastat_base/account_invoice_workflow.xml new file mode 100644 index 00000000..8814135a --- /dev/null +++ b/l10n_fr_intrastat_base/account_invoice_workflow.xml @@ -0,0 +1,24 @@ + + + + + + + legal_intrastat + write({'state':'legal_intrastat'}) + function + + + + + + invoice_legal_intrastat + + + + + + invoice_cancel + + + diff --git a/l10n_fr_intrastat_base/company.py b/l10n_fr_intrastat_base/company.py new file mode 100644 index 00000000..abe72567 --- /dev/null +++ b/l10n_fr_intrastat_base/company.py @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2009-2011 Akretion (http://www.akretion.com/) All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields + +class res_company(osv.osv): + _name = "res.company" + _inherit = "res.company" + _columns = { + 'intrastat_type_ids': fields.one2many('report.intrastat.type', 'company_id', 'Intrastat Type'), + } + +res_company() + diff --git a/l10n_fr_intrastat_base/company_view.xml b/l10n_fr_intrastat_base/company_view.xml new file mode 100644 index 00000000..47ff9446 --- /dev/null +++ b/l10n_fr_intrastat_base/company_view.xml @@ -0,0 +1,20 @@ + + + + + + fr.intrastat.base.company.form + res.company + + + + + + + + + + + + + diff --git a/l10n_fr_intrastat_base/country.py b/l10n_fr_intrastat_base/country.py new file mode 100644 index 00000000..fbd284c6 --- /dev/null +++ b/l10n_fr_intrastat_base/country.py @@ -0,0 +1,33 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (http://tiny.be). All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields + +class res_country(osv.osv): + _inherit = 'res.country' + _columns = { + 'intrastat': fields.boolean('Intrastat member'), + } + _defaults = { + 'intrastat': lambda *a: False, + } + +res_country() diff --git a/l10n_fr_intrastat_base/country_data.xml b/l10n_fr_intrastat_base/country_data.xml new file mode 100644 index 00000000..228c0b41 --- /dev/null +++ b/l10n_fr_intrastat_base/country_data.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/l10n_fr_intrastat_base/country_view.xml b/l10n_fr_intrastat_base/country_view.xml new file mode 100644 index 00000000..a851262c --- /dev/null +++ b/l10n_fr_intrastat_base/country_view.xml @@ -0,0 +1,30 @@ + + + + + + + fr.intrastat.base.country.tree + res.country + + + + + + + + + + fr.intrastat.base.country.form + res.country + + + + + + + + + + + diff --git a/l10n_fr_intrastat_base/intrastat_demo.xml b/l10n_fr_intrastat_base/intrastat_demo.xml new file mode 100644 index 00000000..bc7cc2d7 --- /dev/null +++ b/l10n_fr_intrastat_base/intrastat_demo.xml @@ -0,0 +1,24 @@ + + + + + + Regular export + + export + + + + Regular import + + import + + + + Exclude from intrastat (special) + + other + + + + diff --git a/l10n_fr_intrastat_base/partner_address.py b/l10n_fr_intrastat_base/partner_address.py new file mode 100644 index 00000000..4d4bb34f --- /dev/null +++ b/l10n_fr_intrastat_base/partner_address.py @@ -0,0 +1,35 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-2011 Akretion (http://www.akretion.com/) All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields + +# We want to have the country field of partner_address always set +# because the selection of invoices for intrastat reports is based +# on the country of the invoice partner address ! +class res_partner_address(osv.osv): + _name = 'res.partner.address' + _inherit = 'res.partner.address' + _columns = { + 'country_id': fields.many2one('res.country', 'Country', required=True), + } + +res_partner_address() + diff --git a/l10n_fr_intrastat_base/product.py b/l10n_fr_intrastat_base/product.py new file mode 100644 index 00000000..122a5759 --- /dev/null +++ b/l10n_fr_intrastat_base/product.py @@ -0,0 +1,35 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-2011 Akretion (http://www.akretion.com/) All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields + +class product_template(osv.osv): + _inherit = "product.template" + _columns = { + 'exclude_from_intrastat': fields.boolean('Exclude from Intrastat reports', help="If true, the product or service will not taken into account for Intrastat Product or Service reports. So you should leave this field to false unless you have a good reason. Exemple of good reason : 'Shipping' is a service that should probably be excluded from the Intrastat Service report."), + } + + _default = { + 'exclude_from_intrastat': lambda *a: False, + } + +product_template() + diff --git a/l10n_fr_intrastat_base/product_view.xml b/l10n_fr_intrastat_base/product_view.xml new file mode 100644 index 00000000..070492d3 --- /dev/null +++ b/l10n_fr_intrastat_base/product_view.xml @@ -0,0 +1,36 @@ + + + + + + + fr.intrastat.base.product.normal.form + product.product + + + + + + + + + + + + + + fr.intrastat.base.product.template.form + product.template + + + + + + + + + + + + + diff --git a/l10n_fr_intrastat_base/report_intrastat.py b/l10n_fr_intrastat_base/report_intrastat.py new file mode 100644 index 00000000..1b37aac2 --- /dev/null +++ b/l10n_fr_intrastat_base/report_intrastat.py @@ -0,0 +1,65 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-2011 Akretion (http://www.akretion.com/) All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields +from tools.translate import _ + + +class report_intrastat_type(osv.osv): + _name = "report.intrastat.type" + _description = "Intrastat type" + _columns = { + 'name': fields.char('Name',size=64,help="Name which appear when you select the Intrastat type on the invoice."), + 'active' : fields.boolean('Active', help="The active field allows you to hide the Intrastat type without deleting it."), + 'company_id': fields.many2one('res.company', 'Company'), + 'type': fields.selection([('import', 'Import'),('export', 'Export'), ('other', 'Other')], 'Value', required=True, help="If 'Import' is selected, the corresponding invoices will be selected for the 'Intrastat Import' reports. Same for 'Export'. If 'Other' is selected, the corresponding invoices will NOT be selected in any Intrastat report ; so you should choose it for an invoice only in very particular cases."), + 'intrastat_only': fields.boolean('Intrastat only', help="An invoice which has an Intrastat type which is 'Intrastat only' = true is not a real invoice i.e. once created it won't have an invoice number nor corresponding accounting entries. It follows a different path in the invoice workflow and it's state once created is called 'legal intrastat'. So the purpose of an 'intrastat only' invoice is to add entries to the Intrastat report without impacting anything else. This is used for example for a repair under warranty : nothing is invoiced to the customer, but it creates a movement of goods which should be part of the Intrastat report with a certain value.") + } + + _defaults = { + 'active': lambda *a: 1, + } + + def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): + if not args: + args=[] + + if context is None: + context={} + + ids = [] + + if context.get('type', False) == 'out_invoice': + args = args+['|',('type','=','export'), ('type','=','other')] + + if context.get('type', False) == 'in_invoice': + args = args+['|',('type','=','import'), ('type','=','other')] + + if context.get('type', False) == 'in_refund': + args = args+['|',('type','=','export'), ('type','=','other')] + + if context.get('type', False) == 'out_refund': + args = args+['|',('type','=','import'), ('type','=','other')] + + return super(report_intrastat_type,self).search(cr, user, args, offset, limit, order, context=context, count=count) + +report_intrastat_type() + diff --git a/l10n_fr_intrastat_base/report_intrastat_view.xml b/l10n_fr_intrastat_base/report_intrastat_view.xml new file mode 100644 index 00000000..35f24f28 --- /dev/null +++ b/l10n_fr_intrastat_base/report_intrastat_view.xml @@ -0,0 +1,92 @@ + + + + + + + fr.intrastat.base.report.intrastat.type.tree + report.intrastat.type + tree + + + + + + + + + + + + fr.intrastat.base.report.intrastat.type.form + report.intrastat.type + form + +
+ + + + + + +
+ + + + fr.intrastat.base.report.intrastat.type.config.tree + report.intrastat.type + tree + + + + + + + + + + + + + fr.intrastat.base.report.intrastat.type.config.form + report.intrastat.type + form + +
+ + + + + + + +
+ + + + + Intrastat types + report.intrastat.type + form + + + + + tree + + + + + + + form + + + + + + + + +
+
diff --git a/l10n_fr_intrastat_base/security/ir.model.access.csv b/l10n_fr_intrastat_base/security/ir.model.access.csv new file mode 100644 index 00000000..6125ed62 --- /dev/null +++ b/l10n_fr_intrastat_base/security/ir.model.access.csv @@ -0,0 +1,2 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_report_intrastat_type","report.intrastat.type","model_report_intrastat_type","account.group_account_manager",1,1,1,1