diff --git a/website_product_attachments/README.rst b/website_product_attachments/README.rst new file mode 100644 index 000000000..cb67fdfd1 --- /dev/null +++ b/website_product_attachments/README.rst @@ -0,0 +1,41 @@ +Product Attachments On Website +============================== +This Module allows customer to download documents +that are attached to the products from website + + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developers: Fasluca V10@ cybrosys, Contact: odoo@cybrosys.com + Kavya Raveendran V11@ cybrosys, Contact: odoo@cybrosys.com + Kavya Raveendran V12 @ cybrosys, Contact: odoo@cybrosys.com + Yadhukrishna V13 @cybrosys, odoo@cybrosys.com +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/website_product_attachments/__init__.py b/website_product_attachments/__init__.py new file mode 100644 index 000000000..fe8bc8d02 --- /dev/null +++ b/website_product_attachments/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: v10.0 Fasluca @ cybrosys,(odoo@cybrosys.com) +# v11.0 Kavya Raveendran @ cybrosys,(odoo@cybrosys.com) +# v12.0 Kavya Raveendran @ cybrosys,(odoo@cybrosys.com) +# v13.0 Yadhukrishna @ cybrosys,(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 . +# +############################################################################# +# -*- coding: utf-8 -*- +from . import controllers diff --git a/website_product_attachments/__manifest__.py b/website_product_attachments/__manifest__.py new file mode 100644 index 000000000..b95f544e7 --- /dev/null +++ b/website_product_attachments/__manifest__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Fasluca @ cybrosys,(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': 'Product Attachments on Website', + 'version': '13.0.1.0.0', + 'summary': """This Module Allows Customer to Download Documents + That Are Attached to the Products From Website""", + 'description': 'This Module allows customer to download documents ' + 'that are attached to the products from website', + 'category': 'Website', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['documents', 'website_sale'], + 'data': ['views/template.xml'], + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'demo': [], + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/website_product_attachments/controllers/__init__.py b/website_product_attachments/controllers/__init__.py new file mode 100644 index 000000000..3ec2da698 --- /dev/null +++ b/website_product_attachments/controllers/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: v10.0 Fasluca @ cybrosys,(odoo@cybrosys.com) +# v11.0 Kavya Raveendran @ cybrosys,(odoo@cybrosys.com) +# v12.0 Kavya Raveendran @ cybrosys,(odoo@cybrosys.com) +# v13.0 Yadhukrishna @ cybrosys,(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 . +# +############################################################################# +# -*- coding: utf-8 -*- +from . import website_product_attachment diff --git a/website_product_attachments/controllers/website_product_attachment.py b/website_product_attachments/controllers/website_product_attachment.py new file mode 100644 index 000000000..fac01aac5 --- /dev/null +++ b/website_product_attachments/controllers/website_product_attachment.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: v10.0 Fasluca @ cybrosys,(odoo@cybrosys.com) +# v11.0 Kavya Raveendran @ cybrosys,(odoo@cybrosys.com) +# v12.0 Kavya Raveendran @ cybrosys,(odoo@cybrosys.com) +# v13.0 Yadhukrishna @ cybrosys,(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 . +# +############################################################################# +# -*- coding: utf-8 -*- + +import base64 +from werkzeug.utils import redirect +import io +from odoo import http +from odoo.http import request +from odoo.addons.website.controllers.main import QueryURL +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteSale(WebsiteSale): + + @http.route(['/shop/product/'], type='http', auth="public", website=True) + def product(self, product, category='', search='', **kwargs): + product_context = dict(request.env.context, active_id=product.id) + ProductCategory = request.env['product.public.category'] + Rating = request.env['rating.rating'] + if category: + category = ProductCategory.browse(int(category)).exists() + + attrib_list = request.httprequest.args.getlist('attrib') + attrib_values = [map(int, v.split("-")) for v in attrib_list if v] + attrib_set = set([v[1] for v in attrib_values]) + keep = QueryURL('/shop', category=category and category.id, search=search, attrib=attrib_list) + categs = ProductCategory.search([('parent_id', '=', False)]) + pricelist = request.website.get_current_pricelist() + from_currency = request.env.user.company_id.currency_id + to_currency = pricelist.currency_id + compute_currency = lambda price: from_currency.compute(price, to_currency) + # get the rating attached to a mail.message, and the rating stats of the product + ratings = Rating.search([('message_id', 'in', product.website_message_ids.ids)]) + rating_message_values = dict([(record.message_id.id, record.rating) for record in ratings]) + rating_product = product.rating_get_stats([('website_published', '=', True)]) + if not product_context.get('pricelist'): + product_context['pricelist'] = pricelist.id + product = product.with_context(product_context) + + attachments = request.env['ir.attachment'].search( + [('res_model', '=', 'product.template'), + ('res_id', '=', product.id)], order='id') + + values = { + 'search': search, + 'category': category, + 'pricelist': pricelist, + 'attrib_values': attrib_values, + 'compute_currency': compute_currency, + 'attrib_set': attrib_set, + 'keep': keep, + 'categories': categs, + 'main_object': product, + 'product': product, + '_get_attribute_exclusions': self._get_attribute_exclusion, + 'rating_message_values': rating_message_values, + 'rating_product': rating_product, + 'attachments': attachments + } + return request.render("website_sale.product", values) + + def _get_attribute_exclusion(self, product, reference_product=None): + parent_combination = request.env['product.template.attribute.value'] + if reference_product: + parent_combination |= reference_product.product_template_attribute_value_ids + if reference_product.env.context.get('no_variant_attribute_values'): + # Add "no_variant" attribute values' exclusions + # They are kept in the context since they are not linked to this product variant + parent_combination |= reference_product.env.context.get('no_variant_attribute_values') + return product._get_attribute_exclusions(parent_combination) + + @http.route(['/attachment/download',], type='http', auth='public') + def download_attachment(self, attachment_id): + # Check if this is a valid attachment id + attachment = request.env['ir.attachment'].sudo().search_read( + [('id', '=', int(attachment_id))], + ["name", "datas", "res_model", "res_id", "type", "url"] + ) + + if attachment: + attachment = attachment[0] + else: + return redirect('/shop') + + if attachment["type"] == "url": + if attachment["url"]: + return redirect(attachment["url"]) + else: + return request.not_found() + elif attachment["datas"]: + data = io.BytesIO(base64.standard_b64decode(attachment["datas"])) + return http.send_file(data, filename=attachment['name'], as_attachment=True) + else: + return request.not_found() + + + diff --git a/website_product_attachments/doc/RELEASE_NOTES.md b/website_product_attachments/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..6df1b3b47 --- /dev/null +++ b/website_product_attachments/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 13.11.2019 +#### Version 13.0.1.0.0 +#### ADD +Initial Commit for website_product_attachments. diff --git a/website_product_attachments/static/description/banner.png b/website_product_attachments/static/description/banner.png new file mode 100644 index 000000000..4ff3070c1 Binary files /dev/null and b/website_product_attachments/static/description/banner.png differ diff --git a/website_product_attachments/static/description/cybro_logo.png b/website_product_attachments/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/website_product_attachments/static/description/cybro_logo.png differ diff --git a/website_product_attachments/static/description/icon.png b/website_product_attachments/static/description/icon.png new file mode 100644 index 000000000..ba0ae1879 Binary files /dev/null and b/website_product_attachments/static/description/icon.png differ diff --git a/website_product_attachments/static/description/index.html b/website_product_attachments/static/description/index.html new file mode 100644 index 000000000..361435e6f --- /dev/null +++ b/website_product_attachments/static/description/index.html @@ -0,0 +1,346 @@ +
+
+

