summaryrefslogtreecommitdiff
path: root/addons/website_sale/models
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2020-03-11 07:36:03 +0000
committerSamuel Degueldre <sad@odoo.com>2020-06-10 11:44:33 +0000
commitc058f19bfa33b510addfed314aa27d7e5c7fdb18 (patch)
treedc27563d414038ff848da560bf481de01d2aaa2e /addons/website_sale/models
parent016ed1a00f7a098ad8423235c82cee083bfa7e4d (diff)
[IMP] website_sale: let users create and edit custom product ribbons
Previously, there was only one static "Sale" ribbon. Users might want to have many types of ribbons, for different levels of sales, or to indicate that a product is sold out. This commit lets the user create custom ribbons and use them on prodcuts on the shop page. Additionally, setting a ribbon on a product used to require a reload, this is no longer the case. All ribbon modifications are stored in a cache and the RPCs to put them into effect are only done on save. task-1981170 Part of odoo/odoo#47574 Related: odoo/upgrade#1079 Related: odoo/design-themes#219 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/website_sale/models')
-rw-r--r--addons/website_sale/models/product.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py
index effe4749833..57398dc3130 100644
--- a/addons/website_sale/models/product.py
+++ b/addons/website_sale/models/product.py
@@ -9,12 +9,14 @@ from odoo.tools.translate import html_translate
from odoo.osv import expression
-class ProductStyle(models.Model):
- _name = "product.style"
- _description = 'Product Style'
+class ProductRibbon(models.Model):
+ _name = "product.ribbon"
+ _description = 'Product ribbon'
- name = fields.Char(string='Style Name', required=True)
- html_class = fields.Char(string='HTML Classes')
+ html = fields.Char(string='Ribbon html', required=True)
+ bg_color = fields.Char(string='Ribbon background color', required=False)
+ text_color = fields.Char(string='Ribbon text color', required=False)
+ html_class = fields.Char(string='Ribbon class', required=True, default='')
class ProductPricelist(models.Model):
@@ -186,7 +188,7 @@ class ProductTemplate(models.Model):
help='Accessories show up when the customer reviews the cart before payment (cross-sell strategy).')
website_size_x = fields.Integer('Size X', default=1)
website_size_y = fields.Integer('Size Y', default=1)
- website_style_ids = fields.Many2many('product.style', string='Styles')
+ website_ribbon_id = fields.Many2one('product.ribbon', string='Ribbon')
website_sequence = fields.Integer('Website Sequence', help="Determine the display order in the Website E-commerce",
default=lambda self: self._default_website_sequence(), copy=False)
public_categ_ids = fields.Many2many(