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

[17.0][MIG] account_avatax_exemption #472

Open
wants to merge 30 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
598d046
Add Avatax Exemption module to 14.0
atchuthan Dec 31, 2020
2af4771
String parameter on UserError requires translation.
atchuthan Jan 7, 2021
def6f76
0.1.10 version change
atchuthan Feb 5, 2021
f2a31a0
0.1.12 update
atchuthan Feb 19, 2021
97be6c1
2.0.0 update
atchuthan Feb 26, 2021
5e9baf8
2.0.1 update
atchuthan Mar 5, 2021
359d9b3
remove readonly for taxable field
atchuthan Mar 12, 2021
77af709
AttributeError: 'CustomerPortal (extended by CustomerPortal, Portal' …
amkarthik Mar 29, 2021
d769c58
readme.rst
atchuthan May 21, 2021
021aed6
Moved odoo enterprise related fields to custom module
atchuthan May 21, 2021
eb39989
Update account_avatax_exemption.pot
oca-travis Jun 13, 2021
65cffc3
README.rst
OCA-git-bot Jun 13, 2021
2bfa8c7
account_avatax_exemption: Allow cancel option in Inprogress stage
atchuthan Jul 28, 2021
dedadaf
account_avatax_exemption 14.0.1.1.0
OCA-git-bot Nov 23, 2021
6faee80
Avatax: Use Odoo Tax option
atchuthan Sep 1, 2021
c43e14d
account_avatax_exemption: new parameter added
atchuthan Jul 7, 2022
14495e7
account_avatax_exemption 14.0.1.1.1
OCA-git-bot Jul 7, 2022
fd55699
account_avatax_exemption_base: change license to LGPL
atchuthan Jul 29, 2022
f49c06b
Update account_avatax_exemption.pot
oca-travis Aug 2, 2022
225079f
account_avatax_exemption 14.0.2.0.0
OCA-git-bot Aug 2, 2022
fdbd570
account_avatax_exemption: account_avatax renamed to account_avatax_oca
dreispt Sep 8, 2022
1b37922
account_avatax_exemption 14.0.3.0.0
OCA-git-bot Sep 9, 2022
9d9bb33
README.rst
OCA-git-bot Sep 3, 2023
3a40722
account_avatax_exemption: pre-commit fixes
dreispt Oct 28, 2023
8919578
Update account_avatax_exemption.pot
Oct 28, 2023
a0c2d01
post-merge updates
OCA-git-bot Oct 28, 2023
d6b96a3
[FIX] account_avatax_exemption: black, isort, prettier
Nikul-OSI Mar 13, 2024
040df71
[MIG] account_avatax_exemption: Migrated to v17
Nikul-OSI Mar 13, 2024
d60e493
[IMP] account_avatax_exemption: lint
dnplkndll Jan 14, 2025
4ad9190
[DON'T MERGE] Add test-requirements.txt
dnplkndll Jan 14, 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
95 changes: 95 additions & 0 deletions account_avatax_exemption/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
=================
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/17.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-17-0/account-fiscal-rule-17-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=17.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:%2017.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]>

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/17.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
36 changes: 36 additions & 0 deletions account_avatax_exemption/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "Avatax Exemptions",
"version": "17.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/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",
],
"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
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