Skip to content

Commit

Permalink
[FIX] website_sale: fix tb on dashboard when no sale access
Browse files Browse the repository at this point in the history
Before this commit, if you don't have the sale access right, when you arrive on
main website menu, the dashboard try to load some utms data and will fail with
a traceback.

Now we don't render utm graph it you don't have the sale access right

This commit closes #54695

X-original-commit: 8123bbc
  • Loading branch information
JKE-be committed Aug 12, 2020
1 parent b5f3b02 commit 8bbdfa3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion addons/website_sale/controllers/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ def fetch_dashboard_data(self, website_id, date_from, date_to):
order_per_day_ratio=0, order_sold_ratio=0, order_convertion_pctg=0,
)
)

results['dashboards']['sales'] = sales_values

results['dashboards']['sales']['utm_graph'] = self.fetch_utm_data(datetime_from, datetime_to)
results['groups']['sale_salesman'] = request.env['res.users'].has_group('sales_team.group_sale_salesman')

if not results['groups']['sale_salesman']:
return results

results['dashboards']['sales']['utm_graph'] = self.fetch_utm_data(datetime_from, datetime_to)
# Product-based computation
sale_report_domain = [
('website_id', '=', current_website.id),
Expand Down
2 changes: 1 addition & 1 deletion addons/website_sale/static/src/js/website_sale_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ WebsiteBackend.include({
render_graphs: function() {
this._super();
this.utmGraphData = this.dashboards_data.sales.utm_graph;
this._renderUtmGraph();
this.utmGraphData && this._renderUtmGraph();
},

//--------------------------------------------------------------------------
Expand Down

0 comments on commit 8bbdfa3

Please sign in to comment.