-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by dreispt
- Loading branch information
Showing
51 changed files
with
3,968 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
================= | ||
Avatax Exemptions | ||
================= | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/14.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-14-0/account-fiscal-rule-14-0-account_avatax_exemption | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/93/14.0 | ||
:alt: Try me on Runbot | ||
|
||
|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 smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/account-fiscal-rule/issues/new?body=module:%20account_avatax_exemption%0Aversion:%2014.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]> | ||
|
||
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/14.0/account_avatax_exemption>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import controller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "Avatax Exemptions", | ||
"version": "14.0.1.0.3", | ||
"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_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", | ||
], | ||
"external_dependencies": {"python": ["Avalara"]}, | ||
"installable": True, | ||
"application": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ( | ||
request.env["res.partner.exemption"] | ||
.sudo() | ||
.search_exemption_line(exemption_id) | ||
) | ||
except Exception as e: | ||
message = False, exception_to_unicode(e) | ||
return request.render( | ||
"account_avatax_exemption.exemption_page", {"message": message} | ||
) | ||
|
||
|
||
class WebsiteExemption(CustomerPortal): | ||
def _exemptions_domain(self, search=""): | ||
"""Get user's exemptions domain.""" | ||
|
||
avalara_salestax = ( | ||
request.env["avalara.salestax"] | ||
.sudo() | ||
.search([("exemption_export", "=", True)], limit=1) | ||
) | ||
domain = [("partner_id", "child_of", request.env.user.partner_id.id)] | ||
if avalara_salestax.use_commercial_entity: | ||
domain = [ | ||
( | ||
"partner_id", | ||
"child_of", | ||
request.env.user.partner_id.commercial_partner_id.id, | ||
) | ||
] | ||
|
||
return domain | ||
|
||
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( | ||
self._exemptions_domain() | ||
) | ||
values["exemption_count"] = partner_counts | ||
return values | ||
|
||
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" | ||
|
||
searchbar_sortings = { | ||
"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"] | ||
|
||
# Get the required domains | ||
domain = self._exemptions_domain(search) | ||
|
||
if date_begin and date_end: | ||
domain += [ | ||
("create_date", ">=", date_begin), | ||
("create_date", "<", date_end), | ||
] | ||
|
||
# Make pager | ||
pager = request.website.pager( | ||
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( | ||
domain, | ||
order=order, | ||
limit=self._items_per_page, | ||
offset=pager["offset"], | ||
) | ||
request.session["my_exemptions_history"] = exemptions.ids[:100] | ||
|
||
values.update( | ||
{ | ||
"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 | ||
|
||
def _exemptions_fields(self): | ||
"""Fields to display in the form.""" | ||
return [ | ||
"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( | ||
page, date_begin, date_end, search, sortby | ||
) | ||
return request.render("account_avatax_exemption.portal_my_exemptions", values) | ||
|
||
def _exemption_get_page_view_values(self, exemption, access_token, **kwargs): | ||
values = { | ||
"exemption": exemption, | ||
"fields": self._exemptions_fields(), | ||
"page_name": "exemption", | ||
"user": request.env.user, | ||
} | ||
|
||
return self._get_page_view_values( | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.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.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.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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.