| @ -0,0 +1,58 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | ||||
|  | #    Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU LESSER | ||||
|  | #    GENERAL PUBLIC LICENSE (LGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE | ||||
|  | #    (LGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | import ast | ||||
|  | from odoo import api, fields, models, _ | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | class ProductProduct(models.Model): | ||||
|  |     _inherit = 'product.product' | ||||
|  | 
 | ||||
|  |     @api.model | ||||
|  |     def create(self, vals): | ||||
|  |         """Inherited for passing the product Tags.""" | ||||
|  |         res = super(ProductProduct, self).create(vals) | ||||
|  |         if not res.product_tag_ids: | ||||
|  |             pro_tag = self.env['ir.config_parameter'].sudo().get_param( | ||||
|  |                 'odoo_product_tags.product_tag_ids') | ||||
|  |             if pro_tag: | ||||
|  |                 tag_ids = ast.literal_eval(pro_tag) | ||||
|  |                 res.update({ | ||||
|  |                     "product_tag_ids": [(6, 0, tag_ids)], | ||||
|  |                 }) | ||||
|  |             return res | ||||
|  |         else: | ||||
|  |             return res | ||||
|  | 
 | ||||
|  |     def action_apply_product_tags(self): | ||||
|  |         """Applying product tags""" | ||||
|  |         return { | ||||
|  |             'name': 'Apply Product Tag', | ||||
|  |             'type': 'ir.actions.act_window', | ||||
|  |             'view_type': 'form', | ||||
|  |             'view_mode': 'form', | ||||
|  |             'res_model': 'product.tags.wizard', | ||||
|  |             'context': { | ||||
|  |                 'default_product_ids': self.ids, | ||||
|  |                 'default_is_product': True | ||||
|  |             }, | ||||
|  |             'target': 'new', | ||||
|  |         } | ||||
| @ -1,39 +0,0 @@ | |||||
| # -*- coding: utf-8 -*- |  | ||||
| ############################################################################# |  | ||||
| # |  | ||||
| #    Cybrosys Technologies Pvt. Ltd. |  | ||||
| # |  | ||||
| #    Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |  | ||||
| #    Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |  | ||||
| # |  | ||||
| #    You can modify it under the terms of the GNU LESSER |  | ||||
| #    GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |  | ||||
| # |  | ||||
| #    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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |  | ||||
| # |  | ||||
| #    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |  | ||||
| #    (LGPL v3) along with this program. |  | ||||
| #    If not, see <http://www.gnu.org/licenses/>. |  | ||||
| # |  | ||||
| ############################################################################# |  | ||||
| from odoo import api, fields, models, _ |  | ||||
| from random import randint |  | ||||
| 
 |  | ||||
| 
 |  | ||||
| class ProductTags(models.Model): |  | ||||
|     _name = "product.tags" |  | ||||
|     _description = 'Product Tags' |  | ||||
|     _rec_name = "name" |  | ||||
|     _inherit = ['mail.thread', 'mail.activity.mixin'] |  | ||||
| 
 |  | ||||
|     def _random_color(self): |  | ||||
|         return randint(1, 11) |  | ||||
| 
 |  | ||||
|     name = fields.Char(required=1, copy=False, string='Name') |  | ||||
|     description = fields.Text(string='Description', translate=True) |  | ||||
|     tag_color = fields.Integer(string="Tag Color",  default=_random_color) |  | ||||
|     product_tmpl_ids = fields.Many2many('product.template', string="Products") |  | ||||
| 
 |  | ||||
| 
 | 
