Add module product_detailed_type and product_detailed_type_stock
This commit is contained in:
2
product_detailed_type/__init__.py
Normal file
2
product_detailed_type/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import models
|
||||
from .post_install import set_product_detailed_type
|
||||
19
product_detailed_type/__manifest__.py
Normal file
19
product_detailed_type/__manifest__.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Copyright 2023 Akretion (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': '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,
|
||||
}
|
||||
1
product_detailed_type/models/__init__.py
Normal file
1
product_detailed_type/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import product_template
|
||||
25
product_detailed_type/models/product_template.py
Normal file
25
product_detailed_type/models/product_template.py
Normal file
@@ -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 <alexis.delattre@akretion.com>
|
||||
# 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)
|
||||
7
product_detailed_type/post_install.py
Normal file
7
product_detailed_type/post_install.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# Copyright 2023 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).
|
||||
|
||||
|
||||
def set_product_detailed_type(cr, registry):
|
||||
cr.execute('UPDATE product_template SET detailed_type=type')
|
||||
47
product_detailed_type/views/product.xml
Normal file
47
product_detailed_type/views/product.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2023 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).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="product_template_tree_view" model="ir.ui.view">
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="type" position="after">
|
||||
<field name="detailed_type" optional="hide" readonly="1"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_template_form_view" model="ir.ui.view">
|
||||
<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="detailed_type"/>
|
||||
</field>
|
||||
<field name="type" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_template_search_view" model="ir.ui.view">
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_search_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<filter name="type" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</filter>
|
||||
<filter name="type" position="after">
|
||||
<filter name="detailed_type_groupby" string="Product Type" context="{'group_by': 'detailed_type'}"/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
1
product_detailed_type_stock/__init__.py
Normal file
1
product_detailed_type_stock/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
16
product_detailed_type_stock/__manifest__.py
Normal file
16
product_detailed_type_stock/__manifest__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# Copyright 2023 Akretion (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': '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,
|
||||
}
|
||||
1
product_detailed_type_stock/models/__init__.py
Normal file
1
product_detailed_type_stock/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import product_template
|
||||
13
product_detailed_type_stock/models/product_template.py
Normal file
13
product_detailed_type_stock/models/product_template.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# Copyright 2023 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# 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'})
|
||||
Reference in New Issue
Block a user