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 16.0 #482

Open
wants to merge 29 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
abd42ae
[ADD] Add Avatax Exemption module to 14.0
atchuthan Dec 31, 2020
c37d4a9
String parameter on UserError requires translation.
atchuthan Jan 7, 2021
8fd0db8
0.1.10 version change
atchuthan Feb 5, 2021
cccbc84
0.1.12 update
atchuthan Feb 19, 2021
84e2985
2.0.0 update
atchuthan Feb 26, 2021
5bc34bd
2.0.1 update
atchuthan Mar 5, 2021
49e3314
[FIX] remove readonly for taxable field
atchuthan Mar 12, 2021
0f2ef81
[FIX] AttributeError: 'CustomerPortal (extended by CustomerPortal, Po…
amkarthik Mar 29, 2021
d190d25
[ADD] readme.rst
atchuthan May 21, 2021
2a7cbad
[FIX] Moved odoo enterprise related fields to custom module
atchuthan May 21, 2021
9ea5534
[UPD] Update account_avatax_exemption.pot
oca-travis Jun 13, 2021
bb226f0
[UPD] README.rst
OCA-git-bot Jun 13, 2021
51f3346
[IMP] account_avatax_exemption: Allow cancel option in Inprogress stage
atchuthan Jul 28, 2021
a1565f9
account_avatax_exemption 14.0.1.1.0
OCA-git-bot Nov 23, 2021
d69ad24
[FIX] Avatax: Use Odoo Tax option
atchuthan Sep 1, 2021
5770493
[IMP] account_avatax_exemption: new parameter added
atchuthan Jul 7, 2022
2fcf7b3
account_avatax_exemption 14.0.1.1.1
OCA-git-bot Jul 7, 2022
6268595
[14.0] account_avatax_exemption_base: change license to LGPL
atchuthan Jul 29, 2022
29cc944
[UPD] Update account_avatax_exemption.pot
oca-travis Aug 2, 2022
992da8c
account_avatax_exemption 14.0.2.0.0
OCA-git-bot Aug 2, 2022
54dac3c
[REF] account_avatax_exemption: account_avatax renamed to account_ava…
dreispt Sep 8, 2022
6567671
account_avatax_exemption 14.0.3.0.0
OCA-git-bot Sep 9, 2022
8600a0b
[UPD] README.rst
OCA-git-bot Sep 3, 2023
68ed7f8
[IMP] account_avatax_exemption: pre-commit stuff
AlexPForgeFlow Sep 27, 2023
8910958
[MIG] account_avatax_exemption: Migration to 16.0
AlexPForgeFlow Sep 27, 2023
e6506f0
[FIX] account_avatax_exemption: move method onchange_partner_id in mo…
JordiBForgeFlow Oct 28, 2023
9243cb0
[IMP] account_avatax_exemption: Import tax rules
BernatPForgeFlow Nov 27, 2023
2a8a75c
[FIX] account_avatax_exemption: Hide Exemption Code info
atchuthan Aug 3, 2022
0115e27
[IMP] account_avatax_exemption: pre-commit auto fixes
kobros-tech Jan 28, 2025
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
85 changes: 85 additions & 0 deletions account_avatax_exemption/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
=================
Avatax Exemptions
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c8b257f5868840c5425cd77f06787db45dcd3e6b4f8778dbdf499188212aa3bf
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--fiscal--rule-lightgray.png?logo=github
:target: https://github.com/OCA/account-fiscal-rule/tree/16.0/account_avatax_exemption
:alt: OCA/account-fiscal-rule
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-fiscal-rule-16-0/account-fiscal-rule-16-0-account_avatax_exemption
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-fiscal-rule&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module is a component of the Avatax Exemption Integration with odoo app.

* Export Exemption customer in Avatax
* Export Exemptions for customer based on nexus region
* Export Custom rules based on avatax nexus regions
* Export Product Taxcodes to Avatax

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-fiscal-rule/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-fiscal-rule/issues/new?body=module:%20account_avatax_exemption%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Sodexis

Contributors
~~~~~~~~~~~~

* Sodexis

