Track all content changes in attached letters
This commit is contained in:
parent
f834829a6b
commit
e25105dc45
|
|
@ -16,12 +16,13 @@ class Letters(models.Model):
|
|||
date = fields.Date(string="Date", tracking=True)
|
||||
hijir_date = fields.Char(string="Hijir Date", compute='compute_hijri')
|
||||
content = fields.Html(string="Content", tracking=True)
|
||||
signature = fields.Binary("Signature image",compute='compute_img',store=True)
|
||||
is_sign = fields.Boolean(string='Is Sign',readonly=True)
|
||||
signature = fields.Binary("Signature image", compute='compute_img', store=True)
|
||||
is_sign = fields.Boolean(string='Is Sign', readonly=True)
|
||||
is_signed = fields.Boolean(default=False, readonly=True)
|
||||
new_signature = fields.Binary("Signature image",readonly=True)
|
||||
new_signature = fields.Binary("Signature image", readonly=True)
|
||||
transaction_type = fields.Selection([('internal', 'Internal'), ('outgoing', 'Outgoing'),
|
||||
('incoming', 'Incoming')], default='internal', string='Transaction Type', tracking=True)
|
||||
('incoming', 'Incoming')], default='internal', string='Transaction Type',
|
||||
tracking=True)
|
||||
incoming_transaction_id = fields.Many2one(
|
||||
comodel_name='incoming.transaction',
|
||||
string='Incoming Transaction',
|
||||
|
|
@ -52,12 +53,12 @@ class Letters(models.Model):
|
|||
tracking=True
|
||||
)
|
||||
|
||||
|
||||
@api.depends('transaction_type','name')
|
||||
@api.depends('transaction_type', 'name')
|
||||
def compute_img(self):
|
||||
employee_id = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||
if employee_id:
|
||||
entity = self.env['cm.entity'].search([('type','=','employee'),('employee_id', '=',employee_id.id)], limit=1)
|
||||
entity = self.env['cm.entity'].search([('type', '=', 'employee'), ('employee_id', '=', employee_id.id)],
|
||||
limit=1)
|
||||
for rec in self:
|
||||
rec.signature = entity.image
|
||||
|
||||
|
|
@ -123,9 +124,9 @@ class Letters(models.Model):
|
|||
b64_pdf = base64.b64encode(pdf[0])
|
||||
res_id = ''
|
||||
field_name, res_id = self._get_transaction_values()
|
||||
file_exists = self.env['cm.attachment.rule'].search([(field_name, '=', res_id),('created_from_system','=',True)])
|
||||
if file_exists:
|
||||
file_exists.unlink()
|
||||
# file_exists = self.env['cm.attachment.rule'].search([(field_name, '=', res_id),('created_from_system','=',True)])
|
||||
# if file_exists:
|
||||
# file_exists.unlink()
|
||||
ATTACHMENT_NAME = "Letter"
|
||||
attach_id = self.env['ir.attachment'].create({
|
||||
'name': ATTACHMENT_NAME + '.pdf',
|
||||
|
|
@ -163,10 +164,10 @@ class Letters(models.Model):
|
|||
|
||||
def action_draft(self):
|
||||
self.ensure_one()
|
||||
field_name, res_id = self._get_transaction_values()
|
||||
letter_attachment = self.env['cm.attachment.rule'].search([(field_name, '=', res_id), ('created_from_system', '=', True)])
|
||||
if letter_attachment:
|
||||
letter_attachment.unlink()
|
||||
# field_name, res_id = self._get_transaction_values()
|
||||
# letter_attachment = self.env['cm.attachment.rule'].search([(field_name, '=', res_id), ('created_from_system', '=', True)])
|
||||
# if letter_attachment:
|
||||
# letter_attachment.unlink()
|
||||
self.write({
|
||||
'state': 'draft',
|
||||
'is_signed': False
|
||||
|
|
|
|||
Loading…
Reference in New Issue