[REF] *: improved translatability of error messages

Was part of the PR #19820. Courtesy of Vauxoo
This commit is contained in:
Moises Lopez
2017-11-24 15:35:27 +01:00
committed by qdp-odoo
parent 87ad27748c
commit 593bb5e30d
8 changed files with 12 additions and 12 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from odoo import exceptions
from odoo import exceptions, _
from odoo.http import Controller, request, route
from odoo.addons.bus.models.bus import dispatch
@@ -38,5 +38,5 @@ class BusController(Controller):
if [c for c in channels if not isinstance(c, pycompat.string_types)]:
raise Exception("bus.Bus only string channels are allowed.")
if request.registry.in_test_mode():
raise exceptions.UserError("bus.Bus not available in test mode")
raise exceptions.UserError(_("bus.Bus not available in test mode"))
return self._poll(request.db, channels, last, options)
+2 -2
View File
@@ -640,8 +640,8 @@ class PurchaseOrderLine(models.Model):
if line.product_id.type in ('product', 'consu'):
# Prevent decreasing below received quantity
if float_compare(line.product_qty, line.qty_received, line.product_uom.rounding) < 0:
raise UserError('You cannot decrease the ordered quantity below the received quantity.\n'
'Create a return first.')
raise UserError(_('You cannot decrease the ordered quantity below the received quantity.\n'
'Create a return first.'))
if float_compare(line.product_qty, line.qty_invoiced, line.product_uom.rounding) == -1:
# If the quantity is now below the invoiced quantity, create an activity on the vendor bill
+2 -2
View File
@@ -322,8 +322,8 @@ class SaleOrderLine(models.Model):
def _update_line_quantity(self, values):
if self.mapped('qty_delivered') and values['product_uom_qty'] < max(self.mapped('qty_delivered')):
raise UserError('You cannot decrease the ordered quantity below the delivered quantity.\n'
'Create a return first.')
raise UserError(_('You cannot decrease the ordered quantity below the delivered quantity.\n'
'Create a return first.'))
for line in self:
pickings = self.order_id.picking_ids.filtered(lambda p: p.state not in ('done', 'cancel'))
for picking in pickings:
+1 -1
View File
@@ -256,7 +256,7 @@ class StockMove(models.Model):
elif len(move_lines) == 1:
move_lines[0].qty_done = quantity_done
else:
raise UserError("Cannot set the done quantity from this stock move, work directly with the move lines.")
raise UserError(_("Cannot set the done quantity from this stock move, work directly with the move lines."))
def _set_product_qty(self):
""" The meaning of product_qty field changed lately and is now a functional field computing the quantity
+1 -1
View File
@@ -32,7 +32,7 @@ class ReturnPicking(models.TransientModel):
@api.model
def default_get(self, fields):
if len(self.env.context.get('active_ids', list())) > 1:
raise UserError("You may only return one picking at a time!")
raise UserError(_("You may only return one picking at a time!"))
res = super(ReturnPicking, self).default_get(fields)
move_dest_exists = False
+1 -1
View File
@@ -684,7 +684,7 @@ class SurveyLabel(models.Model):
def _check_question_not_empty(self):
"""Ensure that field question_id XOR field question_id_2 is not null"""
if not bool(self.question_id) != bool(self.question_id_2):
raise ValidationError("A label must be attached to one and only one question")
raise ValidationError(_("A label must be attached to one and only one question"))
class SurveyUserInput(models.Model):
@@ -3,7 +3,7 @@
from datetime import datetime, timedelta
from odoo import fields, http
from odoo import _, fields, http
from odoo.exceptions import AccessError
from odoo.http import request
from odoo import release
@@ -13,7 +13,7 @@ class WebSettingsDashboard(http.Controller):
@http.route('/web_settings_dashboard/data', type='json', auth='user')
def web_settings_dashboard_data(self, **kw):
if not request.env.user.has_group('base.group_erp_manager'):
raise AccessError("Access Denied")
raise AccessError(_("Access Denied"))
installed_apps = request.env['ir.module.module'].search_count([
('application', '=', True),
+1 -1
View File
@@ -1358,7 +1358,7 @@ class IrModelData(models.Model):
if self.env[model].search([('id', '=', res_id)]):
return model, res_id
if raise_on_access_error:
raise AccessError('Not enough access rights on the external ID: %s.%s' % (module, xml_id))
raise AccessError(_('Not enough access rights on the external ID:') + ' %s.%s' % (module, xml_id))
return model, False
@api.model