-
-
Notifications
You must be signed in to change notification settings - Fork 726
[15.0][ADD] website_form_partner_specific_user_account #1152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AungKoKoLin1997
wants to merge
1
commit into
OCA:15.0
Choose a base branch
from
qrtl:15.0-add-website_partner_search
base: 15.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+853
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...form_partner_specific_user_account/odoo/addons/website_form_partner_specific_user_account
This file contains hidden or 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 @@ | ||
| ../../../../website_form_partner_specific_user_account |
This file contains hidden or 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,6 @@ | ||
| import setuptools | ||
|
|
||
| setuptools.setup( | ||
| setup_requires=['setuptools-odoo'], | ||
| odoo_addon=True, | ||
| ) |
This file contains hidden or 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,125 @@ | ||
| ========================================== | ||
| Website Form Partner Specific User Account | ||
| ========================================== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:2e500aa333d78504c4193278e7dcc9109518c14d7bb60052e41f51baa0777d78 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Beta | ||
| .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
| .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwebsite-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/website/tree/15.0/website_form_partner_specific_user_account | ||
| :alt: OCA/website | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/website-15-0/website-15-0-website_form_partner_specific_user_account | ||
| :alt: Translate me on Weblate | ||
| .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
| :target: https://runboat.odoo-community.org/builds?repo=OCA/website&target_branch=15.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module is intended for use when the “Specific User Account” setting | ||
| is enabled on a website. | ||
|
|
||
| It assigns the current website to partners used by website forms and | ||
| ensures partner lookup and assignment are restricted to that website. | ||
|
|
||
| In standard Odoo, partner resolution from website forms does not | ||
| consider the current website. When “Specific User Account” is enabled, | ||
| this may result in a partner from another website being assigned if the | ||
| same email address exists across multiple websites. | ||
|
|
||
| This module addresses this issue. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Configuration | ||
| ============= | ||
|
|
||
| To enable company-based partner isolation for website forms: | ||
|
|
||
| - Go to Website → Configuration → Websites. | ||
| - Open the website you want to configure. | ||
| - Enable Restrict Partner to Company. | ||
|
|
||
| - When enabled, partner lookup and creation from website forms will | ||
| be limited to the website’s company. | ||
| - Only partners belonging to that company will be matched, and any | ||
| newly created partners will be assigned to the same company. | ||
|
|
||
| Known issues / Roadmap | ||
| ====================== | ||
|
|
||
| Partner email is currently inferred from multiple possible form fields | ||
| (email_from, partner_email, email). | ||
|
|
||
| Note: The module assigns the current website to partners missing | ||
| ``website_id``, affecting not only newly created partners from website | ||
| forms but also existing partners when they are used in a website form. | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/website/issues>`_. | ||
| In case of trouble, please check there if your issue has already been reported. | ||
| If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
| `feedback <https://github.com/OCA/website/issues/new?body=module:%20website_form_partner_specific_user_account%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
|
||
| Do not contact contributors directly about support or help with technical issues. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Authors | ||
| ------- | ||
|
|
||
| * Quartile | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - ``Quartile <https://www.quartile.co>``\ \_\_: | ||
|
|
||
| - Aung Ko Ko Lin | ||
| - Yoshi Tashiro | ||
|
|
||
| Maintainers | ||
| ----------- | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
| mission is to support the collaborative development of Odoo features and | ||
| promote its widespread use. | ||
|
|
||
| .. |maintainer-yostashiro| image:: https://github.com/yostashiro.png?size=40px | ||
| :target: https://github.com/yostashiro | ||
| :alt: yostashiro | ||
| .. |maintainer-aungkokolin1997| image:: https://github.com/aungkokolin1997.png?size=40px | ||
| :target: https://github.com/aungkokolin1997 | ||
| :alt: aungkokolin1997 | ||
|
|
||
| Current `maintainers <https://odoo-community.org/page/maintainer-role>`__: | ||
|
|
||
| |maintainer-yostashiro| |maintainer-aungkokolin1997| | ||
|
|
||
| This module is part of the `OCA/website <https://github.com/OCA/website/tree/15.0/website_form_partner_specific_user_account>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or 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,2 @@ | ||
| from . import controllers | ||
| from . import models |
19 changes: 19 additions & 0 deletions
19
website_form_partner_specific_user_account/__manifest__.py
This file contains hidden or 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,19 @@ | ||
| # Copyright 2025 Quartile (https://www.quartile.co) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| { | ||
| "name": "Website Form Partner Specific User Account", | ||
| "summary": ( | ||
| "Restrict website form partner lookup to the current website " | ||
| "when Specific User Account is enabled" | ||
| ), | ||
| "version": "15.0.1.0.0", | ||
| "category": "Website", | ||
| "license": "AGPL-3", | ||
| "author": "Quartile, Odoo Community Association (OCA)", | ||
| "website": "https://github.com/OCA/website", | ||
| "depends": ["website"], | ||
| "data": ["views/website_views.xml"], | ||
| "maintainers": ["yostashiro", "aungkokolin1997"], | ||
| "installable": True, | ||
| } | ||
1 change: 1 addition & 0 deletions
1
website_form_partner_specific_user_account/controllers/__init__.py
This file contains hidden or 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 main |
49 changes: 49 additions & 0 deletions
49
website_form_partner_specific_user_account/controllers/main.py
This file contains hidden or 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,49 @@ | ||
| # Copyright 2025 Quartile (https://www.quartile.co) | ||
| # License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo.addons.website.controllers.form import WebsiteForm | ||
|
|
||
|
|
||
| class WebsiteForm(WebsiteForm): | ||
| def insert_record(self, request, model, values, custom, meta=None): | ||
| website = request.website | ||
| if not website.specific_user_account: | ||
| return super().insert_record(request, model, values, custom, meta) | ||
| partner_id = values.get("partner_id") | ||
| if not partner_id: | ||
| return super().insert_record(request, model, values, custom, meta) | ||
| Partner = request.env["res.partner"].sudo() | ||
| partner = Partner.browse(partner_id) | ||
| if not partner: | ||
| return super().insert_record(request, model, values, custom, meta) | ||
| email = ( | ||
| values.get("email_from") | ||
| or values.get("partner_email") | ||
| or values.get("email") | ||
| ) | ||
| # Intended for newly created partners, but applies to any partner without website_id | ||
| if not partner.website_id: | ||
| partner.website_id = website.id | ||
| # Intended for newly created partners, but applies to any partner without company_id | ||
| if not partner.company_id and website.restrict_partner_to_company: | ||
| partner.company_id = website.company_id.id | ||
| if email and partner.website_id != website: | ||
| domain = [ | ||
| ("email", "=", email), | ||
| ("website_id", "=", website.id), | ||
| ] | ||
| if website.restrict_partner_to_company: | ||
| domain.append(("company_id", "=", website.company_id.id)) | ||
| website_partner = Partner.search(domain, limit=1) | ||
| if not website_partner and values.get("partner_name"): | ||
| vals = { | ||
| "email": email, | ||
| "name": values.get("partner_name"), | ||
| "website_id": website.id, | ||
| } | ||
| if website.restrict_partner_to_company: | ||
| vals["company_id"] = website.company_id.id | ||
| website_partner = Partner.create(vals) | ||
| if website_partner: | ||
| values["partner_id"] = website_partner.id | ||
| return super().insert_record(request, model, values, custom, meta) |
This file contains hidden or 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 website |
13 changes: 13 additions & 0 deletions
13
website_form_partner_specific_user_account/models/website.py
This file contains hidden or 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,13 @@ | ||
| # Copyright 2025 Quartile (https://www.quartile.co) | ||
| # License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class Website(models.Model): | ||
| _inherit = "website" | ||
|
|
||
| restrict_partner_to_company = fields.Boolean( | ||
| help="When enabled, partner lookup and creation from website forms " | ||
| "are restricted to the website's company." | ||
| ) |
7 changes: 7 additions & 0 deletions
7
website_form_partner_specific_user_account/readme/CONFIGURE.md
This file contains hidden or 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,7 @@ | ||
| To enable company-based partner isolation for website forms: | ||
|
|
||
| - Go to Website → Configuration → Websites. | ||
| - Open the website you want to configure. | ||
| - Enable Restrict Partner to Company. | ||
| - When enabled, partner lookup and creation from website forms will be limited to the website’s company. | ||
| - Only partners belonging to that company will be matched, and any newly created partners will be assigned to the same company. |
4 changes: 4 additions & 0 deletions
4
website_form_partner_specific_user_account/readme/CONTRIBUTORS.md
This file contains hidden or 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,4 @@ | ||
| * `Quartile <https://www.quartile.co>`__: | ||
|
|
||
| * Aung Ko Ko Lin | ||
| * Yoshi Tashiro |
12 changes: 12 additions & 0 deletions
12
website_form_partner_specific_user_account/readme/DESCRIPTION.md
This file contains hidden or 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,12 @@ | ||
| This module is intended for use when the “Specific User Account” setting is enabled | ||
| on a website. | ||
|
|
||
| It assigns the current website to partners used by website forms and ensures partner | ||
| lookup and assignment are restricted to that website. | ||
|
|
||
| In standard Odoo, partner resolution from website forms does not consider the | ||
| current website. When “Specific User Account” is enabled, this may result in a | ||
| partner from another website being assigned if the same email address exists | ||
| across multiple websites. | ||
|
|
||
| This module addresses this issue. |
This file contains hidden or 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,6 @@ | ||
| Partner email is currently inferred from multiple possible form fields | ||
| (email_from, partner_email, email). | ||
|
|
||
| Note: The module assigns the current website to partners missing `website_id`, affecting | ||
| not only newly created partners from website forms but also existing partners when they | ||
| are used in a website form. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.