Merge pull request #633 from expsa/dev_odex25_transactions

Dev odex25 transactions
This commit is contained in:
zainab2097 2024-08-11 16:30:56 +03:00 committed by GitHub
commit 0e004c0424
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 13 deletions

View File

@ -80,7 +80,7 @@ class AttachmentRule(models.Model):
default=lambda self: self._default_employee_id(), readonly="True")
entity_id = fields.Many2one(comodel_name='cm.entity', string='Unit Responsible', related='employee_id.parent_id',
store=True)
file_save = fields.Binary('Save File')
file_save = fields.Many2many('ir.attachment', String="Save File")
external_drive_link = fields.Text('External Drive Link')
attachment_filename = fields.Char(string="Attachment Filename")
incoming_transaction_id = fields.Many2one(comodel_name='incoming.transaction', string='Incoming Transaction')
@ -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'

View File

@ -124,7 +124,7 @@
<field name="entity_id" readonly="True"/>
<field name="date" readonly="True"/>
<field name="description" required="False"/>
<field name="file_save" filename="attachment_filename"/>
<field name="file_save" filename="attachment_filename" widget="many2many_attachment_preview"/>
<field name="external_drive_link" widget="url"/>
<field name="attachment_filename" invisible="True"/>
</tree>
@ -233,7 +233,7 @@
<field name="entity_id" readonly="True"/>
<field name="date" readonly="True"/>
<field name="description" required="False"/>
<field name="file_save" filename="attachment_filename"/>
<field name="file_save" filename="attachment_filename" widget="many2many_attachment_preview"/>
<field name="external_drive_link" widget="url"/>
<field name="attachment_filename" invisible="True"/>
</tree>
@ -345,7 +345,7 @@
<field name="entity_id" readonly="True"/>
<field name="date" readonly="True"/>
<field name="description" required="False"/>
<field name="file_save" filename="attachment_filename"/>
<field name="file_save" filename="attachment_filename" widget="many2many_attachment_preview"/>
<field name="external_drive_link" widget="url"/>
<field name="attachment_filename" invisible="True"/>
</tree>