-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] add configuration to ignore warning avatax missing configuratio…
…n on specific companies
- Loading branch information
1 parent
7dc4cc5
commit c45856e
Showing
7 changed files
with
111 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
from . import account_tax | ||
from . import res_company | ||
from . import avatax_rest_api | ||
from . import res_config |
This file contains 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 |
---|---|---|
@@ -1,28 +1,39 @@ | ||
import logging | ||
|
||
from odoo import _, models | ||
from odoo import _, fields, models | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class Company(models.Model): | ||
_inherit = "res.company" | ||
|
||
allow_avatax_configuration = fields.Boolean( | ||
string="Active Avatax for this company", | ||
default=True, | ||
readonly=False, | ||
) | ||
|
||
def get_avatax_config_company(self): | ||
"""Returns the AvaTax configuration for the Company""" | ||
if self: | ||
self.ensure_one() | ||
AvataxConfig = self.env["avalara.salestax"] | ||
res = AvataxConfig.search( | ||
[("company_id", "=", self.id), ("disable_tax_calculation", "=", False)] | ||
) | ||
if len(res) > 1: | ||
_LOGGER.warning( | ||
_("Company %s has too many Avatax configurations!"), | ||
self.display_name, | ||
) | ||
if len(res) < 1: | ||
_LOGGER.warning( | ||
_("Company %s has no Avatax configuration."), self.display_name | ||
if self.allow_avatax_configuration: | ||
res = AvataxConfig.search( | ||
[ | ||
("company_id", "=", self.id), | ||
("disable_tax_calculation", "=", False), | ||
] | ||
) | ||
return res and res[0] | ||
if len(res) > 1: | ||
_LOGGER.warning( | ||
_("Company %s has too many Avatax configurations!"), | ||
self.display_name, | ||
) | ||
if len(res) < 1: | ||
_LOGGER.warning( | ||
_("Company %s has no Avatax configuration."), self.display_name | ||
) | ||
return res and res[0] | ||
return AvataxConfig |
This file contains 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,15 @@ | ||
# Copyright (c) 2024 Groupe Voltaire | ||
# @author Emilie SOUTIRAS <emilie.soutiras@groupevoltaire.com> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
allow_avatax_configuration = fields.Boolean( | ||
string="Active Avatax for this company", | ||
related="company_id.allow_avatax_configuration", | ||
readonly=False, | ||
) |
This file contains 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
This file contains 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
This file contains 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,38 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
~ # Copyright (c) 2024 Groupe Voltaire | ||
~ # @author Emilie SOUTIRAS <emilie.soutiras@groupevoltaire.com> | ||
~ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
--> | ||
<odoo> | ||
<record id="res_config_settings_view_form" model="ir.ui.view"> | ||
<field name="name">res.config.settings.view.form.inherit.product</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="product.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath | ||
expr="//div[@name='default_taxes_setting_container']" | ||
position="inside" | ||
> | ||
<div class="col-12 col-lg-6 o_setting_box" id="avatax_configuration"> | ||
<div class="o_setting_left_pane"> | ||
<field name="allow_avatax_configuration" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label for="allow_avatax_configuration" /> | ||
<span | ||
class="fa fa-lg fa-building-o" | ||
title="Values set here are company-specific." | ||
aria-label="Values set here are company-specific." | ||
groups="base.group_multi_company" | ||
role="img" | ||
/> | ||
<div class="text-muted"> | ||
Avoid the selection of multiple VAT taxes. | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |