transacation changes
This commit is contained in:
parent
cbdb1cf3a1
commit
01d8e684a4
|
|
@ -165,7 +165,7 @@
|
|||
<field name="view_mode">tree,form</field>
|
||||
<field name='domain'>[
|
||||
'&',
|
||||
('state', '=', 'send'),
|
||||
('state', 'in', ['send', 'reply']),
|
||||
'|', '|',
|
||||
'&',
|
||||
('is_forward', '=', False),
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class Letters(models.Model):
|
|||
readonly=True,
|
||||
tracking=True
|
||||
)
|
||||
|
||||
job_name = fields.Char(store=False)
|
||||
@api.depends('transaction_type', 'name')
|
||||
def compute_img(self):
|
||||
employee_id = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||
|
|
@ -118,17 +118,18 @@ class Letters(models.Model):
|
|||
def action_generate_attachment(self):
|
||||
""" this method called from button action in view xml """
|
||||
# generate pdf from report, use report's id as reference
|
||||
REPORT_ID = 'exp_transation_letters.report_letter_action_report'
|
||||
pdf = self.env.ref(REPORT_ID)._render_qweb_pdf(self.ids)
|
||||
for record in self:
|
||||
REPORT_ID = 'exp_transation_letters.report_letter_action_report'
|
||||
pdf = self.env.ref(REPORT_ID)._render_qweb_pdf(self.ids)
|
||||
# pdf result is a list
|
||||
b64_pdf = base64.b64encode(pdf[0])
|
||||
res_id = ''
|
||||
field_name, res_id = self._get_transaction_values()
|
||||
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()
|
||||
ATTACHMENT_NAME = "Letter"
|
||||
attach_id = self.env['ir.attachment'].create({
|
||||
ATTACHMENT_NAME = "Letter"
|
||||
attach_id = self.env['ir.attachment'].create({
|
||||
'name': ATTACHMENT_NAME + '.pdf',
|
||||
'type': 'binary',
|
||||
'datas': b64_pdf,
|
||||
|
|
@ -137,8 +138,11 @@ class Letters(models.Model):
|
|||
'mimetype': 'application/pdf'
|
||||
})
|
||||
# self.attachment_generated = True
|
||||
self.state = 'attached'
|
||||
return self.env['cm.attachment.rule'].sudo().create({
|
||||
employee = self.env['hr.employee'].search([('user_id', '=', attach_id.create_uid.id)], limit=1)
|
||||
record.job_name = employee.job_title if employee and employee.job_title else ' '
|
||||
record.signed_user_id = attach_id.create_uid
|
||||
self.state = 'attached'
|
||||
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)],
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@
|
|||
<span t-esc="o.signed_user_id.name"/>
|
||||
</div>
|
||||
<div style="margin-bottom: 10px; text-align: left;margin-left:25px;font-size:18px;">
|
||||
<span t-esc="o.signed_user_id.employee_id.job_id.name"/>
|
||||
<span t-esc="job_name"/>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 10px; text-align: left;">
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@
|
|||
<span t-esc="o.signed_user_id.name"/>
|
||||
</div>
|
||||
<div style="margin-bottom: 10px; text-align: left;margin-left:25px;font-size:18px;">
|
||||
<span t-esc="o.signed_user_id.employee_id.job_id.name"/>
|
||||
<span t-esc="o.job_name"/>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 10px; text-align: left;">
|
||||
|
|
|
|||
Loading…
Reference in New Issue