Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/website_form_partner_specific_user_account/setup.py
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,
)
125 changes: 125 additions & 0 deletions website_form_partner_specific_user_account/README.rst
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.
2 changes: 2 additions & 0 deletions website_form_partner_specific_user_account/__init__.py
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 website_form_partner_specific_user_account/__manifest__.py
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,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
49 changes: 49 additions & 0 deletions website_form_partner_specific_user_account/controllers/main.py
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)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import website
13 changes: 13 additions & 0 deletions website_form_partner_specific_user_account/models/website.py
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."
)
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.
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 website_form_partner_specific_user_account/readme/DESCRIPTION.md
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.
6 changes: 6 additions & 0 deletions website_form_partner_specific_user_account/readme/ROADMAP.md
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.
Loading