-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] installment: implemented the document upload request wizard
- Implemented document upload wizard - Modifies the new invoice creation
- Loading branch information
Showing
10 changed files
with
239 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,8 @@ | ||
from odoo import models | ||
import logging | ||
from odoo import fields, models | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class SalesOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
document_mapping = { | ||
"installment.nid": "National ID (NID)", | ||
"installment.salary_components": "Salary Components", | ||
"installment.bank_statement": "Bank Statement", | ||
"installment.bank_rate_letter": "Bank Rate Letter", | ||
"installment.rental_contract": "Rental Contract", | ||
"installment.ownership_contract": "Ownership Contract", | ||
} | ||
|
||
def action_upload_documents(self): | ||
workspace_name = "Installment" | ||
sub_folder = self.name | ||
existing_workspace = self.env["documents.folder"].search( | ||
[("name", "=", workspace_name)], limit=1 | ||
) | ||
if not existing_workspace: | ||
new_workspace = self.env["documents.folder"].create( | ||
{ | ||
"name": workspace_name, | ||
"parent_folder_id": None, | ||
"description": f"Workspace for {workspace_name}", | ||
"has_write_access": True, | ||
} | ||
) | ||
subfolder = self.env["documents.folder"].create( | ||
{ | ||
"name": sub_folder, | ||
"parent_folder_id": new_workspace.id, | ||
"description": f"Subfolder for {sub_folder} under {workspace_name}", | ||
"has_write_access": True, | ||
} | ||
) | ||
self._create_document_wizard_request(subfolder) | ||
|
||
else: | ||
existing_sub_folder = self.env["documents.folder"].search( | ||
[("name", "=", sub_folder)], limit=1 | ||
) | ||
if not existing_sub_folder: | ||
subfolder = self.env["documents.folder"].create( | ||
{ | ||
"name": sub_folder, | ||
"parent_folder_id": existing_workspace.id, | ||
"description": f"Subfolder for {sub_folder} under {workspace_name}", | ||
"has_write_access": True, | ||
} | ||
) | ||
self._create_document_wizard_request(subfolder) | ||
else: | ||
exiting_doc_list = self.env["documents.document"].search( | ||
[("folder_id", "=", existing_sub_folder.id)] | ||
) | ||
# Logic for validating docs in sub folder not exist then create | ||
unmatched_doc = [] | ||
for doc in exiting_doc_list: | ||
if doc.name not in self.document_mapping.values(): | ||
unmatched_doc.append(doc.name) | ||
for name in unmatched_doc: | ||
values = { | ||
"name": name, | ||
"owner_id": self.env.user.id, | ||
"partner_id": self.partner_id.id, | ||
"folder_id": subfolder.id, | ||
} | ||
self.env["documents.document"].create(values) | ||
|
||
def _get_document_list(self): | ||
config_param = self.env["ir.config_parameter"].sudo() | ||
# Building document required dictionary dynamically | ||
document = { | ||
key.split(".")[-1]: name | ||
for key, name in self.document_mapping.items() | ||
if config_param.get_param(key, default=False) | ||
} | ||
return document | ||
|
||
def _create_document_wizard_request(self, subfolder): | ||
document_required = self._get_document_list() | ||
for name in document_required.values(): | ||
values = { | ||
"name": name, | ||
"owner_id": self.env.user.id, | ||
"partner_id": self.partner_id.id, | ||
"folder_id": subfolder.id, | ||
} | ||
self.env["documents.document"].create(values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
installment.access_installment_installment,access_installment_installment,installment.model_installment_installment,base.group_user,1,1,1,1 | ||
installment.access_add_emi,access_add_emi,installment.model_add_emi,base.group_user,1,1,1,1 | ||
installment.access_add_emi,access_add_emi,installment.model_add_emi,base.group_user,1,1,1,1 | ||
installment.access_installment_document,access_installment_document,installment.model_installment_document,base.group_user,1,1,1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import add_emi | ||
from . import document_wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.