diff --git a/product_detailed_type/__init__.py b/product_detailed_type/__init__.py new file mode 100644 index 0000000..f4b0900 --- /dev/null +++ b/product_detailed_type/__init__.py @@ -0,0 +1,2 @@ +from . import models +from .post_install import set_product_detailed_type diff --git a/product_detailed_type/__manifest__.py b/product_detailed_type/__manifest__.py new file mode 100644 index 0000000..056bfd9 --- /dev/null +++ b/product_detailed_type/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2023 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Product Detailed Type', + 'version': '14.0.1.0.0', + 'category': 'Product', + 'license': 'LGPL-3', + 'summary': 'Backport detailed_type from v16 to v14', + 'author': 'Akretion', + 'website': 'https://github.com/akretion/odoo-usability', + 'depends': ['product'], + 'data': [ + 'views/product.xml', + ], + 'post_init_hook': 'set_product_detailed_type', + 'installable': True, +} diff --git a/product_detailed_type/models/__init__.py b/product_detailed_type/models/__init__.py new file mode 100644 index 0000000..e8fa8f6 --- /dev/null +++ b/product_detailed_type/models/__init__.py @@ -0,0 +1 @@ +from . import product_template diff --git a/product_detailed_type/models/product_template.py b/product_detailed_type/models/product_template.py new file mode 100644 index 0000000..8e050c3 --- /dev/null +++ b/product_detailed_type/models/product_template.py @@ -0,0 +1,25 @@ +# Copyright 2023 Akretion France (http://www.akretion.com/) +# Copyright 2023 Odoo SA (contains code copy-pasted from Odoo v16) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + detailed_type = fields.Selection([ + ('consu', 'Consumable'), + ('service', 'Service'), + ], string='Product Type', default='consu', required=True, tracking=True) + type = fields.Selection(compute='_compute_type', store=True, string="Type") + + def _detailed_type_mapping(self): + return {} + + @api.depends('detailed_type') + def _compute_type(self): + type_mapping = self._detailed_type_mapping() + for record in self: + record.type = type_mapping.get(record.detailed_type, record.detailed_type) diff --git a/product_detailed_type/post_install.py b/product_detailed_type/post_install.py new file mode 100644 index 0000000..b5bf3fb --- /dev/null +++ b/product_detailed_type/post_install.py @@ -0,0 +1,7 @@ +# Copyright 2023 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +def set_product_detailed_type(cr, registry): + cr.execute('UPDATE product_template SET detailed_type=type') diff --git a/product_detailed_type/views/product.xml b/product_detailed_type/views/product.xml new file mode 100644 index 0000000..eee5c3e --- /dev/null +++ b/product_detailed_type/views/product.xml @@ -0,0 +1,47 @@ + + + + + + + product.template + + + + + + + + + + product.template + + + + + + + 1 + + + + + + product.template + + + + 1 + + + + + + + + + diff --git a/product_detailed_type_stock/__init__.py b/product_detailed_type_stock/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/product_detailed_type_stock/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_detailed_type_stock/__manifest__.py b/product_detailed_type_stock/__manifest__.py new file mode 100644 index 0000000..da55dc6 --- /dev/null +++ b/product_detailed_type_stock/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2023 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Product Detailed Type Stock', + 'version': '14.0.1.0.0', + 'category': 'Product', + 'license': 'LGPL-3', + 'summary': 'Glue module between product_detailed_type and stock', + 'author': 'Akretion', + 'website': 'https://github.com/akretion/odoo-usability', + 'depends': ['product_detailed_type', 'stock'], + 'installable': True, + 'auto_install': True, +} diff --git a/product_detailed_type_stock/models/__init__.py b/product_detailed_type_stock/models/__init__.py new file mode 100644 index 0000000..e8fa8f6 --- /dev/null +++ b/product_detailed_type_stock/models/__init__.py @@ -0,0 +1 @@ +from . import product_template diff --git a/product_detailed_type_stock/models/product_template.py b/product_detailed_type_stock/models/product_template.py new file mode 100644 index 0000000..4f23eec --- /dev/null +++ b/product_detailed_type_stock/models/product_template.py @@ -0,0 +1,13 @@ +# Copyright 2023 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + detailed_type = fields.Selection(selection_add=[ + ('product', 'Storable Product') + ], ondelete={'product': 'set default'})