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

[18.0][MIG] account_avatax_exemption: Migration to 18.0 #475

Open
wants to merge 34 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6236cd1
Add Avatax Exemption module to 14.0
atchuthan Dec 31, 2020
d328f18
String parameter on UserError requires translation.
atchuthan Jan 7, 2021
b8f84af
0.1.10 version change
atchuthan Feb 5, 2021
493015c
0.1.12 update
atchuthan Feb 19, 2021
cc6de07
2.0.0 update
atchuthan Feb 26, 2021
137f0da
2.0.1 update
atchuthan Mar 5, 2021
038ca9c
remove readonly for taxable field
atchuthan Mar 12, 2021
9972b10
AttributeError: 'CustomerPortal (extended by CustomerPortal, Portal' …
amkarthik Mar 29, 2021
dbc8adc
readme.rst
atchuthan May 21, 2021
6b04410
Moved odoo enterprise related fields to custom module
atchuthan May 21, 2021
f66adf8
Update account_avatax_exemption.pot
oca-travis Jun 13, 2021
6a2676e
README.rst
OCA-git-bot Jun 13, 2021
c5878d7
account_avatax_exemption: Allow cancel option in Inprogress stage
atchuthan Jul 28, 2021
f6bdda6
account_avatax_exemption 14.0.1.1.0
OCA-git-bot Nov 23, 2021
bfe7d61
Avatax: Use Odoo Tax option
atchuthan Sep 1, 2021
3ad7bbd
account_avatax_exemption: new parameter added
atchuthan Jul 7, 2022
eeb274f
account_avatax_exemption 14.0.1.1.1
OCA-git-bot Jul 7, 2022
cb2f152
account_avatax_exemption_base: change license to LGPL
atchuthan Jul 29, 2022
d6b30a7
Update account_avatax_exemption.pot
oca-travis Aug 2, 2022
91e965d
account_avatax_exemption 14.0.2.0.0
OCA-git-bot Aug 2, 2022
baf9280
account_avatax_exemption: account_avatax renamed to account_avatax_oca
dreispt Sep 8, 2022
7db1f84
account_avatax_exemption 14.0.3.0.0
OCA-git-bot Sep 9, 2022
bf79100
README.rst
OCA-git-bot Sep 3, 2023
976c060
account_avatax_exemption: pre-commit fixes
dreispt Oct 28, 2023
d24fb50
Update account_avatax_exemption.pot
Oct 28, 2023
e0a990f
post-merge updates
OCA-git-bot Oct 28, 2023
e67faf1
[FIX] account_avatax_exemption: black, isort, prettier
Nikul-OSI Mar 13, 2024
988b900
[MIG] account_avatax_exemption: Migrated to v17
Nikul-OSI Mar 13, 2024
4234bc8
[IMP] account_avatax_exemption: lint
dnplkndll Jan 14, 2025
a601fb4
[IMP] account_avatax_exemption: pre-commit auto fixes
dnplkndll Jan 15, 2025
85639ec
[MIG] account_avatax_exemption: Migration to 18.0
dnplkndll Jan 15, 2025
6c9a27d
[DON'T MERGE] Add test-requirements.txt
dnplkndll Jan 15, 2025
27b2ccf
[IMP] account_avatax_exemption: add more data
kobros-tech Jan 21, 2025
6ab1aa5
[IMP] account_avatax_exemption: Add unique xml_id for form
kobros-tech Feb 6, 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*requirements.txt merge=union
101 changes: 101 additions & 0 deletions account_avatax_exemption/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
=================
Avatax Exemptions
=================

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

.. |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/18.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-18-0/account-fiscal-rule-18-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=18.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:

Usage
=====



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:%2018.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 <[email protected]>
- Stephan Keller <[email protected]>
- SodexisTeam <[email protected]>

- Open Source Integrators (https://opensourceintegrators.com)

- Nikul Chaudhary <[email protected]>

- Kencove (https://kencove.com)

- Don Kendall <[email protected]>
- Mohamed Alkobrosli <[email protected]>
- Wai-Lun Lin <[email protected]>

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/18.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": "18.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_oca",
"account_avatax_sale_oca",
"account_avatax_exemption_base",
],
"data": [
"security/ir.model.access.csv",
"data/cron.xml",
"data/queue.xml",
"data/ir_sequence_data.xml",
"data/res_partner_exemption_business_type.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",
],
"images": ["static/description/avatax_icon.png"],
"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()._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
29 changes: 29 additions & 0 deletions account_avatax_exemption/data/cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<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="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="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="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