Files
odoo_source/addons/website_livechat/views/website_livechat.xml
T
Samuel Degueldre a1e7e3ef7e [FIX] web, *: tours correctly break when there are missing deps
*: im_livechat, website_livechat, website_slides

In c989ff3, the odoo module system has been changed so that it now
errors out when modules are defined but have missing dependencies and
cannot run. Unfortunately, tours are defined in a single bundle,
`assets_tests`, and this bundle is used everywhere tours need to run,
but some of these tours depend on modules that only exist in the backend
and others on modules that only exist in the frontend. We don't want to
break up the `assets_tests` bundle as this creates a poor developer
experience, and so the solution that was chosen at the time is that when
the `assets_tests` bundle is defined, we ignore all module dependency
errors.

This causes a problem however, which is that if a module dependency is
missing in production code, the page will be broken by the module error
(which is expected) but if the `assets_tests` are present, which is the
case when running tours and tests, then it won't, meaning the tours will
happily pass despite the application being broken, which is
unacceptable.

This commit fixes this issue by replacing the assets_test bundle by a
new bundle (`__assets_tests_call__`) within which all module dependency
errors are ignored, which lets dependency errors that are hapenning in
other bundles (ie in production code) happen even during the tests.

Because of this, this commit also fixes the dependency errors that
already existed but were previously silent:

- for im_livechat and website_livechat, the code was refactored to use
the standard mechanism that we use elsewhere to add data directly in the
page: we store the data in __session_info__, and the module that exposes
that data is always present, instead of having a module that's defined
conditionally, which causes issues when non-conditional modules depend
on it.
- in web, the `report_assets_common` bundle was used alongside
`assets_common` but without `assets_frontend` or `assets_backend`.
Reports do not need any js and it appears that it already had what it
needed as far as css is concerned except for one fontawesome override.
Code was changed so that the js from the bundle is not included and it
reports no longer use `assets_common`, the js part of the bundle is no
longer used.
- in website_slides, the `slide_embed_assets` bundle is used alongside
`assets_common` without using `assets_frontend` or `assets_backend`
which is required for `assets_common` to function, the approach here was
to simply take the files from `assets_common` and remove the files that
were causing issues. This bundle should be trimmed at some point, as it
contains way too many things that it does not need.

The file colors.js was also moved to core, as it isn't graph specific
and was causing dependency issues with a field that was importing it.
Fields shouldn't depend on files in specific views' directory.

closes odoo/odoo#104794

Related: odoo/enterprise#33909
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-11-17 15:59:16 +01:00

