[FIX] all: construction of translations lookup

When evaluated, the translation function never finds a match if a variable is
integrated into the untranslated text.

SHAME! 🔔 🙋
This commit is contained in:
Martin Trigaux
2016-01-13 14:46:30 +01:00
parent 2ace8f0270
commit bb56e484b7
23 changed files with 68 additions and 56 deletions
+1 -1
View File
@@ -172,7 +172,7 @@ class AccountMove(models.Model):
if self.user_has_groups('account.group_account_manager'):
lock_date = move.company_id.fiscalyear_lock_date
if move.date <= lock_date:
raise UserError(_("You cannot add/modify entries prior to and inclusive of the lock date %s. Check the company settings or ask someone with the 'Adviser' role" % (lock_date)))
raise UserError(_("You cannot add/modify entries prior to and inclusive of the lock date %s. Check the company settings or ask someone with the 'Adviser' role") % (lock_date))
return True
@api.multi
+1 -1
View File
@@ -118,7 +118,7 @@ class account_register_payments(models.TransientModel):
if not active_model or not active_ids:
raise UserError(_("Programmation error: wizard action executed without active_model or active_ids in context."))
if active_model != 'account.invoice':
raise UserError(_("Programmation error: the expected model for this action is 'account.invoice'. The provided one is '%d'." % active_model))
raise UserError(_("Programmation error: the expected model for this action is 'account.invoice'. The provided one is '%d'.") % active_model)
# Checks on received invoice records
invoices = self.env[active_model].browse(active_ids)
@@ -23,7 +23,7 @@ class AccountJournal(models.Model):
def _set_check_next_number(self):
if self.check_next_number < self.check_sequence_id.number_next_actual:
raise ValidationError(_("The last check number was %s. In order to avoid a check being rejected "
"by the bank, you can only use a greater number." % self.check_sequence_id.number_next_actual))
"by the bank, you can only use a greater number.") % self.check_sequence_id.number_next_actual)
if self.check_sequence_id:
self.check_sequence_id.sudo().number_next_actual = self.check_next_number
@@ -53,7 +53,7 @@ class ReportAssertAccount(models.AbstractModel):
return ', '.join(["%s: %s" % (tup[0], tup[1]) for tup in order_columns(item, column_order)])
else:
return item
result = [_(_format(rec)) for rec in result]
result = [_format(rec) for rec in result]
return result
+4 -4
View File
@@ -72,7 +72,7 @@ class ir_model_fields_anonymization(osv.osv):
if global_state == 'anonymized':
raise UserError(_("The database is currently anonymized, you cannot create, modify or delete fields."))
elif global_state == 'unstable':
msg = _("The database anonymization is currently in an unstable state. Some fields are anonymized," + \
msg = _("The database anonymization is currently in an unstable state. Some fields are anonymized,"
" while some fields are not anonymized. You should try to solve this problem before trying to create, write or delete fields.")
raise UserError(msg)
@@ -339,7 +339,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
# remove the placeholer:
eview.remove(placeholder)
else:
msg = _("The database anonymization is currently in an unstable state. Some fields are anonymized," + \
msg = _("The database anonymization is currently in an unstable state. Some fields are anonymized,"
" while some fields are not anonymized. You should try to solve this problem before trying to do anything else.")
raise UserError(msg)
@@ -372,7 +372,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
if state == 'anonymized':
self._raise_after_history_update(cr, uid, history_id, _('Error !'), _("The database is currently anonymized, you cannot anonymize it again."))
elif state == 'unstable':
msg = _("The database anonymization is currently in an unstable state. Some fields are anonymized," + \
msg = _("The database anonymization is currently in an unstable state. Some fields are anonymized,"
" while some fields are not anonymized. You should try to solve this problem before trying to do anything.")
self._raise_after_history_update(cr, uid, history_id, 'Error !', msg)
@@ -509,7 +509,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
if state == 'clear':
raise UserError(_("The database is not currently anonymized, you cannot reverse the anonymization."))
elif state == 'unstable':
msg = _("The database anonymization is currently in an unstable state. Some fields are anonymized," + \
msg = _("The database anonymization is currently in an unstable state. Some fields are anonymized,"
" while some fields are not anonymized. You should try to solve this problem before trying to do anything.")
raise UserError(msg)
+1 -1
View File
@@ -66,7 +66,7 @@ class AuthSignupHome(openerp.addons.web.controllers.main.Home):
qcontext['error'] = _("Could not reset your password")
_logger.exception('error when resetting password')
except Exception, e:
qcontext['error'] = _(e.message)
qcontext['error'] = e.message
return request.render('auth_signup.reset_password', qcontext)
+1 -1
View File
@@ -32,7 +32,7 @@ def validate_iban(iban):
iban_template = _map_iban_template[country_code]
if len(iban) != len(iban_template.replace(' ', '')):
raise ValidationError(_("The IBAN does not seem to be correct. You should have entered something like this %s\n"\
"Where B = National bank code, S = Branch code, C = Account No, k = Check digit" % iban_template))
"Where B = National bank code, S = Branch code, C = Account No, k = Check digit") % iban_template)
check_chars = iban[4:] + iban[:4]
digits = int(''.join(str(int(char, 36)) for char in check_chars)) # BASE 36: 0..9,A..Z -> 0..35
+1 -1
View File
@@ -108,7 +108,7 @@ class res_partner(osv.osv):
continue
vat_country, vat_number = self._split_vat(partner.vat)
if not check_func(cr, uid, vat_country, vat_number, context=context):
_logger.info(_("Importing VAT Number [%s] is not valid !" % vat_number))
_logger.info("Importing VAT Number [%s] is not valid !", vat_number)
return False
return True
+2 -2
View File
@@ -260,7 +260,7 @@ class calendar_attendee(osv.Model):
meeting_obj = self.pool['calendar.event']
res = self.write(cr, uid, ids, {'state': 'accepted'}, context)
for attendee in self.browse(cr, uid, ids, context=context):
meeting_obj.message_post(cr, uid, attendee.event_id.id, body=_(("%s has accepted invitation") % (attendee.cn)),
meeting_obj.message_post(cr, uid, attendee.event_id.id, body=_("%s has accepted invitation") % (attendee.cn),
subtype="calendar.subtype_invitation", context=context)
return res
@@ -275,7 +275,7 @@ class calendar_attendee(osv.Model):
meeting_obj = self.pool['calendar.event']
res = self.write(cr, uid, ids, {'state': 'declined'}, context)
for attendee in self.browse(cr, uid, ids, context=context):
meeting_obj.message_post(cr, uid, attendee.event_id.id, body=_(("%s has declined invitation") % (attendee.cn)), subtype="calendar.subtype_invitation", context=context)
meeting_obj.message_post(cr, uid, attendee.event_id.id, body=_("%s has declined invitation") % (attendee.cn), subtype="calendar.subtype_invitation", context=context)
return res
def create(self, cr, uid, vals, context=None):
+2 -2
View File
@@ -737,11 +737,11 @@ class gamification_challenge(osv.Model):
if challenge_ended:
# open chatter message
message_body = _("The challenge %s is finished." % challenge.name)
message_body = _("The challenge %s is finished.") % challenge.name
if rewarded_users:
user_names = self.pool['res.users'].name_get(cr, uid, rewarded_users, context=context)
message_body += _("<br/>Reward (badge %s) for every succeeding user was sent to %s." % (challenge.reward_id.name, ", ".join([name for (user_id, name) in user_names])))
message_body += _("<br/>Reward (badge %s) for every succeeding user was sent to %s.") % (challenge.reward_id.name, ", ".join([name for (user_id, name) in user_names]))
else:
message_body += _("<br/>Nobody has succeeded to reach every goal, no badge is rewarded for this challenge.")
+1 -1
View File
@@ -130,7 +130,7 @@ class gamification_goal_definition(osv.Model):
obj.search(cr, uid, domain, context=context, count=True)
except (ValueError, SyntaxError), e:
msg = e.message or (e.msg + '\n' + e.text)
raise UserError(_("The domain for the definition %s seems incorrect, please check it.\n\n%s" % (definition.name, msg)))
raise UserError(_("The domain for the definition %s seems incorrect, please check it.\n\n%s") % (definition.name, msg))
return True
def create(self, cr, uid, vals, context=None):
+6 -6
View File
@@ -34,8 +34,8 @@ class google_service(osv.osv_memory):
req = urllib2.Request("https://accounts.google.com/o/oauth2/token", data, headers)
content = urllib2.urlopen(req, timeout=TIMEOUT).read()
except urllib2.HTTPError:
error_msg = "Something went wrong during your token generation. Maybe your Authorization Code is invalid or already expired"
raise self.pool.get('res.config.settings').get_config_warning(cr, _(error_msg), context=context)
error_msg = _("Something went wrong during your token generation. Maybe your Authorization Code is invalid or already expired")
raise self.pool.get('res.config.settings').get_config_warning(cr, error_msg, context=context)
content = json.loads(content)
return content.get('refresh_token')
@@ -95,8 +95,8 @@ class google_service(osv.osv_memory):
st, res, ask_time = self._do_request(cr, uid, uri, params=data, headers=headers, type='POST', preuri='', context=context)
except urllib2.HTTPError:
error_msg = "Something went wrong during your token generation. Maybe your Authorization Code is invalid"
raise self.pool.get('res.config.settings').get_config_warning(cr, _(error_msg), context=context)
error_msg = _("Something went wrong during your token generation. Maybe your Authorization Code is invalid")
raise self.pool.get('res.config.settings').get_config_warning(cr, error_msg, context=context)
return res
def _refresh_google_token_json(self, cr, uid, refresh_token, service, context=None): # exchange_AUTHORIZATION vs Token (service = calendar)
@@ -125,8 +125,8 @@ class google_service(osv.osv_memory):
self.pool['res.users'].write(cur, uid, [uid], {'google_%s_rtoken' % service: False}, context=context)
error_key = json.loads(e.read()).get("error", "nc")
_logger.exception("Bad google request : %s !" % error_key)
error_msg = "Something went wrong during your token generation. Maybe your Authorization Code is invalid or already expired [%s]" % error_key
raise self.pool.get('res.config.settings').get_config_warning(cr, _(error_msg), context=context)
error_msg = _("Something went wrong during your token generation. Maybe your Authorization Code is invalid or already expired [%s]") % error_key
raise self.pool.get('res.config.settings').get_config_warning(cr, error_msg, context=context)
return res
def _do_request(self, cr, uid, uri, params={}, headers={}, type='POST', preuri="https://www.googleapis.com", context=None):
+21 -3
View File
@@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0\n"
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-07 14:40+0000\n"
"PO-Revision-Date: 2015-09-07 14:40+0000\n"
"POT-Creation-Date: 2016-01-13 13:41+0000\n"
"PO-Revision-Date: 2016-01-13 13:41+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -50,6 +50,24 @@ msgstr ""
msgid "Last Updated on"
msgstr ""
#. module: google_account
#: code:addons/google_account/google_account.py:98
#, python-format
msgid "Something went wrong during your token generation. Maybe your Authorization Code is invalid"
msgstr ""
#. module: google_account
#: code:addons/google_account/google_account.py:37
#, python-format
msgid "Something went wrong during your token generation. Maybe your Authorization Code is invalid or already expired"
msgstr ""
#. module: google_account
#: code:addons/google_account/google_account.py:128
#, python-format
msgid "Something went wrong during your token generation. Maybe your Authorization Code is invalid or already expired [%s]"
msgstr ""
#. module: google_account
#: code:addons/google_account/google_account.py:173
#, python-format
+4 -4
View File
@@ -295,13 +295,13 @@ class google_calendar(osv.AbstractModel):
st, content, ask_time = self.pool['google.service']._do_request(cr, uid, url, params, headers, type='GET', context=context)
except urllib2.HTTPError, e:
if e.code == 401: # Token invalid / Acces unauthorized
error_msg = "Your token is invalid or has been revoked !"
error_msg = _("Your token is invalid or has been revoked !")
registry = openerp.modules.registry.RegistryManager.get(request.session.db)
with registry.cursor() as cur:
self.pool['res.users'].write(cur, SUPERUSER_ID, [uid], {'google_calendar_token': False, 'google_calendar_token_validity': False}, context=context)
raise self.pool.get('res.config.settings').get_config_warning(cr, _(error_msg), context=context)
raise self.pool.get('res.config.settings').get_config_warning(cr, error_msg, context=context)
raise
return (status_response(st), content['id'] or False, ask_time)
@@ -699,8 +699,8 @@ class google_calendar(osv.AbstractModel):
self.pool['res.users'].write(cur, SUPERUSER_ID, [uid], {'google_calendar_last_sync_date': False}, context=context)
error_key = json.loads(str(e))
error_key = error_key.get('error', {}).get('message', 'nc')
error_msg = "Google is lost... the next synchro will be a full synchro. \n\n %s" % error_key
raise self.pool.get('res.config.settings').get_config_warning(cr, _(error_msg), context=context)
error_msg = _("Google is lost... the next synchro will be a full synchro. \n\n %s") % error_key
raise self.pool.get('res.config.settings').get_config_warning(cr, error_msg, context=context)
my_google_att_ids = att_obj.search(cr, uid, [
('partner_id', '=', myPartnerID),
+1 -1
View File
@@ -52,7 +52,7 @@ class AccountAnalyticLine(models.Model):
if not order:
return False
if order.state != 'sale':
raise UserError(_('The Sale Order %s linked to the Analytic Account must be validated before registering expenses.' % order.name))
raise UserError(_('The Sale Order %s linked to the Analytic Account must be validated before registering expenses.') % order.name)
last_so_line = self.env['sale.order.line'].search([('order_id', '=', order.id)], order='sequence desc', limit=1)
last_sequence = last_so_line.sequence + 1 if last_so_line else 100
+2 -2
View File
@@ -529,7 +529,7 @@ class stock_quant(osv.osv):
elif removal_strategy == 'lifo':
order = 'in_date desc, id desc'
return self._quants_get_order(cr, uid, quantity, move, ops=ops, domain=domain, orderby=order, context=context)
raise UserError(_('Removal strategy %s not implemented.' % (removal_strategy,)))
raise UserError(_('Removal strategy %s not implemented.') % (removal_strategy,))
def _quant_create(self, cr, uid, qty, move, lot_id=False, owner_id=False, src_package_id=False, dest_package_id=False,
force_location_from=False, force_location_to=False, context=None):
@@ -2952,7 +2952,7 @@ class stock_inventory(osv.osv):
for inv in self.browse(cr, uid, ids, context=context):
for inventory_line in inv.line_ids:
if inventory_line.product_qty < 0 and inventory_line.product_qty != inventory_line.theoretical_qty:
raise UserError(_('You cannot set a negative product quantity in an inventory line:\n\t%s - qty: %s' % (inventory_line.product_id.name, inventory_line.product_qty)))
raise UserError(_('You cannot set a negative product quantity in an inventory line:\n\t%s - qty: %s') % (inventory_line.product_id.name, inventory_line.product_qty))
self.action_check(cr, uid, [inv.id], context=context)
self.write(cr, uid, [inv.id], {'state': 'done'}, context=context)
self.post_inventory(cr, uid, inv, context=context)
@@ -75,7 +75,7 @@ class survey_mail_compose_message(osv.TransientModel):
else:
emails_checked.append(email)
if error_message:
raise UserError(_("One email at least is incorrect: %s" % error_message))
raise UserError(_("One email at least is incorrect: %s") % error_message)
emails_checked.sort()
values = {'multi_email': '\n'.join(emails_checked)}
+3 -3
View File
@@ -290,12 +290,12 @@ class website(osv.osv):
for page in View.browse(cr, uid, pages, context=context):
if page.page:
dep[page_key].append({
'text': _('Page <b>%s</b> seems to have a link to this page !' % page.key),
'text': _('Page <b>%s</b> seems to have a link to this page !') % page.key,
'link': '/page/%s' % page.key
})
else:
dep[page_key].append({
'text': _('Template <b>%s (id:%s)</b> seems to have a link to this page !' % (page.key, page.id)),
'text': _('Template <b>%s (id:%s)</b> seems to have a link to this page !') % (page.key, page.id),
'link': '#'
})
@@ -311,7 +311,7 @@ class website(osv.osv):
dep[menu_key] = []
for menu in Menu.browse(cr, uid, menus, context=context):
dep[menu_key].append({
'text': _('Menu <b>%s</b> seems to have a link to this page !' % menu.name),
'text': _('Menu <b>%s</b> seems to have a link to this page !') % menu.name,
'link': False
})
+1 -1
View File
@@ -289,7 +289,7 @@ class Website(osv.Model):
dep[page_key] = []
for p in post_obj.browse(cr, uid, posts, context=context):
dep[page_key].append({
'text': _('Blog Post <b>%s</b> seems to have a link to this page !' % p.name),
'text': _('Blog Post <b>%s</b> seems to have a link to this page !') % p.name,
'link': p.website_url
})
+7 -13
View File
@@ -374,7 +374,7 @@ class Post(models.Model):
if (self.post_type == 'question' and not self.forum_id.allow_question) \
or (self.post_type == 'discussion' and not self.forum_id.allow_discussion) \
or (self.post_type == 'link' and not self.forum_id.allow_link):
raise UserError(_('This forum does not allow %s' % self.post_type))
raise UserError(_('This forum does not allow %s') % self.post_type)
def _update_content(self, content, forum_id):
forum = self.env['forum.forum'].browse(forum_id)
@@ -473,26 +473,20 @@ class Post(models.Model):
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
for post in self:
if post.state == 'active' and post.parent_id:
body = _(
'<p>A new answer for <i>%s</i> has been posted. <a href="%s/forum/%s/question/%s">Click here to access the post.</a></p>' %
(post.parent_id.name, base_url, slug(post.parent_id.forum_id), slug(post.parent_id))
)
body = _('<p>A new answer for <i>%s</i> has been posted. <a href="%s/forum/%s/question/%s">Click here to access the post.</a></p>') % \
(post.parent_id.name, base_url, slug(post.parent_id.forum_id), slug(post.parent_id))
post.parent_id.message_post(subject=_('Re: %s') % post.parent_id.name, body=body, subtype='website_forum.mt_answer_new')
elif post.state == 'active' and not post.parent_id:
body = _(
'<p>A new question <i>%s</i> has been asked on %s. <a href="%s/forum/%s/question/%s">Click here to access the question.</a></p>' %
(post.name, post.forum_id.name, base_url, slug(post.forum_id), slug(post))
)
body = _('<p>A new question <i>%s</i> has been asked on %s. <a href="%s/forum/%s/question/%s">Click here to access the question.</a></p>') % \
(post.name, post.forum_id.name, base_url, slug(post.forum_id), slug(post))
post.message_post(subject=post.name, body=body, subtype='website_forum.mt_question_new')
elif post.state == 'pending' and not post.parent_id:
# TDE FIXME: in master, you should probably use a subtype;
# however here we remove subtype but set partner_ids
partners = post.sudo().message_partner_ids.filtered(lambda partner: partner.user_ids and partner.user_ids.karma >= post.forum_id.karma_moderate)
note_subtype = self.sudo().env.ref('mail.mt_note')
body = _(
'<p>A new question <i>%s</i> has been asked on %s and require your validation. <a href="%s/forum/%s/question/%s">Click here to access the question.</a></p>' %
(post.name, post.forum_id.name, base_url, slug(post.forum_id), slug(post))
)
body = _('<p>A new question <i>%s</i> has been asked on %s and require your validation. <a href="%s/forum/%s/question/%s">Click here to access the question.</a></p>') % \
(post.name, post.forum_id.name, base_url, slug(post.forum_id), slug(post))
post.message_post(subject=post.name, body=body, subtype_id=note_subtype.id, partner_ids=partners.ids)
return True
+3 -3
View File
@@ -282,11 +282,11 @@ class website_slides(http.Controller):
return preview
existing_slide = Slide.search([('channel_id', '=', int(data['channel_id'])), ('document_id', '=', document_id)], limit=1)
if existing_slide:
preview['error'] = _('This video already exists in this channel <a target="_blank" href="/slides/slide/%s">click here to view it </a>' % existing_slide.id)
preview['error'] = _('This video already exists in this channel <a target="_blank" href="/slides/slide/%s">click here to view it </a>') % existing_slide.id
return preview
values = Slide._parse_document_url(data['url'], only_preview_fields=True)
if values.get('error'):
preview['error'] = _('Could not fetch data from url. Document or access right not available.\nHere is the received response: %s' % values['error'])
preview['error'] = _('Could not fetch data from url. Document or access right not available.\nHere is the received response: %s') % values['error']
return preview
return values
@@ -318,7 +318,7 @@ class website_slides(http.Controller):
return {'error': e.name}
except Exception as e:
_logger.error(e)
return {'error': _('Internal server error, please try again later or contact administrator.\nHere is the error message: %s' % e.message)}
return {'error': _('Internal server error, please try again later or contact administrator.\nHere is the error message: %s') % e.message}
return {'url': "/slides/slide/%s" % (slide_id.id)}
# --------------------------------------------------
+2 -2
View File
@@ -673,7 +673,7 @@ class BaseModel(object):
(fnct, fields2, order) = spec
length = None
else:
raise UserError(_('Invalid function definition %s in object %s !\nYou must use the definition: store={object:(fnct, fields, priority, time length)}.' % (fname, cls._name)))
raise UserError(_('Invalid function definition %s in object %s !\nYou must use the definition: store={object:(fnct, fields, priority, time length)}.') % (fname, cls._name))
pool._store_function.setdefault(model, [])
t = (cls._name, fname, fnct, tuple(fields2) if fields2 else None, order, length)
if t not in pool._store_function[model]:
@@ -1266,7 +1266,7 @@ class BaseModel(object):
res_msg = trans._get_source(self._name, 'constraint', self.env.lang, msg)
if extra_error:
res_msg += "\n\n%s\n%s" % (_('Error details:'), extra_error)
errors.append(_(res_msg))
errors.append(res_msg)
if errors:
raise ValidationError('\n'.join(errors))
+1 -1
View File
@@ -664,7 +664,7 @@ def trans_export(lang, modules, buffer, format, cr):
else:
raise Exception(_('Unrecognized extension: must be one of '
'.csv, .po, or .tgz (received .%s).' % format))
'.csv, .po, or .tgz (received .%s).') % format)
translations = trans_generate(lang, modules, cr)
modules = set(t[0] for t in translations)