-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] cmis_document: allow to search documents when linking to an exi…
…sting one. The source folders must be provided
- Loading branch information
Showing
7 changed files
with
294 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import mixins |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import cmis_document_link_src_folder_mixin |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2023 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
import json | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools.safe_eval import safe_eval | ||
|
||
|
||
class CmisDocumentLinkSrcFolderMixin(models.AbstractModel): | ||
_name = "cmis.document.link.src.folder.mixin" | ||
_description = "Allow to search files to link on parent record folders cmis" | ||
|
||
cmis_document_link_src_folders = fields.Char( | ||
compute='_compute_cmis_document_link_src_folders', | ||
) | ||
|
||
def _compute_cmis_document_link_src_folders(self): | ||
fnames = self._get_cmis_document_link_src_folders_fnames() | ||
for rec in self: | ||
folders = [] | ||
for fname in fnames: | ||
folder_value = safe_eval(f"rec.{fname}", globals_dict={ | ||
"rec": rec, | ||
}) | ||
if folder_value: | ||
folders.append(folder_value) | ||
rec.cmis_document_link_src_folders = json.dumps(folders) | ||
|
||
# maybe consider to add dynamically the field in the view | ||
# def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False): | ||
|
||
@api.model | ||
def _get_cmis_document_link_src_folders_fnames(self): | ||
""" | ||
Should return a list of field names linked to the current record: | ||
For example, if we have a cmis_document on a sale.order.line, and we want to display | ||
documents from the folder of a sale order, we would need to set "order_id.cmis_folder" | ||
Then it will be evaluated with "rec.order_id.cmis_folder" where rec is a sale.order.line | ||
""" | ||
raise NotImplementedError() |
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.