Browse Source

July 22: [FIX] Bug Fixed 'document_approval'

pull/332/merge
RisvanaCybro 9 months ago
parent
commit
fd497be628
  1. 2
      document_approval/__manifest__.py
  2. 5
      document_approval/doc/RELEASE_NOTES.md
  3. 9
      document_approval/models/document_approval.py
  4. 2
      document_approval/models/document_approval_step.py
  5. 2
      document_approval/security/document_approval_security.xml
  6. BIN
      document_approval/static/description/assets/screenshots/1.png
  7. BIN
      document_approval/static/description/assets/screenshots/2.png
  8. BIN
      document_approval/static/description/assets/screenshots/3.png
  9. BIN
      document_approval/static/description/assets/screenshots/4.png
  10. BIN
      document_approval/static/description/assets/screenshots/5.png
  11. 18
      document_approval/static/description/index.html
  12. 1
      document_approval/views/document_approval_team_views.xml
  13. 3
      document_approval/views/document_approval_views.xml
  14. 8
      document_approval/wizards/document_reject.py
  15. 38
      document_approval/wizards/document_reject_views.xml

2
document_approval/__manifest__.py

@ -21,7 +21,7 @@
############################################################################# #############################################################################
{ {
'name': "Document Approval", 'name': "Document Approval",
"version": "16.0.1.0.0", "version": "16.0.1.0.1",
"category": "Documents Management", "category": "Documents Management",
"summary": "Manager can approve or reject documents", "summary": "Manager can approve or reject documents",
"description": "User can create and upload various document for approvals." "description": "User can create and upload various document for approvals."

5
document_approval/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD #### ADD
- Initial commit for Document Approval - Initial commit for Document Approval
#### 22.07.2024
#### Version 16.0.1.0.1
#### BUG FIX
- BUG FIX

9
document_approval/models/document_approval.py

@ -20,7 +20,7 @@
# #
############################################################################# #############################################################################
from odoo import api, fields, models, _ from odoo import api, fields, models, _
from odoo.exceptions import UserError from odoo.exceptions import UserError, ValidationError
class DocumentApproval(models.Model): class DocumentApproval(models.Model):
@ -96,6 +96,13 @@ class DocumentApproval(models.Model):
'note': step.note 'note': step.note
})] })]
@api.constrains('team_id')
def _check_team_member(self):
"""function to check whether the team has atleast one member."""
if not self.team_id.step_ids.approver_id:
raise ValidationError(
"Your Team member should atleast have one Approver.")
@api.depends('team_id') @api.depends('team_id')
def _compute_show_approve(self): def _compute_show_approve(self):
"""This method _compute_show_approve to compute the valur to the field """This method _compute_show_approve to compute the valur to the field

2
document_approval/models/document_approval_step.py

@ -51,6 +51,6 @@ class DocumentApprovalSteps(models.Model):
note = fields.Char(string='Notes', help="To add notes") note = fields.Char(string='Notes', help="To add notes")
current_state = fields.Selection( current_state = fields.Selection(
selection=[('upcoming', 'Upcoming'), ('pending', 'Pending'), selection=[('upcoming', 'Upcoming'), ('pending', 'Pending'),
('approved', 'Approved')], ('approved', 'Approved'), ('rejected', 'rejected')],
default="upcoming", string="Approval State", default="upcoming", string="Approval State",
help="THe current state of approval") help="THe current state of approval")

2
document_approval/security/document_approval_security.xml

@ -6,7 +6,7 @@
<field name="model_id" <field name="model_id"
ref="document_approval.model_document_approval"/> ref="document_approval.model_document_approval"/>
<field name="domain_force"> <field name="domain_force">
['|',('step_ids.approver_id.id','=',user.id),('approve_initiator_id','=',user.id)] ['|','|',('step_ids.approver_id.id','=',user.id),('approve_initiator_id','=',user.id),('team_id.team_lead_id.id','=',user.id)]
</field> </field>
<field name="perm_read" eval="True"/> <field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/> <field name="perm_write" eval="True"/>

BIN
document_approval/static/description/assets/screenshots/1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
document_approval/static/description/assets/screenshots/2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

BIN
document_approval/static/description/assets/screenshots/3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
document_approval/static/description/assets/screenshots/4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

BIN
document_approval/static/description/assets/screenshots/5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

18
document_approval/static/description/index.html

@ -280,6 +280,24 @@
<img src="assets/screenshots/document_approvals_12.png" <img src="assets/screenshots/document_approvals_12.png"
class="img-thumbnail"> class="img-thumbnail">
</div> </div>
<div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
Step wise Approval
</h3>
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">
We can see the stepwise approvals for the document
</p>
<img src="assets/screenshots/1.png"
class="img-thumbnail">
<img src="assets/screenshots/2.png"
class="img-thumbnail">
<img src="assets/screenshots/3.png"
class="img-thumbnail">
<img src="assets/screenshots/4.png"
class="img-thumbnail">
<img src="assets/screenshots/5.png"
class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;"> <div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;"> <h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">
Document Approved with Signature Document Approved with Signature

1
document_approval/views/document_approval_team_views.xml

