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
119 changes: 119 additions & 0 deletions website_sale_tax_selection/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==========================
Website Sale Tax Selection
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a8f324112977f5f682654a32731f3c23c5baf72bfe07912f7c1aabce9aada540
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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%2Fe--commerce-lightgray.png?logo=github
:target: https://github.com/OCA/e-commerce/tree/19.0/website_sale_tax_selection
:alt: OCA/e-commerce
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/e-commerce-19-0/e-commerce-19-0-website_sale_tax_selection
: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/e-commerce&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module lets a website partner specify how product prices are
displayed in e-commerce: tax excluded, tax included, or the standard
website behavior when no partner value is set.

**Table of contents**

.. contents::
:local:

Configuration
=============

To specify a tax display preference for a commercial entity:

1. Go to **Contacts** and open the company or commercial partner.

2. In the sales section, set **Website Tax Display** to one of:

- **Tax Excluded**
- **Tax Included**

Leave the field empty to use the standard website tax display behavior.

For contacts linked to a company, the value is managed on the commercial
entity and synchronized to its contacts.

Usage
=====

When browsing the e-commerce website, the module checks the current
website user partner.

If that partner has a **Website Tax Display** value from its commercial
entity, website prices are displayed with that tax mode. If no value is
set, Odoo keeps the standard website tax display behavior.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/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/e-commerce/issues/new?body=module:%20website_sale_tax_selection%0Aversion:%2019.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
-------

* Camptocamp

Contributors
------------

- `Camptocamp <https://www.camptocamp.com>`__:

- Maksym Yankin

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-yankinmax| image:: https://github.com/yankinmax.png?size=40px
:target: https://github.com/yankinmax
:alt: yankinmax

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-yankinmax|

This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/19.0/website_sale_tax_selection>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions website_sale_tax_selection/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions website_sale_tax_selection/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2026 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Website Sale Tax Selection",
"summary": "Select e-commerce tax display by website partner",
"version": "19.0.1.0.0",
"development_status": "Beta",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["yankinmax"],
"license": "AGPL-3",
"depends": ["website_sale"],
"data": [
"views/res_partner_views.xml",
"views/res_config_settings_views.xml",
],
"installable": True,
}
32 changes: 32 additions & 0 deletions website_sale_tax_selection/i18n/website_sale_tax_selection.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_tax_selection
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-06-30 00:00+0000\n"
"PO-Revision-Date: 2026-06-30 00:00+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: website_sale_tax_selection
#: model:ir.model.fields,field_description:website_sale_tax_selection.field_res_partner__website_show_line_subtotals_tax_selection
#: model:ir.model.fields,field_description:website_sale_tax_selection.field_res_users__website_show_line_subtotals_tax_selection
msgid "Website Tax Display"
msgstr ""

#. module: website_sale_tax_selection
#: model:ir.model.fields.selection,name:website_sale_tax_selection.selection__res_partner__website_show_line_subtotals_tax_selection__tax_excluded
msgid "Tax Excluded"
msgstr ""

#. module: website_sale_tax_selection
#: model:ir.model.fields.selection,name:website_sale_tax_selection.selection__res_partner__website_show_line_subtotals_tax_selection__tax_included
msgid "Tax Included"
msgstr ""
5 changes: 5 additions & 0 deletions website_sale_tax_selection/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2026 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import res_partner
from . import website
28 changes: 28 additions & 0 deletions website_sale_tax_selection/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2026 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

website_show_line_subtotals_tax_selection = fields.Selection(
selection=[
("tax_excluded", "Tax Excluded"),
("tax_included", "Tax Included"),
],
string="Website Tax Display",
default="tax_excluded",
help=(
"Specify how product prices are displayed on the website for this "
"commercial entity. Leave empty to use the website setting."
),
)

@api.model
def _commercial_fields(self):
"""Add website tax display to commercial fields."""
return super()._commercial_fields() + [
"website_show_line_subtotals_tax_selection"
]
38 changes: 38 additions & 0 deletions website_sale_tax_selection/models/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2026 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo.http import request


class Website(models.Model):
_inherit = "website"

# OVERRIDE: make the tax display dynamic so the current website partner can
# specify a value that takes precedence over the standard website behavior.
show_line_subtotals_tax_selection = fields.Selection(
store=False,
)
Comment thread
yankinmax marked this conversation as resolved.

@api.depends("company_id.account_fiscal_country_id")
@api.depends_context("uid")
def _compute_show_line_subtotals_tax_selection(self):
# OVERRIDE: apply the current website partner tax display preference,
# when set, on top of the standard website behavior.
partner = self._get_current_website_tax_selection_partner()
if partner_tax_selection := partner.website_show_line_subtotals_tax_selection:
for website in self:
website.show_line_subtotals_tax_selection = partner_tax_selection
else:
return super()._compute_show_line_subtotals_tax_selection()
Comment on lines +17 to +27

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will never trigger if partner.website_show_line_subtotals_tax_selection gets updated during the session 🤔

I would add something like this write override in res.partner:

def write(self, vals):
    result = super().write(vals)
    if "website_show_line_subtotals_tax_selection" in vals:
        # The website's non-stored compute reads this field through the
        # current request/env user's partner, a path `@api.depends` can't
        # express, so its cache is never auto-invalidated on this write.
        self.env["website"].invalidate_model(
            ["show_line_subtotals_tax_selection"]
        )
    return result


def _get_current_website_tax_selection_partner(self):
"""Return the partner used to resolve website tax display preference.

:return: Current HTTP request user partner, or environment user partner
when running outside an HTTP request.
:rtype: res.partner
"""
if request and request.env:
return request.env.user.partner_id
return self.env.user.partner_id
3 changes: 3 additions & 0 deletions website_sale_tax_selection/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
12 changes: 12 additions & 0 deletions website_sale_tax_selection/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
To specify a tax display preference for a commercial entity:

1. Go to **Contacts** and open the company or commercial partner.
2. In the sales section, set **Website Tax Display** to one of:

- **Tax Excluded**
- **Tax Included**

Leave the field empty to use the standard website tax display behavior.

For contacts linked to a company, the value is managed on the commercial entity
and synchronized to its contacts.
2 changes: 2 additions & 0 deletions website_sale_tax_selection/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Camptocamp](https://www.camptocamp.com):
- Maksym Yankin
3 changes: 3 additions & 0 deletions website_sale_tax_selection/readme/DESCRIPTION.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description needs to be updated. Stating it will visually disable the website_tax_inclusion_setting is IMHO crucial

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module lets a website partner specify how product prices are displayed in
e-commerce: tax excluded, tax included, or the standard website behavior when no
partner value is set.
6 changes: 6 additions & 0 deletions website_sale_tax_selection/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
When browsing the e-commerce website, the module checks the current website
user partner.

If that partner has a **Website Tax Display** value from its commercial entity,
website prices are displayed with that tax mode. If no value is set, Odoo keeps
the standard website tax display behavior.
Loading
Loading