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

[16.0][MIG] account_avatax_repair_oca: Migration to 16.0 #461

Open
wants to merge 4 commits into
base: 16.0
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
145 changes: 145 additions & 0 deletions account_avatax_repair_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
====================================================
Avalara Avatax Certified Connector for Repair Orders
====================================================

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

.. |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_repair_oca
: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_repair_oca
: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 Integration with odoo app.
Please refer to the corresponding documentation.

**Table of contents**

.. contents::
:local:

Usage
=====

The AvaTax module is integrated into Repair Orders and allows computation of taxes.
Repairs order transactions do not appear in the in the AvaTax interface.

The information placed in the repair order will automatically pass to the invoice
on the Avalara server and can be viewed in the AvaTax control panel.

They will be reported as a net deduction on the line item cost.

Create New Repair Order

- Navigate to: Repairs

- Click Create button

Compute Taxes with AvaTax

- The module will calculate tax when the repair order is confirmed,
when the changes made to a repair order are saved, by navigating to Compute Taxes
or by navigating to Action >> Update taxes with Avatax.
At this step, the repair order will retrieve the tax amount from Avalara
but will not report the transaction to the AvaTax dashboard.
Only invoice, refund, and payment activity are reported to the dashboard.

- The module will check if there is a selected warehouse
and will automatically determine the address of the warehouse
and the origin location. If no address is assigned to the warehouse
the module will automatically use the address of the company as its origin.
Location code will automatically populate with the warehouse code
but can be modified if needed.

- Hide Exemption & Tax Based on shipping address -- this will provide this
feature support at sale order level.


Tax Exemption Status

- Tax exemption status can be defined on Contacts.

- In a multi-company environment, the exemption status is defined per
Company, since each individual company is required to secure the
exemption certificates to claim for exemption application,
and this may not be the case for all Companies.

- If the customer is tax exempt, in the "Avatax" tab, check the "Is Tax Exempt" checkbox.
When checked, the exemption details can be provided.
The Exemption Code is the type of exemption,
and the Exemption Number is an identification number to use on the customer's State.

- This exemption status will only be applied for delivery addresses
in the State matching the State of the exemption address.
The same customer can have exemptions on several states.
For this use additional Contact/Addresses for those states,
and enter the exempention details there.

- To make this data management simpler, is it possible to set the customer as exempt
country wide, using the corresponding checkbox. In this case the exemption status will
be used for delivery addresses in any state. Using this option has compliance risks, so
plase use it with care.

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_repair_oca%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
~~~~~~~

* ForgeFlow

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


