diff --git a/multiple_reference_per_product/__init__.py b/multiple_reference_per_product/__init__.py new file mode 100644 index 000000000..6c1f4e196 --- /dev/null +++ b/multiple_reference_per_product/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2020-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions(odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# + +from . import models \ No newline at end of file diff --git a/multiple_reference_per_product/__manifest__.py b/multiple_reference_per_product/__manifest__.py new file mode 100644 index 000000000..92b0c64ef --- /dev/null +++ b/multiple_reference_per_product/__manifest__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2020-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions(odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + 'name': "Multiple Reference Per Product", + 'version': '14.0.1.0.0', + 'summary': 'Multiple Reference Per Product', + 'description': """Add multiple reference code for a product template or product variant. Easily manage between the + different codes as default code for the product.""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://cybrosys.com/", + 'category': 'Inventory/Inventory', + 'depends': ['stock'], + 'data': [ + 'security/ir.model.access.csv', + 'views/multiple_reference_per_product.xml', + ], + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/multiple_reference_per_product/models/__init__.py b/multiple_reference_per_product/models/__init__.py new file mode 100644 index 000000000..eb0856c78 --- /dev/null +++ b/multiple_reference_per_product/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2020-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions(odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# + +from . import multiple_reference_per_product \ No newline at end of file diff --git a/multiple_reference_per_product/models/multiple_reference_per_product.py b/multiple_reference_per_product/models/multiple_reference_per_product.py new file mode 100644 index 000000000..26076c33b --- /dev/null +++ b/multiple_reference_per_product/models/multiple_reference_per_product.py @@ -0,0 +1,156 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2020-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions(odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# + +from odoo import models, fields, api + + +class MultipleReferencePerProduct(models.Model): + _name = 'multiple.reference.per.product' + _description = 'Multiple Reference Per Product' + _rec_name = 'multiple_references_name' + + multiple_references_name = fields.Char('Multiple References', required=True) + product_id = fields.Many2one('product.product', string="Product", required=True) + is_default_reference = fields.Boolean(string="Is default reference", compute='_is_default_reference') + + def _is_default_reference(self): + """Check if the current code is default code for the product""" + for reference in self: + if reference.product_id: + reference.is_default_reference = True if reference.product_id.default_code == reference.multiple_references_name else False + + def set_as_default(self): + """Set the current code as default code for the product""" + self.ensure_one() + self.product_id.default_code = self.multiple_references_name + + def create_reference(self, reference_code, product_id): + """Add existing default code into the reference model""" + reference = self.create({ + 'multiple_references_name': reference_code, + 'product_id': product_id, + }) + return True if reference else False + + @api.model + def create(self, values): + if values.get('multiple_references_name') and values.get('product_id'): + reference_code = self.search([('multiple_references_name', '=', values.get('multiple_references_name')), ('product_id', '=', values.get('product_id'))]) + print(reference_code) + + if reference_code: + res = reference_code[0] + else: + res = super(MultipleReferencePerProduct, self).create(values) + + if not res.product_id.default_code: + res.product_id.default_code = res.multiple_references_name + return res + + else: + res = super(MultipleReferencePerProduct, self).create(values) + return res + + def write(self, values): + multiple_references_name = values.get('multiple_references_name') + multiple_references_name = [multiple_references_name] if multiple_references_name else self.mapped('name') + + product_id = values.get('product_id') + product_ids = [product_id] if product_id else self.mapped('product_id').ids + + reference_code = self.search([('multiple_references_name', 'in', multiple_references_name), ('product_id', 'in', product_ids)]) + + if reference_code: + return False + + return super(MultipleReferencePerProduct, self).write(values) + + +class ProductProductInherit(models.Model): + _inherit = 'product.product' + + multiple_references_ids = fields.One2many("multiple.reference.per.product", "product_id", string="Multiple " + "References") + multiple_references_code = fields.Char(string="Multiple References", related="multiple_references_ids" + ".multiple_references_name") + multiple_references_id = fields.Many2many("multiple.reference.per.product", string="Multiple References", + compute="_get_multiple_reference") + multiple_references_count = fields.Integer(string="NUmber of references", compute="_get_multiple_reference_count") + + @api.depends('multiple_references_id') + def _get_multiple_reference_count(self): + """Get the count of reference code""" + self.multiple_references_count = len(self.multiple_references_ids) + + def _get_multiple_reference(self): + self.multiple_references_id = self.multiple_references_ids.filtered(lambda references: references.multiple_references_name != self.default_code).ids + + def multiple_references_list(self): + return { + 'name': "Multiple References", + 'type': 'ir.actions.act_window', + 'target': 'current', + 'res_model': 'multiple.reference.per.product', + 'views': [[False, "tree"], [False, "form"]], + 'context': {'default_product_id': self.id}, + 'domain': [('product_id', '=', self.id)], + } + + def write(self, values): + if values.get('default_code'): + if self.default_code: + self.env['multiple.reference.per.product'].sudo().create_reference(self.default_code, self.id) + # print(values) + res = super(ProductProductInherit, self).write(values) + return res + + +class ProductTemplateInherit(models.Model): + _inherit = 'product.template' + + multiple_references_code = fields.Char(string="Multiple References", related="product_variant_ids" + ".multiple_references_ids" + ".multiple_references_name") + multiple_references_id = fields.Many2many("multiple.reference.per.product", string="Multiple References", + compute="_get_multiple_reference") + multiple_references_count = fields.Integer(string="NUmber of references", compute="_get_multiple_reference_count") + + @api.depends('multiple_references_id') + def _get_multiple_reference_count(self): + self.multiple_references_count = len(self.multiple_references_id) + # print("Count",self.multiple_references_count) + + def _get_multiple_reference(self): + self.multiple_references_id = self.product_variant_ids.mapped('multiple_references_id').filtered(lambda references: references.multiple_references_name != self.default_code).ids + + def multiple_references_list(self): + return { + 'name': "Multiple References", + 'type': 'ir.actions.act_window', + 'target': 'current', + 'res_model': 'multiple.reference.per.product', + 'views': [[False, "tree"], [False, "form"]], + 'context': {'default_product_id': self.product_variant_id.id}, + 'domain': [('product_id', '=', self.product_variant_id.id)], + } + + diff --git a/multiple_reference_per_product/security/ir.model.access.csv b/multiple_reference_per_product/security/ir.model.access.csv new file mode 100644 index 000000000..9efdd3ccd --- /dev/null +++ b/multiple_reference_per_product/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_multiple_reference_per_product,multiple.reference.per.product,model_multiple_reference_per_product,,1,1,1,1 \ No newline at end of file diff --git a/multiple_reference_per_product/static/description/banner.png b/multiple_reference_per_product/static/description/banner.png new file mode 100644 index 000000000..eaa2fd323 Binary files /dev/null and b/multiple_reference_per_product/static/description/banner.png differ diff --git a/multiple_reference_per_product/static/description/icon.png b/multiple_reference_per_product/static/description/icon.png new file mode 100644 index 000000000..f4c26a48d Binary files /dev/null and b/multiple_reference_per_product/static/description/icon.png differ diff --git a/multiple_reference_per_product/static/description/images/banner_product_brand_ecommerce.png b/multiple_reference_per_product/static/description/images/banner_product_brand_ecommerce.png new file mode 100644 index 000000000..549aba8a3 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/banner_product_brand_ecommerce.png differ diff --git a/multiple_reference_per_product/static/description/images/banner_product_brand_inventory.png b/multiple_reference_per_product/static/description/images/banner_product_brand_inventory.png new file mode 100644 index 000000000..525083a35 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/banner_product_brand_inventory.png differ diff --git a/multiple_reference_per_product/static/description/images/banner_product_brand_invoicing.png b/multiple_reference_per_product/static/description/images/banner_product_brand_invoicing.png new file mode 100644 index 000000000..266fc6958 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/banner_product_brand_invoicing.png differ diff --git a/multiple_reference_per_product/static/description/images/banner_product_brand_sale.png b/multiple_reference_per_product/static/description/images/banner_product_brand_sale.png new file mode 100644 index 000000000..407700502 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/banner_product_brand_sale.png differ diff --git a/multiple_reference_per_product/static/description/images/banner_product_multi_uom_pos.png b/multiple_reference_per_product/static/description/images/banner_product_multi_uom_pos.png new file mode 100644 index 000000000..a7e36775f Binary files /dev/null and b/multiple_reference_per_product/static/description/images/banner_product_multi_uom_pos.png differ diff --git a/multiple_reference_per_product/static/description/images/banner_website_product_attachments.png b/multiple_reference_per_product/static/description/images/banner_website_product_attachments.png new file mode 100644 index 000000000..7e036d030 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/banner_website_product_attachments.png differ diff --git a/multiple_reference_per_product/static/description/images/checked.png b/multiple_reference_per_product/static/description/images/checked.png new file mode 100644 index 000000000..578cedb80 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/checked.png differ diff --git a/multiple_reference_per_product/static/description/images/cybro_mrpp_005.png b/multiple_reference_per_product/static/description/images/cybro_mrpp_005.png new file mode 100644 index 000000000..0649afe82 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/cybro_mrpp_005.png differ diff --git a/multiple_reference_per_product/static/description/images/cybro_mrpp_01.png b/multiple_reference_per_product/static/description/images/cybro_mrpp_01.png new file mode 100644 index 000000000..223babf7a Binary files /dev/null and b/multiple_reference_per_product/static/description/images/cybro_mrpp_01.png differ diff --git a/multiple_reference_per_product/static/description/images/cybro_mrpp_02.png b/multiple_reference_per_product/static/description/images/cybro_mrpp_02.png new file mode 100644 index 000000000..547c1148a Binary files /dev/null and b/multiple_reference_per_product/static/description/images/cybro_mrpp_02.png differ diff --git a/multiple_reference_per_product/static/description/images/cybro_mrpp_03.png b/multiple_reference_per_product/static/description/images/cybro_mrpp_03.png new file mode 100644 index 000000000..3b9450009 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/cybro_mrpp_03.png differ diff --git a/multiple_reference_per_product/static/description/images/cybro_mrpp_04.png b/multiple_reference_per_product/static/description/images/cybro_mrpp_04.png new file mode 100644 index 000000000..7b5883259 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/cybro_mrpp_04.png differ diff --git a/multiple_reference_per_product/static/description/images/cybro_mrpp_05.png b/multiple_reference_per_product/static/description/images/cybro_mrpp_05.png new file mode 100644 index 000000000..0649afe82 Binary files /dev/null and b/multiple_reference_per_product/static/description/images/cybro_mrpp_05.png differ diff --git a/multiple_reference_per_product/static/description/images/cybrosys.png b/multiple_reference_per_product/static/description/images/cybrosys.png new file mode 100644 index 000000000..d76b5bafb Binary files /dev/null and b/multiple_reference_per_product/static/description/images/cybrosys.png differ diff --git a/multiple_reference_per_product/static/description/index.html b/multiple_reference_per_product/static/description/index.html new file mode 100644 index 000000000..084f3fb3f --- /dev/null +++ b/multiple_reference_per_product/static/description/index.html @@ -0,0 +1,315 @@ +
cybrosys-logo
+
+
+
+

Multiple Reference Per Product

+

Add multiple reference for a single product or product variant

+
+

Key Highlights

+
    +
  • Add multiple reference code for a product.
  • +
  • Easily manage between different reference code.
  • +
  • Set default code for product from these reference codes.
  • +
  • Search products with any of the multiple reference codes.
  • +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +

Overview

+
+

+ This module helps you to maintain multiple reference codes for a single product or product variant with which you can easily filter them out from the product menu. Also manage between different codes as default codes for the product. +

+
+
+ +

Multiple Reference Per Product

+
+
    + +
  • + Add multiple reference code for a product. +
  • + +
  • + Easily manage between different reference code. +
  • + +
  • + Set default code for product from these reference codes. +
  • + +
  • + Search products with any of the multiple reference codes. +
  • + +
+
+ +
+
+

Screenshots

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

Suggested Products

+
+ +
+
+

Our Service

+
+ +
+
+
+

Our Industries

+
+ +
+
+
+ +
+
+

Trading

+

Easily procure and sell your products.

+
+
+
+
+ +
+
+

Manufacturing

+

Plan, track and schedule your operations.

+
+
+
+
+ +
+
+

Restaurant

+

Run your bar or restaurant methodical.

+
+
+
+
+ +
+
+

POS

+

Easy configuring and convivial selling.

+
+
+
+
+ +
+
+

E-commerce & Website

+

Mobile friendly, awe-inspiring product pages.

+
+
+
+
+ +
+
+

Hotel Management

+

An all-inclusive hotel management application.

+
+
+
+
+ +
+
+

Education

+

A Collaborative platform for educational management.

+
+
+
+
+ +
+
+

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 / info@cybrosys.com

+
+
+

Contact Us

+ www.cybrosys.com +
+
+
+
+
+
+
+
+
+ +
+ + + + + + + +
+
+
+ \ No newline at end of file diff --git a/multiple_reference_per_product/views/multiple_reference_per_product.xml b/multiple_reference_per_product/views/multiple_reference_per_product.xml new file mode 100644 index 000000000..3e0fa1b29 --- /dev/null +++ b/multiple_reference_per_product/views/multiple_reference_per_product.xml @@ -0,0 +1,87 @@ + + + + + + multiple.reference.tree.view + multiple.reference.per.product + + + + + + + + + + + multiple.reference.form.view + multiple.reference.per.product + +
+ + + + + + + + + +