| Before Width: | Height: | Size: 51 KiB | 
| Before Width: | Height: | Size: 61 KiB | 
| Before Width: | Height: | Size: 60 KiB | 
| Before Width: | Height: | Size: 59 KiB | 
| After Width: | Height: | Size: 49 KiB | 
| After Width: | Height: | Size: 47 KiB | 
| After Width: | Height: | Size: 54 KiB | 
| After Width: | Height: | Size: 50 KiB | 
| After Width: | Height: | Size: 44 KiB | 
| After Width: | Height: | Size: 53 KiB | 
| Before Width: | Height: | Size: 52 KiB | 
| Before Width: | Height: | Size: 54 KiB | 
| @ -0,0 +1,15 @@ | |||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||
|  | <odoo> | ||||
|  |     <record id="product_product_tree_view" model="ir.ui.view"> | ||||
|  |         <field name="name">product.product.view.list.inherit.odoo.product.tags</field> | ||||
|  |         <field name="model">product.product</field> | ||||
|  |         <field name="inherit_id" ref="product.product_product_tree_view"/> | ||||
|  |         <field name="arch" type="xml"> | ||||
|  |             <xpath expr="//header" position="inside"> | ||||
|  |                 <button class="btn-primary" name="action_apply_product_tags" | ||||
|  |                         type="object" string="Apply Product Tag" | ||||
|  |                 /> | ||||
|  |             </xpath> | ||||
|  |         </field> | ||||
|  |     </record> | ||||
|  | </odoo> | ||||
| @ -1,69 +0,0 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> |  | ||||
| <odoo> |  | ||||
|     <record id="product_tags_view_tree" model="ir.ui.view"> |  | ||||
|         <field name="name">product.tags.tree</field> |  | ||||
|         <field name="model">product.tags</field> |  | ||||
|         <field name="type">tree</field> |  | ||||
|         <field name="arch" type="xml"> |  | ||||
|             <tree> |  | ||||
|                 <field name="name"/> |  | ||||
|                 <field name="tag_color" widget="color_picker"/> |  | ||||
|             </tree> |  | ||||
|         </field> |  | ||||
|     </record> |  | ||||
| 
 |  | ||||
|     <record id="product_tags_view_form" model="ir.ui.view"> |  | ||||
|         <field name="name">product.tags.form</field> |  | ||||
|         <field name="model">product.tags</field> |  | ||||
|         <field name="type">form</field> |  | ||||
|         <field name="arch" type="xml"> |  | ||||
|             <form> |  | ||||
|                 <sheet> |  | ||||
|                     <div class="oe_title"> |  | ||||
|                         <h1> |  | ||||
|                             <field name="name" readonly="1"/> |  | ||||
|                         </h1> |  | ||||
|                     </div> |  | ||||
|                     <group> |  | ||||
|                         <group> |  | ||||
|                             <field name="name"/> |  | ||||
|                         </group> |  | ||||
|                         <group> |  | ||||
|                             <field name="tag_color" widget="color_picker"/> |  | ||||
|                         </group> |  | ||||
|                     </group> |  | ||||
|                     <group> |  | ||||
|                         <field name="product_tmpl_ids" widget="many2many_tags"/> |  | ||||
|                     </group> |  | ||||
|                     <group> |  | ||||
|                         <field name="description"/> |  | ||||
|                     </group> |  | ||||
| 
 |  | ||||
|                 </sheet> |  | ||||
|                 <div class="oe_chatter"> |  | ||||
|                     <field name="message_follower_ids"/> |  | ||||
|                     <field name="activity_ids"/> |  | ||||
|                     <field name="message_ids"/> |  | ||||
|                 </div> |  | ||||
|             </form> |  | ||||
|         </field> |  | ||||
|     </record> |  | ||||
| 
 |  | ||||
|     <record id="action_product_tags" model="ir.actions.act_window"> |  | ||||
|         <field name="name">Product Tags</field> |  | ||||
|         <field name="type">ir.actions.act_window</field> |  | ||||
|         <field name="res_model">product.tags</field> |  | ||||
|         <field name="view_mode">tree,form,kanban</field> |  | ||||
|         <field name="help" type="html"> |  | ||||
|             <p class="o_view_nocontent_smiling_face"> |  | ||||
|                 Create New Product Tags! |  | ||||
|             </p> |  | ||||
|         </field> |  | ||||
|     </record> |  | ||||
| 
 |  | ||||
