Skip to content
Merged
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
113 changes: 113 additions & 0 deletions sale_custom_rounding/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
====================
Sale Custom Rounding
====================

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

.. |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%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/18.0/sale_custom_rounding
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_custom_rounding
: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/sale-workflow&target_branch=18.0
:alt: Try me on Runboat

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

This module allows to select a custom taxes rounding method in sale
orders.

**Table of contents**

.. contents::
:local:

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

To configure this module, you need to:

1. Go to a contact and select an option in the field "Tax Calculation
Rounding Method". This option will be selected by default in sale
orders in which this contact is set as the invoice address.
2. In the simplified view of a child contact, the "Tax Calculation
Rounding Method" field is only visible if the child contact is an
"Invoice Address".
3. If no option is selected in a sale order, the rounding method set in
the company configuration will be applied.
4. If a contact has child contacts, these child contacts will not
inherit the parent contact's rounding method.

Usage
=====

To use this module, you need to:

1. Go to the "Other Information" tab in a sale order to select the
rounding method in the "Tax Calculation Rounding Method" field. If no
option is selected, the rounding method set in the company
configuration will be applied.
2. If the customer has a value in its "Tax Calculation Rounding Method"
field, it will be set in the sale order when this contact is selected
as the invoice address. This option can be changed in the sale order.
3. When multiple sale orders are selected to be invoiced together, the
"Tax Calculation Rounding Method" is used as a grouping field (i.e.
if four sale orders are selected, two of them have the "per line"
rounding method and the other two have the "global rounding" method,
two invoices will be generated).

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

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

* Sygel

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

- `Sygel <https://sygel.es>`__:

- Manuel Regidor <manuel.regidor@sygel.es>

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.

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/18.0/sale_custom_rounding>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions sale_custom_rounding/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
18 changes: 18 additions & 0 deletions sale_custom_rounding/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Sale Custom Rounding",
"summary": "Custom taxes rounding method in sale orders",
"version": "18.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/sale-workflow",
"author": "Sygel, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["account_invoice_custom_rounding", "sale"],
"data": [
"views/sale_views.xml",
],
}
46 changes: 46 additions & 0 deletions sale_custom_rounding/i18n/sale_custom_rounding.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_custom_rounding
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \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: sale_custom_rounding
#: model:ir.model.fields,help:sale_custom_rounding.field_sale_order__tax_calculation_rounding_method
msgid ""
"How total tax amount is computed. If no value selected, the method defined "
"in the company is used."
msgstr ""

#. module: sale_custom_rounding
#: model:ir.model.fields.selection,name:sale_custom_rounding.selection__sale_order__tax_calculation_rounding_method__round_globally
msgid "Round Globally"
msgstr ""

#. module: sale_custom_rounding
#: model:ir.model.fields.selection,name:sale_custom_rounding.selection__sale_order__tax_calculation_rounding_method__round_per_line
msgid "Round per Line"
msgstr ""

#. module: sale_custom_rounding
#: model:ir.model,name:sale_custom_rounding.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: sale_custom_rounding
#: model:ir.model,name:sale_custom_rounding.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: sale_custom_rounding
#: model:ir.model.fields,field_description:sale_custom_rounding.field_sale_order__tax_calculation_rounding_method
msgid "Tax Calculation Rounding Method"
msgstr ""
5 changes: 5 additions & 0 deletions sale_custom_rounding/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import sale_order
from . import sale_order_line
from . import account_tax
21 changes: 21 additions & 0 deletions sale_custom_rounding/models/account_tax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class AccountTax(models.Model):
_inherit = "account.tax"

def _prepare_base_line_for_taxes_computation(self, record, **kwargs):
res = super()._prepare_base_line_for_taxes_computation(record, **kwargs)

# Protect against fake calls with record = None
if record and record._name == "sale.order.line":
order = record.order_id
res["tax_calculation_rounding_method"] = (
order.tax_calculation_rounding_method_override
or order.company_id.tax_calculation_rounding_method
)

return res
44 changes: 44 additions & 0 deletions sale_custom_rounding/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2024 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

tax_calculation_rounding_method_override = fields.Selection(
[
("round_per_line", "Round per Line"),
("round_globally", "Round Globally"),
],
store=True,
readonly=False,
help="How total tax amount is computed. If no value selected, "
"the method defined in the company is used.",
)

@api.onchange("partner_id", "partner_invoice_id")
def _onchange_partner_rounding(self):
partner = self.partner_invoice_id or self.partner_id
self.tax_calculation_rounding_method_override = (
partner.tax_calculation_rounding_method or False
)

def _prepare_invoice(self):
vals = super()._prepare_invoice()
vals["tax_calculation_rounding_method"] = (
self._get_effective_rounding_method() or ""
)
return vals

def _get_invoice_grouping_keys(self):
return super()._get_invoice_grouping_keys() + [
"tax_calculation_rounding_method"
]

def _get_effective_rounding_method(self):
return (
self.tax_calculation_rounding_method_override
or self.company_id.tax_calculation_rounding_method
)
12 changes: 12 additions & 0 deletions sale_custom_rounding/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

@api.depends("order_id.tax_calculation_rounding_method_override")
def _compute_amount(self):
return super()._compute_amount()
3 changes: 3 additions & 0 deletions sale_custom_rounding/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 sale_custom_rounding/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
To configure this module, you need to:

1. Go to a contact and select an option in the field "Tax Calculation
Rounding Method". This option will be selected by default in sale
orders in which this contact is set as the invoice address.
2. In the simplified view of a child contact, the "Tax Calculation
Rounding Method" field is only visible if the child contact is an
"Invoice Address".
3. If no option is selected in a sale order, the rounding method set in
the company configuration will be applied.
4. If a contact has child contacts, these child contacts will not
inherit the parent contact's rounding method.
2 changes: 2 additions & 0 deletions sale_custom_rounding/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Sygel](https://sygel.es):
- Manuel Regidor \<manuel.regidor@sygel.es\>
2 changes: 2 additions & 0 deletions sale_custom_rounding/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows to select a custom taxes rounding method in sale
orders.
15 changes: 15 additions & 0 deletions sale_custom_rounding/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
To use this module, you need to:

1. Go to the "Other Information" tab in a sale order to select the
rounding method in the "Tax Calculation Rounding Method" field. If
no option is selected, the rounding method set in the company
configuration will be applied.
2. If the customer has a value in its "Tax Calculation Rounding Method"
field, it will be set in the sale order when this contact is
selected as the invoice address. This option can be changed in the
sale order.
3. When multiple sale orders are selected to be invoiced together, the
"Tax Calculation Rounding Method" is used as a grouping field (i.e.
if four sale orders are selected, two of them have the "per line"
rounding method and the other two have the "global rounding" method,
two invoices will be generated).
Binary file added sale_custom_rounding/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading