Skip to content

Commit

Permalink
[IMP] cmis_mail: pre-commit execution
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBinsfeld committed Aug 13, 2024
1 parent 2ddcdb0 commit ce3768f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
12 changes: 6 additions & 6 deletions cmis_mail/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@

{
"name": "Cmis Mail",
"description": """
"summary": """
This module allows to store attachments with CMIS from the mail
composer if the source model has at least one CMIS folder.
When attachments are added on the mail composer, a checkbox allows to
enable the CMIS storage. If the source model has more than one CMIS
folder, it is possible to specify in which one the attachments must be
stored.""",
'category': 'Document Management',
"category": "Document Management",
"version": "13.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV",
'website': 'http://alfodoo.org/',
"website": "https://alfodoo.org",
"depends": [
"mail",
"cmis_field",
],
"data": [
"wizards/mail_compose_message.xml",
],
'installable': True,
'images': [
'static/description/main_icon.png',
"installable": True,
"images": [
"static/description/main_icon.png",
],
}
17 changes: 6 additions & 11 deletions cmis_mail/wizards/mail_compose_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import base64
import os
import logging
import mimetypes
import os
from io import BytesIO

from odoo import _, api, fields, models
Expand Down Expand Up @@ -85,9 +85,9 @@ def _sanitize_query_arg(self, arg):
def _cmis_document_exists(self, cmis_parent_folder, file_name):
qfile_name = self._sanitize_query_arg(file_name)
cmis_qry = (
"SELECT cmis:objectId FROM cmis:document WHERE "
"IN_FOLDER('%s') AND cmis:name='%s'"
% (cmis_parent_folder.getObjectId(), qfile_name)
"SELECT cmis:objectId FROM cmis:document WHERE "
"IN_FOLDER('%s') AND cmis:name='%s'"
% (cmis_parent_folder.getObjectId(), qfile_name)
)
_logger.debug("Query CMIS with %s", cmis_qry)
rs = cmis_parent_folder.repository.query(cmis_qry)
Expand Down Expand Up @@ -118,18 +118,13 @@ def _save_attachments_in_cmis(self):
file_name,
cmis_parent_folder,
)
if (
cmis_document_exists
and self.cmis_duplicate_handler == "new_version"
):
if cmis_document_exists and self.cmis_duplicate_handler == "new_version":
doc = cmis_parent_folder.repository.getObject(
rs.getResults()[0].getObjectId()
)
self._update_cmis_document(buffer, file_name, doc)
if self.cmis_duplicate_handler == "error":
raise UserError(
_('Document "%s" already exists in CMIS') % (file_name)
)
raise UserError(_('Document "%s" already exists in CMIS') % (file_name))

def _create_cmis_document(self, buffer, file_name, cmis_parent_folder):
self.ensure_one()
Expand Down
25 changes: 19 additions & 6 deletions cmis_mail/wizards/mail_compose_message.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@
<field name="inherit_id" ref="mail.email_compose_message_wizard_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='template_id']/.." position="after">
<group name="cmis_mail_group" string="Save attachments in CMIS" attrs="{'invisible': ['|', ('attachment_ids', '=', []), ('allowed_cmis_folder_field_ids', '=', [])]}">
<group
name="cmis_mail_group"
string="Save attachments in CMIS"
attrs="{'invisible': ['|', ('attachment_ids', '=', []), ('allowed_cmis_folder_field_ids', '=', [])]}"
>
<group name="cmis_mail_group_left">
<field name="is_save_in_cmis_enabled" string="Enable" widget="boolean_toggle" />
<field name="cmis_folder_field_id"
domain="[('model', '=', model), ('ttype', '=', 'cmis_folder')]"
attrs="{'invisible': ['|', ('is_save_in_cmis_enabled', '=', False), ('is_multiple_cmis_fields', '=', False)]}" />
<field
name="is_save_in_cmis_enabled"
string="Enable"
widget="boolean_toggle"
/>
<field
name="cmis_folder_field_id"
domain="[('model', '=', model), ('ttype', '=', 'cmis_folder')]"
attrs="{'invisible': ['|', ('is_save_in_cmis_enabled', '=', False), ('is_multiple_cmis_fields', '=', False)]}"
/>
</group>
<group name="cmis_mail_group_right">
<field name="cmis_duplicate_handler" attrs="{'invisible': [('is_save_in_cmis_enabled', '=', False)]}" />
<field
name="cmis_duplicate_handler"
attrs="{'invisible': [('is_save_in_cmis_enabled', '=', False)]}"
/>
</group>
<group name="cmis_mail_group_invisible" invisible="1">
<field name="allowed_cmis_folder_field_ids" invisible="1" />
Expand Down

0 comments on commit ce3768f

Please sign in to comment.