|     <menuitem id="sale_menu_product_tags" |  | ||||
|               name="Product Tags" |  | ||||
|               parent="sale.product_menu_catalog" |  | ||||
|               action="action_product_tags" |  | ||||
|               sequence="13"/> |  | ||||
| </odoo> |  | ||||
| @ -1,62 +1,25 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||
| <odoo> | <odoo> | ||||
|     <record model="ir.ui.view" id="product_template_tag_form_view"> |     <record id="product_template_tree_view" model="ir.ui.view"> | ||||
|         <field name="name">product.template.product.tags</field> |         <field name="name">product.template.view.list.inherit.odoo.product.tags</field> | ||||
|         <field name="model">product.template</field> |  | ||||
|         <field name="inherit_id" ref="product.product_template_only_form_view"/> |  | ||||
|         <field name="arch" type="xml"> |  | ||||
|             <xpath expr="//field[@name='invoice_policy']" position="after"> |  | ||||
|                 <field name="product_tags_ids" |  | ||||
|                        widget="many2many_tags" |  | ||||
|                        options="{'color_field': 'tag_color', 'no_create_edit': True}"/> |  | ||||
|             </xpath> |  | ||||
|         </field> |  | ||||
|     </record> |  | ||||
| 
 |  | ||||
|     <record model="ir.ui.view" id="product_template_tag_tree_view"> |  | ||||
|         <field name="name">product.template.product.tags</field> |  | ||||
|         <field name="model">product.template</field> |         <field name="model">product.template</field> | ||||
|         <field name="inherit_id" ref="product.product_template_tree_view"/> |         <field name="inherit_id" ref="product.product_template_tree_view"/> | ||||
|         <field name="arch" type="xml"> |         <field name="arch" type="xml"> | ||||
|             <xpath expr="//tree" position="inside"> |             <xpath expr="//header" position="inside"> | ||||
|                 <header> |                 <button class="btn-primary" name="action_apply_template_tags" | ||||
|                     <button class="btn-primary" name="action_apply_tags" |                         type="object" string="Apply Product Tag" | ||||
|                             type="object" string="Apply Product Tag" |                 /> | ||||
|                             /> |  | ||||
|                 </header> |  | ||||
|             </xpath> |  | ||||
|             <xpath expr="//field[@name='default_code']" position="after"> |  | ||||
|                 <field name="product_tags_ids" |  | ||||
|                        widget="many2many_tags" |  | ||||
|                        options="{'color_field': 'tag_color', 'no_create_edit': True}"/> |  | ||||
|             </xpath> |  | ||||
|         </field> |  | ||||
|     </record> |  | ||||
| 
 |  | ||||
|     <record model="ir.ui.view" id="product_template_tag_kanban_view"> |  | ||||
|         <field name="name">product.template.product.tags</field> |  | ||||
|         <field name="model">product.template</field> |  | ||||
|         <field name="inherit_id" ref="product.product_template_kanban_view"/> |  | ||||
|         <field name="arch" type="xml"> |  | ||||
|             <xpath expr="//div[@name='product_lst_price']" position="before"> |  | ||||
|                 <field name="product_tags_ids" |  | ||||
|                        widget="many2many_tags" |  | ||||
|                        options="{'color_field': 'tag_color', 'no_create_edit': True}"/> |  | ||||
|             </xpath> |             </xpath> | ||||
|         </field> |         </field> | ||||
|     </record> |     </record> | ||||
| 
 |  | ||||
|     <record id="product_template_search_view" model="ir.ui.view"> |     <record id="product_template_search_view" model="ir.ui.view"> | ||||
|         <field name="name">product.template.search</field> |         <field name="name">product.template.search.inherit.odoo.product.tags</field> | ||||
|         <field name="model">product.template</field> |         <field name="model">product.template</field> | ||||
|         <field name="inherit_id" ref="product.product_template_search_view"/> |         <field name="inherit_id" ref="product.product_template_search_view"/> | ||||
|         <field name="arch" type="xml"> |         <field name="arch" type="xml"> | ||||
|             <xpath expr="//filter[@name='services']" position="after"> |             <xpath expr="//filter[@name='services']" position="after"> | ||||
|                 <filter name="product_tags" string="Product Tags" |                 <filter name="product_tags" string="Product Tags" context="{'group_by': 'product_tag_ids'}"/> | ||||
|                         context="{'group_by': 'product_tags_ids'}"/> |  | ||||
|             </xpath> |             </xpath> | ||||
|         </field> |         </field> | ||||
|     </record> |     </record> | ||||
| 
 |  | ||||
| 
 |  | ||||
| </odoo> | </odoo> | ||||
|  | |||||