onlyoffice_odoo icon indicating copy to clipboard operation
onlyoffice_odoo copied to clipboard

Creation of New OnlyOffice Document Without Workspace Selection (v17)

Open wickeddoc87 opened this issue 1 year ago • 1 comments

Description:

When attempting to create a new OnlyOffice document within Odoo(17) Documents without selecting a workspace, the operation fails due to an SQL constraint violation error. This issue arises because the folder_id column in the documents_document table cannot be null, but the creation process attempts to insert a new record without specifying this required field. This behavior not only prevents the creation of new documents but also leads to a poor user experience due to the lack of a clear requirement or validation message prompting the user to select a workspace.

Steps to Reproduce:

  • Navigate to Odoo Documents.
  • Attempt to create a new OnlyOffice document without selecting a workspace/folder.
  • Observe the error as the operation fails.

Expected Behavior: The system should either:

  • Prevent the user from attempting to create a new document without first selecting a workspace, by disabling the creation button or showing a validation message.
  • Automatically assign a default workspace if none is selected to ensure the folder_id constraint is satisfied.

Actual Behavior: Attempting to create a new OnlyOffice document without selecting a workspace results in a SQL constraint violation error due to the folder_id column being null. The error message is as follows:

2024-02-18 16:18:28,578 47 ERROR test odoo.sql_db: bad query: INSERT INTO "documents_document" ("active", "attachment_id", "create_date", "create_uid", "folder_id", "is_editable_attachment", "name", "owner_id", "type", "write_date", "write_uid") VALUES (true, 39, '2024-02-18 16:18:28.545865', 2, NULL, false, 'Neues Dokument.docx', 2, 'empty', '2024-02-18 16:18:28.545865', 2) RETURNING "id"
ERROR: null value in column "folder_id" of relation "documents_document" violates not-null constraint
DETAIL:  Failing row contains (5, 39, null, null, null, 2, null, null, null, null, 2, 2, null, null, null, Neues Dokument.docx, null, null, null, empty, f, null, t, 2024-02-18 16:18:28.545865, 2024-02-18 16:18:28.545865, null).
 
2024-02-18 16:18:28,579 47 ERROR test odoo.addons.onlyoffice_odoo_documents.controllers.controllers: Failed to create document null value in column "folder_id" of relation "documents_document" violates not-null constraint
DETAIL:  Failing row contains (5, 39, null, null, null, 2, null, null, null, null, 2, 2, null, null, null, Neues Dokument.docx, null, null, null, empty, f, null, t, 2024-02-18 16:18:28.545865, 2024-02-18 16:18:28.545865, null).
 
Traceback (most recent call last):
  File "/mnt/custom-addons/foreign/onlyoffice_odoo_documents/controllers/controllers.py", line 38, in post_file_create
    document = request.env["documents.document"].create(data)
  File "<decorator-gen-166>", line 2, in create
  File "/mnt/odoo-server/odoo/api.py", line 414, in _model_create_multi
    return create(self, [arg])
  File "/mnt/enterprise-addons/documents_spreadsheet/models/documents_document.py", line 50, in create
    documents = super().create(vals_list)
  File "<decorator-gen-162>", line 2, in create
  File "/mnt/odoo-server/odoo/api.py", line 415, in _model_create_multi
    return create(self, arg)
  File "/mnt/enterprise-addons/documents/models/documents_document.py", line 515, in create
    documents = super().create(vals_list)
  File "<decorator-gen-128>", line 2, in create
  File "/mnt/odoo-server/odoo/api.py", line 415, in _model_create_multi
    return create(self, arg)
  File "/mnt/odoo-server/addons/mail/models/mail_thread.py", line 259, in create
    threads = super(MailThread, self).create(vals_list)
  File "<decorator-gen-12>", line 2, in create
  File "/mnt/odoo-server/odoo/api.py", line 415, in _model_create_multi
    return create(self, arg)
  File "/mnt/odoo-server/odoo/models.py", line 4601, in create
    records = self._create(data_list)
  File "/mnt/odoo-server/odoo/models.py", line 4789, in _create
    cr.execute(SQL(
  File "/mnt/odoo-server/odoo/sql_db.py", line 332, in execute
    res = self._obj.execute(query, params)
psycopg2.errors.NotNullViolation: null value in column "folder_id" of relation "documents_document" violates not-null constraint
DETAIL:  Failing row contains (5, 39, null, null, null, 2, null, null, null, null, 2, 2, null, null, null, Neues Dokument.docx, null, null, null, empty, f, null, t, 2024-02-18 16:18:28.545865, 2024-02-18 16:18:28.545865, null).

Possible Solutions:

  • Implement front-end validation to ensure a workspace is selected before allowing the user to proceed with document creation.
  • Modify the document creation logic to handle cases where no workspace is selected, possibly by assigning a default workspace.

Additional Information:

  • Odoo Version: 17 Enterprise
  • OnlyOffice Documents Connector Version: 2.1.0

wickeddoc87 avatar Feb 18 '24 16:02 wickeddoc87