* ForgeFlow (https://www.forgeflow.com)

* Alex Paris
* Kencove (https://www.kencove.com)

* Mohamed Alkobrosli

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_repair_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_avatax_repair_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions account_avatax_repair_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Avalara Avatax Certified Connector for Repair Orders",
"version": "16.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"summary": "Repair Orders with automatic Tax application using Avatax",
"license": "AGPL-3",
"category": "Inventory",
"website": "https://github.com/OCA/account-fiscal-rule",
"depends": ["account_avatax_oca", "repair"],
"data": [
"views/repair_order_view.xml",
"views/avalara_salestax_view.xml",
"views/partner_view.xml",
],
"auto_install": True,
}
6 changes: 6 additions & 0 deletions account_avatax_repair_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from . import account_move
from . import partner
from . import repair_order
from . import repair_fee
from . import repair_line
from . import avalara_salestax
17 changes: 17 additions & 0 deletions account_avatax_repair_oca/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import api, models


class AccountMove(models.Model):
_inherit = "account.move"

@api.onchange("partner_id")
def _onchange_partner_id(self):
res = super(AccountMove, self)._onchange_partner_id()
self._onchange_partner_shipping_id()
return res

Check warning on line 11 in account_avatax_repair_oca/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/account_move.py#L9-L11

Added lines #L9 - L11 were not covered by tests

@api.onchange("partner_shipping_id")
def _onchange_partner_shipping_id(self):
res = super(AccountMove, self)._onchange_partner_shipping_id()
self.tax_on_shipping_address = bool(self.partner_shipping_id)
return res

Check warning on line 17 in account_avatax_repair_oca/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/account_move.py#L15-L17

Added lines #L15 - L17 were not covered by tests
21 changes: 21 additions & 0 deletions account_avatax_repair_oca/models/avalara_salestax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from odoo import fields, models


class AvalaraSalestax(models.Model):
_inherit = "avalara.salestax"

use_partner_invoice_id = fields.Boolean(
"Use Invoice partner's customer code in SO",
default=True,
help="Use Sales Order's Invoice Address field to determine Taxable" "Status",
)
repair_calculate_tax = fields.Boolean(
"Auto Calculate Tax on Repair Save",
help="Automatically triggers API to calculate tax If changes made on"
"SO's warehouse_id, tax_on_shipping_address, "
"SO line's price_unit, discount, product_uom_qty",
)
override_line_taxes = fields.Boolean(
help="When checked, the Avatax computed tax will replace any other taxes"
" that may exist in the document line.",
)
27 changes: 27 additions & 0 deletions account_avatax_repair_oca/models/partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from odoo import _, api, fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

@api.onchange("property_exemption_country_wide")
def _onchange_property_exemption_contry_wide(self):
if self.property_exemption_country_wide:
message = (

Check warning on line 10 in account_avatax_repair_oca/models/partner.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/partner.py#L10

Added line #L10 was not covered by tests
_(
"Enabling the exemption status for all states"
" may have tax compliance risks,"
" and should be carefully considered.\n\n"
" Please ensure that your tax advisor was consulted and the"
" necessary tax exemption documentation was obtained"
" for every state this Partner may have transactions."
),
)
return {"warning": {"title": _("Tax Compliance Risk"), "message": message}}

Check warning on line 20 in account_avatax_repair_oca/models/partner.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/partner.py#L20

Added line #L20 was not covered by tests

property_exemption_country_wide = fields.Boolean(
"Exemption Applies Country Wide",
help="When enabled, the delivery address State is irrelevant"
" when looking up the exemption status, meaning that the exemption"
" is considered applicable for all states",
)
72 changes: 72 additions & 0 deletions account_avatax_repair_oca/models/repair_fee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from odoo import api, fields, models


class RepairFee(models.Model):
_inherit = "repair.fee"

tax_amt_avatax = fields.Monetary(string="AvaTax")

@api.depends("tax_amt_avatax")
def _compute_price_total(self):
res = super()._compute_price_total()

Check warning on line 11 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L11

Added line #L11 was not covered by tests
for fee in self:
fee.price_total = fee.price_subtotal + fee.tax_amt_avatax
return res

Check warning on line 14 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L13-L14

Added lines #L13 - L14 were not covered by tests

def _avatax_prepare_line(self, sign=1, doc_type=None):
"""
Prepare a line to use for Avatax computation.
Returns a dict
"""
line = self
res = {}

Check warning on line 22 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L21-L22

Added lines #L21 - L22 were not covered by tests
# Add UPC to product item code
avatax_config = line.company_id.get_avatax_config_company()
product = line.product_id

Check warning on line 25 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L24-L25

Added lines #L24 - L25 were not covered by tests
if product.barcode and avatax_config.upc_enable:
item_code = "UPC:%d" % product.barcode

Check warning on line 27 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L27

Added line #L27 was not covered by tests
else:
item_code = product.default_code or ("ID:%d" % product.id)
tax_code = line.product_id.applicable_tax_code_id.name
amount = sign * line.price_unit * line.product_uom_qty

Check warning on line 31 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L29-L31

Added lines #L29 - L31 were not covered by tests
# Calculate discount amount
discount_amount = 0.0
is_discounted = False
res = {

Check warning on line 35 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L33-L35

Added lines #L33 - L35 were not covered by tests
"qty": line.product_uom_qty,
"itemcode": item_code,
"description": line.name,
"discounted": is_discounted,
"discount": discount_amount,
"amount": amount,
"tax_code": tax_code,
"id": line,
"tax_id": line.tax_id,
}
return res

Check warning on line 46 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L46

Added line #L46 was not covered by tests

@api.onchange("product_uom_qty", "price_unit", "tax_id")
def onchange_reset_avatax_amount(self):
"""
When changing quantities or prices, reset the Avatax computed amount.
The Odoo computed tax amount will then be shown, as a reference.
The Avatax amount will be recomputed upon document validation.
"""
for line in self:
line.tax_amt_avatax = 0
line.repair_id.amount_tax_avatax = 0

Check warning on line 57 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L56-L57

Added lines #L56 - L57 were not covered by tests

@api.depends("product_uom_qty", "price_unit", "tax_id", "tax_amt_avatax")
def _compute_amount(self):
"""
If we have a Avatax computed amount, use it instead of the Odoo computed one
"""
super()._compute_amount()

Check warning on line 64 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L64

Added line #L64 was not covered by tests
for line in self:
if line.tax_amt_avatax: # Has Avatax computed amount
vals = {

Check warning on line 67 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L67

Added line #L67 was not covered by tests
"price_tax": line.tax_amt_avatax,
"price_total": line.price_subtotal + line.tax_amt_avatax,
}
line.update(vals)
return

Check warning on line 72 in account_avatax_repair_oca/models/repair_fee.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_fee.py#L71-L72

Added lines #L71 - L72 were not covered by tests
72 changes: 72 additions & 0 deletions account_avatax_repair_oca/models/repair_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from odoo import api, fields, models


class RepairLine(models.Model):
_inherit = "repair.line"

tax_amt_avatax = fields.Monetary(string="AvaTax")

@api.depends("tax_amt_avatax")
def _compute_price_total(self):
res = super()._compute_price_total()

Check warning on line 11 in account_avatax_repair_oca/models/repair_line.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_line.py#L11

Added line #L11 was not covered by tests
for line in self:
line.price_total = line.price_subtotal + line.tax_amt_avatax
return res

Check warning on line 14 in account_avatax_repair_oca/models/repair_line.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_line.py#L13-L14

Added lines #L13 - L14 were not covered by tests

def _avatax_prepare_line(self, sign=1, doc_type=None):
"""
Prepare a line to use for Avatax computation.
Returns a dict
"""
line = self
res = {}
# Add UPC to product item code
avatax_config = line.company_id.get_avatax_config_company()
product = line.product_id
if product.barcode and avatax_config.upc_enable:
item_code = "UPC:%d" % product.barcode

Check warning on line 27 in account_avatax_repair_oca/models/repair_line.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_line.py#L27

Added line #L27 was not covered by tests
else:
item_code = product.default_code or ("ID:%d" % product.id)
tax_code = line.product_id.applicable_tax_code_id.name
amount = sign * line.price_unit * line.product_uom_qty
# Calculate discount amount
discount_amount = 0.0
is_discounted = False
res = {
"qty": line.product_uom_qty,
"itemcode": item_code,
"description": line.name,
"discounted": is_discounted,
"discount": discount_amount,
"amount": amount,
"tax_code": tax_code,
"id": line,
"tax_id": line.tax_id,
}
return res

@api.onchange("product_uom_qty", "price_unit", "tax_id")
def onchange_reset_avatax_amount(self):
"""
When changing quantities or prices, reset the Avatax computed amount.
The Odoo computed tax amount will then be shown, as a reference.
The Avatax amount will be recomputed upon document validation.
"""
for line in self:
line.tax_amt_avatax = 0
line.repair_id.amount_tax_avatax = 0

@api.depends("product_uom_qty", "price_unit", "tax_id", "tax_amt_avatax")
def _compute_amount(self):
"""
If we have a Avatax computed amount, use it instead of the Odoo computed one
"""
super()._compute_amount()

Check warning on line 64 in account_avatax_repair_oca/models/repair_line.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_line.py#L64

Added line #L64 was not covered by tests
for line in self:
if line.tax_amt_avatax: # Has Avatax computed amount
vals = {

Check warning on line 67 in account_avatax_repair_oca/models/repair_line.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_line.py#L67

Added line #L67 was not covered by tests
"price_tax": line.tax_amt_avatax,
"price_total": line.price_subtotal + line.tax_amt_avatax,
}
line.update(vals)
return

Check warning on line 72 in account_avatax_repair_oca/models/repair_line.py

View check run for this annotation

Codecov / codecov/patch

account_avatax_repair_oca/models/repair_line.py#L71-L72

Added lines #L71 - L72 were not covered by tests
Loading
Loading