Skip to content

Commit

Permalink
String parameter on UserError requires translation.
Browse files Browse the repository at this point in the history
  • Loading branch information
atchuthan committed Jan 7, 2021
1 parent f6d5b53 commit 96ea62b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions account_avatax_exemption/models/avalara_salestax.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import requests

from odoo import fields, models
from odoo import _, fields, models
from odoo.exceptions import UserError

from odoo.addons.account_avatax.models.avatax_rest_api import AvaTaxRESTService
Expand Down Expand Up @@ -288,7 +288,7 @@ def download_exemptions(self):
self = self.search([("exemption_export", "=", True)], limit=1)
if not self.exemption_export:
raise UserError(
"Avatax Exemption export is disabled in Avatax configuration"
_("Avatax Exemption export is disabled in Avatax configuration")
)

avatax_restpoint = AvaTaxRESTService(config=self)
Expand Down
28 changes: 14 additions & 14 deletions account_avatax_exemption/models/exemption.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def create(self, vals):

def export_exemption_rule(self):
if self.filtered(lambda x: x.state != "draft"):
raise UserError("Rule is not in Draft state to Export Custom Rule")
raise UserError(_("Rule is not in Draft state to Export Custom Rule"))
self.write({"state": "progress"})
avalara_salestax = (
self.env["avalara.salestax"]
Expand All @@ -68,7 +68,7 @@ def export_exemption_rule(self):
)
if not avalara_salestax:
raise UserError(
"Avatax Exemption Rule export is disabled in Avatax configuration"
_("Avatax Exemption Rule export is disabled in Avatax configuration")
)
avalara_salestax.export_new_exemption_rules(
rules=self.filtered(lambda x: not x.avatax_id)
Expand All @@ -78,7 +78,7 @@ def export_exemption_rule(self):
def cancel_exemption_rule(self):
self.ensure_one()
if self.state != "done":
raise UserError("Rule is not in Done state to Cancel Custom Rule")
raise UserError(_("Rule is not in Done state to Cancel Custom Rule"))
self.write({"state": "progress"})
avalara_salestax = (
self.env["avalara.salestax"]
Expand All @@ -87,7 +87,7 @@ def cancel_exemption_rule(self):
)
if not avalara_salestax:
raise UserError(
"Avatax Exemption Rule export is disabled in Avatax configuration"
_("Avatax Exemption Rule export is disabled in Avatax configuration")
)
avalara_salestax.with_delay(
priority=5, max_retries=2, description="Cancel Custom Rule %s" % (self.name)
Expand All @@ -96,7 +96,7 @@ def cancel_exemption_rule(self):

def enable_exemption_rule(self):
if self.filtered(lambda x: x.state != "cancel"):
raise UserError("Rule is not in Cancelled state to Re-Export Custom Rule")
raise UserError(_("Rule is not in Cancelled state to Re-Export Custom Rule"))
self.write({"state": "progress"})
avalara_salestax = (
self.env["avalara.salestax"]
Expand All @@ -105,7 +105,7 @@ def enable_exemption_rule(self):
)
if not avalara_salestax:
raise UserError(
"Avatax Exemption Rule export is disabled in Avatax configuration"
_("Avatax Exemption Rule export is disabled in Avatax configuration")
)
avalara_salestax.export_new_exemption_rules(
rules=self.filtered(lambda x: not x.avatax_id)
Expand Down Expand Up @@ -139,7 +139,7 @@ def create_rules(self):
)
if not avalara_salestax:
raise UserError(
"Avatax Exemption Rule export is disabled in Avatax configuration"
_("Avatax Exemption Rule export is disabled in Avatax configuration")
)
for rule in self.rule_ids.filtered(lambda x: x.state == "draft"):
rule.export_exemption_rule()
Expand Down Expand Up @@ -179,12 +179,12 @@ def export_exemption(self):
)
if not avalara_salestax:
raise UserError(
"Avatax Exemption export is disabled in Avatax configuration"
_("Avatax Exemption export is disabled in Avatax configuration")
)
if not self.partner_id.customer_code:
raise UserError("No Customer code added in Partner")
raise UserError(_("No Customer code added in Partner"))
if not self.exemption_line_ids:
raise UserError("No Exemption Lines added")
raise UserError(_("No Exemption Lines added"))
if self.partner_id and not self.partner_id.avatax_id:
avalara_salestax.with_delay(
priority=0,
Expand All @@ -209,7 +209,7 @@ def cancel_exemption(self):
)
if not avalara_salestax:
raise UserError(
"Avatax Exemption export is disabled in Avatax configuration"
_("Avatax Exemption export is disabled in Avatax configuration")
)
if self.state == "done":
for exemption_line in self.exemption_line_ids:
Expand All @@ -220,7 +220,7 @@ def cancel_exemption(self):
)._update_avatax_exemption_line_status(exemption_line, False)
self.write({"state": "progress"})
else:
raise UserError("Exemption status needs to be in Done status to cancel")
raise UserError(_("Exemption status needs to be in Done status to cancel"))
return True

def enable_exemption(self):
Expand All @@ -231,7 +231,7 @@ def enable_exemption(self):
)
if not avalara_salestax:
raise UserError(
"Avatax Exemption export is disabled in Avatax configuration"
_("Avatax Exemption export is disabled in Avatax configuration")
)
if self.state == "cancel":
for exemption_line in self.exemption_line_ids:
Expand All @@ -242,5 +242,5 @@ def enable_exemption(self):
)._update_avatax_exemption_line_status(exemption_line, True)
self.write({"state": "progress"})
else:
raise UserError("Exemption status needs to be in Cancel status to enable")
raise UserError(_("Exemption status needs to be in Cancel status to enable"))
return True

0 comments on commit 96ea62b

Please sign in to comment.