[MIG] intrastat_product_type from v14 to v16
This commit is contained in:
19
intrastat_product_type/README.rst
Normal file
19
intrastat_product_type/README.rst
Normal file
@@ -0,0 +1,19 @@
|
||||
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. 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 *Consumable* products with 2 possible options: *Product* or *Service*. The intrastat declaration will use this field instead of the native *Type* field.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* Akretion
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
@@ -1,4 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import intrastat_product_type
|
||||
from .post_install import set_intrastat_type_on_products
|
||||
from . import models
|
||||
|
||||
@@ -1,27 +1,16 @@
|
||||
# Copyright 2016-2019 Akretion (http://www.akretion.com)
|
||||
# Copyright 2016-2024 Akretion France (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Intrastat Product Type',
|
||||
'version': '12.0.1.0.0',
|
||||
'version': '16.0.1.0.0',
|
||||
'category': 'Accounting',
|
||||
'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',
|
||||
'website': 'https://github.com/akretion/odoo-usability',
|
||||
'depends': ['intrastat_product', 'l10n_fr_intrastat_service'],
|
||||
'data': ['product_view.xml'],
|
||||
'post_init_hook': 'set_intrastat_type_on_products',
|
||||
'installable': False,
|
||||
'data': ['views/product.xml'],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
69
intrastat_product_type/i18n/fr.po
Normal file
69
intrastat_product_type/i18n/fr.po
Normal file
@@ -0,0 +1,69 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * intrastat_product_type
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-12-11 21:40+0000\n"
|
||||
"PO-Revision-Date: 2024-12-11 21:40+0000\n"
|
||||
"Last-Translator: Alexis de Lattre <alexis.delattre@akretion.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: intrastat_product_type
|
||||
#: model:ir.model,name:intrastat_product_type.model_l10n_fr_intrastat_service_declaration
|
||||
msgid "DES"
|
||||
msgstr "DES"
|
||||
|
||||
#. module: intrastat_product_type
|
||||
#: model:ir.model,name:intrastat_product_type.model_intrastat_product_declaration
|
||||
msgid "EMEBI"
|
||||
msgstr "EMEBI"
|
||||
|
||||
#. module: intrastat_product_type
|
||||
#: model:ir.model.fields,field_description:intrastat_product_type.field_product_product__intrastat_type
|
||||
#: model:ir.model.fields,field_description:intrastat_product_type.field_product_template__intrastat_type
|
||||
msgid "Intrastat Type"
|
||||
msgstr "Type intrastat"
|
||||
|
||||
#. module: intrastat_product_type
|
||||
#. odoo-python
|
||||
#: code:addons/intrastat_product_type/models/product.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"On product '%s' which is not a consumable, Intrastat Type must have the same "
|
||||
"value as Type."
|
||||
msgstr ""
|
||||
"Pour le produit '%s' qui n'est pas un consommable, le type intrastat doit avoir "
|
||||
"la même valeur que le type."
|
||||
|
||||
#. module: intrastat_product_type
|
||||
#: model:ir.model,name:intrastat_product_type.model_product_template
|
||||
#: model:ir.model.fields.selection,name:intrastat_product_type.selection__product_template__intrastat_type__product
|
||||
msgid "Product"
|
||||
msgstr "Produit"
|
||||
|
||||
#. module: intrastat_product_type
|
||||
#: model:ir.model.fields.selection,name:intrastat_product_type.selection__product_template__intrastat_type__service
|
||||
msgid "Service"
|
||||
msgstr "Service"
|
||||
|
||||
#. module: intrastat_product_type
|
||||
#: model:ir.model.fields,help:intrastat_product_type.field_product_product__intrastat_type
|
||||
#: model:ir.model.fields,help:intrastat_product_type.field_product_template__intrastat_type
|
||||
msgid ""
|
||||
"Type of product used for the intrastat declarations. It allows you to "
|
||||
"configure a service product as 'Consumable' to have it in pickings but "
|
||||
"configure it with Intrastat Type = 'Service' to consider it as a service for "
|
||||
"intrastat declarations."
|
||||
msgstr ""
|
||||
"Type de produit utilisé pour la DES et l'EMEBI. Cela vous permet de "
|
||||
"configurer un produit de service comme 'consommable' pour l'avoir dans les "
|
||||
"bons de livraison mais de le configurer avec type intrastat = 'Service' pour le "
|
||||
"considérer comme un service pour la DES et l'EMEBI."
|
||||
@@ -1,82 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016-2019 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 odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
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'.")
|
||||
|
||||
@api.multi
|
||||
@api.constrains('type', 'intrastat_type')
|
||||
def check_intrastat_type(self):
|
||||
for pt in self:
|
||||
if pt.intrastat_type == 'product' and pt.type == 'service':
|
||||
raise ValidationError(_(
|
||||
"On the product %s, you cannot set Product Type to "
|
||||
"'Service' and Intrastat Type to 'Product'.") % pt.name)
|
||||
if pt.intrastat_type == 'service' and pt.type == 'product':
|
||||
raise ValidationError(_(
|
||||
"On the product %s, you cannot set Intrastat Type to "
|
||||
"'Service' and Product Type to 'Stockable product' "
|
||||
"(but you can set Product Type to 'Consumable' or "
|
||||
"'Service').") % pt.name)
|
||||
|
||||
@api.onchange('type')
|
||||
def intrastat_type_onchange(self):
|
||||
if self.type in ('product', 'consu'):
|
||||
self.intrastat_type = 'product'
|
||||
elif self.type == 'service':
|
||||
self.intrastat_type = 'service'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('type'):
|
||||
if not vals.get('intrastat_type'):
|
||||
if vals['type'] in ('product', 'consu'):
|
||||
vals['intrastat_type'] = 'product'
|
||||
elif vals['type'] == 'service':
|
||||
vals['intrastat_type'] = 'service'
|
||||
elif (
|
||||
vals.get('intrastat_type') == 'product' and
|
||||
vals['type'] == 'service'):
|
||||
# usefull because intrastat_type = 'product' by default and
|
||||
# wizards in other modules that don't depend on this module
|
||||
# (e.g. sale_rental) may create a product with only
|
||||
# {'type': 'service'} and no 'intrastat_type'
|
||||
vals['intrastat_type'] = 'service'
|
||||
return super(ProductTemplate, self).create(vals)
|
||||
|
||||
|
||||
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
|
||||
3
intrastat_product_type/models/__init__.py
Normal file
3
intrastat_product_type/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from . import product
|
||||
from . import intrastat_product_declaration
|
||||
from . import l10n_fr_intrastat_service_declaration
|
||||
@@ -0,0 +1,17 @@
|
||||
# Copyright 2016-2024 Akretion France (https://www.akretion.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
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
|
||||
@@ -0,0 +1,15 @@
|
||||
# Copyright 2016-2024 Akretion France (https://www.akretion.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
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
|
||||
41
intrastat_product_type/models/product.py
Normal file
41
intrastat_product_type/models/product.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright 2016-2024 Akretion France (https://www.akretion.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
intrastat_type = fields.Selection([
|
||||
('product', 'Product'),
|
||||
('service', 'Service'),
|
||||
],
|
||||
compute='_compute_intrastat_type',
|
||||
readonly=False, store=True, precompute=True, required=True,
|
||||
help="Type of product used for the intrastat declarations. "
|
||||
"It allows you to configure a service product as 'Consumable' "
|
||||
"to have it in pickings but configure it with "
|
||||
"Intrastat Type = 'Service' to consider it as a "
|
||||
"service for intrastat declarations.")
|
||||
|
||||
@api.depends('type')
|
||||
def _compute_intrastat_type(self):
|
||||
for pt in self:
|
||||
if pt.type in ('product', 'consu'):
|
||||
intrastat_type = 'product'
|
||||
else:
|
||||
intrastat_type = 'service'
|
||||
pt.intrastat_type = intrastat_type
|
||||
|
||||
@api.constrains('type', 'intrastat_type')
|
||||
def _check_intrastat_type(self):
|
||||
for pt in self:
|
||||
if pt.type != 'consu' and pt.intrastat_type != pt.type:
|
||||
raise ValidationError(_(
|
||||
"On product '%s' which is not a consumable, "
|
||||
"Intrastat Type must have the same value as Type.")
|
||||
% pt.display_name)
|
||||
@@ -1,10 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016-2019 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
def set_intrastat_type_on_products(cr, registry):
|
||||
cr.execute(
|
||||
"UPDATE product_template SET intrastat_type='service' "
|
||||
"WHERE type='service'")
|
||||
return
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2016-2019 Akretion (http://www.akretion.com/)
|
||||
Copyright 2016-2024 Akretion France (https://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
@@ -13,8 +13,8 @@
|
||||
<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 name="detailed_type" position="after">
|
||||
<field name="intrastat_type" attrs="{'invisible': [('type', '!=', 'consu')]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
Reference in New Issue
Block a user