summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-06-19 12:07:56 +0200
committerChristophe Simonis <chs@odoo.com>2019-06-19 12:07:56 +0200
commit132e38beeffc97c30d79eae1f18836e8117fc45e (patch)
tree5be367853e4e2570719df9437f1f022c0855813c /odoo
parent8a19a6a2a34d318d2c5b799a0e8e108fe04a097c (diff)
parentb5a04fd29ff19839e788b2c383e3af74c883c54d (diff)
[MERGE] forward port branch 11.0 up to b5a04fd29ff
Diffstat (limited to 'odoo')
-rw-r--r--odoo/addons/base/data/res_currency_data.xml1
-rw-r--r--odoo/addons/base/models/ir_actions.py5
-rw-r--r--odoo/addons/base/models/ir_model.py1
-rw-r--r--odoo/models.py38
-rw-r--r--odoo/tools/image.py3
5 files changed, 36 insertions, 12 deletions
diff --git a/odoo/addons/base/data/res_currency_data.xml b/odoo/addons/base/data/res_currency_data.xml
index 1c67808c8a2..487c6f2a3a8 100644
--- a/odoo/addons/base/data/res_currency_data.xml
+++ b/odoo/addons/base/data/res_currency_data.xml
@@ -221,6 +221,7 @@
<field name="symbol">¥</field>
<field name="rounding">1.00</field>
<field name="active" eval="False"/>
+ <field name="position">before</field>
<field name="currency_unit_label">Yen</field>
<field name="currency_subunit_label">Cen</field>
</record>
diff --git a/odoo/addons/base/models/ir_actions.py b/odoo/addons/base/models/ir_actions.py
index bca3dbfe58e..2af5f12bd50 100644
--- a/odoo/addons/base/models/ir_actions.py
+++ b/odoo/addons/base/models/ir_actions.py
@@ -245,7 +245,10 @@ class IrActionsActWindow(models.Model):
existing = self.filtered(lambda rec: rec.id in ids)
if len(existing) < len(self):
# mark missing records in cache with a failed value
- exc = MissingError(_("Record does not exist or has been deleted."))
+ exc = MissingError(
+ _("Record does not exist or has been deleted.")
+ + '\n\n({} {}, {} {})'.format(_('Records:'), (self - existing).ids[:6], _('User:'), self._uid)
+ )
for record in (self - existing):
record._cache.set_failed(self._fields, exc)
return existing
diff --git a/odoo/addons/base/models/ir_model.py b/odoo/addons/base/models/ir_model.py
index c0133e4b653..a70e5044ea3 100644
--- a/odoo/addons/base/models/ir_model.py
+++ b/odoo/addons/base/models/ir_model.py
@@ -1242,6 +1242,7 @@ class IrModelAccess(models.Model):
else:
msg_tail = _("Please contact your system administrator if you think this is an error.") + "\n\n(" + _("Document model") + ": %s)"
msg_params = (model,)
+ msg_tail += ' - ({} {}, {} {})'.format(_('Operation:'), mode, _('User:'), self._uid)
_logger.info('Access Denied by ACLs for operation: %s, uid: %s, model: %s', mode, self._uid, model)
msg = '%s %s' % (msg_heads[mode], msg_tail)
raise AccessError(msg % msg_params)
diff --git a/odoo/models.py b/odoo/models.py
index a6cf0357ec5..6fb19da2c1a 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -2567,9 +2567,13 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
if invalid_fields:
_logger.info('Access Denied by ACLs for operation: %s, uid: %s, model: %s, fields: %s',
operation, self._uid, self._name, ', '.join(invalid_fields))
- raise AccessError(_('The requested operation cannot be completed due to security restrictions. '
- 'Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % \
- (self._description, operation))
+ raise AccessError(
+ _(
+ 'The requested operation cannot be completed due to security restrictions. '
+ 'Please contact your system administrator.\n\n(Document type: %s, Operation: %s)'
+ ) % (self._description, operation)
+ + ' - ({} {}, {} {})'.format(_('User:'), self._uid, _('Fields:'), ', '.join(invalid_fields))
+ )
return fields
@@ -2792,8 +2796,8 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
(self._name, 'read', ','.join([str(r.id) for r in self][:6]), self._uid))
# store an access error exception in existing records
exc = AccessError(
- _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % \
- (self._name, 'read')
+ _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % (self._description, 'read')
+ + ' - ({} {}, {} {})'.format(_('Records:'), self.ids[:6], _('User:'), self._uid)
)
self.env.cache.set_failed(forbidden, self._fields.values(), exc)
@@ -2877,8 +2881,10 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
if self._uid == SUPERUSER_ID:
return
_logger.info('Access Denied by record rules for operation: %s on record ids: %r, uid: %s, model: %s', operation, forbidden_ids, self._uid, self._name)
- raise AccessError(_('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % \
- (self._description, operation))
+ raise AccessError(
+ _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % (self._description, operation)
+ + ' - ({} {}, {}, {})'.format(_('Records:'), forbidden_ids[:6], _('User:'), self._uid)
+ )
else:
# If we get here, the missing_ids are not in the database
if operation in ('read','unlink'):
@@ -2887,7 +2893,13 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
# errors for non-transactional search/read sequences coming from clients
return
_logger.info('Failed operation on deleted record(s): %s, uid: %s, model: %s', operation, self._uid, self._name)
- raise MissingError(_('Missing document(s)') + ':' + _('One of the documents you are trying to access has been deleted, please try again after refreshing.'))
+ raise MissingError(
+ _('Missing document(s)') + ':' + _('One of the documents you are trying to access has been deleted, please try again after refreshing.')
+ + '\n\n({} {}, {} {}, {} {}, {} {})'.format(
+ _('Document type:'), self._description, _('Operation:'), operation,
+ _('Records:'), missing_ids[:6], _('User:'), self._uid,
+ )
+ )
@api.model
def check_access_rights(self, operation, raise_exception=True):
@@ -3231,7 +3243,10 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
for sub_ids in cr.split_for_in_conditions(set(self.ids)):
cr.execute(query, params + [sub_ids])
if cr.rowcount != len(sub_ids):
- raise MissingError(_('One of the records you are trying to modify has already been deleted (Document type: %s).') % self._description)
+ raise MissingError(
+ _('One of the records you are trying to modify has already been deleted (Document type: %s).') % self._description
+ + '\n\n({} {}, {} {})'.format(_('Records:'), sub_ids[:6], _('User:'), self._uid)
+ )
for name in updated:
field = self._fields[name]
@@ -3964,7 +3979,10 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
existing = self.browse(ids + new_ids)
if len(existing) < len(self):
# mark missing records in cache with a failed value
- exc = MissingError(_("Record does not exist or has been deleted."))
+ exc = MissingError(
+ _("Record does not exist or has been deleted.")
+ + '\n\n({} {}, {} {})'.format(_('Records:'), (self - existing).ids[:6], _('User:'), self._uid)
+ )
self.env.cache.set_failed(self - existing, self._fields.values(), exc)
return existing
diff --git a/odoo/tools/image.py b/odoo/tools/image.py
index 1230fdd5981..cab7b66340e 100644
--- a/odoo/tools/image.py
+++ b/odoo/tools/image.py
@@ -159,7 +159,7 @@ def image_resize_image_small(base64_source, size=(64, 64), encoding='base64', fi
# ----------------------------------------
# Crop Image
# ----------------------------------------
-def crop_image(data, type='top', ratio=False, size=None, image_format="PNG"):
+def crop_image(data, type='top', ratio=False, size=None, image_format=None):
""" Used for cropping image and create thumbnail
:param data: base64 data of image.
:param type: Used for cropping position possible
@@ -188,6 +188,7 @@ def crop_image(data, type='top', ratio=False, size=None, image_format="PNG"):
new_h = h
new_w = (h * w_ratio) // h_ratio
+ image_format = image_format or image_stream.format or 'JPEG'
if type == "top":
cropped_image = image_stream.crop((0, 0, new_w, new_h))
cropped_image.save(output_stream, format=image_format)