Skip to content

[ADD] partner_fs_folder: documents folder on partners (Google Drive via fs_folder) - #2223

Draft
davidwul wants to merge 4 commits into
18.0from
18.0-partner-fs-folder
Draft

davidwul wants to merge 4 commits into
18.0from
18.0-partner-fs-folder

Conversation

@davidwul

@davidwul davidwul commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Fundraising needs a place to keep any kind of document about donors and sponsors (contracts, notes, pictures…), shared with the team in Google Drive and reachable from the partner in Odoo.

What it does

  • New module partner_fs_folder (depends on OCA fs_folder and queue_job).
  • Documents tab on the partner; the Create Folder button of the fs_folder widget creates the folder on demand (not for all 20k partners).
  • Folder layout:
    <salesperson>/<ref> - <name>                        partner without parent
    <parent folder>/<ref> - <name>                      contact, subsidiary (any depth)
    _Unassigned/...                                     no salesperson
    
    Only the salesperson of the top partner is used. The parent folder is created when needed.
  • When the salesperson, the parent, the name or the reference of a partner changes, a queue job moves or renames the folder (with its content) and updates the links, including the links of the folders inside it (found by path). The job is idempotent; a missing folder only logs a warning; an existing target folder fails the job without overwriting anything.
  • Access follows the partner: reading the folder needs read access on the partner, changing it needs write access.
  • Works around an fs_folder bug: folder creation reads fs.storage with the user's rights, so non-admin users get an AccessError (only over HTTP, from the second request on). Users must not get read access on fs.storage (it holds the credentials), so folder creation (also from the widget button, initialize_field_value) checks write access on the partner and then uses sudo. Candidate for an OCA fix.

Google Drive

There is no Google Drive backend in OCA storage. Drive is reached through rclone serve webdav on localhost (protocol webdav). Setup with a service account and a Shared Drive is in readme/CONFIGURE.md.

Known limits:

  • Files added in Drive show in Odoo after the rclone cache delay (~30 s).
  • Folders must not be moved or deleted in Drive (the link is the path). Users should be Contributor on the Shared Drive. If a folder is moved in Drive, uploads from Odoo may land in the old (trashed) folder during the cache delay.

Tests

  • 27 unit tests on a local storage: creation, unassigned, idempotence, moves with content, company/contact and subsidiary subfolders, contact attached/detached/changing company, renaming, missing or existing target folder, job deduplication, access rights.
  • Tested over HTTP with a non-admin user against a Google Drive test folder (rclone + OAuth): creation, upload, moves (~2 s per move).

Staging test plan

  1. Service account + Shared Drive "Partners" (service account Content manager, users Contributor).
  2. rclone remote with service_account_file and team_drive, rclone serve webdav as a systemd service on 127.0.0.1.
  3. fs.storage webdav, check method List File, options with timeout: 60, linked to the field Documents Folder.
  4. Check: creation by a fundraiser, upload from Odoo and from Drive, salesperson change on a company with contacts, queue jobs done.

🤖 Generated with Claude Code

Adds a Documents tab on partners with a folder of an external file system
(fs_storage, e.g. a Google Drive Shared Drive served over WebDAV by rclone).

- Folders are created on demand and filed by salesperson:
  <salesperson>/<ref> - <name> (_Unassigned without salesperson).
- Contacts of a company get a subfolder of the company folder.
- A queue job moves the folders when the salesperson or the company changes.
- Works around fs_folder reading fs.storage without sudo on folder creation.

Assisted-by: claude-opus-5-5, medium, claude-code
@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous finding is addressed and no new actionable issues were found.

Reviews (2) · Last reviewed commit: "[FIX] partner_fs_folder: update the link..." · Reviewed by Greptile

Comment thread partner_fs_folder/models/res_partner.py Resolved
… folder

The links of the subfolders were found through the company of the contacts.
A contact detached from the company (or moved to another one) before the job
moving the company folder ran kept a link to the old path: its folder was
moved with the company folder, and its own job then found nothing to move.

Assisted-by: claude-opus-5-5, medium, claude-code
@davidwul

Copy link
Copy Markdown
Contributor Author

@Danielgergely
this is a pr that aim at having gdrive as backend for storing document on partner (proposal for major/middle donor) or any other document and having a storage for employee document. The purpose would be to have the stage as a poc, so I can show this to Philippe, Sarah and Désriée. Could you merge this in stage after having a review that it's not introducing any unwanted behavior?

2 similar comments
@davidwul

Copy link
Copy Markdown
Contributor Author

@Danielgergely
this is a pr that aim at having gdrive as backend for storing document on partner (proposal for major/middle donor) or any other document and having a storage for employee document. The purpose would be to have the stage as a poc, so I can show this to Philippe, Sarah and Désriée. Could you merge this in stage after having a review that it's not introducing any unwanted behavior?

@davidwul

Copy link
Copy Markdown
Contributor Author

@Danielgergely
this is a pr that aim at having gdrive as backend for storing document on partner (proposal for major/middle donor) or any other document and having a storage for employee document. The purpose would be to have the stage as a poc, so I can show this to Philippe, Sarah and Désriée. Could you merge this in stage after having a review that it's not introducing any unwanted behavior?

@davidwul
davidwul marked this pull request as draft November 26, 2026 21:20
… for non-admin users

The button of the fs_folder widget (route /fs_folder/initialize) did not go
through the fs.storage access workaround: non-admin users got an AccessError.
It now creates the folder with action_create_document_folder. The module's own
Create Documents Folder button, a duplicate of the widget button, is removed.

Assisted-by: claude-opus-5-5, medium, claude-code
…rs with partners

- The folder of a partner with a parent (contact, subsidiary) is a subfolder
  of the parent folder, at any depth: a subsidiary company goes in the folder
  of its parent company. The commercial entity was used before, which left
  child companies under their own salesperson.
- When the name or the reference of a partner changes, its folder is renamed
  (by the same queue job as the moves), and the links of the folders inside
  it are updated.

Assisted-by: claude-opus-5-5, medium, claude-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant