[FIX] product: do not translate at code import
Defined as this, the label of the selection field were translated during code import, when building the python model, not when a user access the field values as it should (and is already the case thanks to the ORM). Trying to translate a string when no user-context is available is not only useless but may cause bug on services with multiple databases (e.g. a SaaS). In a multi-worker environment, when the code is imported, the _ method will use multiple scenarios to detect the language and get a cursor. As we have no available cursor in the frame (method _get_cr from GettextAlias), the fallback is made on the cursor of the request. In a multi-worker environment, this could be a cursor linked to a database in another language than English. In such scenario, the selections would be translated in the language of the other database instead of displaying it in English opw-1881956
This commit is contained in:
@@ -174,14 +174,14 @@ class BarcodeRule(models.Model):
|
||||
barcode_nomenclature_id = fields.Many2one('barcode.nomenclature', string='Barcode Nomenclature')
|
||||
sequence = fields.Integer(string='Sequence', help='Used to order rules such that rules with a smaller sequence match first')
|
||||
encoding = fields.Selection([
|
||||
('any', _('Any')),
|
||||
('any', 'Any'),
|
||||
('ean13', 'EAN-13'),
|
||||
('ean8', 'EAN-8'),
|
||||
('upca', 'UPC-A'),
|
||||
], string='Encoding', required=True, default='any', help='This rule will apply only if the barcode is encoded with the specified encoding')
|
||||
type = fields.Selection([
|
||||
('alias', _('Alias')),
|
||||
('product', _('Unit Product'))
|
||||
('alias', 'Alias'),
|
||||
('product', 'Unit Product')
|
||||
], string='Type', required=True, default='product')
|
||||
pattern = fields.Char(string='Barcode Pattern', size=32, help="The barcode matching pattern", required=True, default='.*')
|
||||
alias = fields.Char(string='Alias', size=32, default='0', help='The matched pattern will alias to this barcode', required=True)
|
||||
|
||||
@@ -55,5 +55,5 @@ class AccountAccountTag(models.Model):
|
||||
_inherit = 'account.account.tag'
|
||||
|
||||
nature = fields.Selection([
|
||||
('D', _('Debitable Account')), ('A', _('Creditable Account'))],
|
||||
('D', 'Debitable Account'), ('A', 'Creditable Account')],
|
||||
help='Used in Mexican report of electronic accounting (account nature).')
|
||||
|
||||
@@ -9,9 +9,9 @@ class BarcodeRule(models.Model):
|
||||
_inherit = 'barcode.rule'
|
||||
|
||||
type = fields.Selection(selection_add=[
|
||||
('weight', _('Weighted Product')),
|
||||
('price', _('Priced Product')),
|
||||
('discount', _('Discounted Product')),
|
||||
('client', _('Client')),
|
||||
('cashier', _('Cashier'))
|
||||
('weight', 'Weighted Product'),
|
||||
('price', 'Priced Product'),
|
||||
('discount', 'Discounted Product'),
|
||||
('client', 'Client'),
|
||||
('cashier', 'Cashier')
|
||||
])
|
||||
|
||||
@@ -13,7 +13,7 @@ class BarcodeRule(models.Model):
|
||||
_inherit = 'barcode.rule'
|
||||
|
||||
type = fields.Selection(selection_add=[
|
||||
('credit', _('Credit Card'))
|
||||
('credit', 'Credit Card')
|
||||
])
|
||||
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ class ProductTemplate(models.Model):
|
||||
help="A description of the Product that you want to communicate to your customers. "
|
||||
"This description will be copied to every Sales Order, Delivery Order and Customer Invoice/Credit Note")
|
||||
type = fields.Selection([
|
||||
('consu', _('Consumable')),
|
||||
('service', _('Service'))], string='Product Type', default='consu', required=True,
|
||||
('consu', 'Consumable'),
|
||||
('service', 'Service')], string='Product Type', default='consu', required=True,
|
||||
help='A stockable product is a product for which you manage stock. The "Inventory" app has to be installed.\n'
|
||||
'A consumable product, on the other hand, is a product for which stock is not managed.\n'
|
||||
'A service is a non-material product you provide.\n'
|
||||
|
||||
@@ -197,9 +197,9 @@ class Project(models.Model):
|
||||
help="Internal email associated with this project. Incoming emails are automatically synchronized "
|
||||
"with Tasks (or optionally Issues if the Issue Tracker module is installed).")
|
||||
privacy_visibility = fields.Selection([
|
||||
('followers', _('On invitation only')),
|
||||
('employees', _('Visible by all employees')),
|
||||
('portal', _('Visible by following customers')),
|
||||
('followers', 'On invitation only'),
|
||||
('employees', 'Visible by all employees'),
|
||||
('portal', 'Visible by following customers'),
|
||||
],
|
||||
string='Privacy', required=True,
|
||||
default='employees',
|
||||
|
||||
@@ -8,8 +8,8 @@ class BarcodeRule(models.Model):
|
||||
_inherit = 'barcode.rule'
|
||||
|
||||
type = fields.Selection(selection_add=[
|
||||
('weight', _('Weighted Product')),
|
||||
('location', _('Location')),
|
||||
('lot', _('Lot')),
|
||||
('package', _('Package'))
|
||||
('weight', 'Weighted Product'),
|
||||
('location', 'Location'),
|
||||
('lot', 'Lot'),
|
||||
('package', 'Package')
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user