[IMP] *: replace to new _() syntax
Using a few regex like \((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\) ($1, $3)) Old syntax is still compatible but starts the migration to the new syntax that catches error.
This commit is contained in:
@@ -42,7 +42,7 @@ class AccountAccount(models.Model):
|
||||
def _check_reconcile(self):
|
||||
for account in self:
|
||||
if account.internal_type in ('receivable', 'payable') and account.reconcile == False:
|
||||
raise ValidationError(_('You cannot have a receivable/payable account that is not reconcilable. (account code: %s)') % account.code)
|
||||
raise ValidationError(_('You cannot have a receivable/payable account that is not reconcilable. (account code: %s)', account.code))
|
||||
|
||||
@api.constrains('user_type_id')
|
||||
def _check_user_type_id(self):
|
||||
@@ -52,7 +52,7 @@ class AccountAccount(models.Model):
|
||||
if res.get('company_id_count', 0) >= 2:
|
||||
account_unaffected_earnings = self.search([('company_id', '=', res['company_id'][0]),
|
||||
('user_type_id', '=', data_unaffected_earnings.id)])
|
||||
raise ValidationError(_('You cannot have more than one account with "Current Year Earnings" as type. (accounts: %s)') % [a.code for a in account_unaffected_earnings])
|
||||
raise ValidationError(_('You cannot have more than one account with "Current Year Earnings" as type. (accounts: %s)', [a.code for a in account_unaffected_earnings]))
|
||||
|
||||
name = fields.Char(string="Account Name", required=True, index=True)
|
||||
currency_id = fields.Many2one('res.currency', string='Account Currency',
|
||||
@@ -445,7 +445,7 @@ class AccountAccount(models.Model):
|
||||
if partner_prop_acc:
|
||||
account_name = partner_prop_acc.get_by_record().display_name
|
||||
raise UserError(
|
||||
_('You cannot remove/deactivate the account %s which is set on a customer or vendor.') % account_name
|
||||
_('You cannot remove/deactivate the account %s which is set on a customer or vendor.', account_name)
|
||||
)
|
||||
return super(AccountAccount, self).unlink()
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class AccountBankStmtCashWizard(models.Model):
|
||||
def name_get(self):
|
||||
result = []
|
||||
for cashbox in self:
|
||||
result.append((cashbox.id, _("%s")%(cashbox.total)))
|
||||
result.append((cashbox.id, str(cashbox.total)))
|
||||
return result
|
||||
|
||||
@api.model_create_multi
|
||||
@@ -308,7 +308,7 @@ class AccountBankStatement(models.Model):
|
||||
'statement_id': stmt.id,
|
||||
'journal_id': stmt.journal_id.id,
|
||||
'amount': stmt.difference,
|
||||
'payment_ref': _("Cash difference observed during the counting (%s)") % name,
|
||||
'payment_ref': _("Cash difference observed during the counting (%s)", name),
|
||||
'date': stmt.date,
|
||||
}
|
||||
self.env['account.bank.statement.line'].with_context(counterpart_account_id=account.id).create(st_line_vals)
|
||||
@@ -392,13 +392,13 @@ class AccountBankStatement(models.Model):
|
||||
for statement in self:
|
||||
|
||||
# Chatter.
|
||||
statement.message_post(body=_('Statement %s confirmed.') % statement.name)
|
||||
statement.message_post(body=_('Statement %s confirmed.', statement.name))
|
||||
|
||||
# Bank statement report.
|
||||
if statement.journal_id.type == 'bank':
|
||||
content, content_type = self.env.ref('account.action_report_account_statement')._render(statement.id)
|
||||
self.env['ir.attachment'].create({
|
||||
'name': statement.name and _("Bank Statement %s.pdf") % statement.name or _("Bank Statement.pdf"),
|
||||
'name': statement.name and _("Bank Statement %s.pdf", statement.name) or _("Bank Statement.pdf"),
|
||||
'type': 'binary',
|
||||
'datas': base64.encodebytes(content),
|
||||
'res_model': statement._name,
|
||||
@@ -873,7 +873,7 @@ class AccountBankStatementLine(models.Model):
|
||||
if st_line.currency_id.is_zero(st_line.amount):
|
||||
raise ValidationError(_("The amount of a statement line can't be equal to zero."))
|
||||
if st_line.foreign_currency_id == st_line.currency_id:
|
||||
raise ValidationError(_("The foreign currency must be different than the journal one: %s") % st_line.currency_id.name)
|
||||
raise ValidationError(_("The foreign currency must be different than the journal one: %s", st_line.currency_id.name))
|
||||
if st_line.foreign_currency_id and st_line.foreign_currency_id.is_zero(st_line.amount_currency):
|
||||
raise ValidationError(_("The amount in foreign currency must be set if the amount is not equal to zero."))
|
||||
if not st_line.foreign_currency_id and st_line.amount_currency:
|
||||
|
||||
@@ -213,11 +213,11 @@ class AccountJournal(models.Model):
|
||||
for journal in self:
|
||||
if journal.type == 'bank' and journal.bank_account_id:
|
||||
if journal.bank_account_id.company_id and journal.bank_account_id.company_id != journal.company_id:
|
||||
raise ValidationError(_('The bank account of a bank journal must belong to the same company (%s).') % journal.company_id.name)
|
||||
raise ValidationError(_('The bank account of a bank journal must belong to the same company (%s).', journal.company_id.name))
|
||||
# A bank account can belong to a customer/supplier, in which case their partner_id is the customer/supplier.
|
||||
# Or they are part of a bank journal and their partner_id must be the company's partner_id.
|
||||
if journal.bank_account_id.partner_id != journal.company_id.partner_id:
|
||||
raise ValidationError(_('The holder of a journal\'s bank account must be the company (%s).') % journal.company_id.name)
|
||||
raise ValidationError(_('The holder of a journal\'s bank account must be the company (%s).', journal.company_id.name))
|
||||
|
||||
@api.constrains('company_id')
|
||||
def _check_company_consistency(self):
|
||||
@@ -365,7 +365,7 @@ class AccountJournal(models.Model):
|
||||
journal_entry = self.env['account.move'].search([('journal_id', '=', self.id), ('state', '=', 'posted'), ('secure_sequence_number', '!=', 0)], limit=1)
|
||||
if len(journal_entry) > 0:
|
||||
field_string = self._fields['restrict_mode_hash_table'].get_description(self.env)['string']
|
||||
raise UserError(_("You cannot modify the field %s of a journal that already has accounting entries.") % field_string)
|
||||
raise UserError(_("You cannot modify the field %s of a journal that already has accounting entries.", field_string))
|
||||
result = super(AccountJournal, self).write(vals)
|
||||
|
||||
for journal in self:
|
||||
|
||||
@@ -377,7 +377,7 @@ class AccountMove(models.Model):
|
||||
if p.invoice_warn != 'block' and p.parent_id and p.parent_id.invoice_warn == 'block':
|
||||
p = p.parent_id
|
||||
warning = {
|
||||
'title': _("Warning for %s") % p.name,
|
||||
'title': _("Warning for %s", p.name),
|
||||
'message': p.invoice_warn_msg
|
||||
}
|
||||
if p.invoice_warn == 'block':
|
||||
@@ -758,7 +758,7 @@ class AccountMove(models.Model):
|
||||
return
|
||||
|
||||
rounding_line_vals.update({
|
||||
'name': _('%s (rounding)') % biggest_tax_line.name,
|
||||
'name': _('%s (rounding)', biggest_tax_line.name),
|
||||
'account_id': biggest_tax_line.account_id.id,
|
||||
'tax_repartition_line_id': biggest_tax_line.tax_repartition_line_id.id,
|
||||
'tax_exigible': biggest_tax_line.tax_exigible,
|
||||
@@ -1582,9 +1582,9 @@ class AccountMove(models.Model):
|
||||
lock_date = move.company_id._get_user_fiscal_lock_date()
|
||||
if move.date <= lock_date:
|
||||
if self.user_has_groups('account.group_account_manager'):
|
||||
message = _("You cannot add/modify entries prior to and inclusive of the lock date %s.") % format_date(self.env, lock_date)
|
||||
message = _("You cannot add/modify entries prior to and inclusive of the lock date %s.", format_date(self.env, lock_date))
|
||||
else:
|
||||
message = _("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") % format_date(self.env, lock_date)
|
||||
message = _("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", format_date(self.env, lock_date))
|
||||
raise UserError(message)
|
||||
return True
|
||||
|
||||
@@ -2284,7 +2284,7 @@ class AccountMove(models.Model):
|
||||
raise UserError(_('You need to add a line before posting.'))
|
||||
if move.auto_post and move.date > fields.Date.today():
|
||||
date_msg = move.date.strftime(get_lang(self.env).date_format)
|
||||
raise UserError(_("This move is configured to be auto-posted on %s") % date_msg)
|
||||
raise UserError(_("This move is configured to be auto-posted on %s", date_msg))
|
||||
|
||||
if not move.partner_id:
|
||||
if move.is_sale_document():
|
||||
@@ -3466,9 +3466,9 @@ class AccountMoveLine(models.Model):
|
||||
control_type_failed = journal.type_control_ids and account.user_type_id not in journal.type_control_ids
|
||||
control_account_failed = journal.account_control_ids and account not in journal.account_control_ids
|
||||
if control_journal_failed:
|
||||
raise UserError(_('You cannot use this account (%s) in this journal, check the field \'Allowed Journals\' on the related account.') % account.display_name)
|
||||
raise UserError(_('You cannot use this account (%s) in this journal, check the field \'Allowed Journals\' on the related account.', account.display_name))
|
||||
if control_type_failed or control_account_failed:
|
||||
raise UserError(_('You cannot use this account (%s) in this journal, check the section \'Control-Access\' under tab \'Advanced Settings\' on the related journal.') % account.display_name)
|
||||
raise UserError(_('You cannot use this account (%s) in this journal, check the section \'Control-Access\' under tab \'Advanced Settings\' on the related journal.', account.display_name))
|
||||
|
||||
@api.constrains('account_id', 'tax_ids', 'tax_line_id', 'reconciled')
|
||||
def _check_off_balance(self):
|
||||
|
||||
@@ -67,7 +67,7 @@ class AccountPartialReconcile(models.Model):
|
||||
def _check_required_computed_currencies(self):
|
||||
bad_partials = self.filtered(lambda partial: not partial.debit_currency_id or not partial.credit_currency_id)
|
||||
if bad_partials:
|
||||
raise ValidationError(_("Missing foreign currencies on partials having ids: %s") % bad_partials.ids)
|
||||
raise ValidationError(_("Missing foreign currencies on partials having ids: %s", bad_partials.ids))
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# COMPUTE METHODS
|
||||
|
||||
@@ -205,9 +205,9 @@ class AccountPayment(models.Model):
|
||||
|
||||
if self.is_internal_transfer:
|
||||
if self.payment_type == 'inbound':
|
||||
liquidity_line_name = _('Transfer to %s') % self.journal_id.name
|
||||
liquidity_line_name = _('Transfer to %s', self.journal_id.name)
|
||||
else: # payment.payment_type == 'outbound':
|
||||
liquidity_line_name = _('Transfer from %s') % self.journal_id.name
|
||||
liquidity_line_name = _('Transfer from %s', self.journal_id.name)
|
||||
else:
|
||||
liquidity_line_name = self.payment_reference
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ class AccountTax(models.Model):
|
||||
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def copy(self, default=None):
|
||||
default = dict(default or {}, name=_("%s (Copy)") % self.name)
|
||||
default = dict(default or {}, name=_("%s (Copy)", self.name))
|
||||
return super(AccountTax, self).copy(default=default)
|
||||
|
||||
def name_get(self):
|
||||
|
||||
@@ -1040,7 +1040,7 @@ class AccountTaxRepartitionLineTemplate(models.Model):
|
||||
all_tax_rep_lines = self.mapped('plus_report_line_ids') + self.mapped('minus_report_line_ids')
|
||||
lines_without_tag = all_tax_rep_lines.filtered(lambda x: not x.tag_name)
|
||||
if lines_without_tag:
|
||||
raise ValidationError(_("The following tax report lines are used in some tax repartition template though they don't generate any tag: %s . This probably means you forgot to set a tag_name on these lines.") % str(lines_without_tag.mapped('name')))
|
||||
raise ValidationError(_("The following tax report lines are used in some tax repartition template though they don't generate any tag: %s . This probably means you forgot to set a tag_name on these lines.", str(lines_without_tag.mapped('name'))))
|
||||
|
||||
def get_repartition_line_create_vals(self, company):
|
||||
rslt = [(5, 0, 0)]
|
||||
|
||||
@@ -537,7 +537,7 @@ class ResCompany(models.Model):
|
||||
hash_corrupted = False
|
||||
for move in moves:
|
||||
if move.inalterable_hash != move._compute_hash(previous_hash=previous_hash):
|
||||
rslt.update({'msg_cover': _('Corrupted data on journal entry with id %s.') % move.id})
|
||||
rslt.update({'msg_cover': _('Corrupted data on journal entry with id %s.', move.id)})
|
||||
results_by_journal['results'].append(rslt)
|
||||
hash_corrupted = True
|
||||
break
|
||||
|
||||
@@ -36,7 +36,7 @@ class ResPartnerBank(models.Model):
|
||||
return self._get_qr_code_url(candidate_method, amount, currency, debtor_partner, free_communication, structured_communication)
|
||||
|
||||
elif not silent_errors:
|
||||
error_header = _("The following error prevented '%s' QR-code to be generated though it was detected as eligible: ") % candidate_name
|
||||
error_header = _("The following error prevented '%s' QR-code to be generated though it was detected as eligible: ", candidate_name)
|
||||
raise UserError( error_header + error_message)
|
||||
|
||||
return None
|
||||
|
||||
@@ -96,7 +96,7 @@ class SequenceMixin(models.AbstractModel):
|
||||
"""
|
||||
self.ensure_one()
|
||||
if self._sequence_field not in self._fields or not self._fields[self._sequence_field].store:
|
||||
raise ValidationError(_('%s is not a stored field') % self._sequence_field)
|
||||
raise ValidationError(_('%s is not a stored field', self._sequence_field))
|
||||
where_string, param = self._get_last_sequence_domain(relaxed)
|
||||
if self.id or self.id.origin:
|
||||
where_string += " AND id != %(id)s "
|
||||
|
||||
@@ -202,7 +202,7 @@ class AccrualAccountingWizard(models.TransientModel):
|
||||
record.preview_data = json.dumps({
|
||||
'groups_vals': preview_vals,
|
||||
'options': {
|
||||
'discarded_number': (_("%d moves") % preview_discarded) if preview_discarded else False,
|
||||
'discarded_number': _("%d moves", preview_discarded) if preview_discarded else False,
|
||||
'columns': preview_columns,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -81,7 +81,7 @@ class AccountTransferWizard(models.TransientModel):
|
||||
# Generate counterpart lines' vals
|
||||
for (counterpart_partner, counterpart_currency), counterpart_vals in counterpart_balances.items():
|
||||
source_accounts = self.move_line_ids.mapped('account_id')
|
||||
counterpart_label = len(source_accounts) == 1 and _("Transfer from %s") % source_accounts.display_name or _("Transfer counterpart")
|
||||
counterpart_label = len(source_accounts) == 1 and _("Transfer from %s", source_accounts.display_name) or _("Transfer counterpart")
|
||||
|
||||
if not self.company_id.currency_id.is_zero(counterpart_vals['balance']) or (counterpart_currency and not counterpart_currency.is_zero(counterpart_vals['amount_currency'])):
|
||||
line_vals.append({
|
||||
@@ -112,7 +112,7 @@ class AccountTransferWizard(models.TransientModel):
|
||||
return {
|
||||
'journal_id': self.journal_id.id,
|
||||
'date': self.date,
|
||||
'ref': self.destination_account_id.display_name and _("Transfer entry to %s") % self.destination_account_id.display_name or '',
|
||||
'ref': self.destination_account_id.display_name and _("Transfer entry to %s", self.destination_account_id.display_name) or '',
|
||||
'line_ids': [(0, 0, line) for line in line_vals],
|
||||
}
|
||||
|
||||
|
||||
@@ -143,11 +143,11 @@ class ResPartner(models.Model):
|
||||
partner = self.search([('signup_token', '=', token)], limit=1)
|
||||
if not partner:
|
||||
if raise_exception:
|
||||
raise exceptions.UserError(_("Signup token '%s' is not valid") % token)
|
||||
raise exceptions.UserError(_("Signup token '%s' is not valid", token))
|
||||
return False
|
||||
if check_validity and not partner.signup_valid:
|
||||
if raise_exception:
|
||||
raise exceptions.UserError(_("Signup token '%s' is no longer valid") % token)
|
||||
raise exceptions.UserError(_("Signup token '%s' is no longer valid", token))
|
||||
return False
|
||||
return partner
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class ResUsers(models.Model):
|
||||
invite_partner = user.create_uid.partner_id
|
||||
if invite_partner:
|
||||
# notify invite user that new user is connected
|
||||
title = _("%s connected") % user.name
|
||||
title = _("%s connected", user.name)
|
||||
message = _("This is his first connection. Wish him welcome")
|
||||
self.env['bus.bus'].sendone(
|
||||
(self._cr.dbname, 'res.partner', invite_partner.id),
|
||||
@@ -196,7 +196,7 @@ class ResUsers(models.Model):
|
||||
|
||||
for user in self:
|
||||
if not user.email:
|
||||
raise UserError(_("Cannot send email: user %s has no email address.") % user.name)
|
||||
raise UserError(_("Cannot send email: user %s has no email address.", user.name))
|
||||
# TDE FIXME: make this template technical (qweb)
|
||||
with self.env.cr.savepoint():
|
||||
force_send = not(self.env.context.get('import_file', False))
|
||||
|
||||
@@ -35,7 +35,7 @@ class Partner(models.Model):
|
||||
field_name = re_match.group()[2:-2]
|
||||
field_pos = re_match.start()
|
||||
if field_name not in street_fields:
|
||||
raise UserError(_("Unrecognized field %s in street format.") % field_name)
|
||||
raise UserError(_("Unrecognized field %s in street format.", field_name))
|
||||
if not previous_field:
|
||||
# first iteration: add heading chars in street_format
|
||||
if partner[field_name]:
|
||||
@@ -104,7 +104,7 @@ class Partner(models.Model):
|
||||
# value not found: keep looking for the same field
|
||||
pass
|
||||
if field_name not in street_fields:
|
||||
raise UserError(_("Unrecognized field %s in street format.") % field_name)
|
||||
raise UserError(_("Unrecognized field %s in street format.", field_name))
|
||||
previous_pos = re_match.end()
|
||||
|
||||
# last field value is what remains in street_raw minus trailing chars in street_format
|
||||
|
||||
@@ -91,7 +91,7 @@ class BaseGengoTranslations(models.TransientModel):
|
||||
return (True, gengo)
|
||||
except Exception as e:
|
||||
_logger.exception('Gengo connection failed')
|
||||
return (False, _("Gengo connection failed with this message:\n``%s``") % e)
|
||||
return (False, _("Gengo connection failed with this message:\n``%s``", e))
|
||||
|
||||
def act_update(self):
|
||||
'''
|
||||
|
||||
@@ -297,7 +297,7 @@ class Import(models.TransientModel):
|
||||
_("Invalid cell value at row %(row)s, column %(col)s: %(cell_value)s") % {
|
||||
'row': rowx,
|
||||
'col': colx,
|
||||
'cell_value': xlrd.error_text_from_code.get(cell.value, _("unknown error code %s") % cell.value)
|
||||
'cell_value': xlrd.error_text_from_code.get(cell.value, _("unknown error code %s", cell.value))
|
||||
}
|
||||
)
|
||||
else:
|
||||
@@ -856,13 +856,13 @@ class Import(models.TransientModel):
|
||||
response.raise_for_status()
|
||||
|
||||
if response.headers.get('Content-Length') and int(response.headers['Content-Length']) > maxsize:
|
||||
raise ValueError(_("File size exceeds configured maximum (%s bytes)") % maxsize)
|
||||
raise ValueError(_("File size exceeds configured maximum (%s bytes)", maxsize))
|
||||
|
||||
content = bytearray()
|
||||
for chunk in response.iter_content(DEFAULT_IMAGE_CHUNK_SIZE):
|
||||
content += chunk
|
||||
if len(content) > maxsize:
|
||||
raise ValueError(_("File size exceeds configured maximum (%s bytes)") % maxsize)
|
||||
raise ValueError(_("File size exceeds configured maximum (%s bytes)", maxsize))
|
||||
|
||||
image = Image.open(io.BytesIO(content))
|
||||
w, h = image.size
|
||||
|
||||
@@ -30,7 +30,7 @@ class ImportModule(Controller):
|
||||
@webservice
|
||||
def login_upload(self, login, password, db=None, force='', mod_file=None, **kw):
|
||||
if db and db != request.db:
|
||||
raise Exception(_("Could not select database '%s'") % db)
|
||||
raise Exception(_("Could not select database '%s'", db))
|
||||
uid = request.session.authenticate(request.db, login, password)
|
||||
self.check_user(uid)
|
||||
force = True if force == '1' else False
|
||||
|
||||
@@ -121,7 +121,7 @@ class IrModule(models.Model):
|
||||
with zipfile.ZipFile(module_file, "r") as z:
|
||||
for zf in z.filelist:
|
||||
if zf.file_size > MAX_FILE_SIZE:
|
||||
raise UserError(_("File '%s' exceed maximum allowed file size") % zf.filename)
|
||||
raise UserError(_("File '%s' exceed maximum allowed file size", zf.filename))
|
||||
|
||||
with tempfile.TemporaryDirectory() as module_dir:
|
||||
import odoo.modules.module as module
|
||||
|
||||
@@ -32,9 +32,9 @@ class IrModelFields(models.Model):
|
||||
if 'serialization_field_id' in vals or 'name' in vals:
|
||||
for field in self:
|
||||
if 'serialization_field_id' in vals and field.serialization_field_id.id != vals['serialization_field_id']:
|
||||
raise UserError(_('Changing the storing system for field "%s" is not allowed.') % field.name)
|
||||
raise UserError(_('Changing the storing system for field "%s" is not allowed.', field.name))
|
||||
if field.serialization_field_id and (field.name != vals['name']):
|
||||
raise UserError(_('Renaming sparse field "%s" is not allowed') % field.name)
|
||||
raise UserError(_('Renaming sparse field "%s" is not allowed', field.name))
|
||||
|
||||
return super(IrModelFields, self).write(vals)
|
||||
|
||||
|
||||
@@ -127,9 +127,9 @@ class RecurrenceRule(models.Model):
|
||||
every = _("Every %s %s, ") % (recurrence.interval, period)
|
||||
|
||||
if recurrence.end_type == 'count':
|
||||
end = _("for %s events") % recurrence.count
|
||||
end = _("for %s events", recurrence.count)
|
||||
elif recurrence.end_type == 'end_date':
|
||||
end = _("until %s") % recurrence.until
|
||||
end = _("until %s", recurrence.until)
|
||||
else:
|
||||
end = ''
|
||||
|
||||
@@ -142,7 +142,7 @@ class RecurrenceRule(models.Model):
|
||||
weekday_label = dict(BYDAY_SELECTION)[recurrence.byday]
|
||||
on = _("on the %(position)s %(weekday)s, ") % {'position': recurrence.byday, 'weekday': weekday_label}
|
||||
else:
|
||||
on = _("day %s, ") % recurrence.day
|
||||
on = _("day %s, ", recurrence.day)
|
||||
else:
|
||||
on = ''
|
||||
recurrence.name = every + on + end
|
||||
|
||||
@@ -101,7 +101,7 @@ class SaleOrder(models.Model):
|
||||
}
|
||||
if carrier.invoice_policy == 'real':
|
||||
values['price_unit'] = 0
|
||||
values['name'] += _(' (Estimated Cost: %s )') % self._format_currency_amount(price_unit)
|
||||
values['name'] += _(' (Estimated Cost: %s )', self._format_currency_amount(price_unit))
|
||||
else:
|
||||
values['price_unit'] = price_unit
|
||||
if carrier.free_over and self.currency_id.is_zero(price_unit) :
|
||||
|
||||
@@ -51,7 +51,7 @@ class EventTicket(models.Model):
|
||||
def default_get(self, fields):
|
||||
res = super(EventTicket, self).default_get(fields)
|
||||
if 'name' in fields and (not res.get('name') or res['name'] == _('Registration')) and self.env.context.get('default_event_name'):
|
||||
res['name'] = _('Registration for %s') % self.env.context['default_event_name']
|
||||
res['name'] = _('Registration for %s', self.env.context['default_event_name'])
|
||||
return res
|
||||
|
||||
# description
|
||||
|
||||
@@ -126,7 +126,7 @@ odoo_mailgate: "|/path/to/odoo-mailgate.py --host=localhost -u %(uid)d -p PASSWO
|
||||
server.write({'state': 'done'})
|
||||
except Exception as err:
|
||||
_logger.info("Failed to connect to %s server %s.", server.server_type, server.name, exc_info=True)
|
||||
raise UserError(_("Connection test failed: %s") % tools.ustr(err))
|
||||
raise UserError(_("Connection test failed: %s", tools.ustr(err)))
|
||||
finally:
|
||||
try:
|
||||
if connection:
|
||||
|
||||
@@ -596,7 +596,7 @@ class Challenge(models.Model):
|
||||
def accept_challenge(self):
|
||||
user = self.env.user
|
||||
sudoed = self.sudo()
|
||||
sudoed.message_post(body=_("%s has joined the challenge") % user.name)
|
||||
sudoed.message_post(body=_("%s has joined the challenge", user.name))
|
||||
sudoed.write({'invited_user_ids': [(3, user.id)], 'user_ids': [(4, user.id)]})
|
||||
return sudoed._generate_goals_from_challenge()
|
||||
|
||||
@@ -604,7 +604,7 @@ class Challenge(models.Model):
|
||||
"""The user discard the suggested challenge"""
|
||||
user = self.env.user
|
||||
sudoed = self.sudo()
|
||||
sudoed.message_post(body=_("%s has refused the challenge") % user.name)
|
||||
sudoed.message_post(body=_("%s has refused the challenge", user.name))
|
||||
return sudoed.write({'invited_user_ids': (3, user.id)})
|
||||
|
||||
def _check_challenge_reward(self, force=False):
|
||||
@@ -652,7 +652,7 @@ class Challenge(models.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 = rewarded_users.name_get()
|
||||
|
||||
@@ -430,7 +430,7 @@ class Goal(models.Model):
|
||||
if self.computation_mode == 'manually':
|
||||
# open a wizard window to update the value manually
|
||||
action = {
|
||||
'name': _("Update %s") % self.definition_id.name,
|
||||
'name': _("Update %s", self.definition_id.name),
|
||||
'id': self.id,
|
||||
'type': 'ir.actions.act_window',
|
||||
'views': [[False, 'form']],
|
||||
|
||||
@@ -74,7 +74,7 @@ class User(models.Model):
|
||||
with self.pool.cursor() as cr:
|
||||
self.env.user.with_env(self.env(cr=cr)).write({'google_calendar_rtoken': False})
|
||||
error_key = error.response.json().get("error", "nc")
|
||||
error_msg = _("Something went wrong during your token generation. Maybe your Authorization Code is invalid or already expired [%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 UserError(error_msg)
|
||||
|
||||
def _sync_google_calendar(self, calendar_service: GoogleCalendarService):
|
||||
|
||||
@@ -34,24 +34,24 @@ class HrPlanActivityType(models.Model):
|
||||
def get_responsible_id(self, employee):
|
||||
if self.responsible == 'coach':
|
||||
if not employee.coach_id:
|
||||
raise UserError(_('Coach of employee %s is not set.') % employee.name)
|
||||
raise UserError(_('Coach of employee %s is not set.', employee.name))
|
||||
responsible = employee.coach_id.user_id
|
||||
if not responsible:
|
||||
raise UserError(_('User of coach of employee %s is not set.') % employee.name)
|
||||
raise UserError(_('User of coach of employee %s is not set.', employee.name))
|
||||
elif self.responsible == 'manager':
|
||||
if not employee.parent_id:
|
||||
raise UserError(_('Manager of employee %s is not set.') % employee.name)
|
||||
raise UserError(_('Manager of employee %s is not set.', employee.name))
|
||||
responsible = employee.parent_id.user_id
|
||||
if not responsible:
|
||||
raise UserError(_('User of manager of employee %s is not set.') % employee.name)
|
||||
raise UserError(_('User of manager of employee %s is not set.', employee.name))
|
||||
elif self.responsible == 'employee':
|
||||
responsible = employee.user_id
|
||||
if not responsible:
|
||||
raise UserError(_('User linked to employee %s is required.') % employee.name)
|
||||
raise UserError(_('User linked to employee %s is required.', employee.name))
|
||||
elif self.responsible == 'other':
|
||||
responsible = self.responsible_id
|
||||
if not responsible:
|
||||
raise UserError(_('No specific user given on activity %s.') % self.activity_type_id.name)
|
||||
raise UserError(_('No specific user given on activity %s.', self.activity_type_id.name))
|
||||
return responsible
|
||||
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class Contract(models.Model):
|
||||
for contract in contracts:
|
||||
contract.activity_schedule(
|
||||
'mail.mail_activity_data_todo', contract.date_end,
|
||||
_("The contract of %s is about to expire.") % contract.employee_id.name,
|
||||
_("The contract of %s is about to expire.", contract.employee_id.name),
|
||||
user_id=contract.hr_responsible_id.id or self.env.uid)
|
||||
|
||||
contracts.write({'kanban_state': 'blocked'})
|
||||
|
||||
@@ -466,7 +466,7 @@ class Applicant(models.Model):
|
||||
if applicant.job_id:
|
||||
applicant.job_id.write({'no_of_hired_employee': applicant.job_id.no_of_hired_employee + 1})
|
||||
applicant.job_id.message_post(
|
||||
body=_('New Employee %s Hired') % applicant.partner_name if applicant.partner_name else applicant.name,
|
||||
body=_('New Employee %s Hired', applicant.partner_name if applicant.partner_name else applicant.name),
|
||||
subtype_xmlid="hr_recruitment.mt_job_applicant_hired")
|
||||
applicant.message_post_with_view(
|
||||
'hr_recruitment.applicant_hired_template',
|
||||
|
||||
@@ -142,7 +142,7 @@ class SerialDriver(Driver):
|
||||
self._take_measure()
|
||||
time.sleep(self._protocol.newMeasureDelay)
|
||||
except Exception:
|
||||
msg = _('Error while reading %s') % self.device_name
|
||||
msg = _('Error while reading %s', self.device_name)
|
||||
_logger.exception(msg)
|
||||
self._status = {'status': self.STATUS_ERROR, 'message_title': msg, 'message_body': traceback.format_exc()}
|
||||
self._push_status()
|
||||
|
||||
@@ -68,7 +68,7 @@ def jsonrpc(url, method='call', params=None, timeout=15):
|
||||
return response.get('result')
|
||||
except (ValueError, requests.exceptions.ConnectionError, requests.exceptions.MissingSchema, requests.exceptions.Timeout, requests.exceptions.HTTPError) as e:
|
||||
raise exceptions.AccessError(
|
||||
_('The url that this service requested returned an error. Please contact the author of the app. The url it tried to contact was %s') % url
|
||||
_('The url that this service requested returned an error. Please contact the author of the app. The url it tried to contact was %s', url)
|
||||
)
|
||||
|
||||
#----------------------------------------------------------
|
||||
|
||||
@@ -207,7 +207,7 @@ class MailChannel(models.Model):
|
||||
mail_body = template._render(render_context, engine='ir.qweb', minimal_qcontext=True)
|
||||
mail_body = self.env['mail.render.mixin']._replace_local_links(mail_body)
|
||||
mail = self.env['mail.mail'].sudo().create({
|
||||
'subject': _('Conversation with %s') % self.livechat_operator_id.name,
|
||||
'subject': _('Conversation with %s', self.livechat_operator_id.name),
|
||||
'email_from': company.catchall_formatted or company.email_formatted,
|
||||
'author_id': self.env.user.partner_id.id,
|
||||
'email_to': email,
|
||||
|
||||
@@ -98,7 +98,7 @@ class AccountMove(models.Model):
|
||||
for line in inv.mapped('invoice_line_ids').filtered(lambda x: x.display_type not in ('line_section', 'line_note')):
|
||||
vat_taxes = line.tax_ids.filtered(lambda x: x.tax_group_id.l10n_ar_vat_afip_code)
|
||||
if len(vat_taxes) != 1:
|
||||
raise UserError(_('There must be one and only one VAT tax per line. Check line "%s"') % line.name)
|
||||
raise UserError(_('There must be one and only one VAT tax per line. Check line "%s"', line.name))
|
||||
elif purchase_aliquots == 'zero' and vat_taxes.tax_group_id.l10n_ar_vat_afip_code != '0':
|
||||
raise UserError(_('On invoice id "%s" you must use VAT Not Applicable on every line.') % inv.id)
|
||||
elif purchase_aliquots == 'not_zero' and vat_taxes.tax_group_id.l10n_ar_vat_afip_code == '0':
|
||||
|
||||
@@ -103,10 +103,10 @@ class ResPartner(models.Model):
|
||||
try:
|
||||
module.validate(rec.vat)
|
||||
except module.InvalidChecksum:
|
||||
raise ValidationError(_('The validation digit is not valid for "%s"') % rec.l10n_latam_identification_type_id.name)
|
||||
raise ValidationError(_('The validation digit is not valid for "%s"', rec.l10n_latam_identification_type_id.name))
|
||||
except module.InvalidLength:
|
||||
raise ValidationError(_('Invalid length for "%s"') % rec.l10n_latam_identification_type_id.name)
|
||||
raise ValidationError(_('Invalid length for "%s"', rec.l10n_latam_identification_type_id.name))
|
||||
except module.InvalidFormat:
|
||||
raise ValidationError(_('Only numbers allowed for "%s"') % rec.l10n_latam_identification_type_id.name)
|
||||
raise ValidationError(_('Only numbers allowed for "%s"', rec.l10n_latam_identification_type_id.name))
|
||||
except Exception as error:
|
||||
raise ValidationError(repr(error))
|
||||
|
||||
@@ -88,7 +88,7 @@ class AccountFrFec(models.TransientModel):
|
||||
is_dom_tom = company.country_id.code in dom_tom_group.country_ids.mapped('code')
|
||||
if not is_dom_tom and not company.vat:
|
||||
raise Warning(
|
||||
_("Missing VAT number for company %s") % company.name)
|
||||
_("Missing VAT number for company %s", company.name))
|
||||
if not is_dom_tom and company.vat[0:2] != 'FR':
|
||||
raise Warning(
|
||||
_("FEC is for French companies only !"))
|
||||
|
||||
@@ -28,7 +28,7 @@ class pos_session(models.Model):
|
||||
date_today = datetime.utcnow()
|
||||
session_start = Datetime.from_string(self.start_at)
|
||||
if not date_today - timedelta(hours=24) <= session_start:
|
||||
raise UserError(_("This session has been opened another day. To comply with the French law, you should close sessions on a daily basis. Please close session %s and open a new one.") % self.name)
|
||||
raise UserError(_("This session has been opened another day. To comply with the French law, you should close sessions on a daily basis. Please close session %s and open a new one.", self.name))
|
||||
return True
|
||||
|
||||
def open_frontend_cb(self):
|
||||
|
||||
@@ -64,14 +64,14 @@ class ResCompany(models.Model):
|
||||
('l10n_fr_secure_sequence_number', '!=', 0)], order="l10n_fr_secure_sequence_number ASC")
|
||||
|
||||
if not orders:
|
||||
msg_alert = (_('There isn\'t any order flagged for data inalterability yet for the company %s. This mechanism only runs for point of sale orders generated after the installation of the module France - Certification CGI 286 I-3 bis. - POS') % self.env.company.name)
|
||||
msg_alert = (_('There isn\'t any order flagged for data inalterability yet for the company %s. This mechanism only runs for point of sale orders generated after the installation of the module France - Certification CGI 286 I-3 bis. - POS', self.env.company.name))
|
||||
hash_verified = False
|
||||
|
||||
previous_hash = u''
|
||||
start_order_info = []
|
||||
for order in orders:
|
||||
if order.l10n_fr_hash != order._compute_hash(previous_hash=previous_hash):
|
||||
msg_alert = (_('Corrupted data on point of sale order with id %s.') % order.id)
|
||||
msg_alert = (_('Corrupted data on point of sale order with id %s.', order.id))
|
||||
hash_verified = False
|
||||
break
|
||||
previous_hash = order.l10n_fr_hash
|
||||
|
||||
@@ -102,7 +102,7 @@ class AccountMove(models.Model):
|
||||
"""Reset E-Faktur, so it can be use for other invoice."""
|
||||
for move in self:
|
||||
if move.l10n_id_attachment_id:
|
||||
raise UserError(_('You have already generated the tax report for this document: %s') % move.name)
|
||||
raise UserError(_('You have already generated the tax report for this document: %s', move.name))
|
||||
self.env['l10n_id_efaktur.efaktur.range'].push_number(move.company_id.id, move.l10n_id_tax_number[3:])
|
||||
move.message_post(
|
||||
body='e-Faktur Reset: %s ' % (move.l10n_id_tax_number),
|
||||
|
||||
@@ -83,13 +83,13 @@ class AccountEdiFormat(models.Model):
|
||||
else:
|
||||
company = self.env.company
|
||||
if elements:
|
||||
_logger.info(_('Company not found with codice fiscale: %s. The company\'s user is set by default.') % elements[0].text)
|
||||
_logger.info(_('Company not found with codice fiscale: %s. The company\'s user is set by default.', elements[0].text))
|
||||
else:
|
||||
_logger.info(_('Company not found. The company\'s user is set by default.'))
|
||||
|
||||
if not self.env.is_superuser():
|
||||
if self.env.company != company:
|
||||
raise UserError(_("You can only import invoice concern your current company: %s") % self.env.company.display_name)
|
||||
raise UserError(_("You can only import invoice concern your current company: %s", self.env.company.display_name))
|
||||
|
||||
# Refund type.
|
||||
# TD01 == invoice
|
||||
|
||||
@@ -168,7 +168,7 @@ class AccountMove(models.Model):
|
||||
}
|
||||
|
||||
data = b"<?xml version='1.0' encoding='UTF-8'?>" + invoice._export_as_xml()
|
||||
description = _('Italian invoice: %s') % invoice.move_type
|
||||
description = _('Italian invoice: %s', invoice.move_type)
|
||||
invoice.edi_document_ids = self.env['ir.attachment'].create({
|
||||
'name': report_name,
|
||||
'res_id': invoice.id,
|
||||
|
||||
@@ -156,7 +156,7 @@ class AccountMove(models.Model):
|
||||
invoice_type = rec.move_type
|
||||
if internal_type in ['debit_note', 'invoice'] and invoice_type in ['out_refund', 'in_refund'] and \
|
||||
rec.l10n_latam_document_type_id.code != '99':
|
||||
raise ValidationError(_('You can not use a %s document type with a refund invoice') % internal_type)
|
||||
raise ValidationError(_('You can not use a %s document type with a refund invoice', internal_type))
|
||||
elif internal_type == 'credit_note' and invoice_type in ['out_invoice', 'in_invoice']:
|
||||
raise ValidationError(_('You can not use a %s document type with a invoice') % (internal_type))
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class MailController(http.Controller):
|
||||
def _check_token_and_record_or_redirect(cls, model, res_id, token):
|
||||
comparison = cls._check_token(token)
|
||||
if not comparison:
|
||||
_logger.warning(_('Invalid token in route %s') % request.httprequest.url)
|
||||
_logger.warning(_('Invalid token in route %s', request.httprequest.url))
|
||||
return comparison, None, cls._redirect_to_messaging()
|
||||
try:
|
||||
record = request.env[model].browse(res_id).exists()
|
||||
|
||||
@@ -28,7 +28,7 @@ class MailBlackList(models.Model):
|
||||
for value in values:
|
||||
email = tools.email_normalize(value.get('email'))
|
||||
if not email:
|
||||
raise UserError(_('Invalid email address %r') % value['email'])
|
||||
raise UserError(_('Invalid email address %r', value['email']))
|
||||
if email in all_emails:
|
||||
continue
|
||||
all_emails.append(email)
|
||||
|
||||
@@ -427,7 +427,7 @@ class Channel(models.Model):
|
||||
'email_from': company.catchall_formatted or company.email_formatted,
|
||||
'author_id': self.env.user.partner_id.id,
|
||||
'body_html': view._render({'channel': self, 'partner': partner}, engine='ir.qweb', minimal_qcontext=True),
|
||||
'subject': _("Guidelines of channel %s") % self.name,
|
||||
'subject': _("Guidelines of channel %s", self.name),
|
||||
'recipient_ids': [(4, partner.id)]
|
||||
}
|
||||
mail = self.env['mail.mail'].sudo().create(create_values)
|
||||
@@ -976,7 +976,7 @@ class Channel(models.Model):
|
||||
def _execute_command_help(self, **kwargs):
|
||||
partner = self.env.user.partner_id
|
||||
if self.channel_type == 'channel':
|
||||
msg = _("You are in channel <b>#%s</b>.") % self.name
|
||||
msg = _("You are in channel <b>#%s</b>.", self.name)
|
||||
if self.public == 'private':
|
||||
msg += _(" This channel is private. People must be invited to join it.")
|
||||
else:
|
||||
|
||||
@@ -316,7 +316,7 @@ class MailRenderMixin(models.AbstractModel):
|
||||
render_result = template.render(variables)
|
||||
except Exception as e:
|
||||
_logger.info("Failed to render template : %s" % e, exc_info=True)
|
||||
raise UserError(_("Failed to render template : %s") % e)
|
||||
raise UserError(_("Failed to render template : %s", e))
|
||||
if render_result == u"False":
|
||||
render_result = u""
|
||||
results[record.id] = render_result
|
||||
|
||||
@@ -74,7 +74,7 @@ class MailTemplate(models.Model):
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def copy(self, default=None):
|
||||
default = dict(default or {},
|
||||
name=_("%s (copy)") % self.name)
|
||||
name=_("%s (copy)", self.name))
|
||||
return super(MailTemplate, self).copy(default=default)
|
||||
|
||||
def unlink_action(self):
|
||||
@@ -88,7 +88,7 @@ class MailTemplate(models.Model):
|
||||
view = self.env.ref('mail.email_compose_message_wizard_form')
|
||||
|
||||
for template in self:
|
||||
button_name = _('Send Mail (%s)') % template.name
|
||||
button_name = _('Send Mail (%s)', template.name)
|
||||
action = ActWindow.create({
|
||||
'name': button_name,
|
||||
'type': 'ir.actions.act_window',
|
||||
@@ -200,7 +200,7 @@ class MailTemplate(models.Model):
|
||||
else:
|
||||
res = report._render([res_id])
|
||||
if not res:
|
||||
raise UserError(_('Unsupported report type %s found.') % report.report_type)
|
||||
raise UserError(_('Unsupported report type %s found.', report.report_type))
|
||||
result, format = res
|
||||
|
||||
# TODO in trunk, change return format to binary to match message_post expected format
|
||||
|
||||
@@ -544,7 +544,7 @@ class MailThread(models.AbstractModel):
|
||||
"""
|
||||
self.ensure_one()
|
||||
doc_name = self.env['ir.model']._get(self._name).name
|
||||
return _('%s created') % doc_name
|
||||
return _('%s created', doc_name)
|
||||
|
||||
def _track_subtype(self, init_values):
|
||||
""" Give the subtypes triggered by the changes on the record according
|
||||
@@ -671,7 +671,7 @@ class MailThread(models.AbstractModel):
|
||||
|
||||
def _routing_warn(self, error_message, message_id, route, raise_exception=True):
|
||||
""" Tools method used in _routing_check_route: whether to log a warning or raise an error """
|
||||
short_message = _("Mailbox unavailable - %s") % error_message
|
||||
short_message = _("Mailbox unavailable - %s", error_message)
|
||||
full_message = ('Routing mail with Message-Id %s: route %s: %s' %
|
||||
(message_id, route, error_message))
|
||||
_logger.info(full_message)
|
||||
@@ -791,7 +791,7 @@ class MailThread(models.AbstractModel):
|
||||
self._routing_warn(_('target model unspecified'), message_id, route, raise_exception)
|
||||
return ()
|
||||
elif model not in self.env:
|
||||
self._routing_warn(_('unknown target model %s') % model, message_id, route, raise_exception)
|
||||
self._routing_warn(_('unknown target model %s', model), message_id, route, raise_exception)
|
||||
return ()
|
||||
record_set = self.env[model].browse(thread_id) if thread_id else self.env[model]
|
||||
|
||||
@@ -801,12 +801,12 @@ class MailThread(models.AbstractModel):
|
||||
self._routing_warn(_('reply to missing document (%s,%s), fall back on document creation') % (model, thread_id), message_id, route, False)
|
||||
thread_id = None
|
||||
elif not hasattr(record_set, 'message_update'):
|
||||
self._routing_warn(_('reply to model %s that does not accept document update, fall back on document creation') % model, message_id, route, False)
|
||||
self._routing_warn(_('reply to model %s that does not accept document update, fall back on document creation', model), message_id, route, False)
|
||||
thread_id = None
|
||||
|
||||
# New Document: check model accepts the mailgateway
|
||||
if not thread_id and model and not hasattr(record_set, 'message_new'):
|
||||
self._routing_warn(_('model %s does not accept document creation') % model, message_id, route, raise_exception)
|
||||
self._routing_warn(_('model %s does not accept document creation', model), message_id, route, raise_exception)
|
||||
return ()
|
||||
|
||||
# Update message author. We do it now because we need it for aliases (contact settings)
|
||||
@@ -2595,7 +2595,7 @@ class MailThread(models.AbstractModel):
|
||||
access_link = self._notify_get_action_link('view')
|
||||
|
||||
if model_name:
|
||||
view_title = _('View %s') % model_name
|
||||
view_title = _('View %s', model_name)
|
||||
else:
|
||||
view_title = _('View')
|
||||
|
||||
@@ -2859,7 +2859,7 @@ class MailThread(models.AbstractModel):
|
||||
assignation_msg = view._render(values, engine='ir.qweb', minimal_qcontext=True)
|
||||
assignation_msg = self.env['mail.render.mixin']._replace_local_links(assignation_msg)
|
||||
record.message_notify(
|
||||
subject=_('You have been assigned to %s') % record.display_name,
|
||||
subject=_('You have been assigned to %s', record.display_name),
|
||||
body=assignation_msg,
|
||||
partner_ids=partner_ids,
|
||||
record_name=record.display_name,
|
||||
|
||||
@@ -93,9 +93,9 @@ class MailBlackListMixin(models.AbstractModel):
|
||||
|
||||
def _assert_primary_email(self):
|
||||
if not hasattr(self, "_primary_email") or not isinstance(self._primary_email, str):
|
||||
raise UserError(_('Invalid primary email field on model %s') % self._name)
|
||||
raise UserError(_('Invalid primary email field on model %s', self._name))
|
||||
if self._primary_email not in self._fields or self._fields[self._primary_email].type != 'char':
|
||||
raise UserError(_('Invalid primary email field on model %s') % self._name)
|
||||
raise UserError(_('Invalid primary email field on model %s', self._name))
|
||||
|
||||
def _message_receive_bounce(self, email, partner):
|
||||
""" Override of mail.thread generic method. Purpose is to increment the
|
||||
|
||||
@@ -223,7 +223,7 @@ class MaintenanceEquipment(models.Model):
|
||||
def _create_new_request(self, date):
|
||||
self.ensure_one()
|
||||
self.env['maintenance.request'].create({
|
||||
'name': _('Preventive Maintenance - %s') % self.name,
|
||||
'name': _('Preventive Maintenance - %s', self.name),
|
||||
'request_date': date,
|
||||
'schedule_date': date,
|
||||
'category_id': self.category_id.id,
|
||||
|
||||
@@ -259,7 +259,7 @@ class MassMailing(models.Model):
|
||||
def copy(self, default=None):
|
||||
self.ensure_one()
|
||||
default = dict(default or {},
|
||||
name=_('%s (copy)') % self.name,
|
||||
name=_('%s (copy)', self.name),
|
||||
contact_list_ids=self.contact_list_ids.ids)
|
||||
return super(MassMailing, self).copy(default=default)
|
||||
|
||||
@@ -469,7 +469,7 @@ class MassMailing(models.Model):
|
||||
elif 'email' in target._fields:
|
||||
mail_field = 'email'
|
||||
else:
|
||||
raise UserError(_("Unsupported mass mailing model %s") % self.mailing_model_id.name)
|
||||
raise UserError(_("Unsupported mass mailing model %s", self.mailing_model_id.name))
|
||||
|
||||
if self.unique_ab_testing:
|
||||
query +="""
|
||||
|
||||
@@ -171,7 +171,7 @@ class Mailing(models.Model):
|
||||
if 'phone' in target._fields:
|
||||
phone_fields.append('phone')
|
||||
if not phone_fields:
|
||||
raise UserError(_("Unsupported %s for mass SMS") % self.mailing_model_id.name)
|
||||
raise UserError(_("Unsupported %s for mass SMS", self.mailing_model_id.name))
|
||||
|
||||
query = """
|
||||
SELECT %(select_query)s
|
||||
|
||||
@@ -23,7 +23,7 @@ class MassSMSTest(models.TransientModel):
|
||||
sanitized_numbers = [info['sanitized'] for info in sanitize_res.values() if info['sanitized']]
|
||||
invalid_numbers = [number for number, info in sanitize_res.items() if info['code']]
|
||||
if invalid_numbers:
|
||||
raise exceptions.UserError(_('Following numbers are not correctly encoded: %s, example : "+32 495 85 85 77, +33 545 55 55 55"') % repr(invalid_numbers))
|
||||
raise exceptions.UserError(_('Following numbers are not correctly encoded: %s, example : "+32 495 85 85 77, +33 545 55 55 55"', repr(invalid_numbers)))
|
||||
self.env['sms.api']._send_sms_batch([{
|
||||
'res_id': 0,
|
||||
'number': number,
|
||||
|
||||
@@ -45,7 +45,7 @@ class SMSComposer(models.TransientModel):
|
||||
trace_values['ignored'] = fields.Datetime.now()
|
||||
else:
|
||||
if self.mass_sms_allow_unsubscribe:
|
||||
sms_values['body'] = '%s\n%s' % (sms_values['body'] or '', _('STOP SMS : %s') % self._get_unsubscribe_url(record.id, trace_code, sms_values['number']))
|
||||
sms_values['body'] = '%s\n%s' % (sms_values['body'] or '', _('STOP SMS : %s', self._get_unsubscribe_url(record.id, trace_code, sms_values['number'])))
|
||||
return trace_values
|
||||
|
||||
def _get_blacklist_record_ids(self, records, recipients_info):
|
||||
|
||||
@@ -90,7 +90,7 @@ class MrpBom(models.Model):
|
||||
for bom in self:
|
||||
for bom_line in bom.bom_line_ids:
|
||||
if bom.product_id and bom_line.product_id == bom.product_id:
|
||||
raise ValidationError(_("BoM line product %s should not be the same as BoM product.") % bom.display_name)
|
||||
raise ValidationError(_("BoM line product %s should not be the same as BoM product.", bom.display_name))
|
||||
if bom.product_id and bom_line.bom_product_template_attribute_value_ids:
|
||||
raise ValidationError(_("BoM cannot concern product %s and have a line with attributes (%s) at the same time.")
|
||||
% (bom.product_id.display_name, ", ".join([ptav.display_name for ptav in bom_line.bom_product_template_attribute_value_ids])))
|
||||
|
||||
@@ -718,7 +718,7 @@ class MrpProduction(models.Model):
|
||||
not_cancel = self.filtered(lambda m: m.state != 'cancel')
|
||||
if not_cancel:
|
||||
productions_name = ', '.join([prod.display_name for prod in not_cancel])
|
||||
raise UserError(_('%s cannot be deleted. Try to cancel them before.') % productions_name)
|
||||
raise UserError(_('%s cannot be deleted. Try to cancel them before.', productions_name))
|
||||
|
||||
workorders_to_delete = self.workorder_ids.filtered(lambda wo: wo.state != 'done')
|
||||
if workorders_to_delete:
|
||||
@@ -794,7 +794,7 @@ class MrpProduction(models.Model):
|
||||
moves = []
|
||||
for production in self:
|
||||
if production.product_id in production.bom_id.byproduct_ids.mapped('product_id'):
|
||||
raise UserError(_("You cannot have %s as the finished product and in the Byproducts") % self.product_id.name)
|
||||
raise UserError(_("You cannot have %s as the finished product and in the Byproducts", self.product_id.name))
|
||||
moves = [production._get_move_finished_values(production.product_id.id, production.product_qty, production.product_uom_id.id)]
|
||||
for byproduct in production.bom_id.byproduct_ids:
|
||||
product_uom_factor = production.product_uom_id._compute_quantity(production.product_qty, production.bom_id.product_uom_id)
|
||||
@@ -1554,7 +1554,7 @@ class MrpProduction(models.Model):
|
||||
def button_unbuild(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': _('Unbuild: %s') % self.product_id.display_name,
|
||||
'name': _('Unbuild: %s', self.product_id.display_name),
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mrp.unbuild',
|
||||
'view_id': self.env.ref('mrp.mrp_unbuild_form_view_simplified').id,
|
||||
@@ -1585,7 +1585,7 @@ class MrpProduction(models.Model):
|
||||
('state', '=', 'done')
|
||||
])
|
||||
if sml:
|
||||
raise UserError(_('This serial number for product %s has already been produced') % self.product_id.name)
|
||||
raise UserError(_('This serial number for product %s has already been produced', self.product_id.name))
|
||||
|
||||
for move in self.move_finished_ids:
|
||||
if move.has_tracking != 'serial' or move.product_id == self.product_id:
|
||||
|
||||
@@ -751,7 +751,7 @@ class MrpWorkorder(models.Model):
|
||||
qty_done += line.product_uom_id._compute_quantity(line.qty_done, move.product_uom)
|
||||
rounding = move.product_uom_id.rounding
|
||||
if float_compare(qty_done, move.product_uom_qty, precision_rounding=rounding) != 0:
|
||||
raise UserError(_('You should consume the quantity of %s defined in the BoM. If you want to consume more or less components, change the consumption setting on the BoM.') % move.product_id.name)
|
||||
raise UserError(_('You should consume the quantity of %s defined in the BoM. If you want to consume more or less components, change the consumption setting on the BoM.', move.product_id.name))
|
||||
|
||||
def _check_sn_uniqueness(self):
|
||||
""" Alert the user if the serial number as already been produced """
|
||||
@@ -763,4 +763,4 @@ class MrpWorkorder(models.Model):
|
||||
('state', '=', 'done')
|
||||
])
|
||||
if sml:
|
||||
raise UserError(_('This serial number for product %s has already been produced') % self.product_id.name)
|
||||
raise UserError(_('This serial number for product %s has already been produced', self.product_id.name))
|
||||
|
||||
@@ -159,7 +159,7 @@ class TxSips(models.Model):
|
||||
|
||||
payment_tx = self.search([('reference', '=', reference)])
|
||||
if not payment_tx or len(payment_tx) > 1:
|
||||
error_msg = _('Sips: received data for reference %s') % reference
|
||||
error_msg = _('Sips: received data for reference %s', reference)
|
||||
if not payment_tx:
|
||||
error_msg += _('; no order found')
|
||||
else:
|
||||
|
||||
@@ -82,7 +82,7 @@ class PaymentAcquirerStripe(models.Model):
|
||||
except HTTPError:
|
||||
_logger.error(resp.text)
|
||||
stripe_error = resp.json().get('error', {}).get('message', '')
|
||||
error_msg = " " + (_("Stripe gave us the following info about the problem: '%s'") % stripe_error)
|
||||
error_msg = " " + (_("Stripe gave us the following info about the problem: '%s'", stripe_error))
|
||||
raise ValidationError(error_msg)
|
||||
return resp.json()
|
||||
|
||||
@@ -249,7 +249,7 @@ class PaymentTransactionStripe(models.Model):
|
||||
|
||||
tx = self.search([('reference', '=', reference)])
|
||||
if not tx:
|
||||
error_msg = (_('Stripe: no order found for reference %s') % reference)
|
||||
error_msg = _('Stripe: no order found for reference %s', reference)
|
||||
_logger.error(error_msg)
|
||||
raise ValidationError(error_msg)
|
||||
elif len(tx) > 1:
|
||||
|
||||
@@ -106,9 +106,9 @@ class PhoneMixin(models.AbstractModel):
|
||||
|
||||
def _assert_phone_field(self):
|
||||
if not hasattr(self, "_phone_get_number_fields"):
|
||||
raise UserError(_('Invalid primary phone field on model %s') % self._name)
|
||||
raise UserError(_('Invalid primary phone field on model %s', self._name))
|
||||
if not any(fname in self and self._fields[fname].type == 'char' for fname in self._phone_get_number_fields()):
|
||||
raise UserError(_('Invalid primary phone field on model %s') % self._name)
|
||||
raise UserError(_('Invalid primary phone field on model %s', self._name))
|
||||
|
||||
def _phone_get_number_fields(self):
|
||||
""" This method returns the fields to use to find the number to use to
|
||||
|
||||
@@ -20,9 +20,9 @@ try:
|
||||
raise UserError(_('Unable to parse %s.: %s') % (number, str(e)))
|
||||
|
||||
if not phonenumbers.is_possible_number(phone_nbr):
|
||||
raise UserError(_('Impossible number %s: probably invalid number of digits.') % number)
|
||||
raise UserError(_('Impossible number %s: probably invalid number of digits.', number))
|
||||
if not phonenumbers.is_valid_number(phone_nbr):
|
||||
raise UserError(_('Invalid number %s: probably incorrect prefix.') % number)
|
||||
raise UserError(_('Invalid number %s: probably incorrect prefix.', number))
|
||||
|
||||
return phone_nbr
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ class PosConfig(models.Model):
|
||||
def create(self, values):
|
||||
IrSequence = self.env['ir.sequence'].sudo()
|
||||
val = {
|
||||
'name': _('POS Order %s') % values['name'],
|
||||
'name': _('POS Order %s', values['name']),
|
||||
'padding': 4,
|
||||
'prefix': "%s/" % values['name'],
|
||||
'code': "pos.order",
|
||||
@@ -468,7 +468,7 @@ class PosConfig(models.Model):
|
||||
# force sequence_id field to new pos.order sequence
|
||||
values['sequence_id'] = IrSequence.create(val).id
|
||||
|
||||
val.update(name=_('POS order line %s') % values['name'], code='pos.order.line')
|
||||
val.update(name=_('POS order line %s', values['name']), code='pos.order.line')
|
||||
values['sequence_line_id'] = IrSequence.create(val).id
|
||||
pos_config = super(PosConfig, self).create(values)
|
||||
pos_config.sudo()._check_modules_to_install()
|
||||
|
||||
@@ -363,7 +363,7 @@ class PosOrder(models.Model):
|
||||
total = float_round(self.amount_total, precision_rounding=self.config_id.rounding_method.rounding, rounding_method=self.config_id.rounding_method.rounding_method)
|
||||
|
||||
if not float_is_zero(total - self.amount_paid, precision_rounding=self.currency_id.rounding):
|
||||
raise UserError(_("Order %s is not fully paid.") % self.name)
|
||||
raise UserError(_("Order %s is not fully paid.", self.name))
|
||||
|
||||
self.write({'state': 'paid'})
|
||||
|
||||
@@ -479,7 +479,7 @@ class PosOrder(models.Model):
|
||||
# order. It can be the same session, or if it has been closed the new one that has been opened.
|
||||
current_session = order.session_id.config_id.current_session_id
|
||||
if not current_session:
|
||||
raise UserError(_('To return product(s), you need to open a session in the POS %s') % order.session_id.config_id.display_name)
|
||||
raise UserError(_('To return product(s), you need to open a session in the POS %s', order.session_id.config_id.display_name))
|
||||
refund_order = order.copy({
|
||||
'name': order.name + _(' REFUND'),
|
||||
'session_id': current_session.id,
|
||||
@@ -533,7 +533,7 @@ class PosOrder(models.Model):
|
||||
'mimetype': 'image/jpeg',
|
||||
})
|
||||
mail_values = {
|
||||
'subject': _('Receipt %s') % name,
|
||||
'subject': _('Receipt %s', name),
|
||||
'body_html': message,
|
||||
'author_id': self.env.user.partner_id.id,
|
||||
'email_from': self.env.company.email or self.env.user.email_formatted,
|
||||
|
||||
@@ -111,7 +111,7 @@ class PortalChatter(http.Controller):
|
||||
try:
|
||||
CustomerPortal._document_check_access(self, 'ir.attachment', attachment_id, access_token)
|
||||
except (AccessError, MissingError):
|
||||
raise UserError(_("The attachment %s does not exist or you do not have the rights to access it.") % attachment_id)
|
||||
raise UserError(_("The attachment %s does not exist or you do not have the rights to access it.", attachment_id))
|
||||
|
||||
@http.route(['/mail/chatter_post'], type='http', methods=['POST'], auth='public', website=True)
|
||||
def portal_chatter_post(self, res_model, res_id, message, redirect=None, attachment_ids='', attachment_tokens='', **kw):
|
||||
|
||||
@@ -273,10 +273,10 @@ class CustomerPortal(Controller):
|
||||
raise UserError(_("The attachment does not exist or you do not have the rights to access it."))
|
||||
|
||||
if attachment_sudo.res_model != 'mail.compose.message' or attachment_sudo.res_id != 0:
|
||||
raise UserError(_("The attachment %s cannot be removed because it is not in a pending state.") % attachment_sudo.name)
|
||||
raise UserError(_("The attachment %s cannot be removed because it is not in a pending state.", attachment_sudo.name))
|
||||
|
||||
if attachment_sudo.env['mail.message'].search([('attachment_ids', 'in', attachment_sudo.ids)]):
|
||||
raise UserError(_("The attachment %s cannot be removed because it is linked to a message.") % attachment_sudo.name)
|
||||
raise UserError(_("The attachment %s cannot be removed because it is linked to a message.", attachment_sudo.name))
|
||||
|
||||
return attachment_sudo.unlink()
|
||||
|
||||
@@ -364,12 +364,12 @@ class CustomerPortal(Controller):
|
||||
|
||||
def _show_report(self, model, report_type, report_ref, download=False):
|
||||
if report_type not in ('html', 'pdf', 'text'):
|
||||
raise UserError(_("Invalid report type: %s") % report_type)
|
||||
raise UserError(_("Invalid report type: %s", report_type))
|
||||
|
||||
report_sudo = request.env.ref(report_ref).sudo()
|
||||
|
||||
if not isinstance(report_sudo, type(request.env['ir.actions.report'])):
|
||||
raise UserError(_("%s is not the reference of a report") % report_ref)
|
||||
raise UserError(_("%s is not the reference of a report", report_ref))
|
||||
|
||||
method_name = '_render_qweb_%s' % (report_type)
|
||||
report = getattr(report_sudo, method_name)([model.id], data={'report_type': report_type})[0]
|
||||
|
||||
@@ -17,7 +17,7 @@ class PosConfig(models.Model):
|
||||
def _check_adyen_ask_customer_for_tip(self):
|
||||
for config in self:
|
||||
if config.adyen_ask_customer_for_tip and (not config.tip_product_id or not config.iface_tipproduct):
|
||||
raise ValidationError(_("Please configure a tip product for POS %s to support tipping with Adyen.") % config.name)
|
||||
raise ValidationError(_("Please configure a tip product for POS %s to support tipping with Adyen.", config.name))
|
||||
|
||||
@api.onchange('adyen_ask_customer_for_tip')
|
||||
def _onchange_adyen_ask_customer_for_tip(self):
|
||||
|
||||
@@ -19,7 +19,7 @@ class MercuryTransaction(models.Model):
|
||||
def _get_pos_session(self):
|
||||
pos_session = self.env['pos.session'].search([('state', '=', 'opened'), ('user_id', '=', self.env.uid)], limit=1)
|
||||
if not pos_session:
|
||||
raise UserError(_("No opened point of sale session for user %s found.") % self.env.user.name)
|
||||
raise UserError(_("No opened point of sale session for user %s found.", self.env.user.name))
|
||||
|
||||
pos_session.login()
|
||||
|
||||
|
||||
@@ -519,7 +519,7 @@ class PricelistItem(models.Model):
|
||||
),
|
||||
)
|
||||
elif item.compute_price == 'percentage':
|
||||
item.price = _("%s %% discount") % (item.percent_price)
|
||||
item.price = _("%s %% discount", item.percent_price)
|
||||
else:
|
||||
item.price = _("%s %% discount and %s surcharge") % (item.price_discount, item.price_surcharge)
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ class ProductTemplate(models.Model):
|
||||
if default is None:
|
||||
default = {}
|
||||
if 'name' not in default:
|
||||
default['name'] = _("%s (copy)") % self.name
|
||||
default['name'] = _("%s (copy)", self.name)
|
||||
return super(ProductTemplate, self).copy(default=default)
|
||||
|
||||
def name_get(self):
|
||||
|
||||
@@ -639,7 +639,7 @@ class Task(models.Model):
|
||||
portal_users = task.allowed_user_ids.filtered('share')
|
||||
if portal_users:
|
||||
user_names = ', '.join(portal_users[:10].mapped('name'))
|
||||
raise ValidationError(_("The project visibility setting doesn't allow portal users to see the project's tasks. (%s)") % user_names)
|
||||
raise ValidationError(_("The project visibility setting doesn't allow portal users to see the project's tasks. (%s)", user_names))
|
||||
|
||||
def _compute_attachment_ids(self):
|
||||
for task in self:
|
||||
@@ -752,7 +752,7 @@ class Task(models.Model):
|
||||
if default is None:
|
||||
default = {}
|
||||
if not default.get('name'):
|
||||
default['name'] = _("%s (copy)") % self.name
|
||||
default['name'] = _("%s (copy)", self.name)
|
||||
return super(Task, self).copy(default)
|
||||
|
||||
@api.constrains('parent_id')
|
||||
|
||||
@@ -284,7 +284,7 @@ class PurchaseOrder(models.Model):
|
||||
# Block if partner only has warning but parent company is blocked
|
||||
if partner.purchase_warn != 'block' and partner.parent_id and partner.parent_id.purchase_warn == 'block':
|
||||
partner = partner.parent_id
|
||||
title = _("Warning for %s") % partner.name
|
||||
title = _("Warning for %s", partner.name)
|
||||
message = partner.purchase_warn_msg
|
||||
warning = {
|
||||
'title': title,
|
||||
@@ -721,7 +721,7 @@ class PurchaseOrder(models.Model):
|
||||
def _compose_note(self, updated_dates):
|
||||
"""Helper method for creating log note when user update scheduled date
|
||||
on portal website."""
|
||||
note = _('<p> %s modified receipt dates for the following products:</p>') % self.partner_id.name
|
||||
note = _('<p> %s modified receipt dates for the following products:</p>', self.partner_id.name)
|
||||
for line, date in updated_dates:
|
||||
note += _('<p> - %s from %s to %s </p>') % (line.product_id.display_name, line.date_planned, date)
|
||||
return note
|
||||
@@ -980,7 +980,7 @@ class PurchaseOrderLine(models.Model):
|
||||
product_info = self.product_id
|
||||
|
||||
if product_info.purchase_line_warn != 'no-message':
|
||||
title = _("Warning for %s") % product_info.name
|
||||
title = _("Warning for %s", product_info.name)
|
||||
message = product_info.purchase_line_warn_msg
|
||||
warning['title'] = title
|
||||
warning['message'] = message
|
||||
|
||||
@@ -89,7 +89,7 @@ class PurchaseRequisition(models.Model):
|
||||
('company_id', '=', self.company_id.id),
|
||||
])
|
||||
if any(requisitions):
|
||||
title = _("Warning for %s") % self.vendor_id.name
|
||||
title = _("Warning for %s", self.vendor_id.name)
|
||||
message = _("There is already an open blanket order for this supplier. We suggest you to use to complete this open blanket order instead of creating a new one.")
|
||||
warning = {
|
||||
'title': title,
|
||||
@@ -115,7 +115,7 @@ class PurchaseRequisition(models.Model):
|
||||
def action_in_progress(self):
|
||||
self.ensure_one()
|
||||
if not all(obj.line_ids for obj in self):
|
||||
raise UserError(_("You cannot confirm agreement '%s' because there is no product line.") % self.name)
|
||||
raise UserError(_("You cannot confirm agreement '%s' because there is no product line.", self.name))
|
||||
if self.type_id.quantity_copy == 'none' and self.vendor_id:
|
||||
for requisition_line in self.line_ids:
|
||||
if requisition_line.price_unit <= 0.0:
|
||||
|
||||
@@ -218,7 +218,7 @@ class PurchaseOrder(models.Model):
|
||||
'partner_id': self.partner_id.id
|
||||
})
|
||||
if not self.partner_id.property_stock_supplier.id:
|
||||
raise UserError(_("You must set a Vendor Location for this partner %s") % self.partner_id.name)
|
||||
raise UserError(_("You must set a Vendor Location for this partner %s", self.partner_id.name))
|
||||
return {
|
||||
'picking_type_id': self.picking_type_id.id,
|
||||
'partner_id': self.partner_id.id,
|
||||
@@ -258,9 +258,9 @@ class PurchaseOrder(models.Model):
|
||||
|
||||
validated_picking = self.picking_ids.filtered(lambda p: p.state == 'done')
|
||||
if validated_picking:
|
||||
note += _("<p>Those dates couldn’t be modified accordingly on the receipt %s which had already been validated.</p>") % validated_picking.name
|
||||
note += _("<p>Those dates couldn’t be modified accordingly on the receipt %s which had already been validated.</p>", validated_picking.name)
|
||||
else:
|
||||
note += _("<p>Those dates have been updated accordingly on the receipt %s.</p>") % self.picking_ids[0].name
|
||||
note += _("<p>Those dates have been updated accordingly on the receipt %s.</p>", self.picking_ids[0].name)
|
||||
for line, date in updated_dates:
|
||||
date = datetime.strptime(date, '%Y-%m-%d %H:%M:%S')
|
||||
line._update_date_planned(date)
|
||||
|
||||
@@ -360,7 +360,7 @@ class Repair(models.Model):
|
||||
|
||||
account = operation.product_id.product_tmpl_id._get_product_accounts()['income']
|
||||
if not account:
|
||||
raise UserError(_('No account defined for product "%s".') % operation.product_id.name)
|
||||
raise UserError(_('No account defined for product "%s".', operation.product_id.name))
|
||||
|
||||
invoice_line_vals = {
|
||||
'name': name,
|
||||
@@ -402,7 +402,7 @@ class Repair(models.Model):
|
||||
|
||||
account = fee.product_id.product_tmpl_id._get_product_accounts()['income']
|
||||
if not account:
|
||||
raise UserError(_('No account defined for product "%s".') % fee.product_id.name)
|
||||
raise UserError(_('No account defined for product "%s".', fee.product_id.name))
|
||||
|
||||
invoice_line_vals = {
|
||||
'name': name,
|
||||
|
||||
@@ -160,7 +160,7 @@ class ResourceCalendar(models.Model):
|
||||
def default_get(self, fields):
|
||||
res = super(ResourceCalendar, self).default_get(fields)
|
||||
if not res.get('name') and res.get('company_id'):
|
||||
res['name'] = _('Working Hours of %s') % self.env['res.company'].browse(res['company_id']).name
|
||||
res['name'] = _('Working Hours of %s', self.env['res.company'].browse(res['company_id']).name)
|
||||
if 'attendance_ids' in fields and not res.get('attendance_ids'):
|
||||
res['attendance_ids'] = [
|
||||
(0, 0, {'name': _('Monday Morning'), 'dayofweek': '0', 'hour_from': 8, 'hour_to': 12, 'day_period': 'morning'}),
|
||||
|
||||
@@ -160,7 +160,7 @@ class CustomerPortal(CustomerPortal):
|
||||
session_obj_date = request.session.get('view_quote_%s' % order_sudo.id)
|
||||
if session_obj_date != now and request.env.user.share and access_token:
|
||||
request.session['view_quote_%s' % order_sudo.id] = now
|
||||
body = _('Quotation viewed by customer %s') % order_sudo.partner_id.name
|
||||
body = _('Quotation viewed by customer %s', order_sudo.partner_id.name)
|
||||
_message_post_helper(
|
||||
"sale.order",
|
||||
order_sudo.id,
|
||||
|
||||
@@ -96,7 +96,7 @@ class AccountMove(models.Model):
|
||||
for sale_line in line.sale_line_ids:
|
||||
todo.add((sale_line.order_id, invoice.name))
|
||||
for (order, name) in todo:
|
||||
order.message_post(body=_("Invoice %s paid") % name)
|
||||
order.message_post(body=_("Invoice %s paid", name))
|
||||
return res
|
||||
|
||||
def _get_invoice_delivery_partner_id(self):
|
||||
|
||||
@@ -83,7 +83,7 @@ class PaymentTransaction(models.Model):
|
||||
order.amount_total, self.amount,
|
||||
)
|
||||
order.message_post(
|
||||
subject=_("Amount Mismatch (%s)") % self.acquirer_id.provider,
|
||||
subject=_("Amount Mismatch (%s)", self.acquirer_id.provider),
|
||||
body=_("The order was not confirmed despite response from the acquirer (%s): order total is %r but acquirer replied with %r.") % (
|
||||
self.acquirer_id.provider,
|
||||
order.amount_total,
|
||||
|
||||
@@ -449,7 +449,7 @@ class SaleOrder(models.Model):
|
||||
lines_to_update.append((1, line.id, {'price_unit': price_unit}))
|
||||
self.update({'order_line': lines_to_update})
|
||||
self.show_update_pricelist = False
|
||||
self.message_post(body=_("Product prices have been recomputed according to pricelist <b>%s<b> ") % self.pricelist_id.display_name)
|
||||
self.message_post(body=_("Product prices have been recomputed according to pricelist <b>%s<b> ", self.pricelist_id.display_name))
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
@@ -1595,7 +1595,7 @@ class SaleOrderLine(models.Model):
|
||||
result = {}
|
||||
warning = {}
|
||||
if product.sale_line_warn != 'no-message':
|
||||
title = _("Warning for %s") % product.name
|
||||
title = _("Warning for %s", product.name)
|
||||
message = product.sale_line_warn_msg
|
||||
warning['title'] = title
|
||||
warning['message'] = message
|
||||
|
||||
@@ -110,7 +110,7 @@ class Project(models.Model):
|
||||
return self.action_view_timesheet_plan()
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': _('Timesheets of %s') % self.name,
|
||||
'name': _('Timesheets of %s', self.name),
|
||||
'domain': [('project_id', '!=', False)],
|
||||
'res_model': 'account.analytic.line',
|
||||
'view_id': False,
|
||||
|
||||
@@ -133,7 +133,7 @@ class CrmTeam(models.Model):
|
||||
def _graph_get_model(self):
|
||||
""" skeleton function defined here because it'll be called by crm and/or sale
|
||||
"""
|
||||
raise UserError(_('Undefined graph model for Sales Team: %s') % self.name)
|
||||
raise UserError(_('Undefined graph model for Sales Team: %s', self.name))
|
||||
|
||||
def _graph_get_dates(self, today):
|
||||
""" return a coherent start and end date for the dashboard graph covering a month period grouped by week.
|
||||
@@ -151,7 +151,7 @@ class CrmTeam(models.Model):
|
||||
return 'EXTRACT(WEEK FROM %s)' % self._graph_date_column()
|
||||
|
||||
def _graph_y_query(self):
|
||||
raise UserError(_('Undefined graph model for Sales Team: %s') % self.name)
|
||||
raise UserError(_('Undefined graph model for Sales Team: %s', self.name))
|
||||
|
||||
def _extra_sql_conditions(self):
|
||||
return ''
|
||||
|
||||
@@ -32,7 +32,7 @@ class SMSTemplate(models.Model):
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def copy(self, default=None):
|
||||
default = dict(default or {},
|
||||
name=_("%s (copy)") % self.name)
|
||||
name=_("%s (copy)", self.name))
|
||||
return super(SMSTemplate, self).copy(default=default)
|
||||
|
||||
def unlink(self):
|
||||
@@ -44,7 +44,7 @@ class SMSTemplate(models.Model):
|
||||
view = self.env.ref('sms.sms_composer_view_form')
|
||||
|
||||
for template in self:
|
||||
button_name = _('Send SMS (%s)') % template.name
|
||||
button_name = _('Send SMS (%s)', template.name)
|
||||
action = ActWindow.create({
|
||||
'name': button_name,
|
||||
'type': 'ir.actions.act_window',
|
||||
|
||||
@@ -155,7 +155,7 @@ class SendSMS(models.TransientModel):
|
||||
sanitized_numbers = [info['sanitized'] for info in sanitize_res.values() if info['sanitized']]
|
||||
invalid_numbers = [number for number, info in sanitize_res.items() if info['code']]
|
||||
if invalid_numbers:
|
||||
raise UserError(_('Following numbers are not correctly encoded: %s') % repr(invalid_numbers))
|
||||
raise UserError(_('Following numbers are not correctly encoded: %s', repr(invalid_numbers)))
|
||||
composer.sanitized_numbers = ','.join(sanitized_numbers)
|
||||
else:
|
||||
composer.sanitized_numbers = False
|
||||
@@ -193,7 +193,7 @@ class SendSMS(models.TransientModel):
|
||||
if self.comment_single_recipient and not self.recipient_single_valid:
|
||||
raise UserError(_('Invalid recipient number. Please update it.'))
|
||||
elif not self.comment_single_recipient and self.recipient_invalid_count:
|
||||
raise UserError(_('%s invalid recipients') % self.recipient_invalid_count)
|
||||
raise UserError(_('%s invalid recipients', self.recipient_invalid_count))
|
||||
self._action_send_sms()
|
||||
return False
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class AccountInvoiceSend(models.TransientModel):
|
||||
self.env['bus.bus'].sendone(
|
||||
(self._cr.dbname, 'res.partner', self.env.user.partner_id.id),
|
||||
{'type': 'snailmail_invalid_address', 'title': _("Invalid Addresses"),
|
||||
'message': _("%s of the selected invoice(s) had an invalid address and were not sent") % self.invalid_addresses}
|
||||
'message': _("%s of the selected invoice(s) had an invalid address and were not sent", self.invalid_addresses)}
|
||||
)
|
||||
|
||||
def invalid_addresses_action(self):
|
||||
|
||||
@@ -329,11 +329,11 @@ class Product(models.Model):
|
||||
# TDE FIXME: should probably clean the search methods
|
||||
# to prevent sql injections
|
||||
if field not in ('qty_available', 'virtual_available', 'incoming_qty', 'outgoing_qty', 'free_qty'):
|
||||
raise UserError(_('Invalid domain left operand %s') % field)
|
||||
raise UserError(_('Invalid domain left operand %s', field))
|
||||
if operator not in ('<', '>', '=', '!=', '<=', '>='):
|
||||
raise UserError(_('Invalid domain operator %s') % operator)
|
||||
raise UserError(_('Invalid domain operator %s', operator))
|
||||
if not isinstance(value, (float, int)):
|
||||
raise UserError(_('Invalid domain right operand %s') % value)
|
||||
raise UserError(_('Invalid domain right operand %s', value))
|
||||
|
||||
# TODO: Still optimization possible when searching virtual quantities
|
||||
ids = []
|
||||
|
||||
@@ -499,7 +499,7 @@ class StockMove(models.Model):
|
||||
return
|
||||
|
||||
msg = _("The scheduled date has been automatically updated due to a delay on <a href='#' data-oe-model='%s' data-oe-id='%s'>%s</a>.") % (doc_orig[0]._name, doc_orig[0].id, doc_orig[0].name)
|
||||
msg_subject = _("Scheduled date update due to delay on %s") % doc_orig[0].name
|
||||
msg_subject = _("Scheduled date update due to delay on %s", doc_orig[0].name)
|
||||
# write the message on each document
|
||||
for doc in documents:
|
||||
last_message = doc.message_ids[:1]
|
||||
|
||||
@@ -157,7 +157,7 @@ class StockMoveLine(models.Model):
|
||||
if self.qty_done and self.product_id.tracking == 'serial':
|
||||
qty_done = self.product_uom_id._compute_quantity(self.qty_done, self.product_id.uom_id)
|
||||
if float_compare(qty_done, 1.0, precision_rounding=self.product_id.uom_id.rounding) != 0:
|
||||
message = _('You can only process 1.0 %s of products with unique serial number.') % self.product_id.uom_id.name
|
||||
message = _('You can only process 1.0 %s of products with unique serial number.', self.product_id.uom_id.name)
|
||||
res['warning'] = {'title': _('Warning'), 'message': message}
|
||||
return res
|
||||
|
||||
|
||||
@@ -456,12 +456,12 @@ class StockQuant(models.Model):
|
||||
# if we want to reserve
|
||||
available_quantity = self._get_available_quantity(product_id, location_id, lot_id=lot_id, package_id=package_id, owner_id=owner_id, strict=strict)
|
||||
if float_compare(quantity, available_quantity, precision_rounding=rounding) > 0:
|
||||
raise UserError(_('It is not possible to reserve more products of %s than you have in stock.') % product_id.display_name)
|
||||
raise UserError(_('It is not possible to reserve more products of %s than you have in stock.', product_id.display_name))
|
||||
elif float_compare(quantity, 0, precision_rounding=rounding) < 0:
|
||||
# if we want to unreserve
|
||||
available_quantity = sum(quants.mapped('reserved_quantity'))
|
||||
if float_compare(abs(quantity), available_quantity, precision_rounding=rounding) > 0:
|
||||
raise UserError(_('It is not possible to unreserve more products of %s than you have in stock.') % product_id.display_name)
|
||||
raise UserError(_('It is not possible to unreserve more products of %s than you have in stock.', product_id.display_name))
|
||||
else:
|
||||
return reserved_quants
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ class StockRule(models.Model):
|
||||
if self.procure_method == 'make_to_order' and self.location_src_id:
|
||||
suffix = _("<br>A need is created in <b>%s</b> and a rule will be triggered to fulfill it.") % (source)
|
||||
if self.procure_method == 'mts_else_mto' and self.location_src_id:
|
||||
suffix = _("<br>If the products are not available in <b>%s</b>, a rule will be triggered to bring products in this location.") % source
|
||||
suffix = _("<br>If the products are not available in <b>%s</b>, a rule will be triggered to bring products in this location.", source)
|
||||
message_dict = {
|
||||
'pull': _('When products are needed in <b>%s</b>, <br/> <b>%s</b> are created from <b>%s</b> to fulfill the need.') % (destination, operation, source) + suffix,
|
||||
'push': _('When products arrive in <b>%s</b>, <br/> <b>%s</b> are created to send them in <b>%s</b>.') % (source, operation, destination)
|
||||
|
||||
@@ -118,7 +118,7 @@ class ReturnPicking(models.TransientModel):
|
||||
'move_lines': [],
|
||||
'picking_type_id': picking_type_id,
|
||||
'state': 'draft',
|
||||
'origin': _("Return of %s") % self.picking_id.name,
|
||||
'origin': _("Return of %s", self.picking_id.name),
|
||||
'location_id': self.picking_id.location_dest_id.id,
|
||||
'location_dest_id': self.location_id.id})
|
||||
new_picking.message_post_with_view('mail.message_origin_link',
|
||||
|
||||
@@ -118,7 +118,7 @@ class StockValuationLayerRevaluation(models.TransientModel):
|
||||
move_vals = {
|
||||
'journal_id': self.account_journal_id.id or accounts['stock_journal'].id,
|
||||
'company_id': self.company_id.id,
|
||||
'ref': _("Revaluation of %s") % product_id.display_name,
|
||||
'ref': _("Revaluation of %s", product_id.display_name),
|
||||
'stock_valuation_layer_ids': [(6, None, [revaluation_svl.id])],
|
||||
'date': self.date or fields.Date.today(),
|
||||
'move_type': 'entry',
|
||||
|
||||
@@ -204,7 +204,7 @@ class StockLandedCost(models.Model):
|
||||
|
||||
if not lines:
|
||||
target_model_descriptions = dict(self._fields['target_model']._description_selection(self.env))
|
||||
raise UserError(_("You cannot apply landed costs on the chosen %s(s). Landed costs can only be applied for products with automated inventory valuation and FIFO or average costing method.") % target_model_descriptions[self.target_model])
|
||||
raise UserError(_("You cannot apply landed costs on the chosen %s(s). Landed costs can only be applied for products with automated inventory valuation and FIFO or average costing method.", target_model_descriptions[self.target_model]))
|
||||
return lines
|
||||
|
||||
def compute_landed_cost(self):
|
||||
@@ -285,7 +285,7 @@ class StockLandedCost(models.Model):
|
||||
for cost in self:
|
||||
if not cost._get_targeted_move_ids():
|
||||
target_model_descriptions = dict(self._fields['target_model']._description_selection(self.env))
|
||||
raise UserError(_('Please define %s on which those additional costs should apply.') % target_model_descriptions[cost.target_model])
|
||||
raise UserError(_('Please define %s on which those additional costs should apply.', target_model_descriptions[cost.target_model]))
|
||||
|
||||
def _check_sum(self):
|
||||
""" Check if each cost line its valuation lines sum to the correct amount
|
||||
|
||||
@@ -773,11 +773,11 @@ class ExportXlsxWriter:
|
||||
# fails note that you can't export
|
||||
cell_value = pycompat.to_text(cell_value)
|
||||
except UnicodeDecodeError:
|
||||
raise UserError(_("Binary fields can not be exported to Excel unless their content is base64-encoded. That does not seem to be the case for %s.") % self.field_names[column])
|
||||
raise UserError(_("Binary fields can not be exported to Excel unless their content is base64-encoded. That does not seem to be the case for %s.", self.field_names)[column])
|
||||
|
||||
if isinstance(cell_value, str):
|
||||
if len(cell_value) > self.worksheet.xls_strmax:
|
||||
cell_value = _("The content of this cell is too long for an XLSX file (more than %s characters). Please use the CSV format for this export.") % self.worksheet.xls_strmax
|
||||
cell_value = _("The content of this cell is too long for an XLSX file (more than %s characters). Please use the CSV format for this export.", self.worksheet.xls_strmax)
|
||||
else:
|
||||
cell_value = cell_value.replace("\r", " ")
|
||||
elif isinstance(cell_value, datetime.datetime):
|
||||
|
||||
@@ -284,7 +284,7 @@ class Website(models.Model):
|
||||
copy_menu(submenu, new_menu)
|
||||
for website in self:
|
||||
new_top_menu = top_menu.copy({
|
||||
'name': _('Top Menu for Website %s') % website.id,
|
||||
'name': _('Top Menu for Website %s', website.id),
|
||||
'website_id': website.id,
|
||||
})
|
||||
for submenu in top_menu.child_id:
|
||||
@@ -408,7 +408,7 @@ class Website(models.Model):
|
||||
for page in pages:
|
||||
dependencies.setdefault(page_key, [])
|
||||
dependencies[page_key].append({
|
||||
'text': _('Page <b>%s</b> contains a link to this page') % page.url,
|
||||
'text': _('Page <b>%s</b> contains a link to this page', page.url),
|
||||
'item': page.name,
|
||||
'link': page.url,
|
||||
})
|
||||
@@ -436,7 +436,7 @@ class Website(models.Model):
|
||||
menu_key = _('Menus')
|
||||
for menu in menus:
|
||||
dependencies.setdefault(menu_key, []).append({
|
||||
'text': _('This page is in the menu <b>%s</b>') % menu.name,
|
||||
'text': _('This page is in the menu <b>%s</b>', menu.name),
|
||||
'link': '/web#id=%s&view_type=form&model=website.menu' % menu.id,
|
||||
'item': menu.name,
|
||||
})
|
||||
@@ -472,7 +472,7 @@ class Website(models.Model):
|
||||
for p in pages:
|
||||
dependencies.setdefault(page_key, [])
|
||||
dependencies[page_key].append({
|
||||
'text': _('Page <b>%s</b> is calling this file') % p.url,
|
||||
'text': _('Page <b>%s</b> is calling this file', p.url),
|
||||
'item': p.name,
|
||||
'link': p.url,
|
||||
})
|
||||
|
||||
@@ -67,7 +67,7 @@ class WebsiteVisitor(models.Model):
|
||||
def name_get(self):
|
||||
return [(
|
||||
record.id,
|
||||
(record.name or _('Website Visitor #%s') % record.id)
|
||||
(record.name or _('Website Visitor #%s', record.id))
|
||||
) for record in self]
|
||||
|
||||
@api.depends('partner_id.email_normalized', 'partner_id.mobile', 'partner_id.phone')
|
||||
|
||||
@@ -26,7 +26,7 @@ class Website(models.Model):
|
||||
dep[page_key] = []
|
||||
for p in posts:
|
||||
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),
|
||||
'item': p.name,
|
||||
'link': p.website_url,
|
||||
})
|
||||
@@ -51,7 +51,7 @@ class Website(models.Model):
|
||||
dep[page_key] = []
|
||||
for p in posts:
|
||||
dep[page_key].append({
|
||||
'text': _('Blog Post <b>%s</b> seems to be calling this file !') % p.name,
|
||||
'text': _('Blog Post <b>%s</b> seems to be calling this file !', p.name),
|
||||
'item': p.name,
|
||||
'link': p.website_url,
|
||||
})
|
||||
|
||||
@@ -215,7 +215,7 @@ class BlogPost(models.Model):
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def copy_data(self, default=None):
|
||||
self.ensure_one()
|
||||
name = _("%s (copy)") % self.name
|
||||
name = _("%s (copy)", self.name)
|
||||
default = dict(default or {}, name=name)
|
||||
return super(BlogPost, self).copy_data(default)
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class CrmLeadForwardToPartner(models.TransientModel):
|
||||
if no_email:
|
||||
raise UserError(_('Set an email address for the partner(s): %s') % ", ".join(no_email))
|
||||
if self.forward_type == 'single' and not self.partner_id.email:
|
||||
raise UserError(_('Set an email address for the partner %s') % self.partner_id.name)
|
||||
raise UserError(_('Set an email address for the partner %s', self.partner_id.name))
|
||||
|
||||
partners_leads = {}
|
||||
for lead in self.assignation_lines:
|
||||
|
||||
@@ -464,7 +464,7 @@ class Post(models.Model):
|
||||
filter_regexp = r'(<img.*?>)|(<a[^>]*?href[^>]*?>)|(<[a-z|A-Z]+[^>]*style\s*=\s*[\'"][^\'"]*\s*background[^:]*:[^url;]*url)'
|
||||
content_match = re.search(filter_regexp, content, re.I)
|
||||
if content_match:
|
||||
raise AccessError(_('%d karma required to post an image or link.') % forum.karma_editor)
|
||||
raise AccessError(_('%d karma required to post an image or link.', forum.karma_editor))
|
||||
return content
|
||||
|
||||
def _default_website_meta(self):
|
||||
@@ -492,9 +492,9 @@ class Post(models.Model):
|
||||
raise UserError(_('Posting answer on a [Deleted] or [Closed] question is not possible.'))
|
||||
# karma-based access
|
||||
if not post.parent_id and not post.can_ask:
|
||||
raise AccessError(_('%d karma required to create a new question.') % post.forum_id.karma_ask)
|
||||
raise AccessError(_('%d karma required to create a new question.', post.forum_id.karma_ask))
|
||||
elif post.parent_id and not post.can_answer:
|
||||
raise AccessError(_('%d karma required to answer a question.') % post.forum_id.karma_answer)
|
||||
raise AccessError(_('%d karma required to answer a question.', post.forum_id.karma_answer))
|
||||
if not post.parent_id and not post.can_post:
|
||||
post.sudo().state = 'pending'
|
||||
|
||||
@@ -511,7 +511,7 @@ class Post(models.Model):
|
||||
# Make sure only author or moderator can edit/delete messages
|
||||
for post in self.browse(res_ids):
|
||||
if not post.can_edit:
|
||||
raise AccessError(_('%d karma required to edit a post.') % post.karma_edit)
|
||||
raise AccessError(_('%d karma required to edit a post.', post.karma_edit))
|
||||
return super(Post, self).get_mail_message_access(res_ids, operation, model_name=model_name)
|
||||
|
||||
def write(self, vals):
|
||||
@@ -527,18 +527,18 @@ class Post(models.Model):
|
||||
if 'state' in vals:
|
||||
if vals['state'] in ['active', 'close']:
|
||||
if not post.can_close:
|
||||
raise AccessError(_('%d karma required to close or reopen a post.') % post.karma_close)
|
||||
raise AccessError(_('%d karma required to close or reopen a post.', post.karma_close))
|
||||
trusted_keys += ['state', 'closed_uid', 'closed_date', 'closed_reason_id']
|
||||
elif vals['state'] == 'flagged':
|
||||
if not post.can_flag:
|
||||
raise AccessError(_('%d karma required to flag a post.') % post.forum_id.karma_flag)
|
||||
raise AccessError(_('%d karma required to flag a post.', post.forum_id.karma_flag))
|
||||
trusted_keys += ['state', 'flag_user_id']
|
||||
if 'active' in vals:
|
||||
if not post.can_unlink:
|
||||
raise AccessError(_('%d karma required to delete or reactivate a post.') % post.karma_unlink)
|
||||
raise AccessError(_('%d karma required to delete or reactivate a post.', post.karma_unlink))
|
||||
if 'is_correct' in vals:
|
||||
if not post.can_accept:
|
||||
raise AccessError(_('%d karma required to accept or refuse an answer.') % post.karma_accept)
|
||||
raise AccessError(_('%d karma required to accept or refuse an answer.', post.karma_accept))
|
||||
# update karma except for self-acceptance
|
||||
mult = 1 if vals['is_correct'] else -1
|
||||
if vals['is_correct'] != post.is_correct and post.create_uid.id != self._uid:
|
||||
@@ -546,9 +546,9 @@ class Post(models.Model):
|
||||
self.env.user.sudo().add_karma(post.forum_id.karma_gen_answer_accept * mult)
|
||||
if tag_ids:
|
||||
if set(post.tag_ids.ids) != tag_ids and self.env.user.karma < post.forum_id.karma_edit_retag:
|
||||
raise AccessError(_('%d karma required to retag.') % post.forum_id.karma_edit_retag)
|
||||
raise AccessError(_('%d karma required to retag.', post.forum_id.karma_edit_retag))
|
||||
if any(key not in trusted_keys for key in vals) and not post.can_edit:
|
||||
raise AccessError(_('%d karma required to edit a post.') % post.karma_edit)
|
||||
raise AccessError(_('%d karma required to edit a post.', post.karma_edit))
|
||||
|
||||
res = super(Post, self).write(vals)
|
||||
|
||||
@@ -575,7 +575,7 @@ class Post(models.Model):
|
||||
if post.state == 'active' and post.parent_id:
|
||||
post.parent_id.message_post_with_view(
|
||||
'website_forum.forum_post_template_new_answer',
|
||||
subject=_('Re: %s') % post.parent_id.name,
|
||||
subject=_('Re: %s', post.parent_id.name),
|
||||
partner_ids=[(4, p.id) for p in tag_partners],
|
||||
subtype_id=self.env['ir.model.data'].xmlid_to_res_id('website_forum.mt_answer_new'))
|
||||
elif post.state == 'active' and not post.parent_id:
|
||||
@@ -647,7 +647,7 @@ class Post(models.Model):
|
||||
def validate(self):
|
||||
for post in self:
|
||||
if not post.can_moderate:
|
||||
raise AccessError(_('%d karma required to validate a post.') % post.forum_id.karma_moderate)
|
||||
raise AccessError(_('%d karma required to validate a post.', post.forum_id.karma_moderate))
|
||||
# if state == pending, no karma previously added for the new question
|
||||
if post.state == 'pending':
|
||||
post.create_uid.sudo().add_karma(post.forum_id.karma_gen_question_new)
|
||||
@@ -662,7 +662,7 @@ class Post(models.Model):
|
||||
def refuse(self):
|
||||
for post in self:
|
||||
if not post.can_moderate:
|
||||
raise AccessError(_('%d karma required to refuse a post.') % post.forum_id.karma_moderate)
|
||||
raise AccessError(_('%d karma required to refuse a post.', post.forum_id.karma_moderate))
|
||||
post.moderator_id = self.env.user
|
||||
return True
|
||||
|
||||
@@ -670,7 +670,7 @@ class Post(models.Model):
|
||||
res = []
|
||||
for post in self:
|
||||
if not post.can_flag:
|
||||
raise AccessError(_('%d karma required to flag a post.') % post.forum_id.karma_flag)
|
||||
raise AccessError(_('%d karma required to flag a post.', post.forum_id.karma_flag))
|
||||
if post.state == 'flagged':
|
||||
res.append({'error': 'post_already_flagged'})
|
||||
elif post.state == 'active':
|
||||
@@ -691,7 +691,7 @@ class Post(models.Model):
|
||||
def mark_as_offensive(self, reason_id):
|
||||
for post in self:
|
||||
if not post.can_moderate:
|
||||
raise AccessError(_('%d karma required to mark a post as offensive.') % post.forum_id.karma_moderate)
|
||||
raise AccessError(_('%d karma required to mark a post as offensive.', post.forum_id.karma_moderate))
|
||||
# remove some karma
|
||||
_logger.info('Downvoting user <%s> for posting spam/offensive contents', post.create_uid)
|
||||
post.create_uid.sudo().add_karma(post.forum_id.karma_gen_answer_flagged)
|
||||
@@ -721,7 +721,7 @@ class Post(models.Model):
|
||||
def unlink(self):
|
||||
for post in self:
|
||||
if not post.can_unlink:
|
||||
raise AccessError(_('%d karma required to unlink a post.') % post.karma_unlink)
|
||||
raise AccessError(_('%d karma required to unlink a post.', post.karma_unlink))
|
||||
# if unlinking an answer with accepted answer: remove provided karma
|
||||
for post in self:
|
||||
if post.is_correct:
|
||||
@@ -766,7 +766,7 @@ class Post(models.Model):
|
||||
|
||||
# karma-based action check: use the post field that computed own/all value
|
||||
if not self.can_comment_convert:
|
||||
raise AccessError(_('%d karma required to convert an answer to a comment.') % self.karma_comment_convert)
|
||||
raise AccessError(_('%d karma required to convert an answer to a comment.', self.karma_comment_convert))
|
||||
|
||||
# post the message
|
||||
question = self.parent_id
|
||||
@@ -806,9 +806,9 @@ class Post(models.Model):
|
||||
can_convert = self.env.user.karma >= karma_convert
|
||||
if not can_convert:
|
||||
if is_author and karma_own < karma_all:
|
||||
raise AccessError(_('%d karma required to convert your comment to an answer.') % karma_own)
|
||||
raise AccessError(_('%d karma required to convert your comment to an answer.', karma_own))
|
||||
else:
|
||||
raise AccessError(_('%d karma required to convert a comment to an answer.') % karma_all)
|
||||
raise AccessError(_('%d karma required to convert a comment to an answer.', karma_all))
|
||||
|
||||
# check the message's author has not already an answer
|
||||
question = post.parent_id if post.parent_id else post
|
||||
@@ -846,7 +846,7 @@ class Post(models.Model):
|
||||
)
|
||||
can_unlink = user.karma >= karma_unlink
|
||||
if not can_unlink:
|
||||
raise AccessError(_('%d karma required to unlink a comment.') % karma_unlink)
|
||||
raise AccessError(_('%d karma required to unlink a comment.', karma_unlink))
|
||||
result.append(comment.unlink())
|
||||
return result
|
||||
|
||||
@@ -893,7 +893,7 @@ class Post(models.Model):
|
||||
|
||||
self.ensure_one()
|
||||
if not self.can_comment:
|
||||
raise AccessError(_('%d karma required to comment.') % self.karma_comment)
|
||||
raise AccessError(_('%d karma required to comment.', self.karma_comment))
|
||||
if not kwargs.get('record_name') and self.parent_id:
|
||||
kwargs['record_name'] = self.parent_id.name
|
||||
return super(Post, self).message_post(message_type=message_type, **kwargs)
|
||||
@@ -1005,9 +1005,9 @@ class Vote(models.Model):
|
||||
def _check_karma_rights(self, upvote=None):
|
||||
# karma check
|
||||
if upvote and not self.post_id.can_upvote:
|
||||
raise AccessError(_('%d karma required to upvote.') % self.post_id.forum_id.karma_upvote)
|
||||
raise AccessError(_('%d karma required to upvote.', self.post_id.forum_id.karma_upvote))
|
||||
elif not upvote and not self.post_id.can_downvote:
|
||||
raise AccessError(_('%d karma required to downvote.') % self.post_id.forum_id.karma_downvote)
|
||||
raise AccessError(_('%d karma required to downvote.', self.post_id.forum_id.karma_downvote))
|
||||
|
||||
def _vote_update_karma(self, old_vote, new_vote):
|
||||
if self.post_id.parent_id:
|
||||
@@ -1042,5 +1042,5 @@ class Tags(models.Model):
|
||||
def create(self, vals):
|
||||
forum = self.env['forum.forum'].browse(vals.get('forum_id'))
|
||||
if self.env.user.karma < forum.karma_tag_create:
|
||||
raise AccessError(_('%d karma required to create a new Tag.') % forum.karma_tag_create)
|
||||
raise AccessError(_('%d karma required to create a new Tag.', forum.karma_tag_create))
|
||||
return super(Tags, self.with_context(mail_create_nolog=True, mail_create_nosubscribe=True)).create(vals)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user