* Atchuthan Ubendran <atchuthan@sodexis.com>
* Stephan Keller <skeller@sodexis.com>
* SodexisTeam <dev@sodexis.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/account-fiscal-rule <https://github.com/OCA/account-fiscal-rule/tree/16.0/account_avatax_exemption>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions account_avatax_exemption/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import controller
39 changes: 39 additions & 0 deletions account_avatax_exemption/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "Avatax Exemptions",
"version": "16.0.1.0.0",
"category": "Sales",
"summary": """
This application allows you to add exemptions to Avatax
""",
"website": "https://github.com/OCA/account-fiscal-rule",
"author": "Sodexis, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"website",
"product",
"queue_job",
"account_avatax_sale_oca",
"account_avatax_exemption_base",
],
"data": [
"security/security.xml",
"security/ir.model.access.csv",
"data/cron.xml",
"data/queue.xml",
"data/ir_sequence_data.xml",
"views/avalara_salestax_view.xml",
"views/avalara_exemption_view.xml",
"views/product_view.xml",
"views/exemption_template_views.xml",
"views/res_country_state_view.xml",
"views/website_layout.xml",
"views/website_exemption_tree.xml",
"views/website_exemption_form.xml",
"views/partner_view.xml",
"views/account_move_view.xml",
"views/sale_view.xml",
],
"external_dependencies": {"python": ["Avalara"]},
"installable": True,
"application": True,
}
1 change: 1 addition & 0 deletions account_avatax_exemption/controller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
166 changes: 166 additions & 0 deletions account_avatax_exemption/controller/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import logging

from odoo import _, http
from odoo.http import request, route
from odoo.tools import exception_to_unicode

from odoo.addons.portal.controllers.portal import CustomerPortal

_logger = logging.getLogger(__name__)


class Exemption(http.Controller):
@http.route("/exemption/<int:exemption_id>", website=True, auth="public")
def get_exemption(self, **kw):
exemption_id = kw.get("exemption_id")
try:
message = (

Check warning on line 17 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L15-L17

Added lines #L15 - L17 were not covered by tests
request.env["res.partner.exemption"]
.sudo()
.search_exemption_line(exemption_id)
)
except Exception as e:
message = False, exception_to_unicode(e)
return request.render(

Check warning on line 24 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L22-L24

Added lines #L22 - L24 were not covered by tests
"account_avatax_exemption.exemption_page", {"message": message}
)


class WebsiteExemption(CustomerPortal):
def _exemptions_domain(self, search=""):
"""Get user's exemptions domain."""

avalara_salestax = (

Check warning on line 33 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L33

Added line #L33 was not covered by tests
request.env["avalara.salestax"]
.sudo()
.search([("exemption_export", "=", True)], limit=1)
)
domain = [("partner_id", "child_of", request.env.user.partner_id.id)]

Check warning on line 38 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L38

Added line #L38 was not covered by tests
if avalara_salestax.use_commercial_entity:
domain = [

Check warning on line 40 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L40

Added line #L40 was not covered by tests
(
"partner_id",
"child_of",
request.env.user.partner_id.commercial_partner_id.id,
)
]

return domain

Check warning on line 48 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L48

Added line #L48 was not covered by tests

def _prepare_portal_layout_values(self, exemption=None):
values = super(WebsiteExemption, self)._prepare_portal_layout_values()
partner_counts = request.env["res.partner.exemption"].search_count(

Check warning on line 52 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L51-L52

Added lines #L51 - L52 were not covered by tests
self._exemptions_domain()
)
values["exemption_count"] = partner_counts
return values

Check warning on line 56 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L55-L56

Added lines #L55 - L56 were not covered by tests

def _prepare_exemptions_values(
self, page=1, date_begin=None, date_end=None, search="", sortby=None
):
"""Prepare the rendering context for the exemptions list."""
values = self._prepare_portal_layout_values()
Exemption = request.env["res.partner.exemption"]
base_url = "/my/exemptions"

Check warning on line 64 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L62-L64

Added lines #L62 - L64 were not covered by tests

searchbar_sortings = {

Check warning on line 66 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L66

Added line #L66 was not covered by tests
"date": {"label": _("Newest"), "order": "create_date desc"},
"expiry_date": {"label": _("Expiry Date"), "order": "expiry_date desc"},
}
if not sortby:
sortby = "date"
order = searchbar_sortings[sortby]["order"]

Check warning on line 72 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L71-L72

Added lines #L71 - L72 were not covered by tests

# Get the required domains
domain = self._exemptions_domain(search)

Check warning on line 75 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L75

Added line #L75 was not covered by tests

if date_begin and date_end:
domain += [

Check warning on line 78 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L78

Added line #L78 was not covered by tests
("create_date", ">=", date_begin),
("create_date", "<", date_end),
]