+ Product Attachments on Website +

+

+ Download attachments of products from website. +

+
+ Cybrosys Technologies +
+ +
+ cybrosys technologies
+
+
+
+ +
+
+

+ Overview +

+

+ This Module allows customers to download documents from website that are attached to relevant products +

+

+ Configuration +

+

+ No additional configuration required. +

+
+
+ +
+
+

+ Features +

+

+ + Allows users to attach documents. +

+

+ + Download attachments from website. +

+
+
+ +
+
+

+ Screenshots +

+

+ + Attach your documents like, product specification on product master. +

+
+ +
+

+ + Allow to attach multiple documents for products. +

+
+ +
+

+ + Visitors of your e-commerce portal can download these attachments. +

+
+ +
+
+
+ + +
+
+ cybrosys technologies +
+
+
+
+

+ Our Services +

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

+ + Odoo Support +

+ +
+ +
+
+
+
+
+

+ 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. +

+
+
+
+
+
+
+ +
diff --git a/website_product_attachments/static/description/website-product-attachments-1.png b/website_product_attachments/static/description/website-product-attachments-1.png new file mode 100644 index 000000000..406e10ce1 Binary files /dev/null and b/website_product_attachments/static/description/website-product-attachments-1.png differ diff --git a/website_product_attachments/static/description/website-product-attachments-2.png b/website_product_attachments/static/description/website-product-attachments-2.png new file mode 100644 index 000000000..e08d3c58f Binary files /dev/null and b/website_product_attachments/static/description/website-product-attachments-2.png differ diff --git a/website_product_attachments/static/description/website-product-attachments-3.png b/website_product_attachments/static/description/website-product-attachments-3.png new file mode 100644 index 000000000..ca7cb1871 Binary files /dev/null and b/website_product_attachments/static/description/website-product-attachments-3.png differ diff --git a/website_product_attachments/views/template.xml b/website_product_attachments/views/template.xml new file mode 100644 index 000000000..3a1cb8eb4 --- /dev/null +++ b/website_product_attachments/views/template.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file