From 2188e2f184ef1b749ae6be059654df808f091921 Mon Sep 17 00:00:00 2001 From: tirth-osi Date: Mon, 4 Nov 2024 04:19:36 -0700 Subject: [PATCH 1/3] [ADD] Generic avatax oca rounding --- osi_avatax_rounding_fix/__init__.py | 1 + osi_avatax_rounding_fix/__manifest__.py | 18 ++++++++++++++++++ osi_avatax_rounding_fix/models/__init__.py | 1 + osi_avatax_rounding_fix/models/account_tax.py | 14 ++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 osi_avatax_rounding_fix/__init__.py create mode 100644 osi_avatax_rounding_fix/__manifest__.py create mode 100644 osi_avatax_rounding_fix/models/__init__.py create mode 100644 osi_avatax_rounding_fix/models/account_tax.py diff --git a/osi_avatax_rounding_fix/__init__.py b/osi_avatax_rounding_fix/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/osi_avatax_rounding_fix/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/osi_avatax_rounding_fix/__manifest__.py b/osi_avatax_rounding_fix/__manifest__.py new file mode 100644 index 000000000..a686498da --- /dev/null +++ b/osi_avatax_rounding_fix/__manifest__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +{ # noqa + "name": "Proslat Accounting Enhancement", + "summary": "Proslat Accounting Enhancement", + "version": "17.0.1.0.0", + "author": "Open Source Integrators", + "category": "Accounting", + "depends": [ + 'account_avatax_sale_oca', + ], + "data": [ + ], + "application": False, + "installable": True, + "auto_install": False +} + diff --git a/osi_avatax_rounding_fix/models/__init__.py b/osi_avatax_rounding_fix/models/__init__.py new file mode 100644 index 000000000..b60632946 --- /dev/null +++ b/osi_avatax_rounding_fix/models/__init__.py @@ -0,0 +1 @@ +from . import account_tax diff --git a/osi_avatax_rounding_fix/models/account_tax.py b/osi_avatax_rounding_fix/models/account_tax.py new file mode 100644 index 000000000..bad19bb62 --- /dev/null +++ b/osi_avatax_rounding_fix/models/account_tax.py @@ -0,0 +1,14 @@ +from odoo import api, fields, models + + +class AccountTax(models.Model): + _inherit = 'account.tax' + + @api.model + def _prepare_tax_totals(self, base_lines, currency, tax_lines=None, is_company_currency_requested=False): + vals = super()._prepare_tax_totals(base_lines, currency, tax_lines, is_company_currency_requested) + if vals.get('amount_untaxed'): + vals['amount_untaxed'] = round(vals['amount_untaxed'], 2) + if vals.get('amount_total'): + vals['amount_total'] = round(vals['amount_total'], 2) + return vals From 21711f6e6c91fb414941f526b7f2ca4bec5ea21c Mon Sep 17 00:00:00 2001 From: tirth-osi Date: Mon, 4 Nov 2024 04:27:16 -0700 Subject: [PATCH 2/3] [FIX] Name Change --- osi_avatax_rounding_fix/__manifest__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osi_avatax_rounding_fix/__manifest__.py b/osi_avatax_rounding_fix/__manifest__.py index a686498da..aa453a824 100644 --- a/osi_avatax_rounding_fix/__manifest__.py +++ b/osi_avatax_rounding_fix/__manifest__.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- { # noqa - "name": "Proslat Accounting Enhancement", - "summary": "Proslat Accounting Enhancement", + "name": "OSI Avatax Rounding Fix", + "summary": "OSI Avatax Rounding Fix", "version": "17.0.1.0.0", "author": "Open Source Integrators", "category": "Accounting", From d815dc0b7d4ac982834a465ec6958092b58e6816 Mon Sep 17 00:00:00 2001 From: RLeeOSI <51208020+RLeeOSI@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:50:50 -0800 Subject: [PATCH 3/3] [REF] pre-commit --- osi_avatax_rounding_fix/README.rst | 23 +++++++++++++++++++ osi_avatax_rounding_fix/__manifest__.py | 15 ++++++------ osi_avatax_rounding_fix/models/account_tax.py | 20 +++++++++------- 3 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 osi_avatax_rounding_fix/README.rst diff --git a/osi_avatax_rounding_fix/README.rst b/osi_avatax_rounding_fix/README.rst new file mode 100644 index 000000000..abfc6e930 --- /dev/null +++ b/osi_avatax_rounding_fix/README.rst @@ -0,0 +1,23 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======== +Overview +======== + +* Correct rounding issues on avatax lines + + +======= +Credits +======= + +* Open Source Integrators + + +Contributors +------------ + +* Tirth Patel +* Raphael Lee diff --git a/osi_avatax_rounding_fix/__manifest__.py b/osi_avatax_rounding_fix/__manifest__.py index aa453a824..7430c66b1 100644 --- a/osi_avatax_rounding_fix/__manifest__.py +++ b/osi_avatax_rounding_fix/__manifest__.py @@ -1,18 +1,17 @@ -# -*- coding: utf-8 -*- - -{ # noqa +{ # noqa "name": "OSI Avatax Rounding Fix", "summary": "OSI Avatax Rounding Fix", "version": "17.0.1.0.0", + "license": "LGPL-3", "author": "Open Source Integrators", + "maintainer": "Open Source Integrators", + "website": "https://github.com/ursais/osi-addons", "category": "Accounting", "depends": [ - 'account_avatax_sale_oca', - ], - "data": [ + "account_avatax_sale_oca", ], + "data": [], "application": False, "installable": True, - "auto_install": False + "auto_install": False, } - diff --git a/osi_avatax_rounding_fix/models/account_tax.py b/osi_avatax_rounding_fix/models/account_tax.py index bad19bb62..e091ebcbf 100644 --- a/osi_avatax_rounding_fix/models/account_tax.py +++ b/osi_avatax_rounding_fix/models/account_tax.py @@ -1,14 +1,18 @@ -from odoo import api, fields, models +from odoo import api, models class AccountTax(models.Model): - _inherit = 'account.tax' + _inherit = "account.tax" @api.model - def _prepare_tax_totals(self, base_lines, currency, tax_lines=None, is_company_currency_requested=False): - vals = super()._prepare_tax_totals(base_lines, currency, tax_lines, is_company_currency_requested) - if vals.get('amount_untaxed'): - vals['amount_untaxed'] = round(vals['amount_untaxed'], 2) - if vals.get('amount_total'): - vals['amount_total'] = round(vals['amount_total'], 2) + def _prepare_tax_totals( + self, base_lines, currency, tax_lines=None, is_company_currency_requested=False + ): + vals = super()._prepare_tax_totals( + base_lines, currency, tax_lines, is_company_currency_requested + ) + if vals.get("amount_untaxed"): + vals["amount_untaxed"] = round(vals["amount_untaxed"], 2) + if vals.get("amount_total"): + vals["amount_total"] = round(vals["amount_total"], 2) return vals