Saturday, May 31, 2025
2 changes · 18.0
Resolved issues and error corrections
This fix prevents unnecessary errors when changing a partner's commercial relationship if there are no related accounting entries to update. It keeps accountant-only safeguards in place when financial records are actually affected, while avoiding disruption for harmless partner updates.
Original PR description
commit 0a9c5fcfb9eb1b3532cd67e22b218f255f793091 introduced an automatic way to fix accounting entries when the commercial partner of a res.patrner would change. Only accountants should be doing that, but the error should be raised only if there exist some accounting entries Description of the issue/feature this PR addresses: Current behavior before PR: Desired behavior after PR is merged: --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Emails sent to a project address with attachments now create the related documents using the company of the project folder. This prevents failures in multi-company setups where the project folder belongs to a different company than the current system company.
Original PR description
**Issue:** When an email with an attachment was sent to a project alias (configured to create tasks and documents in a specific project), and the target project's Documents folder was explicitly…
**Issue:** When an email with an attachment was sent to a project alias (configured to create tasks and documents in a specific project), and the target project's Documents folder was explicitly owned by a company (`Company2`) distinct from the current system company (`Company1`), the alias creation process for the resulting documents would fail. The error message indicated a domain mismatch: "We could not create alias Inactive Alias because domain company1.com belongs to company YourCompany while the owner document belongs to company Company2." **Proposed Solution and Justification:** The chosen solution centralizes the `company_id` assignment for new documents within the `_get_document_vals` method of the `documents.mixin.DocumentMixin` abstract model. This method is the primary entry point for determining default values when any model inheriting `DocumentMixin` creates a linked `documents.document` record. The fix ensures that when `document_vals` are prepared, the `company_id` of the new document is explicitly pulled from the `company_id` of its designated `folder` (retrieved via `_get_document_folder()`). **Unit Test Placement Justification:** The accompanying unit test has been placed within the `documents_project` module for the following reasons: * **Module Scope:** The bug specifically manifests when the 'Project' and 'Documents' modules interact via email aliases, a workflow directly supported by the `documents_project` module. Placing the test here ensures it covers the integrated functionality. * **Dependency Guarantee:** By placing it in `documents_project`, the test runner ensures that both `project` and `documents` modules (and their dependencies) are installed and loaded, providing the correct environment to reproduce and verify the fix for the multi-module interaction. * **Functional Relevance:** The test setup mirrors a real-world user workflow (creating a project alias for tasks and documents) that is enabled by the `documents_project` module. **Steps to reproduce:** 1. Install the 'Project' and 'Documents' modules on a fresh Odoo 18 database with demo data. 2. Create two distinct companies via the UI (e.g., Company1, Company2). 3. Ensure each company has a distinct alias domain configured (e.g. @company1domain.com for Company1, @company2domain.com for Company2). 4. Switch to 'Company2'. In the Projects app, create a new project in the Kanban view. 5. During the project configuration wizard, fill out the "Create tasks by sending an email to" field, creating an email alias for the project (e.g. `project@company2domain.com`). 6. In the project settings, ensure the project is restricted to 'Company2' only. 7. Go to 'Documents' -> 'Projects'. Find the folder specific to the newly created project and also restrict it to 'Company2' only. 8. Send a test email with a PDF attachment to the project's alias (e.g. `project@company2domain.com`). 9. Observe the traceback in the server logs, showing the company mismatch error. opw-4727873