Browse Source

Mar 27 [UPDT] : Updated 'enhanced_document_management'

pull/278/merge
AjmalCybro 1 year ago
parent
commit
e4ea4a0ca5
  1. 2
      enhanced_document_management/README.rst
  2. 2
      enhanced_document_management/__manifest__.py
  3. 6
      enhanced_document_management/doc/RELEASE_NOTES.md
  4. 21
      enhanced_document_management/models/document_file.py
  5. 43
      enhanced_document_management/models/request_document.py
  6. 21
      enhanced_document_management/views/incoming_request_document_views.xml

2
enhanced_document_management/README.rst

@ -18,7 +18,7 @@ Company
Credits
-------
* Developers: V16 Mohamed Savad, Gokul PI, Megha AP, Javid, Nisiya
* Developers: V16 Mohamed Savad, Gokul PI, Megha AP, Javid, Nisiya, Farhana Jahan PT
* Contact: odoo@cybrosys.com
Contacts

2
enhanced_document_management/__manifest__.py

@ -21,7 +21,7 @@
#############################################################################
{
'name': 'Document Management',
'version': '16.0.1.1.0',
'version': '16.0.1.0.1',
'category': 'Document Management',
'summary': 'The Document Management module to access document tools',
'description': 'The Document Management module provides a quick access to '

6
enhanced_document_management/doc/RELEASE_NOTES.md

@ -5,3 +5,9 @@
#### ADD
- Initial commit for Document Management
#### 15.03.2024
#### Version 16.0.1.0.1
#### ADD
- Updates have been made to the incoming request menu.

21
enhanced_document_management/models/document_file.py

@ -102,7 +102,7 @@ class Document(models.Model):
def _compute_size(self):
"""Function is used to fetch the file size of an attachment"""
for rec in self:
rec.size = str(rec.attachment_id.file_size/1000) + ' Kb'
rec.size = str(rec.attachment_id.file_size / 1000) + ' Kb'
@api.onchange('days')
def _onchange_days(self):
@ -121,12 +121,12 @@ class Document(models.Model):
information about the file"""
# important to maintain extension and name as different
attachment_id = self.env['ir.attachment'].sudo().create({
'name': self.name,
'datas': self.attachment,
'res_model': 'document.file',
'res_id': self.id,
'public': True,
})
'name': self.name,
'datas': self.attachment,
'res_model': 'document.file',
'res_id': self.id,
'public': True,
})
self.sudo().write({
'name': self.name,
'date': fields.Date.today(),
@ -138,6 +138,11 @@ class Document(models.Model):
'attachment_id': attachment_id.id,
'brochure_url': attachment_id.local_url
})
if self.env.context.get('active_model') == "request.document":
self.env['request.document'].search(
[('id', '=', self.env.context.get('active_id'))]).write({
'state': 'accepted'
})
return {
'type': 'ir.actions.client',
'tag': 'reload'
@ -150,7 +155,7 @@ class Document(models.Model):
for doc in self.browse(document_selected):
zip_obj.write(doc.attachment_id._full_path(
doc.attachment_id.store_fname),
doc.attachment_id.name)
doc.attachment_id.name)
zip_obj.close()
url = f"{request.httprequest.host_url[:-1]}/web/attachments/download"
return {

43
enhanced_document_management/models/request_document.py

@ -19,7 +19,12 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
import base64
from io import BytesIO
import re
from odoo import api, fields, models, _
from odoo.tools import mimetypes
class RequestDocumentUser(models.Model):
@ -44,6 +49,19 @@ class RequestDocumentUser(models.Model):
company_id = fields.Many2one(
related='workspace_id.company_id', string='Company',
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):
"""Function to send document request through email """
@ -57,6 +75,20 @@ class RequestDocumentUser(models.Model):
'email_to': self.user_id.partner_id.email,
}
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
def get_request(self):
@ -72,3 +104,14 @@ class RequestDocumentUser(models.Model):
'workspace_id': rec.workspace.id,
} for rec in request_ids]
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}
}

21
enhanced_document_management/views/incoming_request_document_views.xml

@ -19,6 +19,13 @@
<field name="model">request.document</field>
<field name="arch" type="xml">
<form string="Request document">
<header>
<group attrs="{'invisible':[('state', '=', 'accepted')]}">
<button name="action_accept_request" string="Accept"
type="object" class="btn-primary"
attrs="{'invisible': ['|',('hide_accept_button', '=', False), ('hide_accept_for_user_button', '=', False)]}"/>
</group>
</header>
<sheet>
<group>
<group>
@ -27,6 +34,9 @@
<group>
<field name="workspace_id" string="Workspace"/>
<field name="company_id"/>
<field name="hide_accept_for_user_button" invisible="1"/>
<field name="boolean_user_default" invisible="1"/>
<field name="hide_accept_button" invisible="1"/>
<field name="state" invisible="1"/>
</group>
</group>
@ -56,12 +66,17 @@
<field name="arch" type="xml">
<tree>
<field name="needed_doc" string="Request"/>
<field name="requested_by" string="Requested by" widget="many2one_avatar_user"/>
<field name="user_id" string="Requested to" widget="many2one_avatar_user"/>
<field name="requested_by" string="Requested by"
widget="many2one_avatar_user"/>
<field name="user_id" string="Requested to"
widget="many2one_avatar_user"/>
<field name="create_date" string="Requested Date"/>
<field name="workspace_id" string="Workspace"/>
<field name="needed_doc" string="Document"/>
<field name="state" string="State" widget="badge" decoration-warning="state == 'requested'" decoration-danger="state == 'rejected'" decoration-success="state == 'accepted'"/>
<field name="state" string="State" widget="badge"
decoration-warning="state == 'requested'"
decoration-danger="state == 'rejected'"
decoration-success="state == 'accepted'"/>
</tree>
</field>
</record>

Loading…
Cancel
Save