oca-financial/odoo-bringout-oca-account-fiscal-rule-account_avatax_oca/account_avatax_oca/models/res_company.py
2025-08-29 15:43:04 +02:00

28 lines
881 B
Python

import logging
from odoo import _, models
_LOGGER = logging.getLogger(__name__)
class Company(models.Model):
_inherit = "res.company"
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
)
return res and res[0]