[FW][FIX] website: align website dashboard actions and list view
Before this commit, click on a button stat from the website dashboard, don't always respect the current filter. Date filter was missing, website_id wrongly filtered, or domain not exactly the same. Now, we try to align the dashboard data with the actions. -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr closes odoo/odoo#61936 Forward-port-of: odoo/odoo#61883 Forward-port-of: odoo/odoo#61333 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com> Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ var ajax = require('web.ajax');
|
||||
var core = require('web.core');
|
||||
var Dialog = require('web.Dialog');
|
||||
var field_utils = require('web.field_utils');
|
||||
var pyUtils = require('web.py_utils');
|
||||
var session = require('web.session');
|
||||
var time = require('web.time');
|
||||
var web_client = require('web.web_client');
|
||||
@@ -353,6 +354,7 @@ var Dashboard = AbstractAction.extend({
|
||||
|
||||
on_dashboard_action: function (ev) {
|
||||
ev.preventDefault();
|
||||
var self = this
|
||||
var $action = $(ev.currentTarget);
|
||||
var additional_context = {};
|
||||
if (this.date_range === 'week') {
|
||||
@@ -362,9 +364,18 @@ var Dashboard = AbstractAction.extend({
|
||||
} else if (this.date_range === 'year') {
|
||||
additional_context = {search_default_year: true};
|
||||
}
|
||||
this.do_action($action.attr('name'), {
|
||||
additional_context: additional_context,
|
||||
on_reverse_breadcrumb: this.on_reverse_breadcrumb
|
||||
this._rpc({
|
||||
route: '/web/action/load',
|
||||
params: {
|
||||
'action_id': $action.attr('name'),
|
||||
},
|
||||
})
|
||||
.then(function (action) {
|
||||
action.domain = pyUtils.assembleDomains([action.domain, `[('website_id', '=', ${self.website_id})]`]);
|
||||
return self.do_action(action, {
|
||||
'additional_context': additional_context,
|
||||
'on_reverse_breadcrumb': self.on_reverse_breadcrumb
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class WebsiteSaleBackend(WebsiteBackend):
|
||||
sale_report_domain = [
|
||||
('website_id', '=', current_website.id),
|
||||
('state', 'in', ['sale', 'done']),
|
||||
('date', '>=', date_from),
|
||||
('date', '>=', datetime_from),
|
||||
('date', '<=', fields.Datetime.now())
|
||||
]
|
||||
report_product_lines = request.env['sale.report'].read_group(
|
||||
@@ -67,7 +67,6 @@ class WebsiteSaleBackend(WebsiteBackend):
|
||||
# Sale-based results computation
|
||||
sale_order_domain = [
|
||||
('website_id', '=', current_website.id),
|
||||
('team_id', 'in', request.env['crm.team'].search([('website_ids', '!=', False)]).ids),
|
||||
('date_order', '>=', fields.Datetime.to_string(datetime_from)),
|
||||
('date_order', '<=', fields.Datetime.to_string(datetime_to))]
|
||||
so_group_data = request.env['sale.order'].read_group(sale_order_domain, fields=['state'], groupby='state')
|
||||
@@ -82,8 +81,8 @@ class WebsiteSaleBackend(WebsiteBackend):
|
||||
domain=[
|
||||
('website_id', '=', current_website.id),
|
||||
('state', 'in', ['sale', 'done']),
|
||||
('date', '>=', date_from),
|
||||
('date', '<=', date_to)],
|
||||
('date', '>=', datetime_from),
|
||||
('date', '<=', datetime_to)],
|
||||
fields=['team_id', 'price_subtotal'],
|
||||
groupby=['team_id'],
|
||||
)
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
<separator/>
|
||||
<filter string="From Website" name="from_website" domain="[('website_id', '!=', False)]"/>
|
||||
<separator/>
|
||||
<!-- Dashboard filter - used by context -->
|
||||
<filter string="Last Week" invisible="1" name="week" domain="[('date_order','>', (context_today() - datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
<filter string="Last Month" invisible="1" name="month" domain="[('date_order','>', (context_today() - datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
<filter string="Last Year" invisible="1" name="year" domain="[('date_order','>', (context_today() - datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -73,6 +77,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Dashboard Action -->
|
||||
<record id="action_unpaid_orders_ecommerce" model="ir.actions.act_window">
|
||||
<field name="name">Unpaid Orders</field>
|
||||
<field name="res_model">sale.order</field>
|
||||
@@ -111,11 +116,12 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Dashboard Action -->
|
||||
<record id="sale_order_action_to_invoice" model="ir.actions.act_window">
|
||||
<field name="name">Orders To Invoice</field>
|
||||
<field name="res_model">sale.order</field>
|
||||
<field name="view_mode">tree,form,kanban</field>
|
||||
<field name="domain">[('state', 'in', ('sale', 'done')), ('invoice_status', '=', 'to invoice'), ('website_id', '!=', False)]</field>
|
||||
<field name="domain">[('state', 'in', ('sale', 'done')), ('order_line', '!=', False), ('invoice_status', '=', 'to invoice'), ('website_id', '!=', False)]</field>
|
||||
<field name="context">{'show_sale': True, 'search_default_order_confirmed': 1, 'create': False}</field>
|
||||
<field name="search_view_id" ref="view_sales_order_filter_ecommerce"/>
|
||||
<field name="help" type="html">
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
<filter string="Status" name="groupby_status" context="{'group_by':'state'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Order Date" name="groupby_order_date" context="{'group_by':'date'}"/>
|
||||
<!-- Dashboard filter - used by context -->
|
||||
<filter string="Last Week" invisible="1" name="week" domain="[('date','>=', (context_today() - datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
<filter string="Last Month" invisible="1" name="month" domain="[('date','>=', (context_today() - datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
<filter string="Last Year" invisible="1" name="year" domain="[('date','>=', (context_today() - datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user