|
@ -19,7 +19,12 @@ |
|
|
# If not, see <http://www.gnu.org/licenses/>. |
|
|
# If not, see <http://www.gnu.org/licenses/>. |
|
|
# |
|
|
# |
|
|
############################################################################# |
|
|
############################################################################# |
|
|
|
|
|
import base64 |
|
|
|
|
|
from io import BytesIO |
|
|
|
|
|
import re |
|
|
|
|
|
|
|
|
from odoo import api, fields, models, _ |
|
|
from odoo import api, fields, models, _ |
|
|
|
|
|
from odoo.tools import mimetypes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RequestDocumentUser(models.Model): |
|
|
class RequestDocumentUser(models.Model): |
|
@ -44,6 +49,19 @@ class RequestDocumentUser(models.Model): |
|
|
company_id = fields.Many2one( |
|
|
company_id = fields.Many2one( |
|
|
related='workspace_id.company_id', string='Company', |
|
|
related='workspace_id.company_id', string='Company', |
|
|
help="Company Name") |
|
|
help="Company Name") |
|
|
|
|
|
hide_accept_button = fields.Boolean(string="Accept Upload", |
|
|
|
|
|
help='Boolean for checking the request ' |
|
|
|
|
|
'is accepted or not') |
|
|
|
|
|
hide_accept_for_user_button = fields.Boolean(string="Accept", |
|
|
|
|
|
compute="_compute_hide_accept_for_user_button", |
|
|
|
|
|
help='Boolean for checking ' |
|
|
|
|
|
'the accept button only ' |
|
|
|
|
|
'visible for ' |
|
|
|
|
|
'corresponding users', |
|
|
|
|
|
store=True) |
|
|
|
|
|
boolean_user_default = fields.Boolean(string="User Default", |
|
|
|
|
|
help='Boolean for compute ' |
|
|
|
|
|
'accept button') |
|
|
|
|
|
|
|
|
def action_send_document_request(self): |
|
|
def action_send_document_request(self): |
|
|
"""Function to send document request through email """ |
|
|
"""Function to send document request through email """ |
|
@ -57,6 +75,20 @@ class RequestDocumentUser(models.Model): |
|
|
'email_to': self.user_id.partner_id.email, |
|
|
'email_to': self.user_id.partner_id.email, |
|
|
} |
|
|
} |
|
|
self.env['mail.mail'].sudo().create(main_content).send() |
|
|
self.env['mail.mail'].sudo().create(main_content).send() |
|
|
|
|
|
self.write({ |
|
|
|
|
|
'hide_accept_button': True, |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
def read(self, values): |
|
|
|
|
|
res = super(RequestDocumentUser, self).read(values) |
|
|
|
|
|
self.boolean_user_default = True |
|
|
|
|
|
return res |
|
|
|
|
|
|
|
|
|
|
|
@api.depends('boolean_user_default') |
|
|
|
|
|
def _compute_hide_accept_for_user_button(self): |
|
|
|
|
|
for rec in self: |
|
|
|
|
|
if rec.env.uid == rec.user_id.id: |
|
|
|
|
|
rec.hide_accept_for_user_button = True |
|
|
|
|
|
|
|
|
@api.model |
|
|
@api.model |
|
|
def get_request(self): |
|
|
def get_request(self): |
|
@ -72,3 +104,14 @@ class RequestDocumentUser(models.Model): |
|
|
'workspace_id': rec.workspace.id, |
|
|
'workspace_id': rec.workspace.id, |
|
|
} for rec in request_ids] |
|
|
} for rec in request_ids] |
|
|
return context |
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
def action_accept_request(self): |
|
|
|
|
|
return { |
|
|
|
|
|
'name': _("Upload Document"), |
|
|
|
|
|
'view_mode': 'form', |
|
|
|
|
|
'view_type': 'form', |
|
|
|
|
|
'res_model': 'document.file', |
|
|
|
|
|
'type': 'ir.actions.act_window', |
|
|
|
|
|
'target': 'new', |
|
|
|
|
|
'context': {'default_workspace_id': self.workspace_id.id} |
|
|
|
|
|
} |
|
|