Skip to content

Commit 033bbf1

Browse files
committed
[18.0][MIG] account_avatax_oca: Migration to 18.0
1 parent b66d2ce commit 033bbf1

21 files changed

+1021
-321
lines changed

account_avatax_oca/README.rst

+152-150
Large diffs are not rendered by default.

account_avatax_oca/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Avalara Avatax Certified Connector",
3-
"version": "17.0.1.3.1",
3+
"version": "18.0.1.0.0",
44
"author": "Open Source Integrators, Fabrice Henrion,"
55
"Sodexis, Odoo Community Association (OCA)",
66
"summary": "Compute Sales Tax using the Avalara Avatax Service",

account_avatax_oca/demo/avatax_demo.xml

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<odoo>
2+
<!-- fake avatax API configuraation -->
3+
<record id="avatax_api_configuraation" model="avalara.salestax">
4+
<field name="company_id" ref="base.main_company" />
5+
<field name="account_number">123456789</field>
6+
<field name="license_key">avatax_key</field>
7+
</record>
28

39
<record id="avatax_customer" model="res.partner">
410
<field name="name">Washington Customer</field>
@@ -24,21 +30,20 @@
2430

2531
<record id="avatax_product_sku1" model="product.product">
2632
<field name="name">Test Item P0000000</field>
27-
<field name="detailed_type">product</field>
33+
<field name="type">consu</field>
2834
<field name="list_price">100.0</field>
29-
<field name="tax_code_id" ref="avatax_product_taxcodeP" />
35+
<field name="tax_code_id" ref="account_avatax_oca.avatax_product_taxcodeP" />
3036
</record>
3137
<record id="avatax_product_sku2" model="product.product">
3238
<field name="name">Test Item NT</field>
33-
<field name="detailed_type">product</field>
39+
<field name="type">consu</field>
3440
<field name="list_price">100.0</field>
35-
<field name="tax_code_id" ref="avatax_product_taxcodeNT" />
41+
<field name="tax_code_id" ref="account_avatax_oca.avatax_product_taxcodeNT" />
3642
</record>
3743
<record id="avatax_product_freight" model="product.product">
3844
<field name="name">Common Carrier FR020100</field>
39-
<field name="detailed_type">service</field>
45+
<field name="type">service</field>
4046
<field name="list_price">50.0</field>
41-
<field name="tax_code_id" ref="avatax_product_taxcodeF" />
47+
<field name="tax_code_id" ref="account_avatax_oca.avatax_product_taxcodeF" />
4248
</record>
43-
4449
</odoo>

account_avatax_oca/models/account_move.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import logging
22

3-
from odoo import _, api, fields, models
3+
from odoo import api, fields, models
44
from odoo.exceptions import UserError
5-
from odoo.tests.common import Form
65

76
_logger = logging.getLogger(__name__)
87

@@ -268,12 +267,11 @@ def _avatax_compute_tax(self, commit=False):
268267

269268
# Set Taxes on lines in a way that properly triggers onchanges
270269
# This same approach is also used by the official account_taxcloud connector
271-
with Form(self) as move_form:
272-
for index, taxes in taxes_to_set:
273-
with move_form.invoice_line_ids.edit(index) as line_form:
274-
line_form.tax_ids.clear()
275-
for tax in taxes:
276-
line_form.tax_ids.add(tax)
270+
for index, taxes in taxes_to_set:
271+
# Access the invoice line by index
272+
line = self.invoice_line_ids[index]
273+
# Update the tax_ids field
274+
line.write({"tax_ids": [(6, 0, [tax.id for tax in taxes])]})
277275

278276
return tax_result
279277

@@ -316,7 +314,9 @@ def _post(self, soft=True):
316314
if not addr.date_validation:
317315
# The Validate action will be interrupted
318316
# if the address is not validated
319-
raise UserError(_("Avatax address is not validated!"))
317+
raise UserError(
318+
self.env._("Avatax address is not validated!")
319+
)
320320
# We should compute taxes before validating the invoice
321321
# to ensure correct account moves
322322
# However, we can't save the invoice because it wasn't assigned a

account_avatax_oca/models/account_tax.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from math import copysign
22

3-
from odoo import _, api, exceptions, fields, models
3+
from odoo import api, exceptions, fields, models
44
from odoo.tools.float_utils import float_compare
55

66

@@ -25,7 +25,7 @@ def _get_avalara_tax_domain(self, tax_rate, doc_type):
2525

2626
@api.model
2727
def _get_avalara_tax_name(self, tax_rate, doc_type=None):
28-
return _("{}%*").format(str(tax_rate))
28+
return self.env._("{}%*").format(str(tax_rate))
2929