180 lines
12 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!--
Integrate Livechat in Common Frontend for Website
Template registering all the assets required to execute the Livechat from a page containing Odoo
-->
<template id="loader" inherit_id="website.layout" name="Livechat : include loader on Website">
<xpath expr="//head">
<t t-if="not no_livechat and website and website.channel_id">
<script>
<t t-call="im_livechat.loader">
<t t-set="info" t-value="website.get_livechat_channel_info()"/>
</t>
</script>
</t>
</xpath>
</template>
<!-- Page Layout -->
<template id="channel_page" name="Livechat Channel Satisfaction Page">
<t t-call="website.layout">
<div id="wrap">
<div class="container">
<h1><span>Livechat Channel</span> <small t-field="channel.name" /></h1>
<div t-field="channel.website_description" class="oe_structure mt16" />
<div class="row mt32">
<div class="col-lg-8">
<t t-if="len(ratings) &gt; 0">
<div class="row">
<div class="col-lg-12 mb32">
<h3>Statistics</h3>
<div class="row">
<div class="col-lg-4 d-flex justify-content-end flex-column">
<div class="card bg-success text-white" t-attf-style="height: #{160 + int(percentage['great'])}px;">
<div class="card-body text-center">
<img src="/rating/static/src/img/rating_5.png" style="height:40px" alt="Happy face"/>
</div>
<div class="card-body text-center">
<h2 style="margin: 0">
<b style="font-size: 30px">
<t t-esc="percentage['great']" />
</b>
<small>%</small>
</h2>
</div>
</div>
</div>
<div class="col-lg-4 d-flex justify-content-end flex-column">
<div class="card bg-warning text-white" t-attf-style="height: #{160 + int(percentage['okay'])}px;">
<div class="card-body text-center">
<img src="/rating/static/src/img/rating_3.png" style="height:40px" alt="Neutral face"/>
</div>
<div class="card-body text-center">
<h2 style="margin: 0">
<b style="font-size: 30px">
<t t-esc="percentage['okay']" />
</b>
<small>%</small>
</h2>
</div>
</div>
</div>
<div class="col-lg-4 d-flex justify-content-end flex-column">
<div class="card bg-danger text-white" t-attf-style="height: #{160 + int(percentage['bad'])}px;">
<div class="card-body text-center">
<img src="/rating/static/src/img/rating_1.png" style="height:40px" alt="Sad face"/>
</div>
<div class="card-body text-center">
<h2 style="margin: 0">
<b style="font-size: 30px">
<t t-esc="percentage['bad']" />
</b>
<small>%</small>
</h2>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 mb32">
<h3>The <t t-esc="len(ratings)"/> last feedbacks</h3>
<div>
<t t-foreach="ratings" t-as="rating">
<img t-attf-src='/rating/static/src/img/rating_#{int(rating.rating)}.png' t-att-alt="rating.res_name" width="48px" height="48px"/>
<t t-if="(rating_index+1) % 5 == 0">
<br/>
</t>
</t>
</div>
</div>
</div>
</t>
<t t-if="len(ratings) == 0">
<h4 style="text-align:center">There are no ratings for this channel for now.</h4>
</t>
</div>
<div class="col-lg-4 mb32">
<h3>The Team</h3>
<t t-foreach="team" t-as="user">
<div class="d-flex mt-3">
<img t-att-src="image_data_uri(user.avatar_128)" class="o_image_64_cover rounded o_livechat_operator_avatar" t-att-alt="user.livechat_username or user.name"/>
<div class="flex-grow-1">
<h5>
<t t-if="user.livechat_username">
<t t-esc="user.livechat_username"/>
</t>
<t t-else="">
<t t-esc="user.name"/>
</t>
</h5>
<div class="col-lg-12">
<div class="row">
<t t-if="user.partner_id.id in ratings_per_user">
<div class="col-lg-4 ps-0 pe-0">
<img t-attf-src='/rating/static/src/img/rating_5.png' alt="Great" width="16px" height="16px"/>
<span class="align-middle"><t t-esc="ratings_per_user[user.partner_id.id]['great']"/>%</span>
</div>
<div class="col-lg-4 ps-0 pe-0">
<img t-attf-src='/rating/static/src/img/rating_3.png' alt="Okay" width="16px" height="16px"/>
<span class="align-middle"><t t-esc="ratings_per_user[user.partner_id.id]['okay']"/>%</span>
</div>
<div class="col-lg-4 ps-0 pe-0">
<img t-attf-src='/rating/static/src/img/rating_1.png' alt="Bad" width="16px" height="16px"/>
<span class="align-middle"><t t-esc="ratings_per_user[user.partner_id.id]['bad']"/>%</span>
</div>
</t>
<t t-else="">
<div class="col-lg-12 ps-0 pe-0 o_livechat_no_rating">Not rated yet</div>
</t>
</div>
</div>
</div>
</div>
</t>
</div>
</div>
</div>
</div>
</t>
</template>
<template id="channel_list_page" name="Livechat Channel List Page">
<t t-call="website.layout">
<div id="wrap">
<div class="oe_structure" id="oe_structure_website_livechat_channel_list_1"/>
<div class="container">
<h1 class="pt-3">Livechat Support Channels</h1>
<div class="row mt32 mb32">
<t t-if="not len(channels)">
<div class="col-lg-6 offset-lg-3">
There are no public livechat channels to show.
</div>
</t>
<t t-if="len(channels)">
<div class="col-lg-6">
<t t-foreach="channels" t-as="channel">
<div t-attf-class="d-flex#{' mt-3' if channel_index else ''}">
<a t-attf-href="/livechat/channel/#{ slug(channel)}">
<img t-att-src="channel.image_128 and image_data_uri(channel.image_128) or '/web/static/img/placeholder.png'" t-att-alt="channel.name" class="o_image_64_cover"/>
</a>
<div class="flex-grow-1 h-100 my-auto">
<h4><t t-esc="channel.name"/></h4>
</div>
</div>
</t>
</div>
</t>
</div>
</div>
<div class="oe_structure" id="oe_structure_website_livechat_channel_list_2"/>
</div>
</t>
</template>
</data>
</odoo>