@ -34,7 +34,6 @@
<field name="steps" style="text-align: {left};"/> <field name="steps" style="text-align: {left};"/>
<field name="approver_id"/> <field name="approver_id"/>
<field name="role"/> <field name="role"/>
<field name="state"/>
<field name="note"/> <field name="note"/>
</tree> </tree>
</field> </field>

3
document_approval/views/document_approval_views.xml

@ -44,7 +44,7 @@
attrs="{'invisible': ['|', '|', ('state', 'not in', ('waiting' )),('method', '=', 'sign'), ('show_approve', '=', False)]}"/> attrs="{'invisible': ['|', '|', ('state', 'not in', ('waiting' )),('method', '=', 'sign'), ('show_approve', '=', False)]}"/>
<button string="Reject" name="action_reject" <button string="Reject" name="action_reject"
type="object" type="object"
attrs="{'invisible':['|', '|', '|', ('state', 'not in', ('waiting' )),('method', '=', 'button'), ('method', '=', 'sign'), ('show_approve', '=', False)]}"/> attrs="{'invisible':['|',('state', 'not in', ('waiting' )),('show_approve', '=', False)]}"/>
<field name="state" widget="statusbar" <field name="state" widget="statusbar"
statusbar_visible="draft,waiting,approved,reject"/> statusbar_visible="draft,waiting,approved,reject"/>
</header> </header>
@ -101,6 +101,7 @@
decoration-success="current_state == 'approved'" decoration-success="current_state == 'approved'"
decoration-primary="current_state == 'pending'" decoration-primary="current_state == 'pending'"
decoration-warning="current_state == 'upcoming'" decoration-warning="current_state == 'upcoming'"
decoration-danger="current_state == 'rejected'"
attrs="{'column_invisible': [('parent.state', '=', 'draft')]}"/> attrs="{'column_invisible': [('parent.state', '=', 'draft')]}"/>
<field name="note"/> <field name="note"/>
</tree> </tree>

8
document_approval/wizards/document_reject.py

@ -31,8 +31,14 @@ class DocumentReject(models.TransientModel):
description = fields.Text(string="Description", description = fields.Text(string="Description",
help='For adding reason for the rejection') help='For adding reason for the rejection')
document_id = fields.Many2one("document.approval", string="Document", document_id = fields.Many2one("document.approval", string="Document",
help="To track which document is get approved") help="To track which document is get approved"
)
def action_reject_document(self): def action_reject_document(self):
""" Function to reject document""" """ Function to reject document"""
self.document_id.state = "reject" self.document_id.state = "reject"
for rec in self.document_id.step_ids.filtered(
lambda x: x.approver_id.id == self.env.user.id):
rec.write({
'current_state': 'rejected',
})

38
document_approval/wizards/document_reject_views.xml

@ -7,6 +7,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form> <form>
<group> <group>
<field name="document_id" readonly="1"/>
<field name="description"/> <field name="description"/>
</group> </group>
<footer> <footer>
@ -19,22 +20,22 @@
</field> </field>
</record> </record>
<!--Form view for document reject reason for the menu item --> <!--Form view for document reject reason for the menu item -->
<record id="document_reject_form_view_readonly" model="ir.ui.view"> <!-- <record id="document_reject_form_view_readonly" model="ir.ui.view">-->
<field name="name">document.reject.form.view</field> <!-- <field name="name">document.reject.form.view</field>-->
<field name="model">document.reject</field> <!-- <field name="model">document.reject</field>-->
<field name="arch" type="xml"> <!-- <field name="arch" type="xml">-->
<form create="0"> <!-- <form create="0">-->
<sheet> <!-- <sheet>-->
<group> <!-- <group>-->
<group> <!-- <group>-->
<field name="document_id" readonly="1"/> <!-- <field name="document_id" readonly="1"/>-->
<field name="description" readonly="1"/> <!-- <field name="description"/>-->
</group> <!-- </group>-->
</group> <!-- </group>-->
</sheet> <!-- </sheet>-->
</form> <!-- </form>-->
</field> <!-- </field>-->
</record> <!-- </record>-->
<!-- Tree view for document reject reason --> <!-- Tree view for document reject reason -->
<record id="document_reject_form_view_tree" model="ir.ui.view"> <record id="document_reject_form_view_tree" model="ir.ui.view">
<field name="name">document.reject.view.tree</field> <field name="name">document.reject.view.tree</field>
@ -51,9 +52,8 @@
model="ir.actions.act_window"> model="ir.actions.act_window">
<field name="name">Document Reject</field> <field name="name">Document Reject</field>
<field name="res_model">document.reject</field> <field name="res_model">document.reject</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree</field>
<field name="view_ids" eval="[(5, 0, 0), <field name="view_ids" eval="[(5, 0, 0),
(0,0,{'view_mode':'tree', 'view_id': ref('document_reject_form_view_tree')}), (0,0,{'view_mode':'tree', 'view_id': ref('document_reject_form_view_tree')})]"/>
(0,0,{'view_mode':'form', 'view_id': ref('document_reject_form_view_readonly')}),]"/>
</record> </record>
</odoo> </odoo>

Loading…
Cancel
Save