mirror of
https://gitlab.com/flectra-hq/flectra.git
synced 2026-08-17 16:54:42 -05:00
Merge branch 'master-upstream-patch-16012024' into 'master'
[PATCH] Upstream patch - 16012024 See merge request flectra-hq/flectra!1226
This commit is contained in:
@@ -484,7 +484,7 @@ class account_journal(models.Model):
|
||||
action = self.env["ir.actions.act_window"]._for_xml_id(action_name)
|
||||
|
||||
context = self._context.copy()
|
||||
if 'context' in action and type(action['context']) == str:
|
||||
if 'context' in action and isinstance(action['context'], str):
|
||||
context.update(ast.literal_eval(action['context']))
|
||||
else:
|
||||
context.update(action.get('context', {}))
|
||||
|
||||
@@ -278,7 +278,7 @@ class ResPartner(models.Model):
|
||||
def _asset_difference_search(self, account_type, operator, operand):
|
||||
if operator not in ('<', '=', '>', '>=', '<='):
|
||||
return []
|
||||
if type(operand) not in (float, int):
|
||||
if not isinstance(operand, (float, int)):
|
||||
return []
|
||||
sign = 1
|
||||
if account_type == 'payable':
|
||||
|
||||
@@ -46,7 +46,7 @@ class SequenceMixin(models.AbstractModel):
|
||||
))
|
||||
|
||||
def __init__(self, pool, cr):
|
||||
api.constrains(self._sequence_field, self._sequence_date_field)(type(self)._constrains_date_sequence)
|
||||
api.constrains(self._sequence_field, self._sequence_date_field)(pool[self._name]._constrains_date_sequence)
|
||||
return super().__init__(pool, cr)
|
||||
|
||||
def _constrains_date_sequence(self):
|
||||
|
||||
@@ -35,7 +35,7 @@ class Users(models.Model):
|
||||
init_res = super().__init__(pool, cr)
|
||||
if not sql.column_exists(cr, self._table, "totp_secret"):
|
||||
cr.execute("ALTER TABLE res_users ADD COLUMN totp_secret varchar")
|
||||
type(self).SELF_READABLE_FIELDS = self.SELF_READABLE_FIELDS + ['totp_enabled', 'totp_trusted_device_ids']
|
||||
pool[self._name].SELF_READABLE_FIELDS = self.SELF_READABLE_FIELDS + ['totp_enabled', 'totp_trusted_device_ids']
|
||||
return init_res
|
||||
|
||||
def _mfa_type(self):
|
||||
|
||||
@@ -432,7 +432,7 @@ class BaseAutomation(models.Model):
|
||||
""" Patch method `name` on `model`, unless it has been patched already. """
|
||||
if model not in patched_models[name]:
|
||||
patched_models[name].add(model)
|
||||
ModelClass = type(model)
|
||||
ModelClass = model.env.registry[model._name]
|
||||
origin = getattr(ModelClass, name)
|
||||
method.origin = origin
|
||||
wrapped = api.propagate(origin, method)
|
||||
|
||||
@@ -43,7 +43,7 @@ class GoogleGmailController(http.Controller):
|
||||
|
||||
model = request.env[model_name]
|
||||
|
||||
if not issubclass(type(model), request.env.registry['google.gmail.mixin']):
|
||||
if not isinstance(model, request.env.registry['google.gmail.mixin']):
|
||||
# The model must inherits from the "google.gmail.mixin" mixin
|
||||
raise Forbidden()
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ class User(models.Model):
|
||||
|
||||
init_res = super(User, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + hr_readable_fields + hr_writable_fields
|
||||
type(self).SELF_WRITEABLE_FIELDS = type(self).SELF_WRITEABLE_FIELDS + hr_writable_fields
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + hr_readable_fields + hr_writable_fields
|
||||
pool[self._name].SELF_WRITEABLE_FIELDS = pool[self._name].SELF_WRITEABLE_FIELDS + hr_writable_fields
|
||||
return init_res
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -27,4 +27,4 @@ class User(models.Model):
|
||||
]
|
||||
super(User, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + attendance_readable_fields
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + attendance_readable_fields
|
||||
|
||||
@@ -77,7 +77,7 @@ class Contract(models.Model):
|
||||
contract.calendar_mismatch = contract.resource_calendar_id != contract.employee_id.resource_calendar_id
|
||||
|
||||
def _expand_states(self, states, domain, order):
|
||||
return [key for key, val in type(self).state.selection]
|
||||
return [key for key, val in self._fields['state'].selection]
|
||||
|
||||
@api.depends('employee_id')
|
||||
def _compute_employee_contract(self):
|
||||
|
||||
@@ -21,5 +21,5 @@ class User(models.Model):
|
||||
]
|
||||
init_res = super(User, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + contract_readable_fields
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + contract_readable_fields
|
||||
return init_res
|
||||
|
||||
@@ -53,5 +53,5 @@ class User(models.Model):
|
||||
"""
|
||||
init_res = super(User, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + ['expense_manager_id']
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + ['expense_manager_id']
|
||||
return init_res
|
||||
|
||||
@@ -16,7 +16,7 @@ class User(models.Model):
|
||||
"""
|
||||
init_res = super(User, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + ['employee_cars_count']
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + ['employee_cars_count']
|
||||
return init_res
|
||||
|
||||
def action_get_claim_report(self):
|
||||
|
||||
@@ -38,7 +38,7 @@ class User(models.Model):
|
||||
]
|
||||
init_res = super(User, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + readable_fields
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + readable_fields
|
||||
return init_res
|
||||
|
||||
def _compute_im_status(self):
|
||||
|
||||
@@ -14,7 +14,7 @@ class Users(models.Model):
|
||||
"""
|
||||
init_res = super(Users, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + ['equipment_count']
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + ['equipment_count']
|
||||
return init_res
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,6 @@ class User(models.Model):
|
||||
]
|
||||
init_res = super(User, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + hr_skills_fields
|
||||
type(self).SELF_WRITEABLE_FIELDS = type(self).SELF_WRITEABLE_FIELDS + hr_skills_fields
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + hr_skills_fields
|
||||
pool[self._name].SELF_WRITEABLE_FIELDS = pool[self._name].SELF_WRITEABLE_FIELDS + hr_skills_fields
|
||||
return init_res
|
||||
|
||||
@@ -581,7 +581,7 @@ class IrHttp(models.AbstractModel):
|
||||
elif isinstance(exception, QWebException):
|
||||
values.update(qweb_exception=exception)
|
||||
|
||||
if type(exception.error) == exceptions.AccessError:
|
||||
if isinstance(exception.error, exceptions.AccessError):
|
||||
code = 403
|
||||
|
||||
elif isinstance(exception, werkzeug.exceptions.HTTPException):
|
||||
|
||||
@@ -19,9 +19,9 @@ class Users(models.Model):
|
||||
"""
|
||||
init_res = super(Users, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
|
||||
type(self).SELF_WRITEABLE_FIELDS.extend(['livechat_username'])
|
||||
pool[self._name].SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
|
||||
pool[self._name].SELF_WRITEABLE_FIELDS.extend(['livechat_username'])
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
|
||||
type(self).SELF_READABLE_FIELDS.extend(['livechat_username'])
|
||||
pool[self._name].SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
|
||||
pool[self._name].SELF_READABLE_FIELDS.extend(['livechat_username'])
|
||||
return init_res
|
||||
|
||||
@@ -100,7 +100,7 @@ class LinkTracker(models.Model):
|
||||
utms = {}
|
||||
for key, field_name, cook in self.env['utm.mixin'].tracking_fields():
|
||||
field = self._fields[field_name]
|
||||
attr = getattr(tracker, field_name)
|
||||
attr = tracker[field_name]
|
||||
if field.type == 'many2one':
|
||||
attr = attr.name
|
||||
if attr:
|
||||
|
||||
@@ -87,9 +87,9 @@ class IrModel(models.Model):
|
||||
|
||||
def _reflect_model_params(self, model):
|
||||
vals = super(IrModel, self)._reflect_model_params(model)
|
||||
vals['is_mail_thread'] = issubclass(type(model), self.pool['mail.thread'])
|
||||
vals['is_mail_activity'] = issubclass(type(model), self.pool['mail.activity.mixin'])
|
||||
vals['is_mail_blacklist'] = issubclass(type(model), self.pool['mail.thread.blacklist'])
|
||||
vals['is_mail_thread'] = isinstance(model, self.pool['mail.thread'])
|
||||
vals['is_mail_activity'] = isinstance(model, self.pool['mail.activity.mixin'])
|
||||
vals['is_mail_blacklist'] = isinstance(model, self.pool['mail.thread.blacklist'])
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -96,9 +96,9 @@ class MailMail(models.Model):
|
||||
def default_get(self, fields):
|
||||
# protection for `default_type` values leaking from menu action context (e.g. for invoices)
|
||||
# To remove when automatic context propagation is removed in web client
|
||||
if self._context.get('default_type') not in type(self).message_type.base_field.selection:
|
||||
if self._context.get('default_type') not in self._fields['message_type'].base_field.selection:
|
||||
self = self.with_context(dict(self._context, default_type=None))
|
||||
if self._context.get('default_state') not in type(self).state.base_field.selection:
|
||||
if self._context.get('default_state') not in self._fields['state'].base_field.selection:
|
||||
self = self.with_context(dict(self._context, default_state='outgoing'))
|
||||
return super(MailMail, self).default_get(fields)
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class MailNotification(models.Model):
|
||||
def format_failure_reason(self):
|
||||
self.ensure_one()
|
||||
if self.failure_type != 'UNKNOWN':
|
||||
return dict(type(self).failure_type.selection).get(self.failure_type, _('No Error'))
|
||||
return dict(self._fields['failure_type'].selection).get(self.failure_type, _('No Error'))
|
||||
else:
|
||||
return _("Unknown error") + ": %s" % (self.failure_reason or '')
|
||||
|
||||
|
||||
@@ -719,7 +719,7 @@ class MailThread(models.AbstractModel):
|
||||
bounced_record_done = bounced_record_done or (bounced_record and model.model == bounced_model and bounced_record in rec_bounce_w_email)
|
||||
|
||||
# set record as bounced unless already done due to blacklist mixin
|
||||
if bounced_record and not bounced_record_done and issubclass(type(bounced_record), self.pool['mail.thread']):
|
||||
if bounced_record and not bounced_record_done and isinstance(bounced_record, self.pool['mail.thread']):
|
||||
bounced_record._message_receive_bounce(bounced_email, bounced_partner)
|
||||
|
||||
if bounced_partner and bounced_message:
|
||||
@@ -1642,7 +1642,7 @@ class MailThread(models.AbstractModel):
|
||||
If no partner has been found and/or created for a given emails its
|
||||
matching partner is an empty record.
|
||||
"""
|
||||
if records and issubclass(type(records), self.pool['mail.thread']):
|
||||
if records and isinstance(records, self.pool['mail.thread']):
|
||||
followers = records.mapped('message_partner_ids')
|
||||
else:
|
||||
followers = self.env['res.partner']
|
||||
|
||||
@@ -66,11 +66,11 @@ GROUP BY channel_moderator.res_users_id""", [tuple(self.ids)])
|
||||
"""
|
||||
init_res = super(Users, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
|
||||
type(self).SELF_WRITEABLE_FIELDS.extend(['notification_type'])
|
||||
pool[self._name].SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
|
||||
pool[self._name].SELF_WRITEABLE_FIELDS.extend(['notification_type'])
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
|
||||
type(self).SELF_READABLE_FIELDS.extend(['notification_type'])
|
||||
pool[self._name].SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
|
||||
pool[self._name].SELF_READABLE_FIELDS.extend(['notification_type'])
|
||||
return init_res
|
||||
|
||||
@api.model_create_multi
|
||||
|
||||
@@ -288,7 +288,7 @@ class MailComposer(models.TransientModel):
|
||||
reply_to_value[res_id] = rendered_values.get(res_id, {}).get('email_from', False)
|
||||
|
||||
blacklisted_rec_ids = set()
|
||||
if mass_mail_mode and issubclass(type(self.env[self.model]), self.pool['mail.thread.blacklist']):
|
||||
if mass_mail_mode and isinstance(self.env[self.model], self.pool['mail.thread.blacklist']):
|
||||
self.env['mail.blacklist'].flush(['email'])
|
||||
self._cr.execute("SELECT email FROM mail_blacklist WHERE active=true")
|
||||
blacklist = {x[0] for x in self._cr.fetchall()}
|
||||
|
||||
@@ -25,5 +25,5 @@ class Users(models.Model):
|
||||
"""
|
||||
init_res = super(Users, self).__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + ['flectrabot_state']
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + ['flectrabot_state']
|
||||
return init_res
|
||||
|
||||
@@ -71,7 +71,7 @@ class MailThread(models.AbstractModel):
|
||||
"""
|
||||
defaults = {}
|
||||
|
||||
if issubclass(type(self), self.pool['utm.mixin']):
|
||||
if isinstance(self, self.pool['utm.mixin']):
|
||||
thread_references = msg_dict.get('references', '') or msg_dict.get('in_reply_to', '')
|
||||
msg_references = tools.mail_header_msgid_re.findall(thread_references)
|
||||
if msg_references:
|
||||
|
||||
@@ -293,7 +293,7 @@ class MassMailing(models.Model):
|
||||
return super(MassMailing, self).copy(default=default)
|
||||
|
||||
def _group_expand_states(self, states, domain, order):
|
||||
return [key for key, val in type(self).state.selection]
|
||||
return [key for key, val in self._fields['state'].selection]
|
||||
|
||||
# ------------------------------------------------------
|
||||
# ACTIONS
|
||||
|
||||
@@ -181,9 +181,9 @@ class Mailing(models.Model):
|
||||
target = self.env[self.mailing_model_real]
|
||||
|
||||
partner_fields = []
|
||||
if issubclass(type(target), self.pool['mail.thread.phone']):
|
||||
if isinstance(target, self.pool['mail.thread.phone']):
|
||||
phone_fields = ['phone_sanitized']
|
||||
elif issubclass(type(target), self.pool['mail.thread']):
|
||||
elif isinstance(target, self.pool['mail.thread']):
|
||||
phone_fields = [
|
||||
fname for fname in target._sms_get_number_fields()
|
||||
if fname in target._fields and target._fields[fname].store
|
||||
|
||||
@@ -46,7 +46,7 @@ class MicrosoftOutlookController(http.Controller):
|
||||
|
||||
model = request.env[model_name]
|
||||
|
||||
if not issubclass(type(model), request.env.registry['microsoft.outlook.mixin']):
|
||||
if not isinstance(model, request.env.registry['microsoft.outlook.mixin']):
|
||||
# The model must inherits from the "microsoft.outlook.mixin" mixin
|
||||
raise Forbidden()
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ class MailController(MailController):
|
||||
if not model or not res_id or model not in request.env:
|
||||
return super(MailController, cls)._redirect_to_record(model, res_id, access_token=access_token, **kwargs)
|
||||
|
||||
if issubclass(type(request.env[model]), request.env.registry['portal.mixin']):
|
||||
if isinstance(request.env[model], request.env.registry['portal.mixin']):
|
||||
uid = request.session.uid or request.env.ref('base.public_user').id
|
||||
record_sudo = request.env[model].sudo().browse(res_id).exists()
|
||||
try:
|
||||
|
||||
@@ -424,7 +424,7 @@ class CustomerPortal(Controller):
|
||||
|
||||
report_sudo = request.env.ref(report_ref).with_user(SUPERUSER_ID)
|
||||
|
||||
if not isinstance(report_sudo, type(request.env['ir.actions.report'])):
|
||||
if not isinstance(report_sudo, request.env.registry['ir.actions.report']):
|
||||
raise UserError(_("%s is not the reference of a report", report_ref))
|
||||
|
||||
if hasattr(model, 'company_id'):
|
||||
|
||||
@@ -28,6 +28,6 @@ class Users(models.Model):
|
||||
|
||||
init_res = super().__init__(pool, cr)
|
||||
# duplicate list to avoid modifying the original reference
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + sale_stock_writeable_fields
|
||||
type(self).SELF_WRITEABLE_FIELDS = type(self).SELF_WRITEABLE_FIELDS + sale_stock_writeable_fields
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + sale_stock_writeable_fields
|
||||
pool[self._name].SELF_WRITEABLE_FIELDS = pool[self._name].SELF_WRITEABLE_FIELDS + sale_stock_writeable_fields
|
||||
return init_res
|
||||
|
||||
@@ -107,7 +107,7 @@ class SendSMS(models.TransientModel):
|
||||
continue
|
||||
|
||||
records = composer._get_records()
|
||||
if records and issubclass(type(records), self.pool['mail.thread']):
|
||||
if records and isinstance(records, self.pool['mail.thread']):
|
||||
res = records._sms_get_recipients_info(force_field=composer.number_field_name, partner_fallback=not composer.comment_single_recipient)
|
||||
composer.recipient_valid_count = len([rid for rid, rvalues in res.items() if rvalues['sanitized']])
|
||||
composer.recipient_invalid_count = len([rid for rid, rvalues in res.items() if not rvalues['sanitized']])
|
||||
@@ -120,7 +120,7 @@ class SendSMS(models.TransientModel):
|
||||
def _compute_recipient_single(self):
|
||||
for composer in self:
|
||||
records = composer._get_records()
|
||||
if not records or not issubclass(type(records), self.pool['mail.thread']) or not composer.comment_single_recipient:
|
||||
if not records or not isinstance(records, self.pool['mail.thread']) or not composer.comment_single_recipient:
|
||||
composer.recipient_single_description = False
|
||||
composer.recipient_single_number = ''
|
||||
composer.recipient_single_number_itf = ''
|
||||
@@ -207,7 +207,7 @@ class SendSMS(models.TransientModel):
|
||||
if self.composition_mode == 'numbers':
|
||||
return self._action_send_sms_numbers()
|
||||
elif self.composition_mode == 'comment':
|
||||
if records is None or not issubclass(type(records), self.pool['mail.thread']):
|
||||
if records is None or not isinstance(records, self.pool['mail.thread']):
|
||||
return self._action_send_sms_numbers()
|
||||
if self.comment_single_recipient:
|
||||
return self._action_send_sms_comment_single(records)
|
||||
@@ -257,7 +257,7 @@ class SendSMS(models.TransientModel):
|
||||
sms_record_values = self._prepare_mass_sms_values(records)
|
||||
sms_all = self._prepare_mass_sms(records, sms_record_values)
|
||||
|
||||
if sms_all and self.mass_keep_log and records and issubclass(type(records), self.pool['mail.thread']):
|
||||
if sms_all and self.mass_keep_log and records and isinstance(records, self.pool['mail.thread']):
|
||||
log_values = self._prepare_mass_log_values(records, sms_record_values)
|
||||
records._message_log_batch(**log_values)
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ class BaseDocumentLayout(models.TransientModel):
|
||||
return False, False
|
||||
|
||||
# The "===" gives different base64 encoding a correct padding
|
||||
logo += b'===' if type(logo) == bytes else '==='
|
||||
logo += b'===' if isinstance(logo, bytes) else '==='
|
||||
try:
|
||||
# Catches exceptions caused by logo not being an image
|
||||
image = tools.image_fix_orientation(tools.base64_to_image(logo))
|
||||
|
||||
@@ -38,7 +38,7 @@ class Image(models.AbstractModel):
|
||||
sha = hashlib.sha512(str(getattr(record, '__last_update')).encode('utf-8')).hexdigest()[:7]
|
||||
max_size = '' if max_size is None else '/%s' % max_size
|
||||
|
||||
if options.get('filename-field') and getattr(record, options['filename-field'], None):
|
||||
if options.get('filename-field') and options['filename-field'] in record and record[options['filename-field']]:
|
||||
filename = record[options['filename-field']]
|
||||
elif options.get('filename'):
|
||||
filename = options['filename']
|
||||
@@ -72,7 +72,7 @@ class Image(models.AbstractModel):
|
||||
|
||||
src, src_zoom = self._get_src_urls(record, field_name, options)
|
||||
|
||||
if options.get('alt-field') and getattr(record, options['alt-field'], None):
|
||||
if options.get('alt-field') and options['alt-field'] in record and record[options['alt-field']]:
|
||||
alt = escape(record[options['alt-field']])
|
||||
elif options.get('alt'):
|
||||
alt = options['alt']
|
||||
|
||||
@@ -160,7 +160,7 @@ class Base(models.AbstractModel):
|
||||
def adapt(value):
|
||||
if field_type == 'selection':
|
||||
value = selection_labels.get(value, False)
|
||||
if type(value) == tuple:
|
||||
if isinstance(value, tuple):
|
||||
value = value[1] # FIXME should use technical value (0)
|
||||
return value
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ class ManyToOne(models.AbstractModel):
|
||||
def attributes(self, record, field_name, options, values):
|
||||
attrs = super(ManyToOne, self).attributes(record, field_name, options, values)
|
||||
if options.get('inherit_branding'):
|
||||
many2one = getattr(record, field_name)
|
||||
many2one = record[field_name]
|
||||
if many2one:
|
||||
attrs['data-oe-many2one-id'] = many2one.id
|
||||
attrs['data-oe-many2one-model'] = many2one._name
|
||||
|
||||
@@ -163,7 +163,7 @@ class WebsiteProfile(http.Controller):
|
||||
else:
|
||||
user = request.env.user
|
||||
values = self._profile_edition_preprocess_values(user, **kwargs)
|
||||
whitelisted_values = {key: values[key] for key in type(user).SELF_WRITEABLE_FIELDS if key in values}
|
||||
whitelisted_values = {key: values[key] for key in request.env.registry['res.users'].SELF_WRITEABLE_FIELDS if key in values}
|
||||
user.write(whitelisted_values)
|
||||
if kwargs.get('url_param'):
|
||||
return werkzeug.utils.redirect("/profile/user/%d?%s" % (user.id, kwargs['url_param']))
|
||||
|
||||
@@ -16,11 +16,11 @@ class Users(models.Model):
|
||||
|
||||
def __init__(self, pool, cr):
|
||||
init_res = super(Users, self).__init__(pool, cr)
|
||||
type(self).SELF_WRITEABLE_FIELDS = list(
|
||||
pool[self._name].SELF_WRITEABLE_FIELDS = list(
|
||||
set(
|
||||
self.SELF_WRITEABLE_FIELDS +
|
||||
['country_id', 'city', 'website', 'website_description', 'website_published']))
|
||||
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + ['karma']
|
||||
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + ['karma']
|
||||
return init_res
|
||||
|
||||
@api.model
|
||||
|
||||
Reference in New Issue
Block a user