diff --git a/dynamic_sale_order_fields/README.rst b/dynamic_sale_order_fields/README.rst new file mode 100644 index 000000000..a6afed32c --- /dev/null +++ b/dynamic_sale_order_fields/README.rst @@ -0,0 +1,48 @@ +Sale Order Custom Fields +======================== + +Sale Order Custom Fields + +Depends +======= +[sale_management] addon Odoo + +Tech +==== +* [Python] - Models +* [XML] - Odoo views + +Installation +============ +- www.odoo.com/documentation/15.0/setup/install.html +- Install our custom addon + +License +======= +GNU AFFERO GENERAL PUBLIC LICENSE, Version 3 (AGPLv3) +(http://www.gnu.org/licenses/agpl.html) + +Bug Tracker +=========== +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Credits +======= +* Cybrosys Techno Solutions + + +Author +------ +* Ajmal JK + +Credits +------- +* Developers: Ajmal JK @cybrosys, odoo@cybrosys.com + Version 14: Minhaj T @cybrosys, odoo@cybrosys.com + Version 15: @cybrosys, odoo@cybrosys.com +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. diff --git a/dynamic_sale_order_fields/__init__.py b/dynamic_sale_order_fields/__init__.py new file mode 100644 index 000000000..350976f47 --- /dev/null +++ b/dynamic_sale_order_fields/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Ajmal JK () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 . import models +from . import wizard diff --git a/dynamic_sale_order_fields/__manifest__.py b/dynamic_sale_order_fields/__manifest__.py new file mode 100644 index 000000000..be2d417a7 --- /dev/null +++ b/dynamic_sale_order_fields/__manifest__.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Ajmal JK () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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': 'Sale Order Custom Fields', + 'version': '15.0.1.0.0', + 'summary': """Ability To Add Custom Fields in Sale Order From User Level""", + 'description': """Ability To Add Custom Fields in Sale Order From User Level,Sale Order Custom Fields, + Sale Order Dynamic Fields, odoo15, Dynamic Sale Order Fields, Dynamic Fields, Create Dynamic Fields, Community odoo Studio""", + 'category': 'Sales', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['sale_management'], + 'data': [ + 'data/widget_data.xml', + 'security/ir.model.access.csv', + 'security/sale_dynamic_security_group.xml', + 'wizard/sale_order_fields.xml', + 'views/sale_order_view.xml', + 'views/ir_fields_search_view.xml', + ], + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/dynamic_sale_order_fields/data/widget_data.xml b/dynamic_sale_order_fields/data/widget_data.xml new file mode 100644 index 000000000..3a36ccb38 --- /dev/null +++ b/dynamic_sale_order_fields/data/widget_data.xml @@ -0,0 +1,40 @@ + + + + + + image + Image + + + + many2many_tags + Many2many Tags + + + + binary + Binary + + + + radio + Radio + + + + priority + Priority + + + + monetary + Monetary + + + + selection + Selection + + + diff --git a/dynamic_sale_order_fields/doc/RELEASE_NOTES.md b/dynamic_sale_order_fields/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..6b62f531f --- /dev/null +++ b/dynamic_sale_order_fields/doc/RELEASE_NOTES.md @@ -0,0 +1,9 @@ +## Module + +#### 08.11.2021 +#### Version 15.0.1.0.0 +##### ADD + +- Initial Commit for dynamic_sale_order_fields + + diff --git a/dynamic_sale_order_fields/models/__init__.py b/dynamic_sale_order_fields/models/__init__.py new file mode 100644 index 000000000..08bc69f73 --- /dev/null +++ b/dynamic_sale_order_fields/models/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Ajmal JK () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 . import ir_model_fields +from . import field_widgets + + diff --git a/dynamic_sale_order_fields/models/field_widgets.py b/dynamic_sale_order_fields/models/field_widgets.py new file mode 100644 index 000000000..34d5c6da1 --- /dev/null +++ b/dynamic_sale_order_fields/models/field_widgets.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Ajmal JK () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 odoo import api, models, fields, _ + + +class FieldWidgets(models.Model): + """Need of this model is because we can't filter a selection field dynamically + so when we select a field its widgets also need to change according to field + type, we can't do it by a 'selection' field, need a 'Many2one' field.""" + + _name = 'field.widgets' + _description = 'Field Widgets' + _rec_name = 'description' + + name = fields.Char(string="Name") + description = fields.Char(string="Description") diff --git a/dynamic_sale_order_fields/models/ir_model_fields.py b/dynamic_sale_order_fields/models/ir_model_fields.py new file mode 100644 index 000000000..891d6c50d --- /dev/null +++ b/dynamic_sale_order_fields/models/ir_model_fields.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Ajmal JK () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 odoo import api, models, fields, _ + + +class IrModelFields(models.Model): + """Adding a new field to understand the dynamically created fields.""" + + _inherit = 'ir.model.fields' + + is_dynamic = fields.Boolean(string="Dynamic Field") diff --git a/dynamic_sale_order_fields/security/ir.model.access.csv b/dynamic_sale_order_fields/security/ir.model.access.csv new file mode 100644 index 000000000..357bb114c --- /dev/null +++ b/dynamic_sale_order_fields/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +access_wizard_sale_order_dynamic_fields_base_user,wizard.sale.order.dynamic.fields.base.user,model_sale_order_dynamic_fields,base.group_user,1,1,1,1 +access_field_widgets_base_user,wizard.field.widgets.base.user,model_field_widgets,base.group_user,1,1,1,1 + diff --git a/dynamic_sale_order_fields/security/sale_dynamic_security_group.xml b/dynamic_sale_order_fields/security/sale_dynamic_security_group.xml new file mode 100644 index 000000000..2518c1cd4 --- /dev/null +++ b/dynamic_sale_order_fields/security/sale_dynamic_security_group.xml @@ -0,0 +1,8 @@ + + + + + Create Custom Fields in Sale + + + diff --git a/dynamic_sale_order_fields/static/description/banner.png b/dynamic_sale_order_fields/static/description/banner.png new file mode 100644 index 000000000..a1cd28cf0 Binary files /dev/null and b/dynamic_sale_order_fields/static/description/banner.png differ diff --git a/dynamic_sale_order_fields/static/description/icon.png b/dynamic_sale_order_fields/static/description/icon.png new file mode 100644 index 000000000..5cad92c7d Binary files /dev/null and b/dynamic_sale_order_fields/static/description/icon.png differ diff --git a/dynamic_sale_order_fields/static/description/images/banner_barcode_scanning.jpeg b/dynamic_sale_order_fields/static/description/images/banner_barcode_scanning.jpeg new file mode 100644 index 000000000..529143e4e Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/banner_barcode_scanning.jpeg differ diff --git a/dynamic_sale_order_fields/static/description/images/banner_currency_total.png b/dynamic_sale_order_fields/static/description/images/banner_currency_total.png new file mode 100644 index 000000000..6153ed719 Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/banner_currency_total.png differ diff --git a/dynamic_sale_order_fields/static/description/images/banner_customer_sequence.jpeg b/dynamic_sale_order_fields/static/description/images/banner_customer_sequence.jpeg new file mode 100644 index 000000000..7451342d6 Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/banner_customer_sequence.jpeg differ diff --git a/dynamic_sale_order_fields/static/description/images/banner_previous_rates.jpeg b/dynamic_sale_order_fields/static/description/images/banner_previous_rates.jpeg new file mode 100644 index 000000000..e10c28799 Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/banner_previous_rates.jpeg differ diff --git a/dynamic_sale_order_fields/static/description/images/banner_product_branding.png b/dynamic_sale_order_fields/static/description/images/banner_product_branding.png new file mode 100644 index 000000000..aa12beabb Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/banner_product_branding.png differ diff --git a/dynamic_sale_order_fields/static/description/images/banner_product_expiry.jpeg b/dynamic_sale_order_fields/static/description/images/banner_product_expiry.jpeg new file mode 100644 index 000000000..84a872d44 Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/banner_product_expiry.jpeg differ diff --git a/dynamic_sale_order_fields/static/description/images/checked.png b/dynamic_sale_order_fields/static/description/images/checked.png new file mode 100644 index 000000000..578cedb80 Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/checked.png differ diff --git a/dynamic_sale_order_fields/static/description/images/cybrosys.png b/dynamic_sale_order_fields/static/description/images/cybrosys.png new file mode 100644 index 000000000..d76b5bafb Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/cybrosys.png differ diff --git a/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_1.png b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_1.png new file mode 100644 index 000000000..3b814656d Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_1.png differ diff --git a/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_2.png b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_2.png new file mode 100644 index 000000000..b4204a51e Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_2.png differ diff --git a/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_3.png b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_3.png new file mode 100644 index 000000000..0d75cd35d Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_3.png differ diff --git a/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_4.png b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_4.png new file mode 100644 index 000000000..4e4a78483 Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_4.png differ diff --git a/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_5.png b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_5.png new file mode 100644 index 000000000..f26cb4f2f Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_5.png differ diff --git a/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_6.png b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_6.png new file mode 100644 index 000000000..21d9d73f3 Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_6.png differ diff --git a/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_7.png b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_7.png new file mode 100644 index 000000000..7795b2dc3 Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_7.png differ diff --git a/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_8.png b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_8.png new file mode 100644 index 000000000..3251fa12c Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_8.png differ diff --git a/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_main.png b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_main.png new file mode 100644 index 000000000..1b670bdbb Binary files /dev/null and b/dynamic_sale_order_fields/static/description/images/dynamic_sale_fields_main.png differ diff --git a/dynamic_sale_order_fields/static/description/index.html b/dynamic_sale_order_fields/static/description/index.html new file mode 100644 index 000000000..ba6e14097 --- /dev/null +++ b/dynamic_sale_order_fields/static/description/index.html @@ -0,0 +1,582 @@ +
+ cybrosys-logo
+
+
+
+

Sale Order Custom Fields

+

Create Custom Fields in Sale Order from User + level.

+
+

Key Highlights

+
    +
  • Creates + custom fields in Sale Order. +
  • +
+
+
+
+
+
+
+
+ +
+
+ +

Overview

+
+

+ The Sale Order Custom Fields helps with easy creation of custom fields in sale order without any coding. This module helps to add new fields on the sale order form as per one’s requirement. From the sale configuration menu , one can click create fields and can create a new custom field without any coding. +

+
+
+ +

Sale Order Custom Fields

+
+
    +
  • + Creates + custom fields in Sale Order without coding +
  • +
  • + Can + easily set the position of fields +
  • +
  • + Can + select widgets for fields +
  • +
  • + Can + set the field properties (help,required,copied,read-only,indexed). +
  • +
  • + Can + easily filter the dynamically created fields from settings. +
  • +
+
+ +
+
+

Screenshots

+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + +
+
    +
+
+
+
+
+
+
+

Suggested Products

+
+ +
+
+

Our Service

+
+ +
+
+
+

Our Industries

+
+ +
+
+
+
+ Odoo Industry
+
+
+

+ + Trading

+

+ Easily procure and sell your products.

+
+
+
+
+
+ Odoo Industry +
+
+
+

+ + Manufacturing

+

+ Plan, track and schedule your operations.

+
+
+
+
+
+ + Odoo Industry
+
+
+

+ + Restaurant

+

+ Run your bar or restaurant methodical.

+
+
+
+
+
+ Odoo Industry
+
+
+

+ + POS

+

+ Easy configuring and convivial selling.

+
+
+
+
+
+ Odoo Industry
+
+
+

+ + E-commerce & Website

+

+ Mobile friendly, awe-inspiring product pages.

+
+
+
+
+
+ + Odoo Industry
+
+
+

+ + Hotel Management

+

+ An all-inclusive hotel management application.

+
+
+
+
+
+ + Odoo Industry
+
+
+

+ + Education

+

+ A Collaborative platform for educational management.

+
+
+
+
+
+ Odoo Industry
+
+
+

+ + Service Management

+

+ Keep track of services and invoice accordingly.

+
+
+
+
+
+ +
+
+
+

Need Any Help?

+
+

If you have anything to share with us based on your use of this module, please + let us know. We are ready to offer our support.

+
+

Email us

+

odoo@cybrosys.com

+
+
+

Contact Us

+ www.cybrosys.com +
+
+
+
+
+
+
+
+
+ +
+ + + + + + + +
+
+
+ \ No newline at end of file diff --git a/dynamic_sale_order_fields/views/ir_fields_search_view.xml b/dynamic_sale_order_fields/views/ir_fields_search_view.xml new file mode 100644 index 000000000..130726e0d --- /dev/null +++ b/dynamic_sale_order_fields/views/ir_fields_search_view.xml @@ -0,0 +1,15 @@ + + + + + ir.model.fields.sale.dynamic.fields + ir.model.fields + + + + + + + + + diff --git a/dynamic_sale_order_fields/views/sale_order_view.xml b/dynamic_sale_order_fields/views/sale_order_view.xml new file mode 100644 index 000000000..787943be5 --- /dev/null +++ b/dynamic_sale_order_fields/views/sale_order_view.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/dynamic_sale_order_fields/wizard/__init__.py b/dynamic_sale_order_fields/wizard/__init__.py new file mode 100644 index 000000000..819d74539 --- /dev/null +++ b/dynamic_sale_order_fields/wizard/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Ajmal JK () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 . import sale_order_fields + + diff --git a/dynamic_sale_order_fields/wizard/sale_order_fields.py b/dynamic_sale_order_fields/wizard/sale_order_fields.py new file mode 100644 index 000000000..4c0d5a3ef --- /dev/null +++ b/dynamic_sale_order_fields/wizard/sale_order_fields.py @@ -0,0 +1,130 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies (). +# Author: Ajmal JK () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 xml.etree.ElementTree as xee +from odoo import api, models, fields, _ + + +class SaleOrderDynamicFields(models.TransientModel): + _name = 'sale.order.dynamic.fields' + _description = 'Dynamic Fields' + _inherit = 'ir.model.fields' + + @api.model + def get_possible_field_types(self): + """Return all available field types other than 'one2many' and 'reference' fields.""" + field_list = sorted((key, key) for key in fields.MetaField.by_type) + field_list.remove(('one2many', 'one2many')) + field_list.remove(('reference', 'reference')) + return field_list + + def set_domain(self): + """Return the fields that currently present in the form""" + view_id = self.env.ref('sale.view_order_form') + view_arch = str(view_id.arch_base) + doc = xee.fromstring(view_arch) + field_list = [] + for tag in doc.findall('.//field'): + field_list.append(tag.attrib['name']) + model_id = self.env['ir.model'].sudo().search([('model', '=', 'sale.order')]) + return [('model_id', '=', model_id.id), ('state', '=', 'base'), ('name', 'in', field_list)] + + def _set_default(self): + model_id = self.env['ir.model'].sudo().search([('model', '=', 'sale.order')]) + return [('id', '=', model_id.id)] + + def create_fields(self): + self.env['ir.model.fields'].sudo().create({'name': self.name, + 'field_description': self.field_description, + 'model_id': self.model_id.id, + 'ttype': self.field_type, + 'relation': self.ref_model_id.model, + 'required': self.required, + 'index': self.index, + 'store': self.store, + 'help': self.help, + 'readonly': self.readonly, + 'selection': self.selection_field, + 'copied': self.copied, + 'is_dynamic': True + }) + inherit_id = self.env.ref('sale.view_order_form') + arch_base = _('' + '' + '' + '' + '' + '') % (self.position_field.name, self.position, self.name) + if self.widget: + arch_base = _('' + '' + '' + '' + '' + '') % (self.position_field.name, self.position, self.name, self.widget.name) + + self.env['ir.ui.view'].sudo().create({'name': 'sale.order.dynamic.fields', + 'type': 'form', + 'model': 'sale.order', + 'mode': 'extension', + 'inherit_id': inherit_id.id, + 'arch_base': arch_base, + 'active': True}) + return { + 'type': 'ir.actions.client', + 'tag': 'reload', + } + + position_field = fields.Many2one('ir.model.fields', string='Field Name', + domain=set_domain, required=True) + position = fields.Selection([('before', 'Before'), + ('after', 'After')], string='Position', required=True) + model_id = fields.Many2one('ir.model', string='Model', required=True, index=True, ondelete='cascade', + help="The model this field belongs to", domain=_set_default) + ref_model_id = fields.Many2one('ir.model', string='Model', index=True) + # In odoo 13 the field 'selection' is deprecated, so adding a new field to get the selection values. + selection_field = fields.Char(string="Selection Options") + rel_field = fields.Many2one('ir.model.fields', string='Related Field') + field_type = fields.Selection(selection='get_possible_field_types', string='Field Type', required=True) + ttype = fields.Selection(string="Field Type", related='field_type') + widget = fields.Many2one('field.widgets', string='Widget') + groups = fields.Many2many('res.groups', 'sale_dynamic_fields_group_rel', 'field_id', 'group_id') + extra_features = fields.Boolean(string="Show Extra Properties") + + @api.depends('field_type') + @api.onchange('field_type') + def onchange_field_type(self): + if self.field_type: + if self.field_type == 'binary': + return {'domain': {'widget': [('name', '=', 'image')]}} + elif self.field_type == 'many2many': + return {'domain': {'widget': [('name', 'in', ['many2many_tags', 'binary'])]}} + elif self.field_type == 'selection': + return {'domain': {'widget': [('name', 'in', ['radio', 'priority'])]}} + elif self.field_type == 'float': + return {'domain': {'widget': [('name', '=', 'monetary')]}} + elif self.field_type == 'many2one': + return {'domain': {'widget': [('name', '=', 'selection')]}} + else: + return {'domain': {'widget': [('id', '=', False)]}} + return {'domain': {'widget': [('id', '=', False)]}} diff --git a/dynamic_sale_order_fields/wizard/sale_order_fields.xml b/dynamic_sale_order_fields/wizard/sale_order_fields.xml new file mode 100644 index 000000000..3885fc56d --- /dev/null +++ b/dynamic_sale_order_fields/wizard/sale_order_fields.xml @@ -0,0 +1,66 @@ + + + + + sale.order.dynamic.fields.form + sale.order.dynamic.fields + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + + Create Custom Fields + sale.order.dynamic.fields + form + + new + + +