diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 409551585fa..3e86c4963b7 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -432,7 +432,7 @@ class account_invoice(osv.osv): if t['state'] in ('draft', 'cancel') and t['internal_number']== False: unlink_ids.append(t['id']) else: - raise osv.except_osv(_('Invalid Action!'), _('You cannot delete an invoice which is open or paid. You should refund it instead.')) + raise osv.except_osv(_('Invalid Action!'), _('You can not delete an invoice which is not cancelled. You should refund it instead.')) osv.osv.unlink(self, cr, uid, unlink_ids, context=context) return True diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 4feb97c2f5f..d3697b13ea9 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -436,7 +436,7 @@
- +
diff --git a/addons/account_accountant/account_accountant_data.xml b/addons/account_accountant/account_accountant_data.xml index 14d8f59a5fe..c7d6eb80bc6 100644 --- a/addons/account_accountant/account_accountant_data.xml +++ b/addons/account_accountant/account_accountant_data.xml @@ -28,8 +28,8 @@ notification Accounting and Finance application installed! - With OpenERP's accounting, you get instant access to your financial data, and can setup analytic accounting, forecast taxes, control budgets, easily create and send invoices, record bank statements, etc.

-

The accounting features are fully integrated with other OpenERP applications to automate all your processes: creation of customer invoices, control of supplier invoices, point-of-sale integration, automated follow-ups, etc.

]]>
+ With OpenERP's accounting, you get instant access to your financial data, and can setup analytic accounting, forecast taxes, control budgets, easily create and send invoices, record bank statements, etc.

+

