Merge pull request #3273 from expsa/dev_odex25_transactions
Dev odex25 transactions
This commit is contained in:
commit
7fc0ea34fc
|
|
@ -16,28 +16,29 @@ class Letters(models.Model):
|
||||||
date = fields.Date(string="Date", tracking=True)
|
date = fields.Date(string="Date", tracking=True)
|
||||||
hijir_date = fields.Char(string="Hijir Date", compute='compute_hijri')
|
hijir_date = fields.Char(string="Hijir Date", compute='compute_hijri')
|
||||||
content = fields.Html(string="Content", tracking=True)
|
content = fields.Html(string="Content", tracking=True)
|
||||||
signature = fields.Binary("Signature image",compute='compute_img',store=True)
|
signature = fields.Binary("Signature image", compute='compute_img', store=True)
|
||||||
is_sign = fields.Boolean(string='Is Sign',readonly=True)
|
is_sign = fields.Boolean(string='Is Sign', readonly=True)
|
||||||
is_signed = fields.Boolean(default=False, 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'),
|
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(
|
incoming_transaction_id = fields.Many2one(
|
||||||
comodel_name='incoming.transaction',
|
comodel_name='incoming.transaction',
|
||||||
string='Incoming Transaction',
|
string='Incoming Transaction',
|
||||||
domain="[('state', 'not in', ['closed', 'canceled'])]",
|
domain="[('state', 'not in', ['closed', 'canceled'])]",
|
||||||
tracking=True
|
tracking=True
|
||||||
)
|
)
|
||||||
internal_transaction_id = fields.Many2one(
|
internal_transaction_id = fields.Many2one(
|
||||||
comodel_name='internal.transaction',
|
comodel_name='internal.transaction',
|
||||||
string='Internal Transaction',
|
string='Internal Transaction',
|
||||||
domain="[('state', 'not in', ['closed', 'canceled'])]",
|
domain="[('state', 'not in', ['closed', 'canceled'])]",
|
||||||
tracking=True
|
tracking=True
|
||||||
)
|
)
|
||||||
outgoing_transaction_id = fields.Many2one(
|
outgoing_transaction_id = fields.Many2one(
|
||||||
comodel_name='outgoing.transaction',
|
comodel_name='outgoing.transaction',
|
||||||
string='Outgoing Transaction',
|
string='Outgoing Transaction',
|
||||||
domain="[('state', 'not in', ['closed', 'canceled'])]",
|
domain="[('state', 'not in', ['closed', 'canceled'])]",
|
||||||
tracking=True
|
tracking=True
|
||||||
)
|
)
|
||||||
# attachment_generated = fields.Boolean()
|
# attachment_generated = fields.Boolean()
|
||||||
|
|
@ -52,12 +53,12 @@ class Letters(models.Model):
|
||||||
tracking=True
|
tracking=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@api.depends('transaction_type', 'name')
|
||||||
@api.depends('transaction_type','name')
|
|
||||||
def compute_img(self):
|
def compute_img(self):
|
||||||
employee_id = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
employee_id = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||||
if employee_id:
|
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:
|
for rec in self:
|
||||||
rec.signature = entity.image
|
rec.signature = entity.image
|
||||||
|
|
||||||
|
|
@ -111,7 +112,7 @@ class Letters(models.Model):
|
||||||
elif self.transaction_type == "incoming":
|
elif self.transaction_type == "incoming":
|
||||||
res_id = self.incoming_transaction_id.id
|
res_id = self.incoming_transaction_id.id
|
||||||
field_name = 'incoming_transaction_id'
|
field_name = 'incoming_transaction_id'
|
||||||
|
|
||||||
return field_name, res_id
|
return field_name, res_id
|
||||||
|
|
||||||
def action_generate_attachment(self):
|
def action_generate_attachment(self):
|
||||||
|
|
@ -123,9 +124,9 @@ class Letters(models.Model):
|
||||||
b64_pdf = base64.b64encode(pdf[0])
|
b64_pdf = base64.b64encode(pdf[0])
|
||||||
res_id = ''
|
res_id = ''
|
||||||
field_name, res_id = self._get_transaction_values()
|
field_name, res_id = self._get_transaction_values()
|
||||||
file_exists = self.env['cm.attachment.rule'].search([(field_name, '=', res_id),('created_from_system','=',True)])
|
# file_exists = self.env['cm.attachment.rule'].search([(field_name, '=', res_id),('created_from_system','=',True)])
|
||||||
if file_exists:
|
# if file_exists:
|
||||||
file_exists.unlink()
|
# file_exists.unlink()
|
||||||
ATTACHMENT_NAME = "Letter"
|
ATTACHMENT_NAME = "Letter"
|
||||||
attach_id = self.env['ir.attachment'].create({
|
attach_id = self.env['ir.attachment'].create({
|
||||||
'name': ATTACHMENT_NAME + '.pdf',
|
'name': ATTACHMENT_NAME + '.pdf',
|
||||||
|
|
@ -154,7 +155,7 @@ class Letters(models.Model):
|
||||||
final_content = values.get('content')
|
final_content = values.get('content')
|
||||||
values['content'] = final_content.replace('line-height', '')
|
values['content'] = final_content.replace('line-height', '')
|
||||||
return super(Letters, self).write(values)
|
return super(Letters, self).write(values)
|
||||||
|
|
||||||
def unlink(self):
|
def unlink(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.state == 'attached':
|
if record.state == 'attached':
|
||||||
|
|
@ -163,10 +164,10 @@ class Letters(models.Model):
|
||||||
|
|
||||||
def action_draft(self):
|
def action_draft(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
field_name, res_id = self._get_transaction_values()
|
# field_name, res_id = self._get_transaction_values()
|
||||||
letter_attachment = self.env['cm.attachment.rule'].search([(field_name, '=', res_id), ('created_from_system', '=', True)])
|
# letter_attachment = self.env['cm.attachment.rule'].search([(field_name, '=', res_id), ('created_from_system', '=', True)])
|
||||||
if letter_attachment:
|
# if letter_attachment:
|
||||||
letter_attachment.unlink()
|
# letter_attachment.unlink()
|
||||||
self.write({
|
self.write({
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'is_signed': False
|
'is_signed': False
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue