From 31374c2eeffe824188b1a43768bc216a86d29b03 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 28 Jan 2014 12:10:22 +0100 Subject: [PATCH 01/28] [IMP] this commit translates the hardcoded strings that appears in graph view (addon web_graph) bzr revid: ged@openerp.com-20140128111022-ghoxwvlmywzr2yke --- .../web_graph/static/src/js/graph_widget.js | 31 ++++++++++--------- addons/web_graph/static/src/js/pivot_table.js | 9 ++++-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index 454af202593..c17fd0bcf43 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -4,6 +4,9 @@ (function () { 'use strict'; var QWeb = openerp.web.qweb; +var _lt = openerp.web._lt; +var _t = openerp.web._t; + nv.dev = false; // sets nvd3 library in production mode openerp.web_graph.Graph = openerp.web.Widget.extend({ @@ -39,7 +42,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return this.model.call('fields_get', []).then(function (f) { self.fields = f; - self.fields.__count = {field:'__count', type: 'integer', string:'Quantity'}; + self.fields.__count = {field:'__count', type: 'integer', string:_t('Quantity')}; self.important_fields = self.get_search_fields(); self.measure_list = self.get_measures(); self.add_measures_to_options(); @@ -381,11 +384,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // Drawing the table // ---------------------------------------------------------------------- draw_table: function () { - this.pivot.main_row().title = 'Total'; + this.pivot.main_row().title = _t('Total'); if (this.pivot.measures.length == 1) { this.pivot.main_col().title = this.pivot.measures[0].string; } else { - this.pivot.main_col().title = this.title; + this.pivot.main_col().title = _t(this.title); } this.draw_top_headers(); _.each(this.pivot.rows.headers, this.proxy('draw_row')); @@ -449,7 +452,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ } else { make_cells(pivot.main_col().children, 1); if (pivot.get_cols_leaves().length > 1) { - header_cells[0].push(self.make_border_cell(pivot.measures.length, height, true).text('Total').css('font-weight', 'bold')); + header_cells[0].push(self.make_border_cell(pivot.measures.length, height, true).text(_t('Total')).css('font-weight', 'bold')); } } @@ -554,8 +557,8 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // No groupby if ((dim_x === 0) && (dim_y === 0)) { - data = [{key: 'Total', values:[{ - x: 'Total', + data = [{key: _t('Total'), values:[{ + x: _t('Total'), y: this.pivot.get_total(), }]}]; // Only column groupbys @@ -570,7 +573,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ } else if ((dim_x === 1) && (dim_y === 0)) { data = _.map(this.pivot.main_row().children, function (pt) { var value = self.pivot.get_total(pt), - title = (pt.title !== undefined) ? pt.title : 'Undefined'; + title = (pt.title !== undefined) ? pt.title : _t('Undefined'); return {x: title, y: value}; }); data = [{key: self.pivot.measures[0].string, values:data}]; @@ -579,24 +582,24 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ data = _.map(this.pivot.get_cols_with_depth(1), function (colhdr) { var values = _.map(self.pivot.get_rows_with_depth(1), function (header) { return { - x: header.title || 'Undefined', + x: header.title || _t('Undefined'), y: self.pivot.get_values(header.id, colhdr.id)[0] || 0 }; }); - return {key: colhdr.title || 'Undefined', values: values}; + return {key: colhdr.title || _t('Undefined'), values: values}; }); // At least two row groupby } else { var keys = _.uniq(_.map(this.pivot.get_rows_with_depth(2), function (hdr) { - return hdr.title || 'Undefined'; + return hdr.title || _t('Undefined'); })); data = _.map(keys, function (key) { var values = _.map(self.pivot.get_rows_with_depth(1), function (hdr) { var subhdr = _.find(hdr.children, function (child) { - return ((child.title === key) || ((child.title === undefined) && (key === 'Undefined'))); + return ((child.title === key) || ((child.title === undefined) && (key === _t('Undefined')))); }); return { - x: hdr.title || 'Undefined', + x: hdr.title || _t('Undefined'), y: (subhdr) ? self.pivot.get_total(subhdr)[0] : 0 }; }); @@ -640,7 +643,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return {x: row.title, y: self.pivot.get_values(row.id,col.id)[0] || 0}; }); var title = _.map(col.path, function (p) { - return p || 'Undefined'; + return p || _t('Undefined'); }).join('/'); if (dim_y === 0) { title = self.pivot.measures[0].string; @@ -670,7 +673,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ dim_x = this.pivot.rows.groupby.length; var data = _.map(this.pivot.get_rows_leaves(), function (row) { var title = _.map(row.path, function (p) { - return p || 'Undefined'; + return p || _t('Undefined'); }).join('/'); if (dim_x === 0) { title = self.measure_label; diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js index a5bfba3c09a..89ca36f3b61 100644 --- a/addons/web_graph/static/src/js/pivot_table.js +++ b/addons/web_graph/static/src/js/pivot_table.js @@ -4,6 +4,9 @@ (function () { 'use strict'; +var _lt = openerp.web._lt; +var _t = openerp.web._t; + // PivotTable requires a call to update_data after initialization openerp.web_graph.PivotTable = openerp.web.Class.extend({ @@ -13,7 +16,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ this.no_data = true; this.model = model; this.fields = fields; - this.fields.__count = {type: 'integer', string:'Quantity'}; + this.fields.__count = {type: 'integer', string:_t('Quantity')}; this.measures = options.measures || []; this.rows = { groupby: options.row_groupby, headers: null }; this.cols = { groupby: options.col_groupby, headers: null }; @@ -397,11 +400,11 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ grouped_on = attrs.grouped_on ? this.raw_field(attrs.grouped_on) : false; if (value === false) { - group.attributes.value = 'undefined'; + group.attributes.value = _t('undefined'); } else if (grouped_on && this.fields[grouped_on].type === 'selection') { var selection = this.fields[grouped_on].selection, value_lookup = _.where(selection, {0:value}); - group.attributes.value = value_lookup ? value_lookup[0][1] : 'undefined'; + group.attributes.value = value_lookup ? value_lookup[0][1] : _t('undefined'); } else if (value instanceof Array) { group.attributes.value = value[1]; } From ad76309fbe29f6d4d2d26393bc8d2b1c595a124f Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 28 Jan 2014 14:26:25 +0100 Subject: [PATCH 02/28] [IMP] makes the graph view in pivot table mode always display 'Total' instead of the current measure/title (addon web_graph) bzr revid: ged@openerp.com-20140128132625-pk21iuhuffvx6814 --- addons/web_graph/static/src/js/graph_widget.js | 7 ------- addons/web_graph/static/src/js/pivot_table.js | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index c17fd0bcf43..100ae21acce 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -21,7 +21,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ this.domain = domain; this.mode = options.mode || 'pivot'; // pivot, bar, pie, line this.heatmap_mode = options.heatmap_mode || 'none'; - this.title = options.title || 'Graph'; this.visible_ui = options.visible_ui || true; this.bar_ui = options.bar_ui || 'group'; this.graph_view = options.graph_view || null; @@ -384,12 +383,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // Drawing the table // ---------------------------------------------------------------------- draw_table: function () { - this.pivot.main_row().title = _t('Total'); - if (this.pivot.measures.length == 1) { - this.pivot.main_col().title = this.pivot.measures[0].string; - } else { - this.pivot.main_col().title = _t(this.title); - } this.draw_top_headers(); _.each(this.pivot.rows.headers, this.proxy('draw_row')); }, diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js index 89ca36f3b61..fccb1e4bffa 100644 --- a/addons/web_graph/static/src/js/pivot_table.js +++ b/addons/web_graph/static/src/js/pivot_table.js @@ -238,7 +238,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ }, make_header: function (group, parent) { - var title = parent ? group.attributes.value : ''; + var title = parent ? group.attributes.value : _t('Total'); return { id: _.uniqueId(), path: parent ? parent.path.concat(title) : [], From f27c1df4d2d8c1fe809b4b7c61d4ddfedc6de569 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 28 Jan 2014 16:11:13 +0100 Subject: [PATCH 03/28] [IMP] css changes to improve look and usability of pivot table view (addon web_graph) bzr revid: ged@openerp.com-20140128151113-g8yxl3lphpht4d89 --- addons/web_graph/static/src/css/graph.css | 45 ++++++++++++++----- .../web_graph/static/src/js/graph_widget.js | 1 + 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/addons/web_graph/static/src/css/graph.css b/addons/web_graph/static/src/css/graph.css index 09e86c1de6b..b7d82597c4c 100644 --- a/addons/web_graph/static/src/css/graph.css +++ b/addons/web_graph/static/src/css/graph.css @@ -6,6 +6,15 @@ border-bottom: 1px solid #ccc; padding: 6px 8px; text-align: right; + color: black; +} + +.graph_main_content td:first-child { + background-color: rgb(240, 238, 238); +} + +.graph_main_content table { + margin-top: 10px; } .graph_measure_selection .oe_selected { @@ -26,30 +35,44 @@ .graph_main_content th { font-size: 13px; font-weight: normal; - color: #039; padding: 10px 8px; vertical-align: top; -} - -.graph_main_content thead { - border: 1px solid #6678b1; - border-bottom: 2px solid #6678b1; + color: black; } .graph_main_content tbody td{ - border: 1px solid #ccc; + border: 1px solid #b8b8b8; +} + +.graph_main_content tbody { + border-top: 1px solid black; +} + +.graph_main_content thead { + background-color: rgb(240, 238, 238); + border: 1px solid #b8b8b8; +} + +.graph_main_content thead th { + border-left: 1px solid #b8b8b8; +} + +div.graph_widget { + padding:10px; +} + +.oe_dashboard div.graph_widget { + padding:0; } td.graph_border { - color: #039; text-align: left; - border-right: 1px solid #6678b1; white-space: nowrap; } -.graph_main_content tbody tr:hover td +.graph_main_content table:not(.heatmap) tr:hover td:not(:first-child) { - color: #009; + background-color: rgb(245, 245, 245); } span.field-selection { diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index 100ae21acce..ef547e22632 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -362,6 +362,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ this.$('.graph_main_content svg').remove(); this.$('.graph_main_content div').remove(); this.table.empty(); + this.table.toggleClass('heatmap', this.heatmap_mode !== 'none') this.width = this.$el.width(); this.height = Math.min(Math.max(document.documentElement.clientHeight - 116 - 60, 250), Math.round(0.8*this.$el.width())); From 9344f2f851823624793359c366fb6beeb1ab0242 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 28 Jan 2014 16:11:57 +0100 Subject: [PATCH 04/28] [FIX] changes the hardcoded string 'undefined' into 'Undefined' in pivot table (addon web_graph) bzr revid: ged@openerp.com-20140128151157-3opcfcockwrgr3kx --- addons/web_graph/static/src/js/pivot_table.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js index fccb1e4bffa..770519e52c2 100644 --- a/addons/web_graph/static/src/js/pivot_table.js +++ b/addons/web_graph/static/src/js/pivot_table.js @@ -400,11 +400,11 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ grouped_on = attrs.grouped_on ? this.raw_field(attrs.grouped_on) : false; if (value === false) { - group.attributes.value = _t('undefined'); + group.attributes.value = _t('Undefined'); } else if (grouped_on && this.fields[grouped_on].type === 'selection') { var selection = this.fields[grouped_on].selection, value_lookup = _.where(selection, {0:value}); - group.attributes.value = value_lookup ? value_lookup[0][1] : _t('undefined'); + group.attributes.value = value_lookup ? value_lookup[0][1] : _t('Undefined'); } else if (value instanceof Array) { group.attributes.value = value[1]; } From a482809cf90f35b00f420e30829ed1c06769649d Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 10:23:59 +0100 Subject: [PATCH 05/28] [FIX] correctly compute the attribute 'length' in a query_group so that the list view properly display groups when grouped by 'date:interval' (addon web) bzr revid: ged@openerp.com-20140129092359-20kw6n3sxqobiqu5 --- addons/web/static/src/js/data.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index a2e3e53db3e..4a0807a727a 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -234,9 +234,9 @@ instance.web.QueryGroup = instance.web.Class.extend({ this.model = new instance.web.Model( model, fixed_group.__context, fixed_group.__domain); - var group_size = fixed_group[grouping_field + '_count'] || fixed_group.__count || 0; + var raw_field = grouping_field && grouping_field.split(':')[0]; + var group_size = fixed_group[raw_field + '_count'] || fixed_group.__count || 0; var leaf_group = fixed_group.__context.group_by.length === 0; - var raw_field = (_.contains(grouping_field, ':')) ? grouping_field.split(':')[0] : grouping_field; this.attributes = { folded: !!(fixed_group.__fold), From 1edb9928572fc8b1c21eb862bdd0d6d4d4e9b57d Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 10:56:55 +0100 Subject: [PATCH 06/28] [IMP] removes the hardcoded Day, Month, Year value in crm.phonecall.report model and updates the corresponding view (addon crm) bzr revid: ged@openerp.com-20140129095655-xn031hst4yw79kna --- addons/crm/report/crm_phonecall_report.py | 11 ----------- addons/crm/report/crm_phonecall_report_view.xml | 7 ++++--- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/addons/crm/report/crm_phonecall_report.py b/addons/crm/report/crm_phonecall_report.py index fba095f1174..6a3e3bf208b 100644 --- a/addons/crm/report/crm_phonecall_report.py +++ b/addons/crm/report/crm_phonecall_report.py @@ -40,20 +40,12 @@ class crm_phonecall_report(osv.osv): _auto = False _columns = { - 'name': fields.char('Year', size=64, required=False, readonly=True), 'user_id':fields.many2one('res.users', 'User', readonly=True), 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True), 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'), 'nbr': fields.integer('# of Cases', readonly=True), 'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True), - 'month':fields.selection([('01', 'January'), ('02', 'February'), \ - ('03', 'March'), ('04', 'April'),\ - ('05', 'May'), ('06', 'June'), \ - ('07', 'July'), ('08', 'August'),\ - ('09', 'September'), ('10', 'October'),\ - ('11', 'November'), ('12', 'December')], 'Month', readonly=True), 'create_date': fields.datetime('Create Date', readonly=True, select=True), - 'day': fields.char('Day', size=128, readonly=True), 'delay_close': fields.float('Delay to close', digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"), 'duration': fields.float('Duration', digits=(16,2),readonly=True, group_operator="avg"), 'delay_open': fields.float('Delay to open',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to open the case"), @@ -77,9 +69,6 @@ class crm_phonecall_report(osv.osv): create or replace view crm_phonecall_report as ( select id, - to_char(c.date, 'YYYY') as name, - to_char(c.date, 'MM') as month, - to_char(c.date, 'YYYY-MM-DD') as day, to_char(c.create_date, 'YYYY-MM-DD') as creation_date, to_char(c.date_open, 'YYYY-MM-DD') as opening_date, to_char(c.date_closed, 'YYYY-mm-dd') as date_closed, diff --git a/addons/crm/report/crm_phonecall_report_view.xml b/addons/crm/report/crm_phonecall_report_view.xml index 9de9adeade3..32ae9704064 100644 --- a/addons/crm/report/crm_phonecall_report_view.xml +++ b/addons/crm/report/crm_phonecall_report_view.xml @@ -12,6 +12,7 @@ + @@ -52,9 +53,9 @@ - - - + + + From 8621b5cc895d10dcdbf694be61f1ca8a9d87f73e Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 11:39:29 +0100 Subject: [PATCH 07/28] [IMP] removes the hardcoded day, month, year values in crm.lead.report.assign model and updates the corresponding view (addon crm_partner_assign) bzr revid: ged@openerp.com-20140129103929-f26368pjhswxvzci --- .../crm_partner_assign/report/crm_lead_report.py | 13 +------------ .../report/crm_lead_report_view.xml | 15 ++++++++------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/addons/crm_partner_assign/report/crm_lead_report.py b/addons/crm_partner_assign/report/crm_lead_report.py index c7a6b76ee44..572e1796b00 100644 --- a/addons/crm_partner_assign/report/crm_lead_report.py +++ b/addons/crm_partner_assign/report/crm_lead_report.py @@ -30,22 +30,14 @@ class crm_lead_report_assign(osv.osv): _auto = False _description = "CRM Lead Report" _columns = { - 'year': fields.char('Year', size=64, required=False, readonly=True), 'partner_assigned_id':fields.many2one('res.partner', 'Partner', readonly=True), 'grade_id':fields.many2one('res.partner.grade', 'Grade', readonly=True), 'user_id':fields.many2one('res.users', 'User', readonly=True), 'country_id':fields.many2one('res.country', 'Country', readonly=True), 'section_id':fields.many2one('crm.case.section', 'Sales Team', readonly=True), - 'month':fields.selection([('01', 'January'), ('02', 'February'), \ - ('03', 'March'), ('04', 'April'),\ - ('05', 'May'), ('06', 'June'), \ - ('07', 'July'), ('08', 'August'),\ - ('09', 'September'), ('10', 'October'),\ - ('11', 'November'), ('12', 'December')], 'Month', readonly=True), 'company_id': fields.many2one('res.company', 'Company', readonly=True), - 'date_assign': fields.date('Partner Date', readonly=True), + 'date_assign': fields.date('Assign Date', readonly=True), 'create_date': fields.datetime('Create Date', readonly=True), - 'day': fields.char('Day', size=128, readonly=True), 'delay_open': fields.float('Delay to Assign',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to open the case"), 'delay_close': fields.float('Delay to Close',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"), 'delay_expected': fields.float('Overpassed Deadline',digits=(16,2),readonly=True, group_operator="avg"), @@ -77,9 +69,6 @@ class crm_lead_report_assign(osv.osv): CREATE OR REPLACE VIEW crm_lead_report_assign AS ( SELECT c.id, - to_char(c.date_assign, 'YYYY') as year, - to_char(c.date_assign, 'MM') as month, - to_char(c.date_assign, 'YYYY-MM-DD') as day, to_char(c.create_date, 'YYYY-MM-DD') as creation_date, to_char(c.date_open, 'YYYY-MM-DD') as opening_date, to_char(c.date_closed, 'YYYY-mm-dd') as date_closed, diff --git a/addons/crm_partner_assign/report/crm_lead_report_view.xml b/addons/crm_partner_assign/report/crm_lead_report_view.xml index a7ff8d80f0f..271c9b2016f 100644 --- a/addons/crm_partner_assign/report/crm_lead_report_view.xml +++ b/addons/crm_partner_assign/report/crm_lead_report_view.xml @@ -35,10 +35,9 @@ - - - - + + + @@ -50,9 +49,11 @@ crm.lead.assign.graph crm.lead.report.assign - - + + + + @@ -63,7 +64,7 @@ Opp. Assignment Analysis crm.lead.report.assign form - {'default_type': 'opportunity', "search_default_group_partner_date": 1, "search_default_group_grade":1,'group_by_no_leaf':1,'group_by':[]} + {'default_type': 'opportunity', 'group_by_no_leaf':1,'group_by':[]} graph [('type', '=', 'opportunity')] From 8a80b284933440769544a3a5eff5699d38cae851 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 12:09:48 +0100 Subject: [PATCH 08/28] [IMP] removes the tree view in Partnership Analysis reporting menu, and replaces it with a graph view in pivot table mode (addon crm_partner_assign) bzr revid: ged@openerp.com-20140129110948-yzqb4a9bbugbejnk --- .../report/crm_partner_report_view.xml | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/addons/crm_partner_assign/report/crm_partner_report_view.xml b/addons/crm_partner_assign/report/crm_partner_report_view.xml index 4e7e13afb15..02320219218 100644 --- a/addons/crm_partner_assign/report/crm_partner_report_view.xml +++ b/addons/crm_partner_assign/report/crm_partner_report_view.xml @@ -24,7 +24,7 @@ domain="[]" context="{'group_by':'grade_id'}" /> - @@ -35,25 +35,15 @@ - - - - crm.partner.assign.report.tree + + crm.partner.assign.report.graph crm.partner.report.assign - - - - - - - - - - - - - + + + + + @@ -62,8 +52,8 @@ Partnership Analysis crm.partner.report.assign - {'search_default_group_grade': 1, 'group_by_no_leaf':1,'group_by':[]} - tree + {'group_by_no_leaf':1,'group_by':[]} + graph [('grade_id', '!=', False)] From 90f2184e938835d545397bb625e625fc9345e4b4 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 13:47:39 +0100 Subject: [PATCH 09/28] [IMP] improves the Purchase Analysis reporting view, removes old Day, Month, Year field from the postgres view and updates the dashboard graph view (addon purchase) bzr revid: ged@openerp.com-20140129124739-6sir9fz6jak9ic0y --- addons/purchase/board_purchase_view.xml | 11 ++-- addons/purchase/report/purchase_report.py | 12 +--- .../purchase/report/purchase_report_view.xml | 55 +++---------------- 3 files changed, 14 insertions(+), 64 deletions(-) diff --git a/addons/purchase/board_purchase_view.xml b/addons/purchase/board_purchase_view.xml index d491985cf52..a317138a310 100644 --- a/addons/purchase/board_purchase_view.xml +++ b/addons/purchase/board_purchase_view.xml @@ -17,15 +17,12 @@ purchase.report - - - @@ -39,9 +36,9 @@ purchase.report - - - + + + @@ -50,7 +47,7 @@ purchase.report form graph,tree - {'group_by':['month','category_id'],'group_by_no_leaf':1} + {'group_by_no_leaf':1} [('state','in',('approved','except_picking','except_invoice','done'))] diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index f6a37bb37a7..ada1d83cdaf 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -32,8 +32,6 @@ class purchase_report(osv.osv): _auto = False _columns = { 'date': fields.date('Order Date', readonly=True, help="Date on which this document has been created"), - 'name': fields.char('Year',size=64,required=False, readonly=True), - 'day': fields.char('Day', size=128, readonly=True), 'state': fields.selection([('draft', 'Request for Quotation'), ('confirmed', 'Waiting Supplier Ack'), ('approved', 'Approved'), @@ -60,12 +58,10 @@ class purchase_report(osv.osv): 'negociation': fields.float('Purchase-Standard Price', readonly=True, group_operator="avg"), 'price_standard': fields.float('Products Value', readonly=True, group_operator="sum"), 'nbr': fields.integer('# of Lines', readonly=True), - 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), - ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True), 'category_id': fields.many2one('product.category', 'Category', readonly=True) } - _order = 'name desc,price_total desc' + _order = 'date desc, price_total desc' def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_report') cr.execute(""" @@ -73,9 +69,6 @@ class purchase_report(osv.osv): select min(l.id) as id, s.date_order as date, - to_char(s.date_order, 'YYYY') as name, - to_char(s.date_order, 'MM') as month, - to_char(s.date_order, 'YYYY-MM-DD') as day, s.state, s.date_approve, s.minimum_planned_date as expected_date, @@ -121,9 +114,6 @@ class purchase_report(osv.osv): l.product_id, t.categ_id, s.date_order, - to_char(s.date_order, 'YYYY'), - to_char(s.date_order, 'MM'), - to_char(s.date_order, 'YYYY-MM-DD'), s.state, s.warehouse_id, u.uom_type, diff --git a/addons/purchase/report/purchase_report_view.xml b/addons/purchase/report/purchase_report_view.xml index baaf2f8312c..d7700e5fca7 100644 --- a/addons/purchase/report/purchase_report_view.xml +++ b/addons/purchase/report/purchase_report_view.xml @@ -6,7 +6,12 @@ purchase.report + + + + + @@ -43,66 +48,24 @@ - - - + + + - - purchase.order.qty.amount.graph - purchase.report - - - - - - - - - - - purchase.order.by.user.graph - purchase.report - - - - - - - - - - Purchase Analysis purchase.report form graph - {'search_default_year':1,'search_default_month':1,'search_default_group_partner_id':1,'search_default_group_product_id': 1, 'search_default_orders': 1, 'group_by_no_leaf':1,'group_by':[]} + {'search_default_year':1,'search_default_month':1, 'search_default_orders': 1, 'group_by_no_leaf':1,'group_by':[]} Purchase Analysis allows you to easily check and analyse your company purchase history and performance. From this menu you can track your negotiation performance, the delivery performance of your suppliers, etc. - - Total Qty and Amount by month - purchase.report - form - graph - - - - - Total Orders by User per month - purchase.report - form - graph - - - - From 23f4aca0a88031f53c33c415a718b7c1df90b503 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 14:55:19 +0100 Subject: [PATCH 10/28] [IMP] improves the Reception Analysis reporting view, removes old Day, Month, Year field from the postgres view and updates the dashboard graph view (addon stock) bzr revid: ged@openerp.com-20140129135519-uo98mu24qy2h29pq --- addons/stock/board_warehouse_view.xml | 8 ++++---- addons/stock/report/report_stock_move.py | 11 +---------- addons/stock/report/report_stock_move_view.xml | 11 ++++++++--- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/addons/stock/board_warehouse_view.xml b/addons/stock/board_warehouse_view.xml index a1f327eab5d..136d8991a99 100644 --- a/addons/stock/board_warehouse_view.xml +++ b/addons/stock/board_warehouse_view.xml @@ -7,9 +7,9 @@ report.stock.move - - + + @@ -19,7 +19,7 @@ report.stock.move form graph,tree - [('type','=','in'),('day','<=', time.strftime('%Y-%m-%d')),('day','>',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))] + [('type','=','in'),('date','<=', time.strftime('%Y-%m-%d')),('date','>',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))] {'search_default_in':1} @@ -28,7 +28,7 @@ report.stock.move form graph,tree - [('type','=','out'),('day','<=', time.strftime('%Y-%m-%d')),('day','>',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))] + [('type','=','out'),('date','<=', time.strftime('%Y-%m-%d')),('date','>',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))] {'search_default_out':1} diff --git a/addons/stock/report/report_stock_move.py b/addons/stock/report/report_stock_move.py index db9ea187260..1b183f5fcbd 100644 --- a/addons/stock/report/report_stock_move.py +++ b/addons/stock/report/report_stock_move.py @@ -30,11 +30,6 @@ class report_stock_move(osv.osv): _auto = False _columns = { 'date': fields.date('Date', readonly=True), - 'year': fields.char('Year', size=4, readonly=True), - 'day': fields.char('Day', size=128, readonly=True), - 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), - ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True), 'product_id':fields.many2one('product.product', 'Product', readonly=True), 'company_id':fields.many2one('res.company', 'Company', readonly=True), @@ -63,9 +58,6 @@ class report_stock_move(osv.osv): SELECT min(sm.id) as id, date_trunc('day', sm.date) as date, - to_char(date_trunc('day',sm.date), 'YYYY') as year, - to_char(date_trunc('day',sm.date), 'MM') as month, - to_char(date_trunc('day',sm.date), 'YYYY-MM-DD') as day, avg(date(sm.date)-date(sm.create_date)) as day_diff, avg(date(sm.date_expected)-date(sm.create_date)) as day_diff1, avg(date(sm.date)-date(sm.date_expected)) as day_diff2, @@ -115,8 +107,7 @@ class report_stock_move(osv.osv): coalesce(sp.type, 'other'), date_trunc('day', sm.date), sm.partner_id, sm.state, sm.product_uom, sm.date_expected, sm.product_id, pt.standard_price, sm.picking_id, - sm.company_id, sm.location_id, sm.location_dest_id, pu.factor, pt.categ_id, sp.stock_journal_id, - year, month, day + sm.company_id, sm.location_id, sm.location_dest_id, pu.factor, pt.categ_id, sp.stock_journal_id ) """) diff --git a/addons/stock/report/report_stock_move_view.xml b/addons/stock/report/report_stock_move_view.xml index fa578a82309..452cfd1b3e6 100644 --- a/addons/stock/report/report_stock_move_view.xml +++ b/addons/stock/report/report_stock_move_view.xml @@ -16,6 +16,9 @@ + + + @@ -52,9 +55,9 @@ - - - + + + @@ -66,6 +69,7 @@ form graph + {'contact_display': 'partner','search_default_done':1,'search_default_year':1, 'search_default_month':1, 'search_default_group_type':1, 'group_by': [], 'group_by_no_leaf':1,} Moves Analysis allows you to easily check and analyse your company stock moves. Use this report when you want to analyse the different routes taken by your products and inventory management performance. @@ -78,6 +82,7 @@ + From ddc1d840e7ba26d10cf94d013a3696bbe9777bb3 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 15:30:55 +0100 Subject: [PATCH 11/28] [IMP] improves the Work Order Analysis reporting view, removes old Day, Month, Year field from the postgres view (addon mrp_operations) bzr revid: ged@openerp.com-20140129143055-2qtivjtkpzyb13zw --- .../mrp_operations/report/mrp_workorder_analysis.py | 7 ------- .../report/mrp_workorder_analysis_view.xml | 11 +++++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/addons/mrp_operations/report/mrp_workorder_analysis.py b/addons/mrp_operations/report/mrp_workorder_analysis.py index f91961ad74c..d9d3947bae6 100644 --- a/addons/mrp_operations/report/mrp_workorder_analysis.py +++ b/addons/mrp_operations/report/mrp_workorder_analysis.py @@ -28,10 +28,6 @@ class mrp_workorder(osv.osv): _description = "Work Order Report" _auto = False _columns = { - 'year': fields.char('Year', size=64, readonly=True), - 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), - ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True), - 'day': fields.char('Day', size=64, readonly=True), 'nbr': fields.integer('# of Lines', readonly=True), 'date': fields.date('Date', readonly=True), 'product_id': fields.many2one('product.product', 'Product', readonly=True), @@ -50,9 +46,6 @@ class mrp_workorder(osv.osv): create or replace view mrp_workorder as ( select to_date(to_char(wl.date_planned, 'MM-dd-YYYY'),'MM-dd-YYYY') as date, - to_char(wl.date_planned, 'YYYY') as year, - to_char(wl.date_planned, 'MM') as month, - to_char(wl.date_planned, 'YYYY-MM-DD') as day, min(wl.id) as id, mp.product_id as product_id, sum(wl.hour) as total_hours, diff --git a/addons/mrp_operations/report/mrp_workorder_analysis_view.xml b/addons/mrp_operations/report/mrp_workorder_analysis_view.xml index 144bfb95c63..92c6ef9adb2 100644 --- a/addons/mrp_operations/report/mrp_workorder_analysis_view.xml +++ b/addons/mrp_operations/report/mrp_workorder_analysis_view.xml @@ -10,7 +10,10 @@ + + + @@ -31,9 +34,9 @@ - - - + + + @@ -45,7 +48,7 @@ graph - {'search_default_Workcenter': 1,'search_default_year':1,'search_default_month':1,'group_by_no_leaf':1,'group_by':[]} + {'search_default_Workcenter': 1,'group_by_no_leaf':1,'group_by':[]} From 8dba681c697c6c8e639a917f39a120c82267a6b5 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 15:42:33 +0100 Subject: [PATCH 12/28] [IMP] improves the membership reporting view by adding a measure to the pivot table (num paid) (addon membership) bzr revid: ged@openerp.com-20140129144233-4flp69bq188kdy05 --- addons/membership/report/report_membership_view.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/membership/report/report_membership_view.xml b/addons/membership/report/report_membership_view.xml index bfbdcefca5d..50b579d9ec2 100644 --- a/addons/membership/report/report_membership_view.xml +++ b/addons/membership/report/report_membership_view.xml @@ -40,6 +40,7 @@ + From 906f28109cc1eac445c0035beb0046a902f5cd21 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 16:24:40 +0100 Subject: [PATCH 13/28] [IMP] improves the task analysis reporting view by adding measures to the pivot table (num paid) and changes the view in dashboard project (addon project) bzr revid: ged@openerp.com-20140129152440-ibi9ity10onbi3st --- addons/project/report/project_cumulative.xml | 3 ++- addons/project/report/project_report.py | 9 --------- addons/project/report/project_report_view.xml | 14 +++++++++----- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/addons/project/report/project_cumulative.xml b/addons/project/report/project_cumulative.xml index 8886ae17505..e85d9d80138 100644 --- a/addons/project/report/project_cumulative.xml +++ b/addons/project/report/project_cumulative.xml @@ -6,10 +6,11 @@ project.task.history.cumulative.graph project.task.history.cumulative - + + diff --git a/addons/project/report/project_report.py b/addons/project/report/project_report.py index ed086b4318d..5a473469b2d 100644 --- a/addons/project/report/project_report.py +++ b/addons/project/report/project_report.py @@ -29,8 +29,6 @@ class report_project_task_user(osv.osv): _auto = False _columns = { 'name': fields.char('Task Summary', size=128, readonly=True), - 'day': fields.char('Day', size=128, readonly=True), - 'year': fields.char('Year', size=64, required=False, readonly=True), 'user_id': fields.many2one('res.users', 'Assigned To', readonly=True), 'date_start': fields.date('Assignation Date', readonly=True), 'no_of_days': fields.integer('# of Days', size=128, readonly=True), @@ -52,7 +50,6 @@ class report_project_task_user(osv.osv): 'nbr': fields.integer('# of tasks', readonly=True), 'priority': fields.selection([('4', 'Very Low'), ('3', 'Low'), ('2', 'Medium'), ('1', 'Urgent'), ('0', 'Very urgent')], string='Priority', readonly=True), - 'month':fields.selection(fields.date.MONTHS, 'Month', readonly=True), 'state': fields.selection([('draft', 'Draft'), ('open', 'In Progress'), ('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')],'Status', readonly=True), 'company_id': fields.many2one('res.company', 'Company', readonly=True), 'partner_id': fields.many2one('res.partner', 'Contact', readonly=True), @@ -67,9 +64,6 @@ class report_project_task_user(osv.osv): SELECT (select 1 ) AS nbr, t.id as id, - to_char(date_start, 'YYYY') as year, - to_char(date_start, 'MM') as month, - to_char(date_start, 'YYYY-MM-DD') as day, date_trunc('day',t.date_start) as date_start, date_trunc('day',t.date_end) as date_end, date_trunc('day',t.date_last_stage_update) as date_last_stage_update, @@ -102,9 +96,6 @@ class report_project_task_user(osv.osv): total_hours, planned_hours, hours_delay, - year, - month, - day, create_date, write_date, date_start, diff --git a/addons/project/report/project_report_view.xml b/addons/project/report/project_report_view.xml index 6fb4e24e7ad..aced63a34d6 100644 --- a/addons/project/report/project_report_view.xml +++ b/addons/project/report/project_report_view.xml @@ -11,8 +11,12 @@ report.project.task.user - + + + + + @@ -44,9 +48,9 @@ - - - + + + @@ -59,7 +63,7 @@ form graph - {'search_default_year':1,'search_default_project':1,'group_by_no_leaf':1,'group_by':[]} + {'group_by_no_leaf':1,'group_by':[]} This report allows you to analyse the performance of your projects and users. You can analyse the quantities of tasks, the hours spent compared to the planned hours, the average number of days to open or close a task, etc. From 4b3076e955dadd306c8dd94dd8de9316e826de1b Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 17:03:48 +0100 Subject: [PATCH 14/28] [IMP] improves the reporting views in account module (work on the Pivot tables, and remove some useless day/month/year attributes) (addon account) bzr revid: ged@openerp.com-20140129160348-230nvcutbdqh1hx1 --- .../report/account_analytic_entries_report.py | 8 -------- .../report/account_analytic_entries_report_view.xml | 12 ++++++------ addons/account/report/account_invoice_report.py | 13 +------------ .../account/report/account_invoice_report_view.xml | 10 ++++++---- .../account/report/account_treasury_report_view.xml | 2 ++ 5 files changed, 15 insertions(+), 30 deletions(-) diff --git a/addons/account/report/account_analytic_entries_report.py b/addons/account/report/account_analytic_entries_report.py index f7d1177e3b0..1cd0f4c9026 100644 --- a/addons/account/report/account_analytic_entries_report.py +++ b/addons/account/report/account_analytic_entries_report.py @@ -28,11 +28,6 @@ class analytic_entries_report(osv.osv): _auto = False _columns = { 'date': fields.date('Date', readonly=True), - 'year': fields.char('Year', size=4, readonly=True), - 'day': fields.char('Day', size=128, readonly=True), - 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), - ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), 'user_id': fields.many2one('res.users', 'User',readonly=True), 'name': fields.char('Description', size=64, readonly=True), 'partner_id': fields.many2one('res.partner', 'Partner'), @@ -56,9 +51,6 @@ class analytic_entries_report(osv.osv): min(a.id) as id, count(distinct a.id) as nbr, a.date as date, - to_char(a.date, 'YYYY') as year, - to_char(a.date, 'MM') as month, - to_char(a.date, 'YYYY-MM-DD') as day, a.user_id as user_id, a.name as name, analytic.partner_id as partner_id, diff --git a/addons/account/report/account_analytic_entries_report_view.xml b/addons/account/report/account_analytic_entries_report_view.xml index 047d563cc58..1d2e87be339 100644 --- a/addons/account/report/account_analytic_entries_report_view.xml +++ b/addons/account/report/account_analytic_entries_report_view.xml @@ -6,7 +6,6 @@ analytic.entries.report - @@ -21,9 +20,9 @@ - - - + + + @@ -34,8 +33,9 @@ - - + + + diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index d8dc45f9a3b..8fecf85ee0b 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -55,11 +55,6 @@ class account_invoice_report(osv.osv): _columns = { 'date': fields.date('Date', readonly=True), - 'year': fields.char('Year', size=4, readonly=True), - 'day': fields.char('Day', size=128, readonly=True), - 'month': fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), - ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True), 'product_id': fields.many2one('product.product', 'Product', readonly=True), 'product_qty':fields.float('Qty', readonly=True), 'uom_name': fields.char('Reference Unit of Measure', size=128, readonly=True), @@ -105,7 +100,7 @@ class account_invoice_report(osv.osv): def _select(self): select_str = """ - SELECT sub.id, sub.date, sub.year, sub.month, sub.day, sub.product_id, sub.partner_id, sub.country_id, + SELECT sub.id, sub.date, sub.product_id, sub.partner_id, sub.country_id, sub.payment_term, sub.period_id, sub.uom_name, sub.currency_id, sub.journal_id, sub.fiscal_position, sub.user_id, sub.company_id, sub.nbr, sub.type, sub.state, sub.categ_id, sub.date_due, sub.account_id, sub.account_line_id, sub.partner_bank_id, @@ -118,9 +113,6 @@ class account_invoice_report(osv.osv): select_str = """ SELECT min(ail.id) AS id, ai.date_invoice AS date, - to_char(ai.date_invoice::timestamp with time zone, 'YYYY'::text) AS year, - to_char(ai.date_invoice::timestamp with time zone, 'MM'::text) AS month, - to_char(ai.date_invoice::timestamp with time zone, 'YYYY-MM-DD'::text) AS day, ail.product_id, ai.partner_id, ai.payment_term, ai.period_id, CASE WHEN u.uom_type::text <> 'reference'::text @@ -192,9 +184,6 @@ class account_invoice_report(osv.osv): def _group_by(self): group_by_str = """ GROUP BY ail.product_id, ai.date_invoice, ai.id, - to_char(ai.date_invoice::timestamp with time zone, 'YYYY'::text), - to_char(ai.date_invoice::timestamp with time zone, 'MM'::text), - to_char(ai.date_invoice::timestamp with time zone, 'YYYY-MM-DD'::text), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.account_id, ail.account_id, ai.partner_bank_id, ai.residual, diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 67d568801b7..24723d7fb12 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -6,8 +6,10 @@ account.invoice.report + - + + @@ -47,9 +49,9 @@ - - - + + + diff --git a/addons/account/report/account_treasury_report_view.xml b/addons/account/report/account_treasury_report_view.xml index fe898cd81ce..f1c84849831 100644 --- a/addons/account/report/account_treasury_report_view.xml +++ b/addons/account/report/account_treasury_report_view.xml @@ -24,6 +24,8 @@ + + From d07bb7e8703ec7168c0b601ac2ca8e718ebd3ce1 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 29 Jan 2014 17:07:09 +0100 Subject: [PATCH 15/28] [IMP] improves the reporting view Asset Analysis in accounting module (adds some relevent measures to the pivot table) (addon account_asset) bzr revid: ged@openerp.com-20140129160709-t5e4c9h91y0jug6e --- addons/account_asset/report/account_asset_report_view.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account_asset/report/account_asset_report_view.xml b/addons/account_asset/report/account_asset_report_view.xml index 4655172572c..19299eee501 100644 --- a/addons/account_asset/report/account_asset_report_view.xml +++ b/addons/account_asset/report/account_asset_report_view.xml @@ -7,8 +7,11 @@ asset.asset.report - - + + + + + From 7fd82bc83b27180f40483e0a26f19ab35d2718e2 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 30 Jan 2014 10:18:16 +0100 Subject: [PATCH 16/28] [FIX] remove references to 'month' account.invoice.report field in sale/board_sale_view.xml. That field was removed in the model (addon sale) bzr revid: ged@openerp.com-20140130091816-y7w38epdk440t44m --- addons/sale/board_sale_view.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/sale/board_sale_view.xml b/addons/sale/board_sale_view.xml index 021e0c140af..0ad4a6774fc 100644 --- a/addons/sale/board_sale_view.xml +++ b/addons/sale/board_sale_view.xml @@ -17,7 +17,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -40,8 +40,8 @@ form graph,tree - [('year','ilike',time.strftime('%Y')),('user_id','=',uid)] - {'group_by_no_leaf':1,'group_by':['month']} + [('date','<=', time.strftime('%Y-%m-%d')),('date','>=',time.strftime('%Y-01-01')),('user_id','=',uid)] + {'group_by_no_leaf':1} From e58efb7361a6e2ef9d328545e277060de224d0d1 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 30 Jan 2014 10:44:55 +0100 Subject: [PATCH 17/28] [IMP] replace the Order Analysis tree view by a graph view to use the new Pivot table. Also, removes the Day/Month/Year attributes of the postgres view (addon point_of_sale) bzr revid: ged@openerp.com-20140130094455-cai7dvvozwhojaff --- .../point_of_sale/report/pos_order_report.py | 13 +----- .../report/pos_order_report_view.xml | 46 +++++++------------ 2 files changed, 18 insertions(+), 41 deletions(-) diff --git a/addons/point_of_sale/report/pos_order_report.py b/addons/point_of_sale/report/pos_order_report.py index f3ee5e317c8..5489ccf7099 100644 --- a/addons/point_of_sale/report/pos_order_report.py +++ b/addons/point_of_sale/report/pos_order_report.py @@ -28,11 +28,6 @@ class pos_order_report(osv.osv): _auto = False _columns = { 'date': fields.date('Date Order', readonly=True), - 'year': fields.char('Year', size=4, readonly=True), - 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), - ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), - 'day': fields.char('Day', size=128, readonly=True), 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True), 'product_id':fields.many2one('product.product', 'Product', readonly=True), 'state': fields.selection([('draft', 'New'), ('paid', 'Closed'), ('done', 'Synchronized'), ('invoiced', 'Invoiced'), ('cancel', 'Cancelled')], @@ -57,15 +52,12 @@ class pos_order_report(osv.osv): select min(l.id) as id, count(*) as nbr, - to_date(to_char(s.date_order, 'dd-MM-YYYY'),'dd-MM-YYYY') as date, + s.date_order as date, sum(l.qty * u.factor) as product_qty, sum(l.qty * l.price_unit) as price_total, sum((l.qty * l.price_unit) * (l.discount / 100)) as total_discount, (sum(l.qty*l.price_unit)/sum(l.qty * u.factor))::decimal(16,2) as average_price, sum(cast(to_char(date_trunc('day',s.date_order) - date_trunc('day',s.create_date),'DD') as int)) as delay_validation, - to_char(s.date_order, 'YYYY') as year, - to_char(s.date_order, 'MM') as month, - to_char(s.date_order, 'YYYY-MM-DD') as day, s.partner_id as partner_id, s.state as state, s.user_id as user_id, @@ -78,8 +70,7 @@ class pos_order_report(osv.osv): left join product_template pt on (pt.id=l.product_id) left join product_uom u on (u.id=pt.uom_id) group by - to_char(s.date_order, 'dd-MM-YYYY'),to_char(s.date_order, 'YYYY'),to_char(s.date_order, 'MM'), - to_char(s.date_order, 'YYYY-MM-DD'), s.partner_id,s.state, + s.date_order, s.partner_id,s.state, s.user_id,s.warehouse_id,s.company_id,s.sale_journal,l.product_id,s.create_date having sum(l.qty * u.factor) != 0)""") diff --git a/addons/point_of_sale/report/pos_order_report_view.xml b/addons/point_of_sale/report/pos_order_report_view.xml index 135b6dcadaa..a34bab9c559 100644 --- a/addons/point_of_sale/report/pos_order_report_view.xml +++ b/addons/point_of_sale/report/pos_order_report_view.xml @@ -1,29 +1,18 @@ - - report.pos.order.tree + + report.pos.order.graph report.pos.order - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -36,10 +25,7 @@ - - - + @@ -50,9 +36,9 @@ - - - + + + @@ -62,9 +48,9 @@ Orders Analysis report.pos.order form - tree + graph - {'search_default_year':1,'search_default_today':1,'group_by_no_leaf':1,'group_by':['product_id']} + {'search_default_year':1, 'group_by_no_leaf':1,'group_by':['product_id']} From b44035d478446226da790c0ffa681411bfe66561 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 30 Jan 2014 11:06:56 +0100 Subject: [PATCH 18/28] [FIX] changes reference to removed field account_invoice_report_day to account_invoice_report_date in addon gamification_sale_crm bzr revid: ged@openerp.com-20140130100656-5ki5ihw7tla2yuya --- addons/gamification_sale_crm/sale_crm_goals.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/gamification_sale_crm/sale_crm_goals.xml b/addons/gamification_sale_crm/sale_crm_goals.xml index b48cc8a3117..4c1f8e46149 100644 --- a/addons/gamification_sale_crm/sale_crm_goals.xml +++ b/addons/gamification_sale_crm/sale_crm_goals.xml @@ -10,7 +10,7 @@ True - + [('state','!=','cancel'),('user_id','=',user.id),('type','=','out_invoice')] @@ -86,7 +86,7 @@ count orders - + [('state','=','paid'),('user_id','=',user.id),('type','=','out_invoice')] @@ -96,7 +96,7 @@ True - + [('state','=','paid'),('user_id','=',user.id),('type','=','out_invoice')] @@ -108,7 +108,7 @@ lower invoices - + [('state','!=','cancel'),('user_id','=',user.id),('type','=','out_refund')] @@ -119,7 +119,7 @@ True - + [('state','!=','cancel'),('user_id','=',user.id),('type','=','out_refund')] From 6a8e9256ae554326a18f0fb4b57a84f5f94577e2 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 30 Jan 2014 11:51:40 +0100 Subject: [PATCH 19/28] [IMP] updates the reporting fleet view (cost analysis/indicative costs analysis) to use the new pivot table view (addon fleet) bzr revid: ged@openerp.com-20140130105140-f24cdpt3peqvavxn --- addons/fleet/fleet_board_view.xml | 12 ++++++------ addons/fleet/fleet_view.xml | 20 +++++++++----------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/addons/fleet/fleet_board_view.xml b/addons/fleet/fleet_board_view.xml index 41093d2c283..c4732d9a0f4 100644 --- a/addons/fleet/fleet_board_view.xml +++ b/addons/fleet/fleet_board_view.xml @@ -54,10 +54,10 @@ Costs Analysis fleet.vehicle.cost - + form - tree - {"search_default_parent_false" : True,"search_default_groupby_year" : True,"search_default_groupby_cost_type" : True,"search_default_groupby_cost_subtype" : True, "search_default_groupby_vehicle_id" : True,} + graph + {"search_default_parent_false" : True,"search_default_groupby_year" : True, "search_default_groupby_cost_subtype" : True,"search_default_groupby_vehicle_id" : True}

OpenERP helps you managing the costs for your different vehicles @@ -73,10 +73,10 @@ Indicative Costs Analysis fleet.vehicle.cost - + form - tree - {"search_default_parent_true" : True,"search_default_groupby_cost_subtype" : True,"search_default_groupby_cost_type" : True,"search_default_groupby_parent_id" : True,} + graph + {"search_default_parent_true" : True,"search_default_groupby_cost_subtype" : True,"search_default_groupby_parent_id" : True,}

OpenERP helps you managing the costs for your different vehicles diff --git a/addons/fleet/fleet_view.xml b/addons/fleet/fleet_view.xml index db38821b56e..c8929d2b492 100644 --- a/addons/fleet/fleet_view.xml +++ b/addons/fleet/fleet_view.xml @@ -849,19 +849,17 @@ - - fleet.vehicle.cost.tree + + fleet.vehicle.cost.graph fleet.vehicle.cost - - - - - - - - - + + + + + + + From 9ce7c7d561ba3f2aff9f2eafda1c8dffd05e8b1f Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 30 Jan 2014 13:27:52 +0100 Subject: [PATCH 20/28] [IMP] Use CORS in pos (only two routes) bzr revid: fme@openerp.com-20140130122752-kfgo7u0q0crn3tbr --- addons/hw_proxy/controllers/main.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/addons/hw_proxy/controllers/main.py b/addons/hw_proxy/controllers/main.py index adb59a072b3..e6c19e322d6 100644 --- a/addons/hw_proxy/controllers/main.py +++ b/addons/hw_proxy/controllers/main.py @@ -33,16 +33,11 @@ class Proxy(http.Controller): statuses[driver] = drivers[driver].get_status() return statuses - @http.route('/hw_proxy/hello', type='http', auth='none') + @http.route('/hw_proxy/hello', type='http', auth='none', cors='*') def hello(self): - return request.make_response('ping', { - 'Cache-Control': 'no-cache', - 'Content-Type': 'text/html; charset=utf-8', - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'GET', - }) + return "ping" - @http.route('/hw_proxy/handshake', type='json', auth='none') + @http.route('/hw_proxy/handshake', type='json', auth='none', cors='*') def handshake(self): return True From 85cb9774b7c1e7b476264c841725857e046f22be Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 30 Jan 2014 13:44:02 +0100 Subject: [PATCH 21/28] [IMP] changes the reception analysis reporting view (warehouse) to select the correct pivot table (addon purchase) bzr revid: ged@openerp.com-20140130124402-crfr39uqptlzc3cv --- addons/purchase/report/purchase_report_view.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/purchase/report/purchase_report_view.xml b/addons/purchase/report/purchase_report_view.xml index d7700e5fca7..50b22f40a05 100644 --- a/addons/purchase/report/purchase_report_view.xml +++ b/addons/purchase/report/purchase_report_view.xml @@ -76,6 +76,7 @@ form graph + {'full':'1','contact_display': 'partner','search_default_done':1, 'search_default_month':1, 'search_default_group_type':1, 'group_by': [], 'group_by_no_leaf':1,'search_default_year':1,} Reception Analysis allows you to easily check and analyse your company order receptions and the performance of your supplier's deliveries. From d5031cbee897f8fe6fa111a3cfe4f6510aff9e92 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 30 Jan 2014 13:46:06 +0100 Subject: [PATCH 22/28] [ADD] POS: added cors argument to all routes bzr revid: fme@openerp.com-20140130124606-wetmhcjqqvvkv5dy --- addons/hw_escpos/controllers/main.py | 4 +-- addons/hw_proxy/controllers/main.py | 44 +++++++++++++-------------- addons/hw_scanner/controllers/main.py | 4 +-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/addons/hw_escpos/controllers/main.py b/addons/hw_escpos/controllers/main.py index 5b42e97b442..b4312fb94a8 100644 --- a/addons/hw_escpos/controllers/main.py +++ b/addons/hw_escpos/controllers/main.py @@ -259,12 +259,12 @@ hw_proxy.drivers['escpos'] = driver class EscposProxy(hw_proxy.Proxy): - @http.route('/hw_proxy/open_cashbox', type='json', auth='none') + @http.route('/hw_proxy/open_cashbox', type='json', auth='none', cors='*') def open_cashbox(self): _logger.info('ESC/POS: OPEN CASHBOX') driver.push_task('cashbox') - @http.route('/hw_proxy/print_receipt', type='json', auth='none') + @http.route('/hw_proxy/print_receipt', type='json', auth='none', cors='*') def print_receipt(self, receipt): _logger.info('ESC/POS: PRINT RECEIPT') driver.push_task('receipt',receipt) diff --git a/addons/hw_proxy/controllers/main.py b/addons/hw_proxy/controllers/main.py index e6c19e322d6..5293abd1f25 100644 --- a/addons/hw_proxy/controllers/main.py +++ b/addons/hw_proxy/controllers/main.py @@ -41,7 +41,7 @@ class Proxy(http.Controller): def handshake(self): return True - @http.route('/hw_proxy/status', type='http', auth='none') + @http.route('/hw_proxy/status', type='http', auth='none', cors='*') def status_http(self): resp = '\n\n

Hardware Proxy Status

\n' statuses = self.get_status() @@ -70,39 +70,39 @@ class Proxy(http.Controller): 'Access-Control-Allow-Methods': 'GET', }) - @http.route('/hw_proxy/status_json', type='json', auth='none') + @http.route('/hw_proxy/status_json', type='json', auth='none', cors='*') def status_json(self): return self.get_status() - @http.route('/hw_proxy/scan_item_success', type='json', auth='none') + @http.route('/hw_proxy/scan_item_success', type='json', auth='none', cors='*') def scan_item_success(self, ean): """ A product has been scanned with success """ print 'scan_item_success: ' + str(ean) - @http.route('/hw_proxy/scan_item_error_unrecognized', type='json', auth='none') + @http.route('/hw_proxy/scan_item_error_unrecognized', type='json', auth='none', cors='*') def scan_item_error_unrecognized(self, ean): """ A product has been scanned without success """ print 'scan_item_error_unrecognized: ' + str(ean) - @http.route('/hw_proxy/help_needed', type='json', auth='none') + @http.route('/hw_proxy/help_needed', type='json', auth='none', cors='*') def help_needed(self): """ The user wants an help (ex: light is on) """ print "help_needed" - @http.route('/hw_proxy/help_canceled', type='json', auth='none') + @http.route('/hw_proxy/help_canceled', type='json', auth='none', cors='*') def help_canceled(self): """ The user stops the help request """ print "help_canceled" - @http.route('/hw_proxy/weighting_start', type='json', auth='none') + @http.route('/hw_proxy/weighting_start', type='json', auth='none', cors='*') def weighting_start(self): if self.scale == 'closed': print "Opening (Fake) Connection to Scale..." @@ -113,7 +113,7 @@ class Proxy(http.Controller): else: print "WARNING: Scale already Connected !!!" - @http.route('/hw_proxy/weighting_read_kg', type='json', auth='none') + @http.route('/hw_proxy/weighting_read_kg', type='json', auth='none', cors='*') def weighting_read_kg(self): if self.scale == 'open': print "Reading Scale..." @@ -125,7 +125,7 @@ class Proxy(http.Controller): print "WARNING: Reading closed scale !!!" return 0.0 - @http.route('/hw_proxy/weighting_end', type='json', auth='none') + @http.route('/hw_proxy/weighting_end', type='json', auth='none', cors='*') def weighting_end(self): if self.scale == 'open': print "Closing Connection to Scale ..." @@ -136,7 +136,7 @@ class Proxy(http.Controller): else: print "WARNING: Scale already Closed !!!" - @http.route('/hw_proxy/payment_request', type='json', auth='none') + @http.route('/hw_proxy/payment_request', type='json', auth='none', cors='*') def payment_request(self, price): """ The PoS will activate the method payment @@ -144,55 +144,55 @@ class Proxy(http.Controller): print "payment_request: price:"+str(price) return 'ok' - @http.route('/hw_proxy/payment_status', type='json', auth='none') + @http.route('/hw_proxy/payment_status', type='json', auth='none', cors='*') def payment_status(self): print "payment_status" return { 'status':'waiting' } - @http.route('/hw_proxy/payment_cancel', type='json', auth='none') + @http.route('/hw_proxy/payment_cancel', type='json', auth='none', cors='*') def payment_cancel(self): print "payment_cancel" - @http.route('/hw_proxy/transaction_start', type='json', auth='none') + @http.route('/hw_proxy/transaction_start', type='json', auth='none', cors='*') def transaction_start(self): print 'transaction_start' - @http.route('/hw_proxy/transaction_end', type='json', auth='none') + @http.route('/hw_proxy/transaction_end', type='json', auth='none', cors='*') def transaction_end(self): print 'transaction_end' - @http.route('/hw_proxy/cashier_mode_activated', type='json', auth='none') + @http.route('/hw_proxy/cashier_mode_activated', type='json', auth='none', cors='*') def cashier_mode_activated(self): print 'cashier_mode_activated' - @http.route('/hw_proxy/cashier_mode_deactivated', type='json', auth='none') + @http.route('/hw_proxy/cashier_mode_deactivated', type='json', auth='none', cors='*') def cashier_mode_deactivated(self): print 'cashier_mode_deactivated' - @http.route('/hw_proxy/open_cashbox', type='json', auth='none') + @http.route('/hw_proxy/open_cashbox', type='json', auth='none', cors='*') def open_cashbox(self): print 'open_cashbox' - @http.route('/hw_proxy/print_receipt', type='json', auth='none') + @http.route('/hw_proxy/print_receipt', type='json', auth='none', cors='*') def print_receipt(self, receipt): print 'print_receipt' + str(receipt) - @http.route('/hw_proxy/is_scanner_connected', type='json', auth='none') + @http.route('/hw_proxy/is_scanner_connected', type='json', auth='none', cors='*') def print_receipt(self, receipt): print 'is_scanner_connected?' return False - @http.route('/hw_proxy/scanner', type='json', auth='none') + @http.route('/hw_proxy/scanner', type='json', auth='none', cors='*') def print_receipt(self, receipt): print 'scanner' time.sleep(10) return '' - @http.route('/hw_proxy/log', type='json', auth='none') + @http.route('/hw_proxy/log', type='json', auth='none', cors='*') def log(self, arguments): _logger.info(' '.join(str(v) for v in arguments)) - @http.route('/hw_proxy/print_pdf_invoice', type='json', auth='none') + @http.route('/hw_proxy/print_pdf_invoice', type='json', auth='none', cors='*') def print_pdf_invoice(self, pdfinvoice): print 'print_pdf_invoice' + str(pdfinvoice) diff --git a/addons/hw_scanner/controllers/main.py b/addons/hw_scanner/controllers/main.py index 664606954c3..105856a3e28 100644 --- a/addons/hw_scanner/controllers/main.py +++ b/addons/hw_scanner/controllers/main.py @@ -124,7 +124,7 @@ class Scanner(Thread): self.set_status('error',str(e)) return None - @http.route('/hw_proxy/Vis_scanner_connected', type='json', auth='none') + @http.route('/hw_proxy/Vis_scanner_connected', type='json', auth='none', cors='*') def is_scanner_connected(self): return self.get_device() != None @@ -207,7 +207,7 @@ s = Scanner() hw_proxy.drivers['scanner'] = s class ScannerDriver(hw_proxy.Proxy): - @http.route('/hw_proxy/scanner', type='json', auth='none') + @http.route('/hw_proxy/scanner', type='json', auth='none', cors='*') def scanner(self): if not s.isAlive(): s.start() From 18a2a01853696d5b08e6737e77074e32098ac10c Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 30 Jan 2014 14:13:59 +0100 Subject: [PATCH 23/28] [IMP] improves the reporting view Expenses Analysis (add some measures to the table) in addon hr_expense bzr revid: ged@openerp.com-20140130131359-ziq94d5jmvrxbc3y --- addons/hr_expense/report/hr_expense_report_view.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/hr_expense/report/hr_expense_report_view.xml b/addons/hr_expense/report/hr_expense_report_view.xml index 45a72fa0630..f2ba5290c96 100644 --- a/addons/hr_expense/report/hr_expense_report_view.xml +++ b/addons/hr_expense/report/hr_expense_report_view.xml @@ -10,6 +10,9 @@ + + +
From a768f15038f1c93f2ae2df05487fdfa76c8d1273 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 30 Jan 2014 14:17:37 +0100 Subject: [PATCH 24/28] [IMP] improves the reporting view Timesheet Analysis (add some measures to the table) in addon hr_timesheet_sheet bzr revid: ged@openerp.com-20140130131737-hibhsfqurtxe7weh --- addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml b/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml index 5e2ca249d7d..8e06530ee9b 100644 --- a/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml +++ b/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml @@ -9,6 +9,7 @@ + From e96e86b3148acd823bf2357c6c0350ef789e1002 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 30 Jan 2014 14:20:07 +0100 Subject: [PATCH 25/28] [IMP] improves the reporting view Timesheet Sheet Analysis (add some measures to the table) in addon hr_timesheet_sheet bzr revid: ged@openerp.com-20140130132007-uyvddo0eq8yssft8 --- addons/hr_timesheet_sheet/report/timesheet_report_view.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/hr_timesheet_sheet/report/timesheet_report_view.xml b/addons/hr_timesheet_sheet/report/timesheet_report_view.xml index 47854b1f2fd..a85b17b88af 100644 --- a/addons/hr_timesheet_sheet/report/timesheet_report_view.xml +++ b/addons/hr_timesheet_sheet/report/timesheet_report_view.xml @@ -9,6 +9,10 @@ + + + + From b0fa27dc7c9eda1005dd969e8d91a977fe3dbd31 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 30 Jan 2014 16:11:46 +0100 Subject: [PATCH 26/28] [IMP] Quick fix for cros support in webclient bzr revid: fme@openerp.com-20140130151146-twct15ruxq179ryu --- addons/web/static/src/js/openerpframework.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/openerpframework.js b/addons/web/static/src/js/openerpframework.js index 71f45899f5f..dfe7b1ebdb6 100644 --- a/addons/web/static/src/js/openerpframework.js +++ b/addons/web/static/src/js/openerpframework.js @@ -970,6 +970,7 @@ openerp.Session = openerp.Class.extend(openerp.PropertiesMixin, { this.session_id = options.session_id || null; this.override_session = options.override_session || !!options.session_id || false; this.avoid_recursion = false; + this.use_cors = options.use_cors || false; this.setup(origin); }, setup: function(origin) { @@ -1013,7 +1014,7 @@ openerp.Session = openerp.Class.extend(openerp.PropertiesMixin, { }, check_session_id: function() { var self = this; - if (this.avoid_recursion) + if (this.avoid_recursion || self.use_cors) return $.when(); if (this.session_id) return $.when(); // we already have the session id @@ -1070,6 +1071,15 @@ openerp.Session = openerp.Class.extend(openerp.PropertiesMixin, { "X-Openerp-Session-Id": self.override_session ? self.session_id || '' : '' }); } + } else if (self.use_cors) { + fct = openerp.jsonRpc; + url = self.url(url, null); + options.session_id = self.session_id || ''; + if (self.override_session) { + options.headers = _.extend({}, options.headers, { + "X-Openerp-Session-Id": self.override_session ? self.session_id || '' : '' + }); + } } else { fct = openerp.jsonpRpc; url = self.url(url, null); From 3a8291d8ed9373603bfeb00bb342b74b75e8c8c0 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 30 Jan 2014 16:12:35 +0100 Subject: [PATCH 27/28] [IMP] Use cors in pos devices.js bzr revid: fme@openerp.com-20140130151235-0kewmjr5g2w6aiij --- addons/point_of_sale/static/src/js/devices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index bb13503d903..f52c0e7eaf4 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -142,7 +142,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal // connects to the specified url connect: function(url){ var self = this; - this.connection = new instance.web.Session(undefined,url); + this.connection = new instance.web.Session(undefined,url, { use_cors: true}); this.host = url; this.set_connection_status('connecting',{}); From ff0e5318f65d9cf05812d2edd4b0e0d2ff6d2268 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 30 Jan 2014 16:14:25 +0100 Subject: [PATCH 28/28] [ADD] Support cors for pos demo bzr revid: fme@openerp.com-20140130151425-tkcv5cvx04og0neu --- openerp/http.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openerp/http.py b/openerp/http.py index 717582e2ec5..0f3e7023345 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -410,6 +410,19 @@ class HttpRequest(WebRequest): self.params = params def dispatch(self): + # TODO: refactor this correctly. This is a quick fix for pos demo. + if request.httprequest.method == 'OPTIONS' and request.func.cors: + response = werkzeug.wrappers.Response(status=200) + response.headers.set('Access-Control-Allow-Origin', request.func.cors) + methods = 'GET, POST' + if request.func_request_type == 'json': + methods = 'POST' + elif request.func.methods: + methods = ', '.join(request.func.methods) + response.headers.set('Access-Control-Allow-Methods', methods) + response.headers.set('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept') + return response + r = self._call_function(**self.params) if not r: r = werkzeug.wrappers.Response(status=204) # no content