[FIX] (website_)event_booth(_sale): fix display default booth category image

PURPOSE

Before this commit when a booth category doesn't have an image a
traceback is shown when accessing to the /booths route.
After this commit a default image is shown when the booth category
doesn't have an image.

SPECIFICATION

To allow the public user to see the booth category image we give
everybody the read permission on the model but restrict some
sensitive fields.

LINKS

Task-2635461

Pr: odoo/odoo#77081
Related: odoo/upgrade#2869
Signed-off-by: awa-odoo <awa-odoo@users.noreply.github.com>
This commit is contained in:
Patrick Hoste
2021-10-04 15:30:26 +00:00
parent 1264eb9280
commit 7bfb6d7f01
5 changed files with 12 additions and 7 deletions
@@ -14,4 +14,5 @@ class EventBoothCategory(models.Model):
name = fields.Char(string='Name', required=True, translate=True)
sequence = fields.Integer(string='Sequence', default=10)
description = fields.Html(string='Description', translate=True)
booth_ids = fields.One2many('event.booth', 'booth_category_id', string='Booths')
booth_ids = fields.One2many(
'event.booth', 'booth_category_id', string='Booths', groups='event.group_event_registration_desk')
@@ -16,12 +16,15 @@ class EventBoothCategory(models.Model):
product_id = fields.Many2one(
'product.product', string='Product', required=True,
domain=[('detailed_type', '=', 'event_booth')], default=_default_product_id)
price = fields.Float(string='Price', compute='_compute_price', digits='Product Price', readonly=False, store=True)
currency_id = fields.Many2one(related='product_id.currency_id')
domain=[('detailed_type', '=', 'event_booth')], default=_default_product_id,
groups="event.group_event_registration_desk")
price = fields.Float(
string='Price', compute='_compute_price', digits='Product Price', readonly=False,
store=True, groups="event.group_event_registration_desk")
currency_id = fields.Many2one(related='product_id.currency_id', groups="event.group_event_registration_desk")
price_reduce = fields.Float(
string='Price Reduce', compute='_compute_price_reduce',
compute_sudo=True, digits='Product Price')
compute_sudo=True, digits='Product Price', groups="event.group_event_registration_desk")
image_1920 = fields.Image(compute='_compute_image_1920', readonly=False, store=True)
@api.depends('product_id')
@@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_event_booth_category,event.booth.category,event_booth.model_event_booth_category,,1,0,0,0
access_event_booth_all,event.booth.public,event_booth.model_event_booth,,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_event_booth_category event.booth.category event_booth.model_event_booth_category 1 0 0 0
3 access_event_booth_all event.booth.public event_booth.model_event_booth 1 0 0 0
@@ -61,7 +61,7 @@
<div>
<h5 name="booth_category_name" class="m-0 text-truncate" t-esc="booth_category.name"/>
<span class="img img-responsive">
<img class="img img-fluid mt-2" t-att-title="booth_category.name" t-att-src="image_data_uri(booth_category.image_256)"/>
<div t-field="booth_category.image_1920" t-options="{'widget': 'image', 'preview_image': 'image_256', 'class': 'mt-2'}"/>
</span>
</div>
<div t-if="booth_category_unavailable" class="o_ribbon_right bg-danger">
@@ -35,7 +35,7 @@ odoo.define("website_event_booth_exhibitor.tour", function (require) {
trigger: 'a:contains("Get A Booth")',
}, {
content: 'Choose Premium Booths',
trigger: 'img[title="Premium Booth"]',
trigger: 'img[alt="Premium Booth"]',
}, {
content: 'Choose Booth',
trigger: 'div:contains("OpenWood Demonstrator 2") input',