The accounting features are fully integrated with other OpenERP applications to automate all your processes: creation of customer invoices, control of supplier invoices, point-of-sale integration, automated follow-ups, etc.

]]>
diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index 0dddf441c59..a44226e76c8 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -377,9 +377,8 @@ class account_asset_depreciation_line(osv.osv): move_line_obj = self.pool.get('account.move.line') currency_obj = self.pool.get('res.currency') created_move_ids = [] + asset_ids = [] for line in self.browse(cr, uid, ids, context=context): - if currency_obj.is_zero(cr, uid, line.asset_id.currency_id, line.remaining_value): - can_close = True depreciation_date = time.strftime('%Y-%m-%d') period_ids = period_obj.find(cr, uid, depreciation_date, context=context) company_currency = line.asset_id.company_id.currency_id.id @@ -409,8 +408,8 @@ class account_asset_depreciation_line(osv.osv): 'period_id': period_ids and period_ids[0] or False, 'journal_id': journal_id, 'partner_id': partner_id, - 'currency_id': company_currency <> current_currency and current_currency or False, - 'amount_currency': company_currency <> current_currency and - sign * line.amount or 0.0, + 'currency_id': company_currency != current_currency and current_currency or False, + 'amount_currency': company_currency != current_currency and - sign * line.amount or 0.0, 'date': depreciation_date, }) move_line_obj.create(cr, uid, { @@ -423,16 +422,19 @@ class account_asset_depreciation_line(osv.osv): 'period_id': period_ids and period_ids[0] or False, 'journal_id': journal_id, 'partner_id': partner_id, - 'currency_id': company_currency <> current_currency and current_currency or False, - 'amount_currency': company_currency <> current_currency and sign * line.amount or 0.0, + 'currency_id': company_currency != current_currency and current_currency or False, + 'amount_currency': company_currency != current_currency and sign * line.amount or 0.0, 'analytic_account_id': line.asset_id.category_id.account_analytic_id.id, 'date': depreciation_date, 'asset_id': line.asset_id.id }) self.write(cr, uid, line.id, {'move_id': move_id}, context=context) created_move_ids.append(move_id) - if can_close: - asset_obj.write(cr, uid, [line.asset_id.id], {'state': 'close'}, context=context) + asset_ids.append(line.asset_id.id) + # we re-evaluate the assets to determine whether we can close them + for asset in asset_obj.browse(cr, uid, list(set(asset_ids)), context=context): + if currency_obj.is_zero(cr, uid, asset.currency_id, asset.value_residual): + asset.write({'state': 'close'}) return created_move_ids account_asset_depreciation_line() diff --git a/addons/account_bank_statement_extensions/account_bank_statement_view.xml b/addons/account_bank_statement_extensions/account_bank_statement_view.xml index 3d5560856a3..adc2963c803 100644 --- a/addons/account_bank_statement_extensions/account_bank_statement_view.xml +++ b/addons/account_bank_statement_extensions/account_bank_statement_view.xml @@ -72,12 +72,12 @@ - + - - + + @@ -100,8 +100,8 @@ - - + + diff --git a/addons/account_budget/account_budget_view.xml b/addons/account_budget/account_budget_view.xml index d24124e307d..35194e96b82 100644 --- a/addons/account_budget/account_budget_view.xml +++ b/addons/account_budget/account_budget_view.xml @@ -224,7 +224,6 @@ account.budget.line.search crossovered.budget.lines - search diff --git a/addons/account_check_writing/i18n/lt.po b/addons/account_check_writing/i18n/lt.po new file mode 100644 index 00000000000..35e98d451ad --- /dev/null +++ b/addons/account_check_writing/i18n/lt.po @@ -0,0 +1,199 @@ +# Lithuanian translation for openobject-addons +# Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 +# This file is distributed under the same license as the openobject-addons package. +# FIRST AUTHOR , 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: openobject-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2012-02-08 00:35+0000\n" +"PO-Revision-Date: 2012-11-16 06:33+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Lithuanian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2012-11-17 04:37+0000\n" +"X-Generator: Launchpad (build 16278)\n" + +#. module: account_check_writing +#: selection:res.company,check_layout:0 +msgid "Check on Top" +msgstr "" + +#. module: account_check_writing +#: model:ir.actions.act_window,help:account_check_writing.action_write_check +msgid "" +"The check payment form allows you to track the payment you do to your " +"suppliers specially by check. When you select a supplier, the payment method " +"and an amount for the payment, OpenERP will propose to reconcile your " +"payment with the open supplier invoices or bills.You can print the check" +msgstr "" + +#. module: account_check_writing +#: view:account.voucher:0 +#: model:ir.actions.report.xml,name:account_check_writing.account_print_check_bottom +#: model:ir.actions.report.xml,name:account_check_writing.account_print_check_middle +#: model:ir.actions.report.xml,name:account_check_writing.account_print_check_top +msgid "Print Check" +msgstr "" + +#. module: account_check_writing +#: selection:res.company,check_layout:0 +msgid "Check in middle" +msgstr "" + +#. module: account_check_writing +#: help:res.company,check_layout:0 +msgid "" +"Check on top is compatible with Quicken, QuickBooks and Microsoft Money. " +"Check in middle is compatible with Peachtree, ACCPAC and DacEasy. Check on " +"bottom is compatible with Peachtree, ACCPAC and DacEasy only" +msgstr "" + +#. module: account_check_writing +#: selection:res.company,check_layout:0 +msgid "Check on bottom" +msgstr "" + +#. module: account_check_writing +#: constraint:res.company:0 +msgid "Error! You can not create recursive companies." +msgstr "" + +#. module: account_check_writing +#: help:account.journal,allow_check_writing:0 +msgid "Check this if the journal is to be used for writing checks." +msgstr "" + +#. module: account_check_writing +#: field:account.journal,allow_check_writing:0 +msgid "Allow Check writing" +msgstr "" + +#. module: account_check_writing +#: report:account.print.check.bottom:0 +#: report:account.print.check.middle:0 +#: report:account.print.check.top:0 +msgid "Description" +msgstr "Aprašas" + +#. module: account_check_writing +#: model:ir.model,name:account_check_writing.model_account_journal +msgid "Journal" +msgstr "Žurnalas" + +#. module: account_check_writing +#: model:ir.actions.act_window,name:account_check_writing.action_write_check +#: model:ir.ui.menu,name:account_check_writing.menu_action_write_check +msgid "Write Checks" +msgstr "" + +#. module: account_check_writing +#: report:account.print.check.bottom:0 +#: report:account.print.check.middle:0 +#: report:account.print.check.top:0 +msgid "Discount" +msgstr "" + +#. module: account_check_writing +#: report:account.print.check.bottom:0 +#: report:account.print.check.middle:0 +#: report:account.print.check.top:0 +msgid "Original Amount" +msgstr "" + +#. module: account_check_writing +#: view:res.company:0 +msgid "Configuration" +msgstr "" + +#. module: account_check_writing +#: field:account.voucher,allow_check:0 +msgid "Allow Check Writing" +msgstr "" + +#. module: account_check_writing +#: report:account.print.check.bottom:0 +#: report:account.print.check.middle:0 +#: report:account.print.check.top:0 +msgid "Payment" +msgstr "" + +#. module: account_check_writing +#: field:account.journal,use_preprint_check:0 +msgid "Use Preprinted Check" +msgstr "" + +#. module: account_check_writing +#: sql_constraint:res.company:0 +msgid "The company name must be unique !" +msgstr "" + +#. module: account_check_writing +#: report:account.print.check.bottom:0 +#: report:account.print.check.middle:0 +#: report:account.print.check.top:0 +msgid "Due Date" +msgstr "" + +#. module: account_check_writing +#: model:ir.model,name:account_check_writing.model_res_company +msgid "Companies" +msgstr "" + +#. module: account_check_writing +#: view:res.company:0 +msgid "Default Check Layout" +msgstr "" + +#. module: account_check_writing +#: constraint:account.journal:0 +msgid "" +"Configuration error! The currency chosen should be shared by the default " +"accounts too." +msgstr "" + +#. module: account_check_writing +#: report:account.print.check.bottom:0 +#: report:account.print.check.middle:0 +msgid "Balance Due" +msgstr "" + +#. module: account_check_writing +#: report:account.print.check.bottom:0 +#: report:account.print.check.middle:0 +#: report:account.print.check.top:0 +msgid "Check Amount" +msgstr "" + +#. module: account_check_writing +#: model:ir.model,name:account_check_writing.model_account_voucher +msgid "Accounting Voucher" +msgstr "" + +#. module: account_check_writing +#: sql_constraint:account.journal:0 +msgid "The name of the journal must be unique per company !" +msgstr "" + +#. module: account_check_writing +#: sql_constraint:account.journal:0 +msgid "The code of the journal must be unique per company !" +msgstr "" + +#. module: account_check_writing +#: field:account.voucher,amount_in_word:0 +msgid "Amount in Word" +msgstr "" + +#. module: account_check_writing +#: report:account.print.check.top:0 +msgid "Open Balance" +msgstr "" + +#. module: account_check_writing +#: field:res.company,check_layout:0 +msgid "Choose Check layout" +msgstr "" diff --git a/addons/account_voucher/i18n/nl.po b/addons/account_voucher/i18n/nl.po index 87972b2d22c..84eb08244a6 100644 --- a/addons/account_voucher/i18n/nl.po +++ b/addons/account_voucher/i18n/nl.po @@ -7,14 +7,14 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2012-02-08 01:37+0100\n" -"PO-Revision-Date: 2012-05-10 18:01+0000\n" -"Last-Translator: Raphael Collet (OpenERP) \n" +"PO-Revision-Date: 2012-11-17 09:57+0000\n" +"Last-Translator: Stefan Rijnhart (Therp) \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2012-10-30 05:19+0000\n" -"X-Generator: Launchpad (build 16206)\n" +"X-Launchpad-Export-Date: 2012-11-18 04:37+0000\n" +"X-Generator: Launchpad (build 16278)\n" #. module: account_voucher #: view:sale.receipt.report:0 @@ -846,7 +846,7 @@ msgstr "" #: view:account.voucher:0 #: model:ir.model,name:account_voucher.model_account_voucher msgid "Accounting Voucher" -msgstr "Betalingsintentie" +msgstr "Journaalbon" #. module: account_voucher #: field:account.voucher,number:0 diff --git a/addons/anonymization/security/ir.model.access.csv b/addons/anonymization/security/ir.model.access.csv index 745913eaa65..e758867ce46 100644 --- a/addons/anonymization/security/ir.model.access.csv +++ b/addons/anonymization/security/ir.model.access.csv @@ -3,3 +3,4 @@ access_ir_model_fields_anonymization_group_system,ir_model_fields_anonymization access_ir_model_fields_anonymization_user,ir_model_fields_anonymization user,model_ir_model_fields_anonymization,,1,0,0,0 access_ir_model_fields_anonymization_history_group_system,ir_model_fields_anonymization_history group_user,model_ir_model_fields_anonymization_history,base.group_system,1,1,1,1 access_ir_model_fields_anonymization_history_user,ir_model_fields_anonymization_history user,model_ir_model_fields_anonymization_history,,1,0,0,0 +access_ir_model_fields_anonymization_migration_fix,access_ir_model_fields_anonymization_migration_fix,model_ir_model_fields_anonymization_migration_fix,,1,1,1,1 diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 45ab0c4fbb1..54284dee4da 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -346,8 +346,13 @@ class audittrail_objects_proxy(object_proxy): x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj)) x2m_model = pool.get('ir.model').browse(cr, SUPERUSER_ID, x2m_model_id) - #recursive call on x2m fields that need to be checked too - data.update(self.get_data(cr, SUPERUSER_ID, pool, resource[field], x2m_model, method)) + field_resource_ids = list(set(resource[field])) + if model.model == x2m_model.model: + # we need to remove current resource_id from the many2many to prevent an infinit loop + if resource_id in field_resource_ids: + field_resource_ids.remove(resource_id) + data.update(self.get_data(cr, SUPERUSER_ID, pool, field_resource_ids, x2m_model, method)) + data[(model.id, resource_id)] = {'text':values_text, 'value': values} return data @@ -408,6 +413,10 @@ class audittrail_objects_proxy(object_proxy): x2m_new_values_ids = new_values.get(key, {'value': {}})['value'].get(field_name, []) # We use list(set(...)) to remove duplicates. res_ids = list(set(x2m_old_values_ids + x2m_new_values_ids)) + if model.model == x2m_model.model: + # we need to remove current resource_id from the many2many to prevent an infinit loop + if resource_id in res_ids: + res_ids.remove(resource_id) for res_id in res_ids: lines.update(self.prepare_audittrail_log_line(cr, SUPERUSER_ID, pool, x2m_model, res_id, method, old_values, new_values, field_list)) # if the value value is different than the old value: record the change diff --git a/addons/auth_oauth/controllers/main.py b/addons/auth_oauth/controllers/main.py index 26016f3f0a1..4c7c5377184 100644 --- a/addons/auth_oauth/controllers/main.py +++ b/addons/auth_oauth/controllers/main.py @@ -1,48 +1,101 @@ +import functools import logging import simplejson -import werkzeug.urls -import werkzeug.utils +from werkzeug.exceptions import BadRequest -import openerp +from openerp import SUPERUSER_ID +import openerp.addons.web.http as oeweb +from openerp.addons.web.controllers.main import db_monodb, set_cookie_and_redirect, login_and_redirect +from openerp.modules.registry import RegistryManager _logger = logging.getLogger(__name__) -class OAuthController(openerp.addons.web.http.Controller): +#---------------------------------------------------------- +# helpers +#---------------------------------------------------------- +def fragment_to_query_string(func): + @functools.wraps(func) + def wrapper(self, req, **kw): + if not kw: + return """""" + return func(self, req, **kw) + return wrapper + + +#---------------------------------------------------------- +# Controller +#---------------------------------------------------------- +class OAuthController(oeweb.Controller): _cp_path = '/auth_oauth' - @openerp.addons.web.http.jsonrequest + @oeweb.jsonrequest def list_providers(self, req, dbname): try: - registry = openerp.modules.registry.RegistryManager.get(dbname) + registry = RegistryManager.get(dbname) with registry.cursor() as cr: providers = registry.get('auth.oauth.provider') - l = providers.read(cr, openerp.SUPERUSER_ID, providers.search(cr, openerp.SUPERUSER_ID, [('enabled','=',True)])) + l = providers.read(cr, SUPERUSER_ID, providers.search(cr, SUPERUSER_ID, [('enabled', '=', True)])) except Exception: l = [] return l - @openerp.addons.web.http.httprequest + @oeweb.httprequest + @fragment_to_query_string def signin(self, req, **kw): state = simplejson.loads(kw['state']) dbname = state['d'] provider = state['p'] - registry = openerp.modules.registry.RegistryManager.get(dbname) + context = state.get('c', {}) + registry = RegistryManager.get(dbname) with registry.cursor() as cr: try: u = registry.get('res.users') - credentials = u.auth_oauth(cr, openerp.SUPERUSER_ID, provider, kw) + credentials = u.auth_oauth(cr, SUPERUSER_ID, provider, kw, context=context) cr.commit() - return openerp.addons.web.controllers.main.login_and_redirect(req, *credentials) + return login_and_redirect(req, *credentials) except AttributeError: # auth_signup is not installed - _logger.error("auth_signup not installed on database %s: oauth sign up cancelled."%dbname) + _logger.error("auth_signup not installed on database %s: oauth sign up cancelled." % (dbname,)) url = "/#action=login&oauth_error=1" - except Exception,e: + except Exception, e: # signup error _logger.exception("OAuth2: %s" % str(e)) url = "/#action=login&oauth_error=2" - return openerp.addons.web.controllers.main.set_cookie_and_redirect(req, url) + return set_cookie_and_redirect(req, url) + + @oeweb.httprequest + def oea(self, req, **kw): + """login user via OpenERP Account provider""" + dbname = kw.pop('db', None) + if not dbname: + dbname = db_monodb(req) + if not dbname: + return BadRequest() + + registry = RegistryManager.get(dbname) + with registry.cursor() as cr: + IMD = registry['ir.model.data'] + model, provider_id = IMD.get_object_reference(cr, SUPERUSER_ID, 'auth_oauth', 'provider_openerp') + assert model == 'auth.oauth.provider' + + state = { + 'd': dbname, + 'p': provider_id, + 'c': {'no_user_creation': True}, + } + + kw['state'] = simplejson.dumps(state) + return self.signin(req, **kw) # vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auth_oauth/res_users.py b/addons/auth_oauth/res_users.py index 115e3136f00..7e7b3753a4e 100644 --- a/addons/auth_oauth/res_users.py +++ b/addons/auth_oauth/res_users.py @@ -24,7 +24,7 @@ class res_users(osv.Model): ('uniq_users_oauth_provider_oauth_uid', 'unique(oauth_provider_id, oauth_uid)', 'OAuth UID must be unique per provider'), ] - def auth_oauth_rpc(self, cr, uid, endpoint, access_token, context=None): + def _auth_oauth_rpc(self, cr, uid, endpoint, access_token, context=None): params = urllib.urlencode({'access_token': access_token}) if urlparse.urlparse(endpoint)[4]: url = endpoint + '&' + params @@ -34,6 +34,17 @@ class res_users(osv.Model): response = f.read() return simplejson.loads(response) + def _auth_oauth_validate(self, cr, uid, provider, access_token, context=None): + """ return the validation data corresponding to the access token """ + p = self.pool.get('auth.oauth.provider').browse(cr, uid, provider, context=context) + validation = self._auth_oauth_rpc(cr, uid, p.validation_endpoint, access_token) + if validation.get("error"): + raise Exception(validation['error']) + if p.data_endpoint: + data = self._auth_oauth_rpc(cr, uid, p.data_endpoint, access_token) + validation.update(data) + return validation + def auth_oauth(self, cr, uid, provider, params, context=None): # Advice by Google (to avoid Confused Deputy Problem) # if validation.audience != OUR_CLIENT_ID: @@ -41,25 +52,21 @@ class res_users(osv.Model): # else: # continue with the process access_token = params.get('access_token') - p = self.pool.get('auth.oauth.provider').browse(cr, uid, provider, context=context) - - validation = self.auth_oauth_rpc(cr, uid, p.validation_endpoint, access_token) - if validation.get("error"): - raise Exception(validation['error']) - if p.data_endpoint: - data = self.auth_oauth_rpc(cr, uid, p.data_endpoint, access_token) - validation.update(data) + validation = self._auth_oauth_validate(cr, uid, provider, access_token) # required oauth_uid = validation['user_id'] if not oauth_uid: raise openerp.exceptions.AccessDenied() - email = validation.get('email', 'provider_%d_user_%d' % (p.id, oauth_uid)) + email = validation.get('email', 'provider_%d_user_%d' % (provider, oauth_uid)) + login = email # optional name = validation.get('name', email) res = self.search(cr, uid, [("oauth_uid", "=", oauth_uid), ('oauth_provider_id', '=', provider)]) if res: assert len(res) == 1 - self.write(cr, uid, res[0], {'oauth_access_token': access_token}) + user = self.browse(cr, uid, res[0], context=context) + login = user.login + user.write({'oauth_access_token': access_token}) else: # New user if signup module available if not hasattr(self, '_signup_create_user'): @@ -67,9 +74,9 @@ class res_users(osv.Model): new_user = { 'name': name, - 'login': email, + 'login': login, 'user_email': email, - 'oauth_provider_id': p.id, + 'oauth_provider_id': provider, 'oauth_uid': oauth_uid, 'oauth_access_token': access_token, 'active': True, @@ -77,7 +84,7 @@ class res_users(osv.Model): # TODO pass signup token to allow attach new user to right partner self._signup_create_user(cr, uid, new_user) - credentials = (cr.dbname, email, access_token) + credentials = (cr.dbname, login, access_token) return credentials def check_credentials(self, cr, uid, password): diff --git a/addons/auth_oauth/static/src/js/auth_oauth.js b/addons/auth_oauth/static/src/js/auth_oauth.js index 15683cfac2a..2aa66877d42 100644 --- a/addons/auth_oauth/static/src/js/auth_oauth.js +++ b/addons/auth_oauth/static/src/js/auth_oauth.js @@ -36,7 +36,10 @@ openerp.auth_oauth = function(instance) { ev.preventDefault(); var index = $(ev.target).data('index'); var p = this.oauth_providers[index]; - var ret = location.protocol+"//"+location.host+"/"; + var ret = _.str.sprintf('%s//%s/auth_oauth/signin', location.protocol, location.host); + if (instance.session.debug) { + ret += '?debug'; + } var dbname = self.$("form [name=db]").val(); var state_object = { d: dbname, @@ -55,16 +58,4 @@ openerp.auth_oauth = function(instance) { }, }); - instance.web.WebClient = instance.web.WebClient.extend({ - start: function() { - this._super.apply(this, arguments); - var params = $.deparam(window.location.hash.substring(1)); - // alert(JSON.stringify(params)); - if (params.hasOwnProperty('access_token')) { - var url = "/auth_oauth/signin" + '?' + $.param(params); - window.location = url; - } - }, - }); - }; diff --git a/addons/base_calendar/crm_meeting_view.xml b/addons/base_calendar/crm_meeting_view.xml index 10c65ab850b..8590bcb8b49 100644 --- a/addons/base_calendar/crm_meeting_view.xml +++ b/addons/base_calendar/crm_meeting_view.xml @@ -221,7 +221,7 @@
- +
diff --git a/addons/base_gengo/wizard/base_gengo_translations.py b/addons/base_gengo/wizard/base_gengo_translations.py index d8a96a2ced9..bfd51480141 100644 --- a/addons/base_gengo/wizard/base_gengo_translations.py +++ b/addons/base_gengo/wizard/base_gengo_translations.py @@ -19,19 +19,24 @@ # ############################################################################## -from osv import osv, fields -from tools.translate import _ +import logging import re +import time + +from openerp.osv import osv, fields +from openerp import tools +from openerp.tools.translate import _ + +_logger = logging.getLogger(__name__) + try: from mygengo import MyGengo except ImportError: - raise osv.except_osv(_('Gengo ImportError'), _('Please install mygengo lib from http://pypi.python.org/pypi/mygengo')) - -import logging -import tools -import time - -_logger = logging.getLogger(__name__) + _logger.warning('Gengo library not found, Gengo features disabled. If you plan to use it, please install the mygengo library from http://pypi.python.org/pypi/mygengo') + class MyGengo(object): + def __init__(self, *args, **kwargs): + # no context for translations - so don't bother + raise ImportError('Gengo library not found, please install mygengo from http://pypi.python.org/pypi/mygengo') GENGO_DEFAULT_LIMIT = 20 @@ -48,7 +53,7 @@ class base_gengo_translations(osv.osv_memory): _name = 'base.gengo.translations' _columns = { 'restart_send_job': fields.boolean("Restart Sending Job"), - 'lang_id': fields.many2one('res.lang', 'Language', help="Leave empty if you don't want to restrict the request to a single language"), + 'lang_id': fields.many2one('res.lang', 'Language', required=True), } def gengo_authentication(self, cr, uid, context=None): @@ -62,21 +67,19 @@ class base_gengo_translations(osv.osv_memory): by the cron) or in a dialog box (if requested by the user), thus it's important to return it translated. ''' - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) if not user.company_id.gengo_public_key or not user.company_id.gengo_private_key: - return (False, _("Invalid Gengo configuration. Gengo authentication `Public Key` or `Private Key` is missing. Complete Gengo authentication parameters under `Settings > Companies > Gengo Parameters`.")) + return (False, _("Gengo `Public Key` or `Private Key` are missing. Enter your Gengo authentication parameters under `Settings > Companies > Gengo Parameters`.")) try: 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) except Exception, e: - return (False, _("Gengo Connection Error\n%s") %e) + _logger.exception('Gengo connection failed') + return (False, _("Gengo connection failed with this message:\n``%s``") % e) def do_check_schedular(self, cr, uid, xml_id, name, fn, context=None): """ @@ -87,7 +90,7 @@ class base_gengo_translations(osv.osv_memory): cron_vals.update({'name': name, "function": fn}) try: res = [] - model, res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base_gengo', xml_id) + _, res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base_gengo', xml_id) cron_pool.write(cr, uid, [res], cron_vals, context=context) except: #the cron job was not found, probably deleted previously, so we create it again using default values @@ -108,7 +111,7 @@ class base_gengo_translations(osv.osv_memory): supported_langs = self.pool.get('ir.translation')._get_all_supported_languages(cr, uid, context=context) language = self.pool.get('ir.translation')._get_gengo_corresponding_language(wizard.lang_id.code) if language not in supported_langs: - raise osv.except_osv(_("Warning"), _('This language is not supported by the Gengo translation services.')) + raise osv.except_osv(_("Warning"), _('This language is not supported by the Gengo translation services.')) #send immediately a new request for the selected language (if any) ctx = context.copy() @@ -207,8 +210,6 @@ class base_gengo_translations(osv.osv_memory): Send a request to Gengo with all the term_ids in a different job, get the response and update the terms in database accordingly. """ - - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) flag, gengo = self.gengo_authentication(cr, uid, context=context) if flag: request = self.pack_jobs_request(cr, uid, term_ids, context=context) diff --git a/addons/base_gengo/wizard/base_gengo_translations_view.xml b/addons/base_gengo/wizard/base_gengo_translations_view.xml index 09c3a77b1d5..7b6be31d042 100644 --- a/addons/base_gengo/wizard/base_gengo_translations_view.xml +++ b/addons/base_gengo/wizard/base_gengo_translations_view.xml @@ -6,14 +6,9 @@ base.gengo.translations
- - - - - - - + + +