# Make pager
pager = request.website.pager(

Check warning on line 84 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L84

Added line #L84 was not covered by tests
url=base_url,
url_args={"date_begin": date_begin, "date_end": date_end, "sortby": sortby},
total=Exemption.search_count(domain),
page=page,
step=self._items_per_page,
)

# Current records to display
exemptions = Exemption.search(

Check warning on line 93 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L93

Added line #L93 was not covered by tests
domain,
order=order,
limit=self._items_per_page,
offset=pager["offset"],
)
request.session["my_exemptions_history"] = exemptions.ids[:100]

Check warning on line 99 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L99

Added line #L99 was not covered by tests

values.update(

Check warning on line 101 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L101

Added line #L101 was not covered by tests
{
"date": date_begin,
"date_end": date_end,
"exemptions": exemptions,
"page_name": "exemption",
"pager": pager,
"default_url": base_url,
"search": search,
"searchbar_sortings": searchbar_sortings,
"sortby": sortby,
}
)

return values

Check warning on line 115 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L115

Added line #L115 was not covered by tests

def _exemptions_fields(self):
"""Fields to display in the form."""
return [

Check warning on line 119 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L119

Added line #L119 was not covered by tests
"partner_id",
"exemption_type",
"exemption_code_id",
"state",
"exemption_number",
"exemption_number_type",
"effective_date",
"expiry_date",
]

@route(
["/my/exemptions", "/my/exemptions/page/<int:page>"],
type="http",
auth="user",
website=True,
)
def portal_my_exemptions(
self, page=1, date_begin=None, date_end=None, sortby=None, search="", **kw
):
"""List all of your exemptions."""
values = self._prepare_exemptions_values(

Check warning on line 140 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L140

Added line #L140 was not covered by tests
page, date_begin, date_end, search, sortby
)
return request.render("account_avatax_exemption.portal_my_exemptions", values)

Check warning on line 143 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L143

Added line #L143 was not covered by tests

def _exemption_get_page_view_values(self, exemption, access_token, **kwargs):
values = {

Check warning on line 146 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L146

Added line #L146 was not covered by tests
"exemption": exemption,
"fields": self._exemptions_fields(),
"page_name": "exemption",
"user": request.env.user,
}

return self._get_page_view_values(

Check warning on line 153 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L153

Added line #L153 was not covered by tests
exemption, access_token, values, "my_exemption_history", False, **kwargs
)

@route(
["/my/exemptions/<model('res.partner.exemption'):exemption>"],
type="http",
auth="user",
website=True,
)
def portal_my_exemptions_read(self, exemption, access_token=None, **kw):
"""Read a exemption form."""
values = self._exemption_get_page_view_values(exemption, access_token, **kw)
return request.render("account_avatax_exemption.exemptions_followup", values)

Check warning on line 166 in account_avatax_exemption/controller/main.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_exemption/controller/main.py#L165-L166

Added lines #L165 - L166 were not covered by tests
32 changes: 32 additions & 0 deletions account_avatax_exemption/data/cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<odoo noupdate="1">
<record id="ir_cron_export_new_tax_item" model="ir.cron">
<field name="name">Avatax TaxItem: Export New Items</field>
<field name="model_id" ref="account_avatax_oca.model_avalara_salestax" />
<field name="state">code</field>
<field name="code">model.export_new_tax_items()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="active" eval="False" />
</record>
<record id="ir_cron_export_exemption_rule" model="ir.cron">
<field name="name">Avatax Rules: Export New Rules</field>
<field name="model_id" ref="account_avatax_oca.model_avalara_salestax" />
<field name="state">code</field>
<field name="code">model.export_new_exemption_rules()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="active" eval="False" />
</record>
<record id="ir_cron_download_exemption" model="ir.cron">
<field name="name">Avatax Exemption Download</field>
<field name="model_id" ref="account_avatax_oca.model_avalara_salestax" />
<field name="state">code</field>
<field name="code">model.download_exemptions()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="active" eval="False" />
</record>
</odoo>
9 changes: 9 additions & 0 deletions account_avatax_exemption/data/ir_sequence_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<odoo noupdate="1">
<record id="seq_exemption_code_rule" model="ir.sequence">
<field name="name">Exemption Custom Rule Sequence</field>
<field name="code">exemption.code.rule.sequence</field>
<field name="prefix">RULE</field>
<field name="padding">5</field>
<field name="company_id" eval="False" />
</record>
</odoo>
Loading
Loading