Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] account_avatax_exemption: Migration to V17 #42

Open
wants to merge 1 commit into
base: 17_nc_mig_account_avatax_exemption
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Do NOT update manually; changes here will be overwritten by Copier
_commit: v1.19
_commit: v1.21.1
_src_path: gh:oca/oca-addons-repo-template
additional_ruff_rules: []
ci: GitHub
Expand Down
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ exclude: |
readme/.*\.(rst|md)$|
# Ignore build and dist directories in addons
/build/|/dist/|
# Ignore test files in addons
/tests/samples/.*|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
Expand All @@ -41,7 +43,7 @@ repos:
hooks:
- id: whool-init
- repo: https://github.com/oca/maintainer-tools
rev: f71041f22b8cd68cf7c77b73a14ca8d8cd190a60
rev: 9a170331575a265c092ee6b24b845ec508e8ef75
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
Expand Down Expand Up @@ -110,7 +112,7 @@ repos:
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/OCA/pylint-odoo
rev: v8.0.19
rev: v9.0.4
hooks:
- id: pylint_odoo
name: pylint with optional checks
Expand Down
1 change: 1 addition & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fix = true
extend-select = [
"B",
"C90",
"E501", # line too long (default 88)
"I", # isort
"UP", # pyupgrade
]
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
[account_avatax_oca](account_avatax_oca/) | 17.0.1.3.1 | [![dreispt](https://github.com/dreispt.png?size=30px)](https://github.com/dreispt) | Compute Sales Tax using the Avalara Avatax Service
[account_avatax_sale_oca](account_avatax_sale_oca/) | 17.0.1.1.0 | [![dreispt](https://github.com/dreispt.png?size=30px)](https://github.com/dreispt) | Sales Orders with automatic Tax application using Avatax
[account_avatax_website_sale](account_avatax_website_sale/) | 17.0.1.0.0 | [![cybernexus](https://github.com/cybernexus.png?size=30px)](https://github.com/cybernexus) | Ecommerce Sales Orders require tax recalculation prior to payment.
[account_fiscal_position_autodetect_optional_vies](account_fiscal_position_autodetect_optional_vies/) | 17.0.1.0.0 | [![victoralmau](https://github.com/victoralmau.png?size=30px)](https://github.com/victoralmau) | Account Fiscal Position Autodetect optional VIES
[account_fiscal_position_partner_type](account_fiscal_position_partner_type/) | 17.0.1.0.0 | | Account Fiscal Position Partner Type
[l10n_eu_oss_oca](l10n_eu_oss_oca/) | 17.0.1.0.0 | | L10n EU OSS OCA

[//]: # (end addons)

Expand Down
6 changes: 4 additions & 2 deletions account_avatax_exemption/models/avalara_salestax.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ def _export_base_rule_based_on_type(self, rule):
"cap": 0,
"threshold": 0,
"effectiveDate": fields.Datetime.to_string(fields.Date.today()),
"description": f"{rule.state_id.avatax_name} - {rule.exemption_code_id.code} - {rule.name}",
"description": f"{rule.state_id.avatax_name} - \
{rule.exemption_code_id.code} - {rule.name}",
"country": rule.state_id.country_id.code,
"region": rule.state_id.code,
"stateFIPS": rule.state_id.avatax_code,
Expand Down Expand Up @@ -632,7 +633,8 @@ def _export_avatax_exemption_line(self, exemption_line):
self.with_delay(
priority=6,
max_retries=2,
description=f"Link Customer {exemption_line.partner_id.display_name} with Exemption {exemption_line.name}",
description=f"Link Customer {exemption_line.partner_id.display_name}\
with Exemption {exemption_line.name}",
).link_certificates_to_customer(exemption_line)

return result
Expand Down
16 changes: 8 additions & 8 deletions account_avatax_exemption/models/exemption.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class ExemptionRule(models.Model):
("cancel", "Cancelled"),
],
default="draft",
string="State",
)
exemption_code_id = fields.Many2one(
"exemption.code", string="Entity Use Code", required=True
Expand All @@ -39,13 +38,14 @@ def _check_avatax_rate(self):
if record.avatax_rate < 0 or record.avatax_rate > 100:
raise ValidationError(_("Avatax rate range is from 0 to 100"))

@api.model
def create(self, vals):
if vals.get("name", _("New")) == _("New"):
vals["name"] = self.env["ir.sequence"].next_by_code(
"exemption.code.rule.sequence"
) or _("New")
return super().create(vals)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get("name", _("New")) == _("New"):
vals["name"] = self.env["ir.sequence"].next_by_code(
"exemption.code.rule.sequence"
) or _("New")
return super().create(vals_list)

def export_exemption_rule(self):
if self.filtered(lambda x: x.state != "draft"):
Expand Down
12 changes: 8 additions & 4 deletions account_avatax_exemption/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class QueueJob(models.Model):

def _related_action_avatax_rule(self):
rule = self.args[0]
action = self.env.ref(
action = self.env["ir.actions.actions"]._for_xml_id(
"account_avatax_exemption.exemption_rule_act_window"
).read([])[0]
)
action.update(
{
"view_mode": "form",
Expand All @@ -20,7 +20,9 @@ def _related_action_avatax_rule(self):

def _related_action_avatax_tax_item(self):
product = self.args[0]
action = self.env.ref("product.product_normal_action_sell").read([])[0]
action = self.env["ir.actions.actions"]._for_xml_id(
"product.product_normal_action_sell"
)
action.update(
{
"view_mode": "form",
Expand All @@ -32,7 +34,9 @@ def _related_action_avatax_tax_item(self):

def _related_action_avatax_customer(self):
partner = self.args[0]
action = self.env.ref("account.res_partner_action_customer").read([])[0]
action = self.env["ir.actions.actions"]._for_xml_id(
"account.res_partner_action_customer"
)
action.update(
{
"view_mode": "form",
Expand Down
2 changes: 1 addition & 1 deletion account_avatax_exemption/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_exemption_code_rule,access_exemption_code_rule,model_exemption_code_rule,base.group_user,1,1,1,1
access_portal_exemption_code,access_portal_exemption_code,account_avatax_oca.model_exemption_code,,1,0,0,0
access_portal_exemption_code,access_portal_exemption_code,account_avatax_oca.model_exemption_code,base.group_user,1,0,0,0
12 changes: 7 additions & 5 deletions account_avatax_exemption/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -430,7 +430,9 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
8 changes: 2 additions & 6 deletions account_avatax_exemption/views/partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='customer_code']/.." position="after">
<group
col="2"
colspan="4"
invisible="not is_company and parent_id != False"
>
<group col="2" colspan="4" invisible="parent_id and not is_company">
<field name="avatax_id" />
<field name="id" invisible="1" />
<field name="is_company" invisible="1" />
<label for="exemption_ids" />
</group>
<field name="exemption_ids" context="{'hide_partner':id}" nolabel="1" />
<div invisibl="is_company or not parent_id">
<div invisible="is_company or not parent_id">
<p>
Avatax Exemption related settings are managed on
<button
Expand Down