Transaction tasks
This commit is contained in:
parent
bac7939e01
commit
b187787ece
|
|
@ -88,6 +88,26 @@ class AttachmentRule(models.Model):
|
|||
outgoing_transaction_id = fields.Many2one(comodel_name='outgoing.transaction', string='Outgoing Transaction')
|
||||
date = fields.Datetime(string='Date', default=fields.Datetime.now)
|
||||
description = fields.Char(string='Description')
|
||||
signed = fields.Boolean(string='Signed')
|
||||
|
||||
def action_signature(self):
|
||||
for rec in self:
|
||||
x = self.env['letters.letters'].search([('internal_transaction_id','=',rec.internal_transaction_id.id)],limit=1)
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': 'Preferences',
|
||||
'res_model': 'res.users',
|
||||
'view_mode': 'form',
|
||||
'view_id': self.env.ref('base.view_users_form_simple_modif').id,
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_id': self.env.user.id,
|
||||
'default_letter_id': x.id ,
|
||||
'default_attachment_id': rec.id,
|
||||
},
|
||||
'res_id': self.env.user.id,
|
||||
}
|
||||
|
||||
|
||||
# @api.constrains('file_save')
|
||||
# def _check_attachment_size(self):
|
||||
|
|
|
|||
|
|
@ -86,8 +86,6 @@ class Transaction(models.Model):
|
|||
for rec in self:
|
||||
rec.signature =self.env.user.sign_signature
|
||||
|
||||
|
||||
|
||||
def action_read(self):
|
||||
for rec in self:
|
||||
rec.is_reade = True
|
||||
|
|
|
|||
|
|
@ -125,6 +125,12 @@
|
|||
<field name="date" readonly="True"/>
|
||||
<field name="description" required="False"/>
|
||||
<field name="file_save" filename="attachment_filename" widget="many2many_attachment_preview"/>
|
||||
<button name="action_signature"
|
||||
type="object"
|
||||
string="Sign"
|
||||
class="btn-link"
|
||||
icon="fa-signature" attrs="{'invisible':[('signed','=',True)]}"/>
|
||||
<field name="signed"/>
|
||||
<field name="external_drive_link" widget="url"/>
|
||||
<field name="attachment_filename" invisible="True"/>
|
||||
</tree>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from . import letter
|
||||
from . import res_users
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ class Letters(models.Model):
|
|||
hijir_date = fields.Char(string="Hijir Date", compute='compute_hijri')
|
||||
content = fields.Html(string="Content")
|
||||
signature = fields.Binary("Signature image",compute='compute_img',store=True)
|
||||
is_sign = fields.Boolean(string='Is Sign',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')
|
||||
incoming_transaction_id = fields.Many2one(comodel_name='incoming.transaction', string='Incoming Transaction')
|
||||
|
|
@ -88,6 +90,7 @@ class Letters(models.Model):
|
|||
file_exists = self.env['cm.attachment.rule'].search([(field_name, '=', res_id)])
|
||||
if file_exists:
|
||||
file_exists.unlink()
|
||||
self.is_sign = True
|
||||
ATTACHMENT_NAME = "Letter"
|
||||
attach_id = self.env['ir.attachment'].create({
|
||||
'name': ATTACHMENT_NAME + '.pdf',
|
||||
|
|
@ -97,15 +100,15 @@ class Letters(models.Model):
|
|||
'mimetype': 'application/x-pdf'
|
||||
})
|
||||
return self.env['cm.attachment.rule'].sudo().create({
|
||||
'employee_id': self.unite.id,
|
||||
'entity_id': self.unite.id,
|
||||
'file_save': [(6, 0, attach_id.ids)] ,
|
||||
'attachment_filename': ATTACHMENT_NAME,
|
||||
field_name:res_id,
|
||||
'date': datetime.datetime.now(),
|
||||
'description': self.name,
|
||||
})
|
||||
|
||||
'employee_id': self.unite.id,
|
||||
'entity_id': self.unite.id,
|
||||
'file_save': [(6, 0, attach_id.ids)],
|
||||
'attachment_filename': ATTACHMENT_NAME,
|
||||
field_name: res_id,
|
||||
'date': datetime.datetime.now(),
|
||||
'description': self.name,
|
||||
'signed' : True if self.is_sign else False
|
||||
})
|
||||
|
||||
def write(self, values):
|
||||
if values.get('content'):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
from odoo import models,fields, api, _
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
letter_id = fields.Many2one('letters.letters')
|
||||
attachment_id = fields.Many2one('cm.attachment.rule')
|
||||
|
||||
def write(self, vals):
|
||||
# Access the context
|
||||
context = self.env.context
|
||||
|
||||
# Retrieve the letter_id from the context
|
||||
letter_id = context.get('default_letter_id') if context else None
|
||||
attachment_id = context.get('default_attachment_id') if context else None
|
||||
|
||||
# Custom logic before updating the record
|
||||
if 'sign_signature' in vals and letter_id:
|
||||
# Ensure letter_id is a valid recordset
|
||||
letter_record = self.env['letters.letters'].browse(letter_id)
|
||||
attachment_record = self.env['cm.attachment.rule'].browse(attachment_id)
|
||||
if letter_record.exists():
|
||||
letter_record.new_signature = vals.get('sign_signature')
|
||||
letter_record.action_generate_attachment()
|
||||
if attachment_record:
|
||||
attachment_record.signed = True
|
||||
|
||||
|
||||
# Call the super method to perform the standard write operation
|
||||
result = super(ResUsers, self).write(vals)
|
||||
|
||||
return result
|
||||
|
|
@ -273,14 +273,14 @@
|
|||
<t t-call="exp_transation_letters.letter_external_layout">
|
||||
<style type="text/css">
|
||||
@font-face {
|
||||
font-family: 'DroidKufi';
|
||||
src: url("/exp_transation_letters/static/src/fonts/DroidKufi-Bold.ttf") format("truetype");
|
||||
font-family: 'Al-Mohanad';
|
||||
src: url("/exp_transation_letters/static/src/fonts/Al-Mohanad.ttf") format("truetype");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.droidkufi-font {
|
||||
font-family: 'DroidKufi', sans-serif;
|
||||
font-family: 'Al-Mohanad', sans-serif;
|
||||
}
|
||||
</style>
|
||||
<div class="page droidkufi-font">
|
||||
|
|
@ -296,7 +296,7 @@
|
|||
<br/>
|
||||
<br/>
|
||||
<div style="margin-top: 0px;" dir="ltr">
|
||||
<img t-if="o.signature" t-attf-src="data:image/*;base64,{{o.signature}}"
|
||||
<img t-if="o.new_signature" t-attf-src="data:image/*;base64,{{o.new_signature}}"
|
||||
style="margin-top:50px;height:100px;width:100px; border: 0px;margin-left:25px"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -41,7 +41,8 @@
|
|||
<field name="content"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="signature" widget="image"/>
|
||||
<field name="signature" widget="image" invisible="1"/>
|
||||
<field name="new_signature" widget="image"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Reference in New Issue