/
project.py
55 lines (48 loc) · 1.76 KB
/
project.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import _, api, fields, models
class ProjectTask(models.Model):
_inherit = 'project.task'
customer_signature = fields.Binary(
string='Customer acceptance',
)
@api.multi
def action_task_send(self):
self.ensure_one()
template = self.env.ref(
'project_task_digitized_signature.email_task_template',
False,
)
compose_form = self.env.ref('mail.email_compose_message_wizard_form',
False)
ctx = dict(
default_model='project.task',
default_res_id=self.id,
default_use_template=bool(template),
default_template_id=template and template.id or False,
default_composition_mode='comment',
mark_invoice_as_sent=True,
)
return {
'name': _('Compose Email'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(compose_form.id, 'form')],
'view_id': compose_form.id,
'target': 'new',
'context': ctx,
}
@api.model
def create(self, values):
task = super(ProjectTask, self).create(values)
if task.customer_signature:
values = {'customer_signature': task.customer_signature}
task._track_signature(values, 'customer_signature')
return task
@api.multi
def write(self, values):
self.env['mail.thread']._track_signature(values, 'customer_signature')
return super(ProjectTask, self).write(values)