)
#
# This program is free software: you can modify
# it under the terms of the GNU Affero General Public License (AGPL) as
@@ -20,57 +19,81 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
-###################################################################################
-
+################################################################################
from odoo import fields, models, api
from ast import literal_eval
class ProductVisibility(models.Model):
+ """Inherit res.partner for adding the fields for selecting the products"""
_inherit = 'res.partner'
filter_mode = fields.Selection(
[('null', 'No Filter'), ('product_only', 'Product Wise'),
- ('categ_only', 'Category Wise')], string='Filter Mode', default='null')
+ ('categ_only', 'Category Wise')], string='Filter Mode', default='null',
+ help="Select any mode")
website_available_product_ids = fields.Many2many('product.template',
string='Available Product',
- domain="[('is_published', '=', True)]",
- help='The website will only display products which are within one '
- 'of the selected category trees. If no category is specified,'
- ' all available products will be shown')
+ domain="[('is_published"
+ "', '=', True)]",
+ help='The website will '
+ 'only display '
+ 'products which are '
+ 'within one'
+ 'of the selected '
+ 'category trees. If '
+ 'no category is '
+ 'specified,'
+ 'all available '
+ 'products will be '
+ 'shown')
website_available_cat_ids = fields.Many2many('product.public.category',
- string='Available Product Categories',
- help='The website will only display products which are selected.'
- ' If no product is specified,'
- ' all available products will be shown')
+ string='Available Product '
+ 'Categories',
+ help='The website will only '
+ 'display products which '
+ 'are selected.'
+ 'If no product is '
+ 'specified,'
+ 'all available products '
+ 'will be shown')
@api.onchange("filter_mode")
def onchange_filter_mod(self):
+ """Function for viewing the modes and product/category"""
if self.filter_mode == 'null':
self.website_available_cat_ids = None
self.website_available_product_ids = None
class WebsiteGuestVisibility(models.TransientModel):
+ """Inherit the model res.config.settings for adding the fields for
+ selecting the product for visitors"""
_inherit = 'res.config.settings'
product_visibility_guest_user = fields.Boolean(
- string="Product visibility Guest User")
+ string="Product visibility Guest User", help="Product Visibility")
filter_mode = fields.Selection([('product_only', 'Product Wise'),
('categ_only', 'Category Wise')],
string='Filter Mode', default='product_only')
-
available_product_ids = fields.Many2many('product.template',
string='Available Product',
- domain="[('is_published', '=', True)]",
- help='The website will only display products which are within one '
- 'of the selected category trees. If no category is specified,'
- ' all available products will be shown')
+ domain="[('is_published', '=', "
+ "True)]",
+ help='The website will only '
+ 'display products which are '
+ 'within one of the selected'
+ ' category trees. If no'
+ ' category is specified,'
+ 'all available products '
+ 'will be shown')
available_cat_ids = fields.Many2many('product.public.category',
string='Available Product Categories',
- help='The website will only display products which are selected.'
+ help='The website will only display '
+ 'products which are selected.'
' If no product is specified,'
- ' all available products will be shown')
+ 'all available products will be '
+ 'shown')
@api.model
def set_values(self):
@@ -89,7 +112,6 @@ class WebsiteGuestVisibility(models.TransientModel):
self.available_cat_ids = None
elif self.filter_mode == 'categ_only':
self.available_product_ids = None
-
self.env['ir.config_parameter'].sudo().set_param(
'website_product_visibility.available_product_ids',
self.available_product_ids.ids)
diff --git a/product_visibility_website/static/description/index.html b/product_visibility_website/static/description/index.html
index a5f99de37..585f255bd 100644
--- a/product_visibility_website/static/description/index.html
+++ b/product_visibility_website/static/description/index.html
@@ -135,7 +135,6 @@
-
@@ -399,7 +398,7 @@
-
+
@@ -526,7 +525,7 @@
-
+
diff --git a/product_visibility_website/views/website_product_visibility.xml b/product_visibility_website/views/website_product_visibility.xml
index 0c314da20..e47373ceb 100644
--- a/product_visibility_website/views/website_product_visibility.xml
+++ b/product_visibility_website/views/website_product_visibility.xml
@@ -1,8 +1,8 @@
-
- base.view.partner.form.inherit
+
+ res.partner.view.form.inherit.product.visibility.website
res.partner
@@ -22,9 +22,8 @@
-
-
- website.config.view.inherit
+
+ res.config.settings.view.form.inherit.product.visibility.website
res.config.settings
@@ -63,4 +62,4 @@
-
\ No newline at end of file
+