3030
@api.model
3131
def get_avalara_tax(self, tax_rate, doc_type):
@@ -38,7 +38,7 @@ def get_avalara_tax(self, tax_rate, doc_type):
3838
tax_template = self.search(domain, limit=1)
3939
if not tax_template:
4040
raise exceptions.UserError(
41-
_("Please configure Avatax Tax for Company %s:")
41+
self.env._("Please configure Avatax Tax for Company %s:")
4242
% self.env.company.name
4343
)
4444
# If you get a unique constraint error here,
@@ -105,7 +105,7 @@ def compute_all(
105105
if avatax_amount is None:
106106
avatax_amount = 0.0
107107
raise exceptions.UserError(
108-
_(
108+
self.env._(
109109
"Incorrect retrieval of Avatax amount for Invoice "
110110
"%(avatax_invoice)s: product %(product.display_name)s, "
111111
"price_unit %(-price_unit)f , quantity %(quantity)f"

account_avatax_oca/models/avalara_salestax.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22

3-
from odoo import _, api, fields, models
3+
from odoo import api, fields, models
44
from odoo.exceptions import UserError
55

66
from .avatax_rest_api import AvaTaxRESTService
@@ -214,7 +214,7 @@ def create_transaction(
214214
if not partner.customer_code:
215215
if not avatax_config.auto_generate_customer_code:
216216
raise UserError(
217-
_(
217+
self.env._(
218218
"Customer Code for customer %(partner.name)s not defined.\n\n "
219219
"You can edit the Customer Code in customer profile. "
220220
'You can fix by clicking "Generate Customer Code" '
@@ -226,12 +226,14 @@ def create_transaction(
226226

227227
if not shipping_address:
228228
raise UserError(
229-
_("There is no source shipping address defined for partner %s.")
229+
self.env._(
230+
"There is no source shipping address defined for partner %s."
231+
)
230232
% partner.name
231233
)
232234

233235
if not ship_from_address:
234-
raise UserError(_("There is no Company address defined."))
236+
raise UserError(self.env._("There is no Company address defined."))
235237

236238
if avatax_config.validation_on_save:
237239
for address in [partner, shipping_address, ship_from_address]:
@@ -246,27 +248,31 @@ def create_transaction(
246248
):
247249
if not shipping_address.date_validation:
248250
raise UserError(
249-
_(
251+
self.env._(
250252
"Please validate the shipping address for the partner "
251253
"%(partner.name)s."
252254
)
253255
)
254256

255257
# if not avatax_config.address_validation:
256258
if not ship_from_address.date_validation:
257-
raise UserError(_("Please validate the origin warehouse address."))
259+
raise UserError(
260+
self.env._("Please validate the origin warehouse address.")
261+
)
258262

259263
if avatax_config.disable_tax_calculation:
260264
_logger.info(
261-
"Avatax tax calculation is disabled. Skipping %s %s.",
265+
self.env._("Avatax tax calculation is disabled. Skipping %s %s."),
262266
doc_code,
263267
doc_type,
264268
)
265269
return False
266270

267271
if commit and avatax_config.disable_tax_reporting:
268272
_logger.warning(
269-
_("Avatax commiting document %s, but it tax reporting is disabled."),
273+
self.env._(
274+
"Avatax commiting document %s, but it tax reporting is disabled."
275+
),
270276
doc_code,
271277
)
272278

account_avatax_oca/models/avatax_rest_api.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pprint
55
import socket
66

7-
from odoo import _, fields, tools
7+
from odoo import _, fields
88
from odoo.exceptions import UserError
99

1010
_logger = logging.getLogger(__name__)
@@ -26,6 +26,7 @@ def __init__(
2626
config=None,
2727
):
2828
self.config = config
29+
self.env = config and config.env or None
2930
self.timeout = not config and timeout or config.request_timeout
3031
self.is_log_enabled = enable_log or config and config.logging
3132
# Set elements adapter defaults
@@ -250,7 +251,7 @@ def get_tax(
250251
lineslist = [
251252
{
252253
"number": line["id"].id,
253-
"description": tools.ustr(line.get("description", ""))[:255],
254+
"description": str(line.get("description", ""))[:255],
254255
"itemCode": line.get("itemcode"),
255256
"quantity": line.get("qty", 1),
256257
"amount": line.get("amount", 0.0),

account_avatax_oca/models/partner.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time
33
from random import random
44

5-
from odoo import _, api, fields, models
5+
from odoo import api, fields, models
66
from odoo.exceptions import UserError
77

88
from .avatax_rest_api import AvaTaxRESTService
@@ -22,7 +22,7 @@ class ResPartner(models.Model):
2222
def _onchange_property_exemption_contry_wide(self):
2323
if self.property_exemption_country_wide:
2424
message = (
25-
_(
25+
self.env._(
2626
"Enabling the exemption status for all states"
2727
" may have tax compliance risks,"
2828
" and should be carefully considered.\n\n"
@@ -31,7 +31,12 @@ def _onchange_property_exemption_contry_wide(self):
3131
" for every state this Partner may have transactions."
3232
),
3333
)
34-
return {"warning": {"title": _("Tax Compliance Risk"), "message": message}}
34+
return {
35+
"warning": {
36+
"title": self.env._("Tax Compliance Risk"),
37+
"message": message,
38+
}
39+
}
3540

3641
date_validation = fields.Date(
3742
"Last Validation Date",
@@ -101,7 +106,7 @@ def check_exemption_number(self):
101106
partner.property_exemption_code_id or partner.property_exemption_number
102107
):
103108
raise UserError(
104-
_(
109+
self.env._(
105110
"Please enter either Exemption Number or Exemption Code"
106111
" for marking customer as Exempt."
107112
)

account_avatax_oca/models/res_company.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22

3-
from odoo import _, models
3+
from odoo import models
44

55
_LOGGER = logging.getLogger(__name__)
66

@@ -18,11 +18,12 @@ def get_avatax_config_company(self):
1818
)
1919
if len(res) > 1:
2020
_LOGGER.warning(
21-
_("Company %s has too many Avatax configurations!"),
21+
self.env._("Company %s has too many Avatax configurations!"),
2222
self.display_name,
2323
)
2424
if len(res) < 1:
2525
_LOGGER.warning(
26-
_("Company %s has no Avatax configuration."), self.display_name
26+
self.env._("Company %s has no Avatax configuration."),
27+
self.display_name,
2728
)
2829
return res and res[0]

account_avatax_oca/readme/CONTRIBUTORS.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
- Murtuza Saleh
1010
- Sodexis
1111
- Atchuthan Ubendran
12+
- Kencove (<https://www.kencove.com>)
13+
- Mohamed Alkobrosli \<<[email protected]>\>

0 commit comments

Comments
 (0)