[FIX] To show all columns in a Kanban view even if they are empty.
This commit is contained in:
@@ -635,6 +635,8 @@ class website(osv.osv):
|
||||
size = '' if size is None else '/%s' % size
|
||||
return '/website/image/%s/%s/%s%s' % (model, id, field, size)
|
||||
|
||||
def google_analytics_data(self, cr, uid, main_object, context=None):
|
||||
return {}
|
||||
|
||||
class website_menu(osv.osv):
|
||||
_name = "website.menu"
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
t-att-data-website-id="website.id if editable and website else None"
|
||||
t-att-data-editable="'1' if editable else None"
|
||||
t-att-data-translatable="'1' if translatable else None"
|
||||
t-att-data-view-xmlid="xmlid"
|
||||
t-att-data-view-xmlid="xmlid if editable else None"
|
||||
t-att-data-main-object="repr(main_object) if editable else None"
|
||||
t-att-data-oe-company-name="res_company.name">
|
||||
<head>
|
||||
@@ -87,22 +87,10 @@
|
||||
<link rel="alternate" t-att-hreflang="lang['hreflang']" t-att-href="lang['href']"/>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-call-assets="web.assets_common"/>
|
||||
<t t-call-assets="website.assets_frontend"/>
|
||||
|
||||
<t t-raw="head or ''" name='layout_head'/>
|
||||
<t t-if="website and website.google_analytics_key">
|
||||
<script id="tracking_code">
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', _.str.trim('<t t-esc="website.google_analytics_key"/>'), 'auto');
|
||||
ga('send','pageview');
|
||||
</script>
|
||||
</t>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapwrap">
|
||||
@@ -148,6 +136,19 @@
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script t-if="website and website.google_analytics_key and not editable">
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', _.str.trim('<t t-esc="website.google_analytics_key"/>'), 'auto');
|
||||
ga_google_analytics_data = <t t-raw="json.dumps(website.google_analytics_data(main_object))"/>;
|
||||
for(i in ga_google_analytics_data) {
|
||||
ga('set', i, ga_google_analytics_data[i]);
|
||||
}
|
||||
ga('send','pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</template>
|
||||
|
||||
@@ -58,18 +58,18 @@ class Versioning_Controller(Website):
|
||||
result.append({'id':version_id, 'name':ver.browse(version_id).name, 'bold':1})
|
||||
return result
|
||||
|
||||
@http.route(['/website_version/has_experiments'], type = 'json', auth = "public", website = True)
|
||||
@http.route(['/website_version/has_experiments'], type = 'json', auth = "user", website = True)
|
||||
def has_experiments(self, view_id):
|
||||
v = request.env['ir.ui.view'].browse(int(view_id))
|
||||
website_id = request.context.get('website_id')
|
||||
return bool(request.env["website_version.experiment_version"].search([('version_id.view_ids.key', '=', v.key),('experiment_id.website_id.id','=',website_id)]))
|
||||
|
||||
@http.route(['/website_version/publish_version'], type = 'json', auth = "public", website = True)
|
||||
@http.route(['/website_version/publish_version'], type = 'json', auth = "user", website = True)
|
||||
def publish_version(self, version_id, save_master, copy_master_name):
|
||||
request.session['version_id'] = 0
|
||||
return request.env['website_version.version'].publish_version(int(version_id), save_master, copy_master_name)
|
||||
|
||||
@http.route(['/website_version/diff_version'], type = 'json', auth = "public", website = True)
|
||||
@http.route(['/website_version/diff_version'], type = 'json', auth = "user", website = True)
|
||||
def diff_version(self, version_id):
|
||||
mod_version = request.env['website_version.version']
|
||||
version = mod_version.browse(int(version_id))
|
||||
@@ -78,25 +78,6 @@ class Versioning_Controller(Website):
|
||||
name_list.append(view.name)
|
||||
return name_list
|
||||
|
||||
@http.route(['/website_version/get_analytics'], type = 'json', auth = "public", website = True)
|
||||
def get_analytics(self, view_id):
|
||||
#To get the ExpId and the VarId of the view if it is in a running experiment
|
||||
result = {'ExpId':False, 'VarId': 0}
|
||||
obj_v = request.env['ir.ui.view']
|
||||
view = obj_v.browse(int(view_id))
|
||||
#search all the running experiments with the key of view
|
||||
exp_ids = request.env['website_version.experiment'].search([('experiment_version_ids.version_id.view_ids.key', '=', view.key),('state','=','running'),('experiment_version_ids.version_id.website_id', '=',request.context['website_id'])])
|
||||
if exp_ids:
|
||||
#No overlap between running experiments then we can take the first one
|
||||
x = exp_ids[0]
|
||||
result['ExpId'] = x.google_id
|
||||
if view.version_id:
|
||||
exp_ver_ids = request.env['website_version.experiment_version'].search([('experiment_id','=',exp_ids[0].id),('version_id','=',view.version_id.id)])
|
||||
if exp_ver_ids:
|
||||
y = exp_ver_ids[0]
|
||||
result['VarId'] = y.google_index
|
||||
return result
|
||||
|
||||
@http.route(['/website_version/google_access'], type='json', auth="user")
|
||||
def google_authorize(self, **kw):
|
||||
#Check if client_id and client_secret are set to get the authorization from Google
|
||||
@@ -118,7 +99,7 @@ class Versioning_Controller(Website):
|
||||
"url": url
|
||||
}
|
||||
|
||||
@http.route(['/website_version/set_google_access'], type = 'json', auth = "public", website = True)
|
||||
@http.route(['/website_version/set_google_access'], type = 'json', auth = "user", website = True)
|
||||
def set_google_access(self, ga_key, view_id, client_id, client_secret):
|
||||
#To set ga_key, view_id, client_id, client_secret
|
||||
website_id = request.context.get('website_id')
|
||||
@@ -130,7 +111,7 @@ class Versioning_Controller(Website):
|
||||
icp.set_param('google_management_client_secret', client_secret or '', groups=['base.group_system'])
|
||||
|
||||
|
||||
@http.route(['/website_version/all_versions_all_goals'], type = 'json', auth = "public", website = True)
|
||||
@http.route(['/website_version/all_versions_all_goals'], type = 'json', auth = "user", website = True)
|
||||
def all_versions_all_goals(self, view_id):
|
||||
#To get all versions and all goals to create an experiment
|
||||
view = request.env['ir.ui.view']
|
||||
@@ -162,7 +143,7 @@ class Versioning_Controller(Website):
|
||||
return (False,exp.name)
|
||||
return (True,"")
|
||||
|
||||
@http.route(['/website_version/launch_experiment'], type = 'json', auth = "public", website = True)
|
||||
@http.route(['/website_version/launch_experiment'], type = 'json', auth = "user", website = True)
|
||||
def launch_experiment(self, name, version_ids, objectives):
|
||||
tab = []
|
||||
check = self.check_view(version_ids)
|
||||
|
||||
@@ -41,8 +41,8 @@ class Goals(osv.Model):
|
||||
_name = "website_version.goals"
|
||||
|
||||
_columns = {
|
||||
'name': fields.char(string="Name", size=256, required=True),
|
||||
'google_ref': fields.char(string="Reference Google", size=256, required=True),
|
||||
'name': fields.char(string="Name", required=True),
|
||||
'google_ref': fields.char(string="Reference Google", required=True),
|
||||
}
|
||||
|
||||
EXPERIMENT_STATES = [('running','Running'),('paused','Paused'),('ended','Ended')]
|
||||
@@ -62,7 +62,7 @@ class Experiment(osv.Model):
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char(string="Title", size=256, required=True),
|
||||
'name': fields.char(string="Title", required=True),
|
||||
'experiment_version_ids': fields.one2many('website_version.experiment_version', 'experiment_id',string="experiment_version_ids"),
|
||||
'website_id': fields.many2one('website',string="Website", required=True),
|
||||
'state': fields.selection(EXPERIMENT_STATES, 'Status', required=True, copy=False, track_visibility='onchange'),
|
||||
@@ -70,7 +70,7 @@ class Experiment(osv.Model):
|
||||
'color': fields.integer('Color Index'),
|
||||
'version_number' : fields.function(_get_version_number,type='integer'),
|
||||
'sequence': fields.integer('Sequence', required=True, help="Test."),
|
||||
'google_id': fields.char(string="Google_id", size=256),
|
||||
'google_id': fields.char(string="Google_id"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
@@ -302,9 +302,3 @@ class google_management(osv.AbstractModel):
|
||||
icp.set_param(cr, SUPERUSER_ID, 'google_%s_rtoken' % self.STR_SERVICE, all_token.get('refresh_token'))
|
||||
icp.set_param(cr, SUPERUSER_ID, 'google_%s_token_validity' % self.STR_SERVICE, datetime.now() + timedelta(seconds=all_token.get('expires_in')))
|
||||
icp.set_param(cr, SUPERUSER_ID, 'google_%s_token' % self.STR_SERVICE, all_token.get('access_token'))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -81,7 +81,9 @@ class view(osv.Model):
|
||||
def get_view_id(self, cr, uid, xml_id, context=None):
|
||||
if context and 'website_id' in context and not isinstance(xml_id, (int, long)):
|
||||
domain = [('key', '=', xml_id), '|', ('website_id', '=', context['website_id']), ('website_id', '=', False)]
|
||||
[xml_id] = self.search(cr, uid, domain, order='website_id', limit=1, context=context)
|
||||
if 'version_id' in context:
|
||||
domain += ['|', ('version_id', '=', context['version_id']), ('version_id', '=', False)]
|
||||
[xml_id] = self.search(cr, uid, domain, order='website_id,version_id', limit=1, context=context)
|
||||
else:
|
||||
xml_id = super(view, self).get_view_id(cr, uid, xml_id, context=context)
|
||||
return xml_id
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from openerp import api
|
||||
from openerp.osv import osv,fields
|
||||
from openerp.http import request
|
||||
import random
|
||||
@@ -9,12 +10,12 @@ class NewWebsite(osv.Model):
|
||||
_inherit = "website"
|
||||
|
||||
_columns = {
|
||||
'tuto_sync': fields.boolean("How to get GA key and View ID"),
|
||||
'tuto_google_analytics': fields.boolean("How to get GA key and View ID"),
|
||||
'google_analytics_view_id': fields.char('View ID'),
|
||||
'google_management_authorization': fields.char('Google authorization')
|
||||
}
|
||||
|
||||
def get_current_version(self,cr,uid,context=None):
|
||||
def get_current_version(self, cr, uid, context=None):
|
||||
snap = request.registry['website_version.version']
|
||||
version_id = request.context.get('version_id')
|
||||
|
||||
@@ -24,7 +25,7 @@ class NewWebsite(osv.Model):
|
||||
return snap.name_get(cr, uid, [version_id], context=context)[0];
|
||||
|
||||
def get_current_website(self, cr, uid, context=None):
|
||||
website = super(NewWebsite,self).get_current_website(cr, uid, context=context)
|
||||
website = super(NewWebsite, self).get_current_website(cr, uid, context=context)
|
||||
#We just set the cookie for the first visit
|
||||
if 'website_version_experiment' in request.httprequest.cookies:
|
||||
EXP = json.loads(request.httprequest.cookies.get('website_version_experiment'))
|
||||
@@ -61,4 +62,25 @@ class NewWebsite(osv.Model):
|
||||
request.context['experiment_id'] = 1
|
||||
return website
|
||||
|
||||
@api.model
|
||||
def google_analytics_data(self, main_object):
|
||||
result = super(NewWebsite, self).google_analytics_data(main_object)
|
||||
#To get the ExpId and the VarId of the view if it is in a running experiment
|
||||
|
||||
if main_object and main_object._name == 'ir.ui.view':
|
||||
view = main_object
|
||||
#search all the running experiments with the key of view
|
||||
exp_ids = self.env['website_version.experiment'].search([('experiment_version_ids.version_id.view_ids.key', '=', view.key),('state','=','running'),('experiment_version_ids.version_id.website_id', '=',self.env.context.get('website_id'))])
|
||||
if exp_ids:
|
||||
#No overlap between running experiments then we can take the first one
|
||||
result['expId'] = exp_ids[0].google_id
|
||||
version_id = self.env.context.get('version_id') or self.env.context['website_version_experiment'].get(exp_ids[0].google_id)
|
||||
if version_id:
|
||||
exp_ver_ids = self.env['website_version.experiment_version'].search([('experiment_id','=',exp_ids[0].id),('version_id','=', int(version_id))])
|
||||
if exp_ver_ids:
|
||||
result['expVar'] = exp_ver_ids[0].google_index
|
||||
else:
|
||||
result['expVar'] = 0
|
||||
return result
|
||||
|
||||
|
||||
|
||||
@@ -43,31 +43,6 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="assets_frontend_AB" name="website_AB assets" inherit_id="website.layout">
|
||||
<xpath expr="//script[contains(@id, 'tracking_code')]" position="replace">
|
||||
<script id='tracking_code'>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', _.str.trim('<t t-esc="website.google_analytics_key"/>'), {'cookieDomain': 'none'});
|
||||
ga('send','pageview');
|
||||
edit = $('html').attr('data-editable');
|
||||
if (edit != "1"){
|
||||
var view_id = $('html').attr('data-view-xmlid');
|
||||
openerp.jsonRpc( '/website_version/get_analytics', 'call', { 'view_id':view_id }).then(function (result) {
|
||||
var exp = result['ExpId'];
|
||||
var ver = result['VarId'];
|
||||
ga('set', 'expId', exp);
|
||||
ga('set', 'expVar', ver);
|
||||
ga('send', 'pageview');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="assets_backend" name="stock assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel="stylesheet" href="/website_version/static/src/css/google_analytics.css"/>
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
<field name="name" position="replace">
|
||||
</field>
|
||||
<field name="google_analytics_key" position="before">
|
||||
<field name="tuto_sync"/>
|
||||
<field name="tuto_google_analytics"/>
|
||||
<div colspan="4">
|
||||
<div attrs="{'invisible':[('tuto_sync','=',False)]}">
|
||||
<div attrs="{'invisible':[('tuto_google_analytics','=',False)]}">
|
||||
<br/><h2>How to get the Google Analytics Key and the View ID</h2>
|
||||
<ul>
|
||||
<li> Go to <a href='https://www.google.com/analytics/' target='_blank'>https://www.google.com/analytics/</a>
|
||||
|
||||
+8
-7
@@ -1865,14 +1865,20 @@ class BaseModel(object):
|
||||
result = []
|
||||
known_values = {}
|
||||
def append_left(left_side):
|
||||
grouped_value = left_side[groupby] and left_side[groupby][0]
|
||||
if isinstance(left_side[groupby], (list, tuple)):
|
||||
grouped_value = left_side[groupby][0]
|
||||
else:
|
||||
grouped_value = left_side[groupby]
|
||||
if not grouped_value in known_values:
|
||||
result.append(left_side)
|
||||
known_values[grouped_value] = left_side
|
||||
else:
|
||||
known_values[grouped_value].update({count_field: left_side[count_field]})
|
||||
def append_right(right_side):
|
||||
grouped_value = right_side[0]
|
||||
if isinstance(right_side, (list, tuple)):
|
||||
grouped_value = right_side[0]
|
||||
else:
|
||||
grouped_value = right_side
|
||||
if not grouped_value in known_values:
|
||||
line = dict(result_template)
|
||||
line[groupby] = right_side
|
||||
@@ -1882,11 +1888,6 @@ class BaseModel(object):
|
||||
while read_group_result or all_groups:
|
||||
left_side = read_group_result[0] if read_group_result else None
|
||||
right_side = all_groups[0] if all_groups else None
|
||||
assert left_side is None or left_side[groupby] is False \
|
||||
or isinstance(left_side[groupby], (tuple,list)), \
|
||||
'M2O-like pair expected, got %r' % left_side[groupby]
|
||||
assert right_side is None or isinstance(right_side, (tuple,list)), \
|
||||
'M2O-like pair expected, got %r' % right_side
|
||||
if left_side is None:
|
||||
append_right(all_groups.pop(0))
|
||||
elif right_side is None:
|
||||
|
||||
Reference in New Issue
Block a user