From b5793bc85b97e99b89875417f1212a9be471fca7 Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Mon, 1 Apr 2013 11:05:00 +0530 Subject: [PATCH 001/177] [FIX]Fixed the issue of file input widget which is not working in firefox and IE. bzr revid: msh@openerp.com-20130401053500-q8tsnnr59u2aqawt --- addons/web/static/src/css/base.css | 9 +++++---- addons/web/static/src/css/base.sass | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 385405e39ca..cbfa554c735 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1,4 +1,4 @@ -@charset "utf-8"; +@charset "UTF-8"; @font-face { font-family: "mnmliconsRegular"; src: url("/web/static/src/font/mnmliconsv21-webfont.eot") format("eot"); @@ -1269,7 +1269,7 @@ color: white; padding: 2px 4px; margin: 1px 6px 0 0; - border: 1px solid lightGray; + border: 1px solid lightgrey; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); -moz-border-radius: 4px; -webkit-border-radius: 4px; @@ -1301,7 +1301,7 @@ transform: scale(1.1); } .openerp .oe_secondary_submenu .oe_active { - border-top: 1px solid lightGray; + border-top: 1px solid lightgrey; border-bottom: 1px solid #dedede; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2), inset 0 -1px 3px rgba(40, 40, 40, 0.2); @@ -2284,7 +2284,7 @@ } .openerp .oe_form .oe_form_label_help[for] span, .openerp .oe_form .oe_form_label[for] span { font-size: 80%; - color: darkGreen; + color: darkgreen; vertical-align: top; position: relative; top: -4px; @@ -2475,6 +2475,7 @@ } .openerp .oe_hidden_input_file { position: relative; + overflow-x: hidden; } .openerp .oe_hidden_input_file input.oe_form_binary_file { z-index: 0; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 5fe5b1ceaf4..fcace37ec03 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1967,6 +1967,7 @@ $sheet-padding: 16px // Position: relative is used for the hidden input[type=file] // Do not remove it anymore ! position: relative + overflow-x: hidden input.oe_form_binary_file z-index: 0 line-height: 0 From 0a71d06be3909cfde8e3bd41752af2ba84dae023 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 12 Mar 2014 14:22:13 +0100 Subject: [PATCH 002/177] [IMP] work in progress on stats buttons. The goal is to allow buttons with dynamic/statistical informations in form views (addon web) bzr revid: ged@openerp.com-20140312132213-hclaw6jc87u220zq --- addons/web/static/src/css/base.css | 17 ++++++++++++ addons/web/static/src/css/base.sass | 14 ++++++++++ addons/web/static/src/js/view_form.js | 37 +++++++++++++++++++++++++-- addons/web/static/src/xml/base.xml | 10 ++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index e43a2fb654e..263a867390e 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -462,6 +462,23 @@ .openerp .oe_button_box button { margin: 4px; } +.openerp .oe_button_box .oe_stat_button { + font-weight: normal; + display: inline-table; + width: 48% !important; + height: 45px; + margin: 1px; +} +.openerp .oe_button_box .oe_stat_button > div { + display: table-cell; + vertical-align: middle; + padding: 0; +} +.openerp .oe_button_box .oe_stat_button .stat_button_icon { + color: #7c7bad; + font-size: 24px; + padding: 4px; +} .openerp .oe_avatar > img { max-height: 90px; max-width: 90px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index b19db9e4ebd..2d5ae82135e 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -433,6 +433,20 @@ $sheet-padding: 16px text-align: right button margin: 4px + .oe_stat_button + font-weight: normal + display: inline-table + width: 48% !important + height: 45px + margin: 1px + > div + display: table-cell + vertical-align: middle + padding: 0 + .stat_button_icon + color: #7C7BAD + font-size: 24px + padding: 4px .oe_avatar > img max-height: 90px diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index f1fc377fa94..a8973d760fa 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1218,6 +1218,9 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt $('button', doc).each(function() { $(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button'); }); + $('statbutton', doc).each(function() { + $(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button'); + }); // IE's html parser is also a css parser. How convenient... $('board', doc).each(function() { $(this).attr('layout', $(this).attr('style')); @@ -1277,6 +1280,9 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt var defs = []; _.each(this.to_replace, function(el) { defs.push(el[0].replace(el[1])); + if (el[1].children().length) { + el[0].$el.append(el[1].children()); + } }); this.to_replace = []; return $.when.apply($, defs); @@ -1304,7 +1310,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt var tagname = $tag[0].nodeName.toLowerCase(); if (this.tags_registry.contains(tagname)) { this.tags_to_init.push($tag); - return $tag; + return (tagname === 'statbutton') ? this.process_statbutton($tag) : $tag; } var fn = self['process_' + tagname]; if (fn) { @@ -1321,6 +1327,17 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt return $tag; } }, + process_statbutton: function ($button) { + var self = this; + console.log('yenrst'); + if ($button.children().length) { + $button.children().each(function() { + self.process($(this)); + }); + } + return $button; + }, + process_widget: function($widget) { this.widgets_to_init.push($widget); return $widget; @@ -1976,7 +1993,6 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ var self = this; var context = this.build_context(); - return this.view.do_execute_action( _.extend({}, this.node.attrs, {context: context}), this.view.dataset, this.view.datarecord.id, function () { @@ -1990,6 +2006,22 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ } }); +instance.web.form.StatButton = instance.web.form.WidgetButton.extend({ + template: 'StatButton', + + init: function(field_manager, node) { + var icon = node.attrs.icon; + this._super(field_manager, node); + + // debugger; + if (icon) { + this.icon = ""; + } + + }, + +}); + /** * Interface to be implemented by fields. * @@ -5899,6 +5931,7 @@ instance.web.form.widgets = new instance.web.Registry({ */ instance.web.form.tags = new instance.web.Registry({ 'button' : 'instance.web.form.WidgetButton', + 'statbutton' : 'instance.web.form.StatButton', }); instance.web.form.custom_widgets = new instance.web.Registry({ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 80b82c1f40b..fa96fe1ac8a 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1360,6 +1360,16 @@ + + +
From ee478106748e52b314ac80a69d34a9b50cc29e4f Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 12 Mar 2014 14:45:38 +0100 Subject: [PATCH 003/177] [IMP] css tweaks to stat buttons bzr revid: ged@openerp.com-20140312134538-7b3o22lakb8qk45a --- addons/web/static/src/css/base.css | 3 ++- addons/web/static/src/css/base.sass | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 263a867390e..524bd79cc52 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -467,7 +467,8 @@ display: inline-table; width: 48% !important; height: 45px; - margin: 1px; + margin: 0px; + color: #666666; } .openerp .oe_button_box .oe_stat_button > div { display: table-cell; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 2d5ae82135e..f81232b7ee8 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -438,7 +438,8 @@ $sheet-padding: 16px display: inline-table width: 48% !important height: 45px - margin: 1px + margin: 0px + color: #666 > div display: table-cell vertical-align: middle From d2637811dec84306ab80cc49f40a8b823d7984a6 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Thu, 13 Mar 2014 13:48:43 +0100 Subject: [PATCH 004/177] [IMP] adds PercentPie and X2Many widgets to formview. PercentPie takes a field 'float' and displays a read-only pie chart to visualize the corresponding percent. X2Many takes a 1tomany or a manytomany field and display a read only string '
- - - - + + + + + + @@ -1945,7 +1947,7 @@ - +
From af61fd53bc86583aca872d4d884e976fed885d30 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Fri, 14 Mar 2014 15:21:55 +0100 Subject: [PATCH 008/177] [IMP] removes the tooltip when mouse hovers over a 'percentpie' widget (addon web) bzr revid: ged@openerp.com-20140314142155-u8suij5tikxwd0zi --- addons/web/static/src/js/view_form.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index dcb15d3d16d..c4bddd90f34 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2837,6 +2837,7 @@ instance.web.form.FieldPercentPie = instance.web.form.AbstractField.extend({ .donut(true) .showLegend(false) .showLabels(false) + .tooltips(false) .color(['#7C7BAD','#DDD']) .donutRatio(0.62); From e8198d74b68c3f1fba677b596a2eedf60af8ad83 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Mon, 17 Mar 2014 16:27:10 +0100 Subject: [PATCH 009/177] [IMP] various tweaks to stat_button, to fix issues mentioned in code review. This is mostly cosmetic cleanups, only notable change is that stat_button is now a proper html button instead of a label (addon web) bzr revid: ged@openerp.com-20140317152710-c33q8kua33o001la --- addons/web/static/src/css/base.css | 9 +++++--- addons/web/static/src/css/base.sass | 10 +++++---- addons/web/static/src/js/view_form.js | 16 ++++++-------- addons/web/static/src/xml/base.xml | 31 +++++++++------------------ 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 0b432d0c145..1d843e7e250 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -460,6 +460,9 @@ width: 400px; text-align: left; } +.openerp .oe_button_box .oe_stat_button:hover { + background: #dddddd; +} .openerp .oe_button_box .oe_stat_button { font-weight: normal; display: inline-table; @@ -467,7 +470,8 @@ height: 45px; margin: 0px -1px -1px 0px; color: #666666; - border-color: #dddddd; + border: 1px solid #666666; + background: white; } .openerp .oe_button_box .oe_stat_button > div { display: table-cell; @@ -478,9 +482,8 @@ .openerp .oe_button_box .oe_stat_button .stat_button_icon { color: #7c7bad; font-size: 24px; - padding: 0px; + padding: 0px 3px; text-align: center; - width: 40px; } .openerp .oe_button_box .oe_stat_button svg { width: 38px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 336f583e019..cca0deb4a1f 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -432,6 +432,8 @@ $sheet-padding: 16px .oe_button_box width: 400px text-align: left + .oe_stat_button:hover + background: #ddd .oe_stat_button font-weight: normal display: inline-table @@ -439,18 +441,18 @@ $sheet-padding: 16px height: 45px margin: 0px -1px -1px 0px color: #666 - border-color: #ddd + border: 1px solid #666 + background: white > div display: table-cell vertical-align: middle text-align: left - padding: 0 + padding: 0 .stat_button_icon color: #7C7BAD font-size: 24px - padding: 0px + padding: 0px 3px text-align: center - width: 40px svg width: 38px height: 38px diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index c4bddd90f34..969e0150737 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1916,8 +1916,8 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ template: 'WidgetButton', init: function(field_manager, node) { node.attrs.type = node.attrs['data-button-type']; - this.is_stat_button = node.attrs.class ? _.include(node.attrs.class.split(' '), 'oe_stat_button') : false; - this.icon = ""; + this.is_stat_button = /\boe_stat_button\b/.test(node.attrs['class']); + this.icon = node.attrs.icon && ""; this._super(field_manager, node); this.force_disabled = false; this.string = (this.node.attrs.string || '').replace(/_/g, ''); @@ -2845,16 +2845,12 @@ instance.web.form.FieldPercentPie = instance.web.form.AbstractField.extend({ .datum([{'x': 'value', 'y': value}, {'x': 'complement', 'y': 100 - value}]) .transition() .call(chart) - .attr('width', size) - .attr('height',size); + .attr({width:size, height:size}); d3.select(svg) .append("text") - .attr("x", size/2) - .attr("y", size/2 + 3) - .style("font-size", "10px") - .style("font-weight", "bold") - .attr("text-anchor", "middle") + .attr({x: size/2, y: size/2 + 3, 'text-anchor': 'middle'}) + .style({"font-size": "10px", "font-weight": "bold"}) .text(formatted_value); return chart; @@ -5923,7 +5919,7 @@ instance.web.form.StatInfo = instance.web.form.AbstractField.extend({ }, render_value: function() { var text = _.str.sprintf("%d %s", this.get("value") || 0, this.string); - this.$().html(QWeb.render("StatInfo", {text: text})); + this.$el.html(QWeb.render("StatInfo", {text: text})); }, }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index b24bd8642cc..cc56dc2de13 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1189,7 +1189,7 @@
- + @@ -1356,26 +1356,15 @@
- - - - - - + From 373cb908caf5792367e49050e3d4ae086a097d0c Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Tue, 18 Mar 2014 09:55:25 +0100 Subject: [PATCH 010/177] [FIX] correctly handle the case where a 'stat button' has a string attribute (it needs to be displayed in a div instead of a span) (addon web) bzr revid: ged@openerp.com-20140318085525-vllzeycht9841g41 --- addons/web/static/src/xml/base.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index cc56dc2de13..508c507d935 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1362,11 +1362,11 @@ t-att-autofocus="widget.node.attrs.autofocus" t-att-accesskey="widget.node.attrs.accesskey"> -
- +
+ +
-
- +
From c49befd59f5ab3ef50a061b29dcef36b55c79088 Mon Sep 17 00:00:00 2001 From: "Parth Gajjar (Open ERP)" Date: Tue, 18 Mar 2014 19:00:36 +0530 Subject: [PATCH 011/177] [ADD] added website_gengo module bzr revid: pga@tinyerp.com-20140318133036-j1hcrz7bybolw44u --- .../wizard/base_gengo_translations.py | 1 + addons/website/controllers/main.py | 2 + .../static/src/js/website.translator.js | 4 +- addons/website_gengo/__init__.py | 21 +++++ addons/website_gengo/__openerp__.py | 40 ++++++++ addons/website_gengo/controllers/__init__.py | 1 + addons/website_gengo/controllers/main.py | 0 .../static/src/js/website_gengo.js | 91 +++++++++++++++++++ .../static/src/xml/website.gengo.xml | 73 +++++++++++++++ addons/website_gengo/views/website_gengo.xml | 12 +++ 10 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 addons/website_gengo/__init__.py create mode 100644 addons/website_gengo/__openerp__.py create mode 100644 addons/website_gengo/controllers/__init__.py create mode 100644 addons/website_gengo/controllers/main.py create mode 100644 addons/website_gengo/static/src/js/website_gengo.js create mode 100644 addons/website_gengo/static/src/xml/website.gengo.xml create mode 100644 addons/website_gengo/views/website_gengo.xml diff --git a/addons/base_gengo/wizard/base_gengo_translations.py b/addons/base_gengo/wizard/base_gengo_translations.py index bfd51480141..00c175e1450 100644 --- a/addons/base_gengo/wizard/base_gengo_translations.py +++ b/addons/base_gengo/wizard/base_gengo_translations.py @@ -74,6 +74,7 @@ class base_gengo_translations(osv.osv_memory): gengo = MyGengo( public_key=user.company_id.gengo_public_key.encode('ascii'), private_key=user.company_id.gengo_private_key.encode('ascii'), + sandbox = True, ) gengo.getAccountStats() return (True, gengo) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index aee0997e4b4..4d20dd11d40 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -240,6 +240,8 @@ class Website(openerp.addons.web.controllers.main.Home): 'source': initial_content, 'value': new_content, } + if t.get('gengo_translation'): + new_trans['gengo_translation'] = t.get('gengo_translation') irt.create(request.cr, request.uid, new_trans) return True diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index 399e5e731b2..c330d511170 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -120,7 +120,9 @@ } else { node.className += ' oe_translatable_todo'; } - node.contentEditable = true; + if(!this.gengo_translate){ + node.contentEditable = true; + } var nid = _.uniqueId(); $(node).attr('data-oe-nodeid', nid); this.initial_content[nid] = content; diff --git a/addons/website_gengo/__init__.py b/addons/website_gengo/__init__.py new file mode 100644 index 00000000000..654cb5b6b1a --- /dev/null +++ b/addons/website_gengo/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-Today OpenERP S.A. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + diff --git a/addons/website_gengo/__openerp__.py b/addons/website_gengo/__openerp__.py new file mode 100644 index 00000000000..6ebb5e8ed30 --- /dev/null +++ b/addons/website_gengo/__openerp__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-Today OpenERP S.A. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'Website Gengo Translator', + 'category': 'Website', + 'version': '1.0', + 'description': """ +Website Gengo Translator +======================== +""", + 'author': 'OpenERP SA', + 'depends': [ + 'website', + 'base_gengo' + ], + 'data': [ + 'views/website_gengo.xml', + ], + 'qweb': [], + 'installable': True, +} diff --git a/addons/website_gengo/controllers/__init__.py b/addons/website_gengo/controllers/__init__.py new file mode 100644 index 00000000000..8ee9bae18d9 --- /dev/null +++ b/addons/website_gengo/controllers/__init__.py @@ -0,0 +1 @@ +import main diff --git a/addons/website_gengo/controllers/main.py b/addons/website_gengo/controllers/main.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/addons/website_gengo/static/src/js/website_gengo.js b/addons/website_gengo/static/src/js/website_gengo.js new file mode 100644 index 00000000000..6c5c2903dc6 --- /dev/null +++ b/addons/website_gengo/static/src/js/website_gengo.js @@ -0,0 +1,91 @@ +(function () { + 'use strict'; + + var website = openerp.website; + website.add_template_file('/website_gengo/static/src/xml/website.gengo.xml'); + + website.EditorBar.include({ + events: _.extend({}, website.EditorBar.prototype.events, { + 'click a[data-action=translation_gengo]': 'translation_gengo', + 'click a[data-action=translation_gengo_post]': 'translation_gengo_post', + }), + start: function () { + this.gengo_translate = false; + this._super.apply(this, arguments); + var self = this; + self.$('button[data-action=edit]') + .after(openerp.qweb.render('website.ButtonGengoTranslator')); + }, + translation_gengo: function () { + var self = this; + var dialog = new website.GengoTranslatorDialog(); + dialog.appendTo($(document.body)); + self.gengo_translate = true; + dialog.on('activate', this, function () { + dialog.$el.modal('hide'); + self.translate().then(function () { + self.gengo_translate = false; + self.$el.find('.gengo_translate').addClass("hidden"); + self.$el.find('.gengo_post').removeClass("hidden"); + }); + }); + + }, + translation_gengo_post: function () { + var self = this; + var translatable_list = $.find('.oe_translatable_todo'); + var dialog = new website.GengoTranslatorPostDialog(); + dialog.appendTo($(document.body)); + dialog.on('service_level', this, function () { + var gengo_service_level = dialog.$el.find(".form-control").val(); + dialog.$el.modal('hide'); + var trans ={} + $('.oe_translatable_todo').each(function () { + var $node = $(this); + var data = $node.data(); + if (!trans[data.oeTranslationViewId]) { + trans[data.oeTranslationViewId] = []; + } + trans[data.oeTranslationViewId].push({ + initial_content: self.getInitialContent(this), + new_content:self.getInitialContent(this), + translation_id: data.oeTranslationId || null, + gengo_translation: gengo_service_level + }); + }); + openerp.jsonRpc('/website/set_translations', 'call', { + 'data': trans, + 'lang': website.get_context()['lang'], + }); + }); + + }, + }); + + website.GengoTranslatorDialog = openerp.Widget.extend({ + events: _.extend({}, website.EditorBar.prototype.events, { + 'hidden.bs.modal': 'destroy', + 'click button[data-action=activate]': function (ev) { + this.trigger('activate'); + }, + }), + template: 'website.GengoTranslatorDialog', + start: function () { + this.$el.modal(); + }, + }); + + website.GengoTranslatorPostDialog = openerp.Widget.extend({ + events: _.extend({}, website.EditorBar.prototype.events, { + 'hidden.bs.modal': 'destroy', + 'click button[data-action=service_level]': function (ev) { + this.trigger('service_level'); + }, + }), + template: 'website.GengoTranslatorPostDialog', + start: function () { + this.$el.modal(); + }, + }); + +})(); diff --git a/addons/website_gengo/static/src/xml/website.gengo.xml b/addons/website_gengo/static/src/xml/website.gengo.xml new file mode 100644 index 00000000000..25d0cf8e44c --- /dev/null +++ b/addons/website_gengo/static/src/xml/website.gengo.xml @@ -0,0 +1,73 @@ + + + + Buy Translation + + + + + + + + + + + \ No newline at end of file diff --git a/addons/website_gengo/views/website_gengo.xml b/addons/website_gengo/views/website_gengo.xml new file mode 100644 index 00000000000..56681df4c42 --- /dev/null +++ b/addons/website_gengo/views/website_gengo.xml @@ -0,0 +1,12 @@ + + + + + + + + From 43419ed6e9ec4dc3edbcc121055e4148260fdeb2 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 19 Mar 2014 09:49:31 +0100 Subject: [PATCH 012/177] [IMP] Allow openerp.tools.convert_file() to optionally take the full path name bzr revid: fme@openerp.com-20140319084931-1ipjqi2dd3ug7i2t --- openerp/tools/convert.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openerp/tools/convert.py b/openerp/tools/convert.py index 43ee96660bd..eb7652f3737 100644 --- a/openerp/tools/convert.py +++ b/openerp/tools/convert.py @@ -952,8 +952,9 @@ form: module.record_id""" % (xml_id,) 'url': self._tag_url } -def convert_file(cr, module, filename, idref, mode='update', noupdate=False, kind=None, report=None): - pathname = os.path.join(module, filename) +def convert_file(cr, module, filename, idref, mode='update', noupdate=False, kind=None, report=None, pathname=None): + if pathname is None: + pathname = os.path.join(module, filename) fp = misc.file_open(pathname) ext = os.path.splitext(filename)[1].lower() try: From 40fdb08a7db13c52c49026f8425bc40dac5a7696 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 19 Mar 2014 09:53:43 +0100 Subject: [PATCH 013/177] [WIP] base_import_module bzr revid: fme@openerp.com-20140319085343-zkee3rmqc9dzpa7h --- addons/base_import_module/__init__.py | 2 + addons/base_import_module/__openerp__.py | 21 ++++++++ .../controllers/__init__.py | 1 + addons/base_import_module/controllers/main.py | 38 ++++++++++++++ addons/base_import_module/models/__init__.py | 2 + addons/base_import_module/models/ir_module.py | 49 +++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 addons/base_import_module/__init__.py create mode 100644 addons/base_import_module/__openerp__.py create mode 100644 addons/base_import_module/controllers/__init__.py create mode 100644 addons/base_import_module/controllers/main.py create mode 100644 addons/base_import_module/models/__init__.py create mode 100644 addons/base_import_module/models/ir_module.py diff --git a/addons/base_import_module/__init__.py b/addons/base_import_module/__init__.py new file mode 100644 index 00000000000..9f86759e32b --- /dev/null +++ b/addons/base_import_module/__init__.py @@ -0,0 +1,2 @@ +import controllers +import models diff --git a/addons/base_import_module/__openerp__.py b/addons/base_import_module/__openerp__.py new file mode 100644 index 00000000000..ba37462642c --- /dev/null +++ b/addons/base_import_module/__openerp__.py @@ -0,0 +1,21 @@ +{ + 'name': 'Base import module', + 'description': """ +Import a custom data module +=========================== + +This module allows authorized users to import a custom data module (.xml files and static assests) +for customization purpose. +""", + 'category': 'Uncategorized', + 'website': 'http://www.openerp.com', + 'author': 'OpenERP SA', + 'depends': ['web'], + 'installable': True, + 'auto_install': False, + 'data': [], + 'css': [], + 'js': [], + 'qweb': [], + 'test': [], +} diff --git a/addons/base_import_module/controllers/__init__.py b/addons/base_import_module/controllers/__init__.py new file mode 100644 index 00000000000..8ee9bae18d9 --- /dev/null +++ b/addons/base_import_module/controllers/__init__.py @@ -0,0 +1 @@ +import main diff --git a/addons/base_import_module/controllers/main.py b/addons/base_import_module/controllers/main.py new file mode 100644 index 00000000000..6ddd0158b4d --- /dev/null +++ b/addons/base_import_module/controllers/main.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +import os +import zipfile +from os.path import join as opj + +import openerp +from openerp.http import Controller, route, request + +MAX_FILE_SIZE = 100 * 1024 * 1024 # in megabytes + +class ImportModule(Controller): + + @route('/base_import_module/upload', type='http', auth='none') + def upload(self, mod_file=None, **kw): + assert request.db # TODO: custom ensure_db? + request.uid = openerp.SUPERUSER_ID # TODO: proper security + + imm = request.registry['ir.module.module'] + + if not mod_file: + raise Exception("No file sent.") + if not zipfile.is_zipfile(mod_file): + raise Exception("Not a zipfile.") + + with zipfile.ZipFile(mod_file, "r") as z: + for zf in z.filelist: + if zf.file_size > MAX_FILE_SIZE: + raise Exception("File %r exceed maximum allowed file size" % zf.filename) + + with openerp.tools.osutil.tempdir() as module_dir: + z.extractall(module_dir) + dirs = [d for d in os.listdir(module_dir) if os.path.isdir(opj(module_dir, d))] + for mod_name in dirs: + # assert mod_name.startswith('theme_') + path = opj(module_dir, mod_name) + imm.import_module(request.cr, request.uid, mod_name, path, context=request.context) + return 'ok' + diff --git a/addons/base_import_module/models/__init__.py b/addons/base_import_module/models/__init__.py new file mode 100644 index 00000000000..a28c82fe5ba --- /dev/null +++ b/addons/base_import_module/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import ir_module diff --git a/addons/base_import_module/models/ir_module.py b/addons/base_import_module/models/ir_module.py new file mode 100644 index 00000000000..be03067972b --- /dev/null +++ b/addons/base_import_module/models/ir_module.py @@ -0,0 +1,49 @@ +import logging +from os.path import join as opj + +import openerp +from openerp.osv import osv, fields +from openerp.tools import convert_file + +_logger = logging.getLogger(__name__) + +class view(osv.osv): + _inherit = "ir.module.module" + _columns = { + 'is_theme': fields.boolean('Theme'), + } + _defaults = { + 'is_theme': False, + } + + def import_module(self, cr, uid, module, path, context=None): + known_mods = self.browse(cr, uid, self.search(cr, uid, [])) + known_mods_names = dict([(m.name, m) for m in known_mods]) + + mod = known_mods_names.get(module) + terp = openerp.modules.load_information_from_description_file(module, mod_path=path) + values = self.get_values_from_terp(terp) + + unmet_dependencies = set(terp['depends']).difference(known_mods_names.keys()) + if unmet_dependencies: + raise Exception("Unmet module dependencies: %s" % ', '.join(unmet_dependencies)) + + if mod: + self.write(cr, uid, mod.id, values) + mode = 'update' + else: + assert terp.get('installable', True), "Module not installable" + self.create(cr, uid, dict(name=module, state='uninstalled', **values)) + mode = 'init' + + for kind in ['data', 'init_xml', 'update_xml']: + for filename in terp[kind]: + _logger.info("module %s: loading %s", module, filename) + noupdate = False + if filename.endswith('.csv') and kind in ('init', 'init_xml'): + noupdate = True + pathname = opj(path, filename) + idref = {} + convert_file(cr, module, filename, idref, mode=mode, noupdate=noupdate, kind=kind, pathname=pathname) + + return True From 46cfd8940f7f3f0557335538892389751730ee6d Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 19 Mar 2014 09:54:54 +0100 Subject: [PATCH 014/177] [FIX] doc typo bzr revid: fme@openerp.com-20140319085454-1pnjm55b4vxfm1wc --- openerp/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/http.py b/openerp/http.py index 4f6a6cdd86a..0dc5e86171b 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -1027,7 +1027,7 @@ class Root(object): return self.dispatch(environ, start_response) def load_addons(self): - """ Load all addons from addons patch containg static files and + """ Load all addons from addons path containing static files and controllers and configure them. """ statics = {} From 14c3ffcb39e860e0f893d2727b4129eeea87244d Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 19 Mar 2014 09:57:08 +0100 Subject: [PATCH 015/177] [IMP] Allow openerp.modules.load_information_from_description_file() to take an optional mod_path argument bzr revid: fme@openerp.com-20140319085708-prrs0m4gjvuu4o86 --- openerp/modules/module.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openerp/modules/module.py b/openerp/modules/module.py index 8958813baa2..b0b7e0aeb94 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -169,13 +169,15 @@ def get_module_icon(module): return ('/' + module + '/') + '/'.join(iconpath) return '/base/' + '/'.join(iconpath) -def load_information_from_description_file(module): +def load_information_from_description_file(module, mod_path=None): """ :param module: The name of the module (sale, purchase, ...) + :param mod_path: Physical path of module, if not providedThe name of the module (sale, purchase, ...) """ - terp_file = get_module_resource(module, '__openerp__.py') - mod_path = get_module_path(module) + if not mod_path: + mod_path = get_module_path(module) + terp_file = opj(mod_path, '__openerp__.py') if terp_file: info = {} if os.path.isfile(terp_file): From f4cfed3f0e89f8841b16ad578dd2c360f01d18ec Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 19 Mar 2014 09:57:18 +0100 Subject: [PATCH 016/177] [IMP] improves the look of the stat buttons in form view: the statinfo widget displays the information on two lines, the padding/margin/width have been adjusted. (addon web) bzr revid: ged@openerp.com-20140319085718-9v1l3pb43ee6qws6 --- addons/web/static/src/css/base.css | 14 +++++++++++--- addons/web/static/src/css/base.sass | 13 ++++++++++--- addons/web/static/src/js/view_form.js | 9 ++++++--- addons/web/static/src/xml/base.xml | 5 ++--- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 1d843e7e250..53043f2f4c5 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -461,16 +461,22 @@ text-align: left; } .openerp .oe_button_box .oe_stat_button:hover { - background: #dddddd; + background: #7c7bad; + color: white; +} +.openerp .oe_button_box .oe_stat_button:hover .fa { + color: white; } .openerp .oe_button_box .oe_stat_button { font-weight: normal; display: inline-table; width: 33% !important; - height: 45px; + height: 42px; margin: 0px -1px -1px 0px; + padding: 0; color: #666666; - border: 1px solid #666666; + border: 1px solid #dddddd; + border-radius: 0; background: white; } .openerp .oe_button_box .oe_stat_button > div { @@ -478,11 +484,13 @@ vertical-align: middle; text-align: left; padding: 0; + line-height: 120%; } .openerp .oe_button_box .oe_stat_button .stat_button_icon { color: #7c7bad; font-size: 24px; padding: 0px 3px; + width: 37px; text-align: center; } .openerp .oe_button_box .oe_stat_button svg { diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index cca0deb4a1f..466f60fa861 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -433,25 +433,32 @@ $sheet-padding: 16px width: 400px text-align: left .oe_stat_button:hover - background: #ddd + background: #7c7bad + color: white + .fa + color: white .oe_stat_button font-weight: normal display: inline-table width: 33% !important - height: 45px + height: 42px margin: 0px -1px -1px 0px + padding: 0 color: #666 - border: 1px solid #666 + border: 1px solid #dddddd + border-radius: 0 background: white > div display: table-cell vertical-align: middle text-align: left padding: 0 + line-height: 120% .stat_button_icon color: #7C7BAD font-size: 24px padding: 0px 3px + width: 37px text-align: center svg width: 38px diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 969e0150737..5840d718bf8 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1917,7 +1917,7 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ init: function(field_manager, node) { node.attrs.type = node.attrs['data-button-type']; this.is_stat_button = /\boe_stat_button\b/.test(node.attrs['class']); - this.icon = node.attrs.icon && ""; + this.icon = node.attrs.icon && ""; this._super(field_manager, node); this.force_disabled = false; this.string = (this.node.attrs.string || '').replace(/_/g, ''); @@ -5918,8 +5918,11 @@ instance.web.form.StatInfo = instance.web.form.AbstractField.extend({ this.set("value", 0); }, render_value: function() { - var text = _.str.sprintf("%d %s", this.get("value") || 0, this.string); - this.$el.html(QWeb.render("StatInfo", {text: text})); + var options = { + value: this.get("value") || 0, + text: this.string, + }; + this.$el.html(QWeb.render("StatInfo", options)); }, }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 508c507d935..e35d0c977b3 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1362,7 +1362,7 @@ t-att-autofocus="widget.node.attrs.autofocus" t-att-accesskey="widget.node.attrs.accesskey"> -
+
@@ -1937,6 +1937,5 @@
-
-
+
From b8d87606f0579bbdfdf75dee4669d5f0fd9bb279 Mon Sep 17 00:00:00 2001 From: "Parth Gajjar (Open ERP)" Date: Wed, 19 Mar 2014 19:01:21 +0530 Subject: [PATCH 017/177] [IMP] added gengo statistics, displayed inprogress elements bzr revid: pga@tinyerp.com-20140319133121-31umju0ea84sm93y --- addons/website/controllers/main.py | 2 +- addons/website/static/src/css/editor.css | 4 ++ addons/website/static/src/css/editor.sass | 2 + .../static/src/js/website.translator.js | 5 ++ addons/website_gengo/__init__.py | 1 + addons/website_gengo/controllers/main.py | 19 +++++++ .../static/src/js/website_gengo.js | 51 +++++++++++++++++-- .../static/src/xml/website.gengo.xml | 32 ++++++++++-- 8 files changed, 108 insertions(+), 8 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 4d20dd11d40..011a31e00e3 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -206,7 +206,7 @@ class Website(openerp.addons.web.controllers.main.Home): views_ids = [view.get('id') for view in views if view.get('active')] domain = [('type', '=', 'view'), ('res_id', 'in', views_ids), ('lang', '=', lang)] irt = request.registry.get('ir.translation') - return irt.search_read(request.cr, request.uid, domain, ['id', 'res_id', 'value'], context=request.context) + return irt.search_read(request.cr, request.uid, domain, ['id', 'res_id', 'value','state'], context=request.context) @http.route('/website/set_translations', type='json', auth='public', website=True) def set_translations(self, data, lang): diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index da0fad43caf..5755bb06b03 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -145,6 +145,10 @@ table.editorbar-panel td.selected { background: #ffffb6; } +.oe_translatable_inprogress { + background: #b7e4ff; +} + /* ---- MENU ---- {{{ */ div.oe_menu_buttons { top: -8px; diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index 4571dcd257e..21b43ac77f3 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -115,6 +115,8 @@ table.editorbar-panel padding: 0 10px .oe_translatable_todo background: rgb(255, 255, 182) +.oe_translatable_todo + background: rgb(183, 228, 255) // }}} diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index c330d511170..12c740300c6 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -115,8 +115,13 @@ var trans = this.translations.filter(function (t) { return t.res_id === view_id && t.value === content; }); + console.log(trans); + console.log(this.translations); if (trans.length) { node.setAttribute('data-oe-translation-id', trans[0].id); + if(trans[0].state && trans[0].state == 'inprogress'){ + node.className += ' oe_translatable_inprogress'; + } } else { node.className += ' oe_translatable_todo'; } diff --git a/addons/website_gengo/__init__.py b/addons/website_gengo/__init__.py index 654cb5b6b1a..6da11461444 100644 --- a/addons/website_gengo/__init__.py +++ b/addons/website_gengo/__init__.py @@ -19,3 +19,4 @@ # ############################################################################## +import controllers \ No newline at end of file diff --git a/addons/website_gengo/controllers/main.py b/addons/website_gengo/controllers/main.py index e69de29bb2d..167e3e7bd36 100644 --- a/addons/website_gengo/controllers/main.py +++ b/addons/website_gengo/controllers/main.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from openerp.addons.web import http +from openerp.addons.web.http import request +class website_gengo(http.Controller): + + @http.route('/website/get_gengo_info', type='json', auth='user', website=True) + def get_gengo_info(self, view_id, lang): + ir_translation_obj = request.registry['ir.translation'] + res_lang_obj = request.registry['res.lang'] + translation_ids = ir_translation_obj.search(request.cr, request.uid, [('res_id','=',view_id),('gengo_translation','!=', False),('lang','=',lang)]) + result={"total":0,"inprogess":0,"done":0} + for trans in ir_translation_obj.browse(request.cr, request.uid, translation_ids): + result['total'] += len(trans.source.split()) + if trans.state == 'translated': + result['done'] += len(trans.source.split()) + elif trans.state == 'inprogress': + result['inprogess'] += len(trans.source.split()) + return result diff --git a/addons/website_gengo/static/src/js/website_gengo.js b/addons/website_gengo/static/src/js/website_gengo.js index 6c5c2903dc6..94cc2ab5c11 100644 --- a/addons/website_gengo/static/src/js/website_gengo.js +++ b/addons/website_gengo/static/src/js/website_gengo.js @@ -8,13 +8,19 @@ events: _.extend({}, website.EditorBar.prototype.events, { 'click a[data-action=translation_gengo]': 'translation_gengo', 'click a[data-action=translation_gengo_post]': 'translation_gengo_post', + 'click a[data-action=translation_gengo_info]': 'translation_gengo_info', }), start: function () { this.gengo_translate = false; this._super.apply(this, arguments); var self = this; - self.$('button[data-action=edit]') - .after(openerp.qweb.render('website.ButtonGengoTranslator')); + var gengo_langs = ["ar_SA","id_ID","nl_NL","fr_CA","pl_PL","zh_TW","sv_SE","ko_KR","pt_PT","en_US","ja_JP","es_ES","zh_CN","de_DE","fr_FR","fr_BE","ru_RU","it_IT","pt_BR"]; + if (gengo_langs.indexOf(website.get_context()['lang']) != -1) + { + self.$('button[data-action=edit]') + .after(openerp.qweb.render('website.ButtonGengoTranslator')); + + } }, translation_gengo: function () { var self = this; @@ -25,8 +31,15 @@ dialog.$el.modal('hide'); self.translate().then(function () { self.gengo_translate = false; - self.$el.find('.gengo_translate').addClass("hidden"); - self.$el.find('.gengo_post').removeClass("hidden"); + if($('.oe_translatable_todo').length > 0){ + self.$el.find('.gengo_translate').addClass("hidden"); + self.$el.find('.gengo_post').removeClass("hidden"); + } + else{ + self.$el.find('.gengo_translate').addClass("hidden"); + self.$el.find('.gengo_inprogress').removeClass("hidden"); + + } }); }); @@ -39,6 +52,8 @@ dialog.on('service_level', this, function () { var gengo_service_level = dialog.$el.find(".form-control").val(); dialog.$el.modal('hide'); + self.$el.find('.gengo_post').addClass("hidden"); + self.$el.find('.gengo_inprogress').removeClass("hidden"); var trans ={} $('.oe_translatable_todo').each(function () { var $node = $(this); @@ -60,6 +75,18 @@ }); }, + translation_gengo_info: function () { + var repr = $(document.documentElement).data('mainObject') + var view_id = repr.match(/.+\((.+), (\d+)\)/)[2]; + openerp.jsonRpc('/website/get_gengo_info', 'call', { + 'view_id': view_id, + 'lang': website.get_context()['lang'], + }).done(function(res){ + var dialog = new website.GengoTranslatorStatisticDialog(res); + dialog.appendTo($(document.body)); + + }); + }, }); website.GengoTranslatorDialog = openerp.Widget.extend({ @@ -87,5 +114,21 @@ this.$el.modal(); }, }); + + website.GengoTranslatorStatisticDialog = openerp.Widget.extend({ + events: _.extend({}, website.EditorBar.prototype.events, { + 'hidden.bs.modal': 'destroy', + }), + template: 'website.GengoTranslatorStatisticDialog', + init:function(res){ + this.total = res.total; + this.inprogess = res.inprogess; + this.done = res.done; + return this._super.apply(this, arguments); + }, + start: function (res) { + this.$el.modal(this.res); + }, + }); })(); diff --git a/addons/website_gengo/static/src/xml/website.gengo.xml b/addons/website_gengo/static/src/xml/website.gengo.xml index 25d0cf8e44c..39338a15fca 100644 --- a/addons/website_gengo/static/src/xml/website.gengo.xml +++ b/addons/website_gengo/static/src/xml/website.gengo.xml @@ -1,8 +1,7 @@ - Buy Translation - + Buy Translation + + + + \ No newline at end of file From 38ae695d00e5afe95da7220e0029c53ed0cda510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Mar 2014 15:46:08 +0100 Subject: [PATCH 018/177] [IMP] payment modules: added provider selection field that is different from the name. This allows to distinguish name and provider. Provider is a more technical field, used to call some specific methods (_method_name). The name field is used for display on the website. Code and views udpated accordingly. bzr revid: tde@openerp.com-20140319144608-0i4rv520l0bh53f0 --- addons/payment/models/payment_acquirer.py | 33 +++++++++++-------- addons/payment/views/payment_acquirer.xml | 6 ++++ addons/payment_adyen/data/adyen.xml | 3 +- addons/payment_adyen/models/adyen.py | 18 +++++----- .../payment_adyen/views/payment_acquirer.xml | 2 +- addons/payment_ogone/data/ogone.xml | 3 +- addons/payment_ogone/models/ogone.py | 7 +++- .../payment_ogone/views/payment_acquirer.xml | 2 +- addons/payment_paypal/data/paypal.xml | 3 +- addons/payment_paypal/models/paypal.py | 5 +++ .../payment_paypal/views/payment_acquirer.xml | 2 +- addons/payment_transfer/data/transfer.xml | 3 +- .../models/payment_acquirer.py | 5 +++ addons/website_sale/views/website_sale.xml | 2 +- 14 files changed, 63 insertions(+), 31 deletions(-) diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 9ad77b3c4cf..464cb0c8f5c 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -52,8 +52,15 @@ class PaymentAcquirer(osv.Model): _name = 'payment.acquirer' _description = 'Payment Acquirer' + def _get_providers(self, cr, uid, context=None): + return [] + + # indirection to ease inheritance + _provider_selection = lambda self, *args, **kwargs: self._get_providers(*args, **kwargs) + _columns = { 'name': fields.char('Name', required=True), + 'provider': fields.selection(_provider_selection, string='Provider', required=True), 'company_id': fields.many2one('res.company', 'Company', required=True), 'pre_msg': fields.html('Message', help='Message displayed to explain and help the payment process.'), 'post_msg': fields.html('Thanks Message', help='Message displayed after having done the payment process.'), @@ -84,10 +91,10 @@ class PaymentAcquirer(osv.Model): } def _check_required_if_provider(self, cr, uid, ids, context=None): - """ If the field has 'required_if_provider=""' attribute, then it - required if record.name is . """ + """ If the field has 'required_if_provider=""' attribute, then it + required if record.provider is . """ for acquirer in self.browse(cr, uid, ids, context=context): - if any(c for c, f in self._all_columns.items() if getattr(f.column, 'required_if_provider', None) == acquirer.name and not acquirer[c]): + if any(c for c, f in self._all_columns.items() if getattr(f.column, 'required_if_provider', None) == acquirer.provider and not acquirer[c]): return False return True @@ -98,8 +105,8 @@ class PaymentAcquirer(osv.Model): def get_form_action_url(self, cr, uid, id, context=None): """ Returns the form action URL, for form-based acquirer implementations. """ acquirer = self.browse(cr, uid, id, context=context) - if hasattr(self, '%s_get_form_action_url' % acquirer.name): - return getattr(self, '%s_get_form_action_url' % acquirer.name)(cr, uid, id, context=context) + if hasattr(self, '%s_get_form_action_url' % acquirer.provider): + return getattr(self, '%s_get_form_action_url' % acquirer.provider)(cr, uid, id, context=context) return False def form_preprocess_values(self, cr, uid, id, reference, amount, currency_id, tx_id, partner_id, partner_values, tx_values, context=None): @@ -178,7 +185,7 @@ class PaymentAcquirer(osv.Model): }) # compute fees - fees_method_name = '%s_compute_fees' % acquirer.name + fees_method_name = '%s_compute_fees' % acquirer.provider if hasattr(self, fees_method_name): fees = getattr(self, fees_method_name)( cr, uid, id, tx_data['amount'], tx_data['currency_id'], partner_data['country_id'], context=None) @@ -237,7 +244,7 @@ class PaymentAcquirer(osv.Model): partner_values, tx_values, context=context) # call _form_generate_values to update the tx dict with acqurier specific values - cust_method_name = '%s_form_generate_values' % (acquirer.name) + cust_method_name = '%s_form_generate_values' % (acquirer.provider) if hasattr(self, cust_method_name): method = getattr(self, cust_method_name) partner_values, tx_values = method(cr, uid, id, partner_values, tx_values, context=context) @@ -383,14 +390,14 @@ class PaymentTransaction(osv.Model): acquirer = self.pool['payment.acquirer'].browse(cr, uid, values.get('acquirer_id'), context=context) # compute fees - custom_method_name = '%s_compute_fees' % acquirer.name + custom_method_name = '%s_compute_fees' % acquirer.provider if hasattr(Acquirer, custom_method_name): fees = getattr(Acquirer, custom_method_name)( cr, uid, acquirer.id, values.get('amount', 0.0), values.get('currency_id'), values.get('country_id'), context=None) values['fees'] = float_round(fees, 2) # custom create - custom_method_name = '%s_create' % acquirer.name + custom_method_name = '%s_create' % acquirer.provider if hasattr(self, custom_method_name): values.update(getattr(self, custom_method_name)(cr, uid, values, context=context)) @@ -469,7 +476,7 @@ class PaymentTransaction(osv.Model): if values.get('acquirer_id'): acquirer = self.pool['payment.acquirer'].browse(cr, uid, values.get('acquirer_id'), context=context) - custom_method_name = '_%s_s2s_send' % acquirer.name + custom_method_name = '_%s_s2s_send' % acquirer.provider if hasattr(self, custom_method_name): tx_id, result = getattr(self, custom_method_name)(cr, uid, values, cc_values, context=context) @@ -482,7 +489,7 @@ class PaymentTransaction(osv.Model): tx = self.browse(cr, uid, tx_id, context=context) invalid_parameters = None - invalid_param_method_name = '_%s_s2s_get_invalid_parameters' % tx.acquirer_id.name + invalid_param_method_name = '_%s_s2s_get_invalid_parameters' % tx.acquirer_id.provider if hasattr(self, invalid_param_method_name): invalid_parameters = getattr(self, invalid_param_method_name)(cr, uid, tx, data, context=context) @@ -493,7 +500,7 @@ class PaymentTransaction(osv.Model): _logger.error(_error_message) return False - feedback_method_name = '_%s_s2s_validate' % tx.acquirer_id.name + feedback_method_name = '_%s_s2s_validate' % tx.acquirer_id.provider if hasattr(self, feedback_method_name): return getattr(self, feedback_method_name)(cr, uid, tx, data, context=context) @@ -503,7 +510,7 @@ class PaymentTransaction(osv.Model): """ Get the tx status. """ tx = self.browse(cr, uid, tx_id, context=context) - invalid_param_method_name = '_%s_s2s_get_tx_status' % tx.acquirer_id.name + invalid_param_method_name = '_%s_s2s_get_tx_status' % tx.acquirer_id.provider if hasattr(self, invalid_param_method_name): return getattr(self, invalid_param_method_name)(cr, uid, tx, context=context) diff --git a/addons/payment/views/payment_acquirer.xml b/addons/payment/views/payment_acquirer.xml index 5dbd748bda7..e2e0644480d 100644 --- a/addons/payment/views/payment_acquirer.xml +++ b/addons/payment/views/payment_acquirer.xml @@ -16,6 +16,7 @@ + @@ -66,6 +67,7 @@ + @@ -77,6 +79,10 @@ + + + + diff --git a/addons/payment_adyen/data/adyen.xml b/addons/payment_adyen/data/adyen.xml index 8f6e7e218e4..5ca0f4d71e9 100644 --- a/addons/payment_adyen/data/adyen.xml +++ b/addons/payment_adyen/data/adyen.xml @@ -3,7 +3,8 @@ - adyen + Adyen + adyen test diff --git a/addons/payment_adyen/models/adyen.py b/addons/payment_adyen/models/adyen.py index 80103f50dae..607d65738c5 100644 --- a/addons/payment_adyen/models/adyen.py +++ b/addons/payment_adyen/models/adyen.py @@ -26,14 +26,14 @@ class AcquirerAdyen(osv.Model): - yhpp: hosted payment page: pay.shtml for single, select.shtml for multiple """ - if env == 'prod': - return { - 'adyen_form_url': 'https://prod.adyen.com/hpp/pay.shtml', - } - else: - return { - 'adyen_form_url': 'https://test.adyen.com/hpp/pay.shtml', - } + return { + 'adyen_form_url': 'https://%s.adyen.com/hpp/pay.shtml' % env, + } + + def _get_providers(self, cr, uid, context=None): + providers = super(AcquirerAdyen, self)._get_providers(cr, uid, context=context) + providers.append(['adyen', 'Adyen']) + return providers _columns = { 'adyen_merchant_account': fields.char('Merchant Account', required_if_provider='adyen'), @@ -54,7 +54,7 @@ class AcquirerAdyen(osv.Model): :return string: shasign """ assert inout in ('in', 'out') - assert acquirer.name == 'adyen' + assert acquirer.provider == 'adyen' if inout == 'in': keys = "paymentAmount currencyCode shipBeforeDate merchantReference skinCode merchantAccount sessionValidity shopperEmail shopperReference recurringContract allowedMethods blockedMethods shopperStatement merchantReturnData billingAddressType deliveryAddressType offset".split() diff --git a/addons/payment_adyen/views/payment_acquirer.xml b/addons/payment_adyen/views/payment_acquirer.xml index 1510a110c43..396bf9c32d5 100644 --- a/addons/payment_adyen/views/payment_acquirer.xml +++ b/addons/payment_adyen/views/payment_acquirer.xml @@ -8,7 +8,7 @@ - + diff --git a/addons/payment_ogone/data/ogone.xml b/addons/payment_ogone/data/ogone.xml index e94276ba3e1..ade39cfb79c 100644 --- a/addons/payment_ogone/data/ogone.xml +++ b/addons/payment_ogone/data/ogone.xml @@ -3,7 +3,8 @@ - ogone + Credit Card + ogone test diff --git a/addons/payment_ogone/models/ogone.py b/addons/payment_ogone/models/ogone.py index 2ae9722b655..f6cab44f0b5 100644 --- a/addons/payment_ogone/models/ogone.py +++ b/addons/payment_ogone/models/ogone.py @@ -36,6 +36,11 @@ class PaymentAcquirerOgone(osv.Model): 'ogone_afu_agree_url': 'https://secure.ogone.com/ncol/%s/AFU_agree.asp' % (env,), } + def _get_providers(self, cr, uid, context=None): + providers = super(PaymentAcquirerOgone, self)._get_providers(cr, uid, context=context) + providers.append(['ogone', 'Ogone']) + return providers + _columns = { 'ogone_pspid': fields.char('PSPID', required_if_provider='ogone'), 'ogone_userid': fields.char('API User ID', required_if_provider='ogone'), @@ -57,7 +62,7 @@ class PaymentAcquirerOgone(osv.Model): :return string: shasign """ assert inout in ('in', 'out') - assert acquirer.name == 'ogone' + assert acquirer.provider == 'ogone' key = getattr(acquirer, 'ogone_shakey_' + inout) def filter_key(key): diff --git a/addons/payment_ogone/views/payment_acquirer.xml b/addons/payment_ogone/views/payment_acquirer.xml index accce4d70d2..f297eb9431a 100644 --- a/addons/payment_ogone/views/payment_acquirer.xml +++ b/addons/payment_ogone/views/payment_acquirer.xml @@ -8,7 +8,7 @@ - + diff --git a/addons/payment_paypal/data/paypal.xml b/addons/payment_paypal/data/paypal.xml index fe28ed30331..0ea6cd5a848 100644 --- a/addons/payment_paypal/data/paypal.xml +++ b/addons/payment_paypal/data/paypal.xml @@ -3,7 +3,8 @@ - paypal + Paypal + paypal test diff --git a/addons/payment_paypal/models/paypal.py b/addons/payment_paypal/models/paypal.py index a5e31e9571c..de852702880 100644 --- a/addons/payment_paypal/models/paypal.py +++ b/addons/payment_paypal/models/paypal.py @@ -34,6 +34,11 @@ class AcquirerPaypal(osv.Model): 'paypal_rest_url': 'https://api.sandbox.paypal.com/v1/oauth2/token', } + def _get_providers(self, cr, uid, context=None): + providers = super(AcquirerPaypal, self)._get_providers(cr, uid, context=context) + providers.append(['paypal', 'Paypal']) + return providers + _columns = { 'paypal_email_account': fields.char('Paypal Email ID', required_if_provider='paypal'), 'paypal_seller_account': fields.char( diff --git a/addons/payment_paypal/views/payment_acquirer.xml b/addons/payment_paypal/views/payment_acquirer.xml index 835d96f42e9..3fb5db184f6 100644 --- a/addons/payment_paypal/views/payment_acquirer.xml +++ b/addons/payment_paypal/views/payment_acquirer.xml @@ -8,7 +8,7 @@ - + diff --git a/addons/payment_transfer/data/transfer.xml b/addons/payment_transfer/data/transfer.xml index c2863971d34..d67e07bdfef 100644 --- a/addons/payment_transfer/data/transfer.xml +++ b/addons/payment_transfer/data/transfer.xml @@ -3,7 +3,8 @@ - transfer + Transfer + transfer manual diff --git a/addons/payment_transfer/models/payment_acquirer.py b/addons/payment_transfer/models/payment_acquirer.py index 90b1329ff25..b8c3d023674 100644 --- a/addons/payment_transfer/models/payment_acquirer.py +++ b/addons/payment_transfer/models/payment_acquirer.py @@ -14,6 +14,11 @@ _logger = logging.getLogger(__name__) class TransferPaymentAcquirer(osv.Model): _inherit = 'payment.acquirer' + def _get_providers(self, cr, uid, context=None): + providers = super(TransferPaymentAcquirer, self)._get_providers(cr, uid, context=context) + providers.append(['transfer', 'Transfer']) + return providers + def transfer_get_form_action_url(self, cr, uid, id, context=None): return '/payment/transfer/feedback' diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index b870a676cc9..cfd8a131fb7 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -956,7 +956,7 @@ + t-att-src="'/payment_%s/static/src/img/%s_icon.png' % (acquirer.provider, acquirer.provider)"/> From b7a68828edb5b12196f6fd7bc76bb0d63f39d61c Mon Sep 17 00:00:00 2001 From: "Parth Gajjar (Open ERP)" Date: Thu, 20 Mar 2014 12:40:28 +0530 Subject: [PATCH 019/177] [IMP] improved statistics, added sendbox options for testing, improved UI bzr revid: pga@tinyerp.com-20140320071028-adyh8d89o7dij81o --- addons/base_gengo/res_company.py | 1 + addons/base_gengo/res_company_view.xml | 9 +++++++-- .../wizard/base_gengo_translations.py | 2 +- .../static/src/js/website.translator.js | 2 +- addons/website_gengo/controllers/main.py | 2 +- .../static/src/js/website_gengo.js | 19 +++++++++++++++---- .../static/src/xml/website.gengo.xml | 15 ++++++++++----- 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/addons/base_gengo/res_company.py b/addons/base_gengo/res_company.py index 3d038ac0813..645564b4eeb 100644 --- a/addons/base_gengo/res_company.py +++ b/addons/base_gengo/res_company.py @@ -30,6 +30,7 @@ class res_company(osv.Model): "gengo_public_key": fields.text("Gengo Public Key"), "gengo_comment": fields.text("Comments", help="This comment will be automatically be enclosed in each an every request sent to Gengo"), "gengo_auto_approve": fields.boolean("Auto Approve Translation ?", help="Jobs are Automatically Approved by Gengo."), + "gengo_sandbox": fields.boolean("Sandbox", help="Enable if you using testing account"), } _defaults = { diff --git a/addons/base_gengo/res_company_view.xml b/addons/base_gengo/res_company_view.xml index 0f99efc8ad0..d08d809eb9c 100644 --- a/addons/base_gengo/res_company_view.xml +++ b/addons/base_gengo/res_company_view.xml @@ -17,8 +17,13 @@ - - + + + + + + + diff --git a/addons/base_gengo/wizard/base_gengo_translations.py b/addons/base_gengo/wizard/base_gengo_translations.py index 00c175e1450..9b96e8c91e3 100644 --- a/addons/base_gengo/wizard/base_gengo_translations.py +++ b/addons/base_gengo/wizard/base_gengo_translations.py @@ -74,7 +74,7 @@ class base_gengo_translations(osv.osv_memory): gengo = MyGengo( public_key=user.company_id.gengo_public_key.encode('ascii'), private_key=user.company_id.gengo_private_key.encode('ascii'), - sandbox = True, + sandbox = user.company_id.gengo_sandbox, ) gengo.getAccountStats() return (True, gengo) diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index 12c740300c6..a2893e61248 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -119,7 +119,7 @@ console.log(this.translations); if (trans.length) { node.setAttribute('data-oe-translation-id', trans[0].id); - if(trans[0].state && trans[0].state == 'inprogress'){ + if(trans[0].state && (trans[0].state == 'inprogress' || trans[0].state == 'to_translate')){ node.className += ' oe_translatable_inprogress'; } } else { diff --git a/addons/website_gengo/controllers/main.py b/addons/website_gengo/controllers/main.py index 167e3e7bd36..7c22829464e 100644 --- a/addons/website_gengo/controllers/main.py +++ b/addons/website_gengo/controllers/main.py @@ -14,6 +14,6 @@ class website_gengo(http.Controller): result['total'] += len(trans.source.split()) if trans.state == 'translated': result['done'] += len(trans.source.split()) - elif trans.state == 'inprogress': + elif trans.state in ['inprogress','to_translate']: result['inprogess'] += len(trans.source.split()) return result diff --git a/addons/website_gengo/static/src/js/website_gengo.js b/addons/website_gengo/static/src/js/website_gengo.js index 94cc2ab5c11..badb51f9296 100644 --- a/addons/website_gengo/static/src/js/website_gengo.js +++ b/addons/website_gengo/static/src/js/website_gengo.js @@ -9,6 +9,7 @@ 'click a[data-action=translation_gengo]': 'translation_gengo', 'click a[data-action=translation_gengo_post]': 'translation_gengo_post', 'click a[data-action=translation_gengo_info]': 'translation_gengo_info', + 'click a[data-action=reload]': 'reload', }), start: function () { this.gengo_translate = false; @@ -32,12 +33,12 @@ self.translate().then(function () { self.gengo_translate = false; if($('.oe_translatable_todo').length > 0){ - self.$el.find('.gengo_translate').addClass("hidden"); - self.$el.find('.gengo_post').removeClass("hidden"); + self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden"); + self.$el.find('.gengo_post,.gengo_info,.gengo_discard').removeClass("hidden"); } else{ - self.$el.find('.gengo_translate').addClass("hidden"); - self.$el.find('.gengo_inprogress').removeClass("hidden"); + self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden"); + self.$el.find('.gengo_inprogress,.gengo_info,.gengo_discard').removeClass("hidden"); } }); @@ -71,6 +72,8 @@ openerp.jsonRpc('/website/set_translations', 'call', { 'data': trans, 'lang': website.get_context()['lang'], + }).done(function(){ + $('.oe_translatable_todo').addClass('oe_translatable_inprogress').removeClass('oe_translatable_todo'); }); }); @@ -87,6 +90,9 @@ }); }, + reload: function () { + website.reload(); + }, }); website.GengoTranslatorDialog = openerp.Widget.extend({ @@ -121,9 +127,14 @@ }), template: 'website.GengoTranslatorStatisticDialog', init:function(res){ + var self = this; this.total = res.total; this.inprogess = res.inprogess; this.done = res.done; + this.new_words = 0; + $('.oe_translatable_todo').each(function () { + self.new_words += $(this).text().split(" ").length; + }); return this._super.apply(this, arguments); }, start: function (res) { diff --git a/addons/website_gengo/static/src/xml/website.gengo.xml b/addons/website_gengo/static/src/xml/website.gengo.xml index 39338a15fca..00733829d42 100644 --- a/addons/website_gengo/static/src/xml/website.gengo.xml +++ b/addons/website_gengo/static/src/xml/website.gengo.xml @@ -1,7 +1,9 @@ - Buy Translation + Gengo Translation + +