Merge pull request #541 from expsa/dev_trans_attch_preview

[UPD] _onchange_file_save in AttachmentRule has been disabled
This commit is contained in:
Tahir Hassan 2024-08-05 17:48:38 +04:00 committed by GitHub
commit a8e4247c7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 9 deletions

View File

@ -98,15 +98,15 @@ class AttachmentRule(models.Model):
# if file_size > max_size:
# raise ValidationError(_('Attachment %s exceeds the maximum allowed size of 4 MB.') % record.attachment_filename)
@api.onchange('file_save')
def _onchange_file_save(self):
max_size = 4 * 1024 * 1024 # 4 MB
for record in self:
if record.file_save:
file_size = len(base64.b64decode(record.file_save))
if file_size > max_size:
record.file_save = False
raise UserError(_('Attachment %s exceeds the maximum allowed size of 4 MB.') % record.attachment_filename)
# @api.onchange('file_save')
# def _onchange_file_save(self):
# max_size = 4 * 1024 * 1024 # 4 MB
# for record in self:
# if record.file_save:
# file_size = len(base64.b64decode(record.file_save))
# if file_size > max_size:
# record.file_save = False
# raise UserError(_('Attachment %s exceeds the maximum allowed size of 4 MB.') % record.attachment_filename)
class TransactionTrace(models.Model):
_name = 'cm.transaction.trace'