Add module intrastat_product_type

This commit is contained in:
Alexis de Lattre
2016-04-15 22:01:45 +02:00
parent 80763de94b
commit 0498f6e24e
5 changed files with 124 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import intrastat_product_type
from .post_install import set_intrastat_type_on_products

View File

@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product Type module for Odoo
# Copyright (C) 2016 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Intrastat Product Type',
'version': '0.1',
'category': 'Accounting & Finance',
'license': 'AGPL-3',
'summary': 'Adds a special field Intrastat Type on Products',
'description': """
Intrastat Product Type
======================
This module is designed for a very special usage scenario. Some companies want to handle the delivery of services the same way as they handle the delivery of goods ; they want to show the services in the delivery note, etc. So, those companies configure the services with Type = *Consumable*. This works well to have the services on the outgoing pickings, but it is a problem for the intrastat declarations.
This module adds a field *Intrastat Type* on the Product Form with 2 possible options: *Product* or *Service*. The intrastat declaration will use this field instead of the native *Type* field.
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['intrastat_product', 'l10n_fr_intrastat_service'],
'data': ['product_view.xml'],
'post_init_hook': 'set_intrastat_type_on_products',
'installable': True,
}

View File

@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (http://www.akretion.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# @author Alexis de Lattre <alexis.delattre@akretion.com>
from openerp import models, fields
class ProductTemplate(models.Model):
_inherit = 'product.template'
intrastat_type = fields.Selection([
('product', 'Product'),
('service', 'Service'),
], string='Intrastat Type', default='product', required=True,
help="Type of product used for the intrastat declarations. "
"For example, you can configure a product with "
"'Product Type' = 'Consumable' and 'Intrastat Type' = 'Service'.")
class L10nFrIntrastatServiceDeclaration(models.Model):
_inherit = "l10n.fr.intrastat.service.declaration"
def _is_service(self, invoice_line):
if invoice_line.product_id.intrastat_type == 'service':
return True
else:
return False
class IntrastatProductDeclaration(models.Model):
_inherit = 'intrastat.product.declaration'
def _is_product(self, invoice_line):
if (
invoice_line.product_id and
invoice_line.product_id.intrastat_type == 'product'):
return True
else:
return False

View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
def set_intrastat_type_on_products(cr, pool):
cr.execute(
"UPDATE product_template SET intrastat_type='service' "
"WHERE type='service'")
return

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">intrastat_product_type.product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml">
<field name="type" position="after">
<field name="intrastat_type"/>
</field>
</field>
</record>
</data>
</openerp>