From 2bef3c4bc8dd4c2dc88c8cb003c0a46773c7c911 Mon Sep 17 00:00:00 2001 From: Daniel Reis Date: Tue, 2 Aug 2022 21:02:42 +0100 Subject: [PATCH 01/27] account_avatax_sale_oca: renamed from account_sale_avatax --- account_avatax_sale_oca/README.rst | 162 ++++++ account_avatax_sale_oca/__init__.py | 1 + account_avatax_sale_oca/__manifest__.py | 19 + .../i18n/account_avatax_sale.pot | 202 +++++++ account_avatax_sale_oca/models/__init__.py | 5 + .../models/account_move.py | 17 + account_avatax_sale_oca/models/account_tax.py | 44 ++ .../models/avalara_salestax.py | 21 + account_avatax_sale_oca/models/partner.py | 27 + account_avatax_sale_oca/models/sale_order.py | 373 +++++++++++++ .../readme/CONTRIBUTORS.rst | 17 + .../readme/DESCRIPTION.rst | 2 + account_avatax_sale_oca/readme/USAGE.rst | 58 +++ .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 493 ++++++++++++++++++ .../views/avalara_salestax_view.xml | 38 ++ .../views/partner_view.xml | 18 + .../views/sale_order_view.xml | 93 ++++ 18 files changed, 1590 insertions(+) create mode 100644 account_avatax_sale_oca/README.rst create mode 100644 account_avatax_sale_oca/__init__.py create mode 100644 account_avatax_sale_oca/__manifest__.py create mode 100644 account_avatax_sale_oca/i18n/account_avatax_sale.pot create mode 100644 account_avatax_sale_oca/models/__init__.py create mode 100644 account_avatax_sale_oca/models/account_move.py create mode 100644 account_avatax_sale_oca/models/account_tax.py create mode 100644 account_avatax_sale_oca/models/avalara_salestax.py create mode 100644 account_avatax_sale_oca/models/partner.py create mode 100644 account_avatax_sale_oca/models/sale_order.py create mode 100644 account_avatax_sale_oca/readme/CONTRIBUTORS.rst create mode 100644 account_avatax_sale_oca/readme/DESCRIPTION.rst create mode 100644 account_avatax_sale_oca/readme/USAGE.rst create mode 100644 account_avatax_sale_oca/static/description/icon.png create mode 100644 account_avatax_sale_oca/static/description/index.html create mode 100644 account_avatax_sale_oca/views/avalara_salestax_view.xml create mode 100644 account_avatax_sale_oca/views/partner_view.xml create mode 100644 account_avatax_sale_oca/views/sale_order_view.xml diff --git a/account_avatax_sale_oca/README.rst b/account_avatax_sale_oca/README.rst new file mode 100644 index 000000000..72f83f9fa --- /dev/null +++ b/account_avatax_sale_oca/README.rst @@ -0,0 +1,162 @@ +========================================= +Avalara Avatax Connector for Sales Orders +========================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |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/15.0/account_avatax_sale + :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-15-0/account-fiscal-rule-15-0-account_avatax_sale + :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/15.0 + :alt: Try me on Runbot + +|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 Sales Orders and allows computation of taxes. +Sales order transactions do not appear in the in the AvaTax interface. + +The information placed in the sales order will automatically pass to the invoice +on the Avalara server and can be viewed in the AvaTax control panel. + +Discounts are handled when they are enabled in Odoo's settings. +They will be reported as a net deduction on the line item cost. + +Create New Sales Order + +- Navigate to: Sales >> Orders >> Orders + +- Click Create button + +Compute Taxes with AvaTax + +- The module will calculate tax when the sales order is confirmed, + or by navigating to Action >> Update taxes with Avatax. + At this step, the sales 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 exemptiions 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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Open Source Integrators +* Fabrice Henrion +* Sodexis + +Contributors +~~~~~~~~~~~~ + +* Odoo SA + + * Fabrice Henrion + +* Open Source Integrators (https://opensourceintegrators.com) + + * Daniel Reis + * Bhavesh Odedra + * Sandip Mangukiya + +* Serpent CS + + * Murtuza Saleh + +* Sodexis + + * Atchuthan Ubendran + +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. + +.. |maintainer-dreispt| image:: https://github.com/dreispt.png?size=40px + :target: https://github.com/dreispt + :alt: dreispt + +Current `maintainer `__: + +|maintainer-dreispt| + +This module is part of the `OCA/account-fiscal-rule `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_avatax_sale_oca/__init__.py b/account_avatax_sale_oca/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_avatax_sale_oca/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_avatax_sale_oca/__manifest__.py b/account_avatax_sale_oca/__manifest__.py new file mode 100644 index 000000000..2ad6c0043 --- /dev/null +++ b/account_avatax_sale_oca/__manifest__.py @@ -0,0 +1,19 @@ +{ + "name": "Avalara Avatax Certified Connector for Sales Orders", + "version": "15.0.1.1.0", + "author": "Open Source Integrators, Fabrice Henrion," + "Sodexis, Odoo Community Association (OCA)", + "summary": "Sales Orders with automatic Tax application using Avatax", + "license": "AGPL-3", + "category": "Accounting", + "website": "https://github.com/OCA/account-fiscal-rule", + "depends": ["account_avatax_oca", "sale_stock"], + "data": [ + "views/sale_order_view.xml", + "views/partner_view.xml", + "views/avalara_salestax_view.xml", + ], + "auto_install": True, + "development_status": "Production/Stable", + "maintainers": ["dreispt"], +} diff --git a/account_avatax_sale_oca/i18n/account_avatax_sale.pot b/account_avatax_sale_oca/i18n/account_avatax_sale.pot new file mode 100644 index 000000000..7cf0ef086 --- /dev/null +++ b/account_avatax_sale_oca/i18n/account_avatax_sale.pot @@ -0,0 +1,202 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_avatax_sale +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_avalara_salestax__sale_calculate_tax +msgid "Auto Calculate Tax on SO Save" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,help:account_avatax_sale.field_avalara_salestax__sale_calculate_tax +msgid "" +"Automatically triggers API to calculate tax If changes made onSO's " +"warehouse_id, tax_on_shipping_address, SO line's price_unit, discount, " +"product_uom_qty" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__tax_amount +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order_line__tax_amt +msgid "AvaTax" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model,name:account_avatax_sale.model_avalara_salestax +msgid "AvaTax Configuration" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__avatax_request_log +msgid "Avatax API Request Log" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__avatax_response_log +msgid "Avatax API Response Log" +msgstr "" + +#. module: account_avatax_sale +#: model_terms:ir.ui.view,arch_db:account_avatax_sale.sale_order_update_form_view +msgid "Avatax Log" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__calculate_tax_on_save +msgid "Calculate Tax On Save" +msgstr "" + +#. module: account_avatax_sale +#: model_terms:ir.ui.view,arch_db:account_avatax_sale.sale_order_update_form_view +msgid "Compute Taxes" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model,name:account_avatax_sale.model_res_partner +msgid "Contact" +msgstr "" + +#. module: account_avatax_sale +#: code:addons/account_avatax_sale/models/partner.py:0 +#, python-format +msgid "" +"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." +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_res_partner__property_exemption_country_wide +#: model:ir.model.fields,field_description:account_avatax_sale.field_res_users__property_exemption_country_wide +msgid "Exemption Applies Country Wide" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__exemption_code_id +msgid "Exemption Code" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__exemption_code +msgid "Exemption Number" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__hide_exemption +msgid "Hide Exemption & Tax Based on shipping address" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,help:account_avatax_sale.field_sale_order__exemption_code_id +msgid "It show the customer exemption code" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,help:account_avatax_sale.field_sale_order__exemption_code +msgid "It show the customer exemption number" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model,name:account_avatax_sale.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__location_code +msgid "Location Code" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,help:account_avatax_sale.field_sale_order__location_code +msgid "Origin address location code" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_avalara_salestax__override_line_taxes +msgid "Override Line Taxes" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model,name:account_avatax_sale.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model,name:account_avatax_sale.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model,name:account_avatax_sale.model_account_tax +msgid "Tax" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__tax_address_id +msgid "Tax Address" +msgstr "" + +#. module: account_avatax_sale +#: code:addons/account_avatax_sale/models/partner.py:0 +#, python-format +msgid "Tax Compliance Risk" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__tax_on_shipping_address +msgid "Tax based on shipping address" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,help:account_avatax_sale.field_sale_order__hide_exemption +msgid "" +"Uncheck the this field to show exemption fields on SO/Invoice form view. " +"Also, it will show Tax based on shipping address button" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.actions.server,name:account_avatax_sale.action_sale_order_compute_taxes +msgid "Update taxes with AvaTax" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_sale_order__is_avatax +msgid "Use Avatax API" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,field_description:account_avatax_sale.field_avalara_salestax__use_partner_invoice_id +msgid "Use Invoice partner's customer code in SO" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,help:account_avatax_sale.field_avalara_salestax__use_partner_invoice_id +msgid "Use Sales Order's Invoice Address field to determine TaxableStatus" +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,help:account_avatax_sale.field_avalara_salestax__override_line_taxes +msgid "" +"When checked, the Avatax computed tax will replace any other taxes that may " +"exist in the document line." +msgstr "" + +#. module: account_avatax_sale +#: model:ir.model.fields,help:account_avatax_sale.field_res_partner__property_exemption_country_wide +#: model:ir.model.fields,help:account_avatax_sale.field_res_users__property_exemption_country_wide +msgid "" +"When enabled, the delivery address State is irrelevant when looking up the " +"exemption status, meaning that the exemption is considered applicable for " +"all states" +msgstr "" diff --git a/account_avatax_sale_oca/models/__init__.py b/account_avatax_sale_oca/models/__init__.py new file mode 100644 index 000000000..65f793277 --- /dev/null +++ b/account_avatax_sale_oca/models/__init__.py @@ -0,0 +1,5 @@ +from . import account_move +from . import account_tax +from . import partner +from . import sale_order +from . import avalara_salestax diff --git a/account_avatax_sale_oca/models/account_move.py b/account_avatax_sale_oca/models/account_move.py new file mode 100644 index 000000000..d8319eebc --- /dev/null +++ b/account_avatax_sale_oca/models/account_move.py @@ -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 + + @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 diff --git a/account_avatax_sale_oca/models/account_tax.py b/account_avatax_sale_oca/models/account_tax.py new file mode 100644 index 000000000..4962f3dac --- /dev/null +++ b/account_avatax_sale_oca/models/account_tax.py @@ -0,0 +1,44 @@ +from odoo import models + + +class AccountTax(models.Model): + _inherit = "account.tax" + + def compute_all( + self, + price_unit, + currency=None, + quantity=1.0, + product=None, + partner=None, + is_refund=False, + handle_price_include=True, + include_caba_tags=False, + ): + res = super().compute_all( + price_unit, + currency, + quantity, + product, + partner, + is_refund, + handle_price_include, + include_caba_tags=False, + ) + for_avatax_object = self.env.context.get("for_avatax_object") + if for_avatax_object: + # Find the Avatax amount in the document Lines + # Looks up the line for the current product, price_unit, and quantity + # Note that the price_unit used must consider discount + avatax_ids = self.env["account.tax"].search([("is_avatax", "=", True)]).ids + for tax_data in [x for x in res["taxes"] if x["id"] in avatax_ids]: + line = for_avatax_object.order_line.filtered( + lambda x: tax_data["id"] in x.tax_id.ids + and x.product_id == product + and x.product_uom_qty == quantity + and x.price_unit == price_unit + )[:1] + if line.tax_amt: # Avatax Amount + tax_data["amount"] = line.tax_amt + res["total_included"] = res["total_excluded"] + line.tax_amt + return res diff --git a/account_avatax_sale_oca/models/avalara_salestax.py b/account_avatax_sale_oca/models/avalara_salestax.py new file mode 100644 index 000000000..86ff1434e --- /dev/null +++ b/account_avatax_sale_oca/models/avalara_salestax.py @@ -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", + ) + sale_calculate_tax = fields.Boolean( + "Auto Calculate Tax on SO 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.", + ) diff --git a/account_avatax_sale_oca/models/partner.py b/account_avatax_sale_oca/models/partner.py new file mode 100644 index 000000000..b698fbe93 --- /dev/null +++ b/account_avatax_sale_oca/models/partner.py @@ -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 = ( + _( + "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}} + + 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", + ) diff --git a/account_avatax_sale_oca/models/sale_order.py b/account_avatax_sale_oca/models/sale_order.py new file mode 100644 index 000000000..142f6bdca --- /dev/null +++ b/account_avatax_sale_oca/models/sale_order.py @@ -0,0 +1,373 @@ +from odoo import api, fields, models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + @api.depends( + "order_line.tax_id", "order_line.price_unit", "amount_total", "amount_untaxed" + ) + def _compute_tax_totals_json(self): + # Make the Sales Order data available to the AccountTax.compute_all() method + # This is needed to take in consideration the additional Avatax fields + enriched_self = self.with_context(for_avatax_object=self) + return super(SaleOrder, enriched_self)._compute_tax_totals_json() + + @api.model + @api.depends("company_id", "partner_id", "partner_invoice_id", "state") + def _compute_hide_exemption(self): + avatax_config = self.env.company.get_avatax_config_company() + for order in self: + order.hide_exemption = avatax_config.hide_exemption + + hide_exemption = fields.Boolean( + "Hide Exemption & Tax Based on shipping address", + compute=_compute_hide_exemption, # For past transactions visibility + default=lambda self: self.env.company.get_avatax_config_company, + help="Uncheck the this field to show exemption fields on SO/Invoice form view. " + "Also, it will show Tax based on shipping address button", + ) + tax_amount = fields.Monetary(string="AvaTax") + + @api.onchange("partner_shipping_id", "partner_id") + def onchange_partner_shipping_id(self): + """ + Apply the exemption number and code from the Invoice Partner Data + We can only apply an exemption status that matches the delivery + address Country and State. + + The setup for this is to add contact/addresses for the Invoicing Partner, + for each of the states we can claim exepmtion for. + """ + res = super(SaleOrder, self).onchange_partner_shipping_id() + self.tax_on_shipping_address = bool(self.partner_shipping_id) + return res + + @api.depends("partner_invoice_id", "tax_address_id", "company_id") + def _compute_onchange_exemption(self): + for order in self.filtered(lambda x: x.state not in ["done", "cancel"]): + invoice_partner = order.partner_invoice_id.commercial_partner_id + ship_to_address = order.tax_address_id + # Find an exemption address matching the Country + State + # of the Delivery address + exemption_addresses = ( + invoice_partner | invoice_partner.child_ids + ).filtered("property_tax_exempt") + exemption_address_naive = exemption_addresses.filtered( + lambda a: a.country_id == ship_to_address.country_id + and ( + a.state_id == ship_to_address.state_id + or invoice_partner.property_exemption_country_wide + ) + )[:1] + # Force Company to get the correct values form the Property fields + exemption_address = exemption_address_naive.with_company( + order.company_id.id + ) + order.exemption_code = exemption_address.property_exemption_number + order.exemption_code_id = exemption_address.property_exemption_code_id + + def _prepare_invoice(self): + invoice_vals = super(SaleOrder, self)._prepare_invoice() + invoice_vals.update( + { + "exemption_code": self.exemption_code or "", + "exemption_code_id": self.exemption_code_id.id or False, + "exemption_locked": True, + "location_code": self.location_code or "", + "warehouse_id": self.warehouse_id.id or "", + "tax_on_shipping_address": self.tax_on_shipping_address, + "so_partner_id": self.partner_id.id, + } + ) + return invoice_vals + + @api.onchange("order_line", "fiscal_position_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 order in self: + order.tax_amount = 0 + order.order_line.write({"tax_amt": 0}) + + @api.depends("order_line.price_total", "order_line.product_uom_qty", "tax_amount") + def _amount_all(self): + """ + Compute fields amount_untaxed, amount_tax, amount_total + Their computation needs to be overriden, + to use the amounts returned by Avatax service, stored in specific fields. + """ + res = super()._amount_all() + for order in self: + if order.tax_amount: + order.update( + { + "amount_tax": order.tax_amount, + "amount_total": order.amount_untaxed + order.tax_amount, + } + ) + return res + + @api.depends("tax_on_shipping_address", "partner_id", "partner_shipping_id") + def _compute_tax_address_id(self): + for invoice in self: + invoice.tax_address_id = ( + invoice.partner_shipping_id + if invoice.tax_on_shipping_address + else invoice.partner_id + ) + + is_avatax = fields.Boolean(related="fiscal_position_id.is_avatax") + exemption_code = fields.Char( + "Exemption Number", + compute=_compute_onchange_exemption, + readonly=False, # New computed writeable fields + store=True, + help="It show the customer exemption number", + ) + exemption_code_id = fields.Many2one( + "exemption.code", + "Exemption Code", + compute=_compute_onchange_exemption, + readonly=False, # New computed writeable fields + store=True, + help="It show the customer exemption code", + ) + tax_on_shipping_address = fields.Boolean( + "Tax based on shipping address", default=True + ) + tax_address_id = fields.Many2one( + "res.partner", + "Tax Address", + readonly=True, + states={"draft": [("readonly", False)]}, + compute="_compute_tax_address_id", + store=True, + ) + location_code = fields.Char(help="Origin address location code") + calculate_tax_on_save = fields.Boolean() + avatax_request_log = fields.Text( + "Avatax API Request Log", readonly=True, copy=False + ) + avatax_response_log = fields.Text( + "Avatax API Response Log", readonly=True, copy=False + ) + + def _get_avatax_doc_type(self, commit=False): + return "SalesOrder" + + def _avatax_prepare_lines(self, order_lines, doc_type=None): + """ + Prepare the lines to use for Avatax computation. + Returns a list of dicts + """ + lines = [ + line._avatax_prepare_line(sign=1, doc_type=doc_type) + for line in order_lines.filtered(lambda line: not line.display_type) + ] + return [x for x in lines if x] + + def _avatax_compute_tax(self): + """Contact REST API and recompute taxes for a Sale Order""" + self and self.ensure_one() + doc_type = self._get_avatax_doc_type() + Tax = self.env["account.tax"] + avatax_config = self.company_id.get_avatax_config_company() + if not avatax_config: + return False + partner = self.partner_id + if avatax_config.use_partner_invoice_id: + partner = self.partner_invoice_id + taxable_lines = self._avatax_prepare_lines(self.order_line) + tax_result = avatax_config.create_transaction( + self.date_order, + self.name, + doc_type, + partner, + self.warehouse_id.partner_id or self.company_id.partner_id, + self.tax_address_id or self.partner_id, + taxable_lines, + self.user_id, + self.exemption_code or None, + self.exemption_code_id.code or None, + currency_id=self.currency_id, + log_to_record=self, + ) + tax_result_lines = {int(x["lineNumber"]): x for x in tax_result["lines"]} + for line in self.order_line: + tax_result_line = tax_result_lines.get(line.id) + if tax_result_line: + # Should we check the rate with the tax amount? + # tax_amount = tax_result_line["taxCalculated"] + # rate = round(tax_amount / line.price_subtotal * 100, 2) + rate = tax_result_line["rate"] + tax = Tax.get_avalara_tax(rate, doc_type) + if tax not in line.tax_id: + line_taxes = ( + tax + if avatax_config.override_line_taxes + else tax | line.tax_id.filtered(lambda x: not x.is_avatax) + ) + line.tax_id = line_taxes + line.tax_amt = tax_result_line["tax"] + self.tax_amount = tax_result.get("totalTax") + return True + + def avalara_compute_taxes(self): + """ + Use Avatax API to compute taxes. + Sets the Taxes on each line, and lets odoo perfomr teh calculations. + """ + for order in self: + if order.fiscal_position_id.is_avatax: + order._avatax_compute_tax() + return True + + def action_confirm(self): + avatax_config = self.company_id.get_avatax_config_company() + if avatax_config and avatax_config.force_address_validation: + for addr in [self.partner_id, self.partner_shipping_id]: + if not addr.date_validation: + # The Confirm action will be interrupted + # if the address is not validated + return addr.button_avatax_validate_address() + if avatax_config: + self.avalara_compute_taxes() + res = super(SaleOrder, self).action_confirm() + return res + + @api.onchange( + "order_line", + "tax_on_shipping_address", + "tax_address_id", + "partner_id", + ) + def onchange_avatax_calculation(self): + avatax_config = self.env.company.get_avatax_config_company() + self.calculate_tax_on_save = False + if avatax_config.sale_calculate_tax: + if ( + self._origin.tax_address_id.street != self.tax_address_id.street + or self._origin.partner_id != self.partner_id + or self._origin.tax_on_shipping_address != self.tax_on_shipping_address + ): + self.calculate_tax_on_save = True + return + for line in self.order_line: + if ( + line._origin.product_uom_qty != line.product_uom_qty + or line._origin.discount != line.discount + or line._origin.price_unit != line.price_unit + or line._origin.warehouse_id != line.warehouse_id + ): + self.calculate_tax_on_save = True + break + + @api.model + def create(self, vals): + record = super(SaleOrder, self).create(vals) + avatax_config = self.env.company.get_avatax_config_company() + if ( + avatax_config.sale_calculate_tax + and record.calculate_tax_on_save + and not self._context.get("skip_second_write", False) + ): + record.with_context(skip_second_write=True).write( + { + "calculate_tax_on_save": False, + } + ) + record.avalara_compute_taxes() + return record + + def write(self, vals): + result = super(SaleOrder, self).write(vals) + avatax_config = self.env.company.get_avatax_config_company() + for record in self: + if ( + avatax_config.sale_calculate_tax + and record.calculate_tax_on_save + and record.state != "done" + and not self._context.get("skip_second_write", False) + ): + record.with_context(skip_second_write=True).write( + { + "calculate_tax_on_save": False, + } + ) + record.avalara_compute_taxes() + return result + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + tax_amt = fields.Monetary(string="AvaTax") + + 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 + 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 * (1 - line.discount / 100.0) + ) + # Calculate discount amount + discount_amount = 0.0 + is_discounted = False + if line.discount: + discount_amount = ( + sign * line.price_unit * line.product_uom_qty * line.discount / 100.0 + ) + is_discounted = True + 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", "discount", "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 = 0 + line.order_id.tax_amount = 0 + + @api.depends("product_uom_qty", "discount", "price_unit", "tax_id", "tax_amt") + def _compute_amount(self): + """ + If we have a Avatax computed amount, use it instead of the Odoo computed one + """ + res = super()._compute_amount() + for line in self: + if line.tax_amt: # Has Avatax computed amount + vals = { + "price_tax": line.tax_amt, + "price_total": line.price_subtotal + line.tax_amt, + } + line.update(vals) + return res diff --git a/account_avatax_sale_oca/readme/CONTRIBUTORS.rst b/account_avatax_sale_oca/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..329425fba --- /dev/null +++ b/account_avatax_sale_oca/readme/CONTRIBUTORS.rst @@ -0,0 +1,17 @@ +* Odoo SA + + * Fabrice Henrion + +* Open Source Integrators (https://opensourceintegrators.com) + + * Daniel Reis + * Bhavesh Odedra + * Sandip Mangukiya + +* Serpent CS + + * Murtuza Saleh + +* Sodexis + + * Atchuthan Ubendran diff --git a/account_avatax_sale_oca/readme/DESCRIPTION.rst b/account_avatax_sale_oca/readme/DESCRIPTION.rst new file mode 100644 index 000000000..b9f7adc12 --- /dev/null +++ b/account_avatax_sale_oca/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module is a component of the Avatax Integration with odoo app. +Please refer to the corresponding documentation. diff --git a/account_avatax_sale_oca/readme/USAGE.rst b/account_avatax_sale_oca/readme/USAGE.rst new file mode 100644 index 000000000..a59537c3a --- /dev/null +++ b/account_avatax_sale_oca/readme/USAGE.rst @@ -0,0 +1,58 @@ +The AvaTax module is integrated into Sales Orders and allows computation of taxes. +Sales order transactions do not appear in the in the AvaTax interface. + +The information placed in the sales order will automatically pass to the invoice +on the Avalara server and can be viewed in the AvaTax control panel. + +Discounts are handled when they are enabled in Odoo's settings. +They will be reported as a net deduction on the line item cost. + +Create New Sales Order + +- Navigate to: Sales >> Orders >> Orders + +- Click Create button + +Compute Taxes with AvaTax + +- The module will calculate tax when the sales order is confirmed, + or by navigating to Action >> Update taxes with Avatax. + At this step, the sales 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 exemptiions 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. diff --git a/account_avatax_sale_oca/static/description/icon.png b/account_avatax_sale_oca/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3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KF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/account_avatax_sale_oca/static/description/index.html b/account_avatax_sale_oca/static/description/index.html new file mode 100644 index 000000000..84576c500 --- /dev/null +++ b/account_avatax_sale_oca/static/description/index.html @@ -0,0 +1,493 @@ + + + + + + +Avalara Avatax Connector for Sales Orders + + + +
+

Avalara Avatax Connector for Sales Orders

+ + +

Production/Stable License: AGPL-3 OCA/account-fiscal-rule Translate me on Weblate Try me on Runbot

+

This module is a component of the Avatax Integration with odoo app. +Please refer to the corresponding documentation.

+

Table of contents

+ +
+

Usage

+

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

+

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

+

Discounts are handled when they are enabled in Odoo’s settings. +They will be reported as a net deduction on the line item cost.

+

Create New Sales Order

+
    +
  • Navigate to: Sales >> Orders >> Orders
  • +
  • Click Create button
  • +
+

Compute Taxes with AvaTax

+
    +
  • The module will calculate tax when the sales order is confirmed, +or by navigating to Action >> Update taxes with Avatax. +At this step, the sales 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 exemptiions 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. +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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Open Source Integrators
  • +
  • Fabrice Henrion
  • +
  • Sodexis
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

dreispt

+

This module is part of the OCA/account-fiscal-rule project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_avatax_sale_oca/views/avalara_salestax_view.xml b/account_avatax_sale_oca/views/avalara_salestax_view.xml new file mode 100644 index 000000000..7764600ca --- /dev/null +++ b/account_avatax_sale_oca/views/avalara_salestax_view.xml @@ -0,0 +1,38 @@ + + + + avalara.salestax.inherit + avalara.salestax + + + +
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
diff --git a/account_avatax_sale_oca/views/partner_view.xml b/account_avatax_sale_oca/views/partner_view.xml new file mode 100644 index 000000000..de57645a0 --- /dev/null +++ b/account_avatax_sale_oca/views/partner_view.xml @@ -0,0 +1,18 @@ + + + Partner Form: add Exempt Country Wide + res.partner + + + + + + + + diff --git a/account_avatax_sale_oca/views/sale_order_view.xml b/account_avatax_sale_oca/views/sale_order_view.xml new file mode 100644 index 000000000..309c9f766 --- /dev/null +++ b/account_avatax_sale_oca/views/sale_order_view.xml @@ -0,0 +1,93 @@ + + + sale.order.update.form.view + sale.order + form + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sale.order.form.view.editable + sale.order + + + + + 0 + + + 0 + + + + + Update taxes with AvaTax + + + code + records.avalara_compute_taxes() + + From ff6faa85f91eae6b9b83b5d28ee61d5272b4f9ad Mon Sep 17 00:00:00 2001 From: oca-ci Date: Thu, 8 Sep 2022 16:07:02 +0000 Subject: [PATCH 02/27] Update account_avatax_sale_oca.pot --- .../i18n/account_avatax_sale_oca.pot | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 account_avatax_sale_oca/i18n/account_avatax_sale_oca.pot diff --git a/account_avatax_sale_oca/i18n/account_avatax_sale_oca.pot b/account_avatax_sale_oca/i18n/account_avatax_sale_oca.pot new file mode 100644 index 000000000..da0bb2ff9 --- /dev/null +++ b/account_avatax_sale_oca/i18n/account_avatax_sale_oca.pot @@ -0,0 +1,202 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_avatax_sale_oca +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_avalara_salestax__sale_calculate_tax +msgid "Auto Calculate Tax on SO Save" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,help:account_avatax_sale_oca.field_avalara_salestax__sale_calculate_tax +msgid "" +"Automatically triggers API to calculate tax If changes made onSO's " +"warehouse_id, tax_on_shipping_address, SO line's price_unit, discount, " +"product_uom_qty" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__tax_amount +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order_line__tax_amt +msgid "AvaTax" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model,name:account_avatax_sale_oca.model_avalara_salestax +msgid "AvaTax Configuration" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__avatax_request_log +msgid "Avatax API Request Log" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__avatax_response_log +msgid "Avatax API Response Log" +msgstr "" + +#. module: account_avatax_sale_oca +#: model_terms:ir.ui.view,arch_db:account_avatax_sale_oca.sale_order_update_form_view +msgid "Avatax Log" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__calculate_tax_on_save +msgid "Calculate Tax On Save" +msgstr "" + +#. module: account_avatax_sale_oca +#: model_terms:ir.ui.view,arch_db:account_avatax_sale_oca.sale_order_update_form_view +msgid "Compute Taxes" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model,name:account_avatax_sale_oca.model_res_partner +msgid "Contact" +msgstr "" + +#. module: account_avatax_sale_oca +#: code:addons/account_avatax_sale_oca/models/partner.py:0 +#, python-format +msgid "" +"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." +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_res_partner__property_exemption_country_wide +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_res_users__property_exemption_country_wide +msgid "Exemption Applies Country Wide" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__exemption_code_id +msgid "Exemption Code" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__exemption_code +msgid "Exemption Number" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__hide_exemption +msgid "Hide Exemption & Tax Based on shipping address" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,help:account_avatax_sale_oca.field_sale_order__exemption_code_id +msgid "It show the customer exemption code" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,help:account_avatax_sale_oca.field_sale_order__exemption_code +msgid "It show the customer exemption number" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model,name:account_avatax_sale_oca.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__location_code +msgid "Location Code" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,help:account_avatax_sale_oca.field_sale_order__location_code +msgid "Origin address location code" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_avalara_salestax__override_line_taxes +msgid "Override Line Taxes" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model,name:account_avatax_sale_oca.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model,name:account_avatax_sale_oca.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model,name:account_avatax_sale_oca.model_account_tax +msgid "Tax" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__tax_address_id +msgid "Tax Address" +msgstr "" + +#. module: account_avatax_sale_oca +#: code:addons/account_avatax_sale_oca/models/partner.py:0 +#, python-format +msgid "Tax Compliance Risk" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__tax_on_shipping_address +msgid "Tax based on shipping address" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,help:account_avatax_sale_oca.field_sale_order__hide_exemption +msgid "" +"Uncheck the this field to show exemption fields on SO/Invoice form view. " +"Also, it will show Tax based on shipping address button" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.actions.server,name:account_avatax_sale_oca.action_sale_order_compute_taxes +msgid "Update taxes with AvaTax" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_sale_order__is_avatax +msgid "Use Avatax API" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,field_description:account_avatax_sale_oca.field_avalara_salestax__use_partner_invoice_id +msgid "Use Invoice partner's customer code in SO" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,help:account_avatax_sale_oca.field_avalara_salestax__use_partner_invoice_id +msgid "Use Sales Order's Invoice Address field to determine TaxableStatus" +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,help:account_avatax_sale_oca.field_avalara_salestax__override_line_taxes +msgid "" +"When checked, the Avatax computed tax will replace any other taxes that may " +"exist in the document line." +msgstr "" + +#. module: account_avatax_sale_oca +#: model:ir.model.fields,help:account_avatax_sale_oca.field_res_partner__property_exemption_country_wide +#: model:ir.model.fields,help:account_avatax_sale_oca.field_res_users__property_exemption_country_wide +msgid "" +"When enabled, the delivery address State is irrelevant when looking up the " +"exemption status, meaning that the exemption is considered applicable for " +"all states" +msgstr "" From 244902d37d2a749799e2a89e7700e85de44c4669 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Thu, 8 Sep 2022 16:10:13 +0000 Subject: [PATCH 03/27] README.rst --- account_avatax_sale_oca/README.rst | 14 +++++++------- .../static/description/index.html | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/account_avatax_sale_oca/README.rst b/account_avatax_sale_oca/README.rst index 72f83f9fa..f12eb566b 100644 --- a/account_avatax_sale_oca/README.rst +++ b/account_avatax_sale_oca/README.rst @@ -1,6 +1,6 @@ -========================================= -Avalara Avatax Connector for Sales Orders -========================================= +=================================================== +Avalara Avatax Certified Connector for Sales Orders +=================================================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! @@ -14,10 +14,10 @@ Avalara Avatax Connector for Sales Orders :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/15.0/account_avatax_sale + :target: https://github.com/OCA/account-fiscal-rule/tree/15.0/account_avatax_sale_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-15-0/account-fiscal-rule-15-0-account_avatax_sale + :target: https://translation.odoo-community.org/projects/account-fiscal-rule-15-0/account-fiscal-rule-15-0-account_avatax_sale_oca :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/15.0 @@ -101,7 +101,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -157,6 +157,6 @@ Current `maintainer `__: |maintainer-dreispt| -This module is part of the `OCA/account-fiscal-rule `_ project on GitHub. +This module is part of the `OCA/account-fiscal-rule `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_avatax_sale_oca/static/description/index.html b/account_avatax_sale_oca/static/description/index.html index 84576c500..98b127ef3 100644 --- a/account_avatax_sale_oca/static/description/index.html +++ b/account_avatax_sale_oca/static/description/index.html @@ -4,7 +4,7 @@ -Avalara Avatax Connector for Sales Orders +Avalara Avatax Certified Connector for Sales Orders -
-

Avalara Avatax Connector for Sales Orders

+
+

Avalara Avatax Certified Connector for Sales Orders

-

Production/Stable License: AGPL-3 OCA/account-fiscal-rule Translate me on Weblate Try me on Runbot

+

Production/Stable License: AGPL-3 OCA/account-fiscal-rule Translate me on Weblate Try me on Runbot

This module is a component of the Avatax Integration with odoo app. Please refer to the corresponding documentation.

Table of contents

@@ -439,7 +439,7 @@

Bug Tracker

Bugs are tracked on GitHub 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.

+feedback.

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

@@ -484,7 +484,7 @@

Maintainers

promote its widespread use.

Current maintainer:

dreispt

-

This module is part of the OCA/account-fiscal-rule project on GitHub.

+

This module is part of the OCA/account-fiscal-rule project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

From c749bce76d666f8fda784631554acc4a71a7dc72 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Thu, 8 Sep 2022 16:10:15 +0000 Subject: [PATCH 04/27] account_avatax_sale_oca 15.0.2.0.0 --- account_avatax_sale_oca/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_avatax_sale_oca/__manifest__.py b/account_avatax_sale_oca/__manifest__.py index 2ad6c0043..1ef28965a 100644 --- a/account_avatax_sale_oca/__manifest__.py +++ b/account_avatax_sale_oca/__manifest__.py @@ -1,6 +1,6 @@ { "name": "Avalara Avatax Certified Connector for Sales Orders", - "version": "15.0.1.1.0", + "version": "15.0.2.0.0", "author": "Open Source Integrators, Fabrice Henrion," "Sodexis, Odoo Community Association (OCA)", "summary": "Sales Orders with automatic Tax application using Avatax", From ab896440a94907e1917b52322131d4e6788c2ed5 Mon Sep 17 00:00:00 2001 From: Nikul-OSI Date: Fri, 7 Apr 2023 18:08:21 +0530 Subject: [PATCH 05/27] account_avatax_sale_oca: black, isort, prettier --- account_avatax_sale_oca/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_avatax_sale_oca/__manifest__.py b/account_avatax_sale_oca/__manifest__.py index 1ef28965a..fabeb0f48 100644 --- a/account_avatax_sale_oca/__manifest__.py +++ b/account_avatax_sale_oca/__manifest__.py @@ -1,6 +1,6 @@ { "name": "Avalara Avatax Certified Connector for Sales Orders", - "version": "15.0.2.0.0", + "version": "16.0.1.0.0", "author": "Open Source Integrators, Fabrice Henrion," "Sodexis, Odoo Community Association (OCA)", "summary": "Sales Orders with automatic Tax application using Avatax", From 252bc2bc7fc600931133f2258d761cecbc6723c6 Mon Sep 17 00:00:00 2001 From: Nikul-OSI Date: Mon, 10 Apr 2023 14:33:56 +0530 Subject: [PATCH 06/27] account_avatax_sale_oca: Migrated to v16 --- account_avatax_sale_oca/models/account_move.py | 13 +++---------- account_avatax_sale_oca/models/account_tax.py | 2 ++ account_avatax_sale_oca/models/sale_order.py | 15 ++++++--------- account_avatax_sale_oca/readme/CONTRIBUTORS.rst | 2 ++ account_avatax_sale_oca/views/sale_order_view.xml | 4 ++++ 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/account_avatax_sale_oca/models/account_move.py b/account_avatax_sale_oca/models/account_move.py index d8319eebc..b99a34b30 100644 --- a/account_avatax_sale_oca/models/account_move.py +++ b/account_avatax_sale_oca/models/account_move.py @@ -4,14 +4,7 @@ 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 - - @api.onchange("partner_shipping_id") + @api.onchange("partner_id", "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 + for move in self: + move.tax_on_shipping_address = bool(move.partner_shipping_id) diff --git a/account_avatax_sale_oca/models/account_tax.py b/account_avatax_sale_oca/models/account_tax.py index 4962f3dac..92209e9e4 100644 --- a/account_avatax_sale_oca/models/account_tax.py +++ b/account_avatax_sale_oca/models/account_tax.py @@ -14,6 +14,7 @@ def compute_all( is_refund=False, handle_price_include=True, include_caba_tags=False, + fixed_multiplicator=1, ): res = super().compute_all( price_unit, @@ -24,6 +25,7 @@ def compute_all( is_refund, handle_price_include, include_caba_tags=False, + fixed_multiplicator=fixed_multiplicator, ) for_avatax_object = self.env.context.get("for_avatax_object") if for_avatax_object: diff --git a/account_avatax_sale_oca/models/sale_order.py b/account_avatax_sale_oca/models/sale_order.py index 142f6bdca..ba8d6cf1f 100644 --- a/account_avatax_sale_oca/models/sale_order.py +++ b/account_avatax_sale_oca/models/sale_order.py @@ -7,11 +7,11 @@ class SaleOrder(models.Model): @api.depends( "order_line.tax_id", "order_line.price_unit", "amount_total", "amount_untaxed" ) - def _compute_tax_totals_json(self): + def _compute_tax_totals(self): # Make the Sales Order data available to the AccountTax.compute_all() method # This is needed to take in consideration the additional Avatax fields enriched_self = self.with_context(for_avatax_object=self) - return super(SaleOrder, enriched_self)._compute_tax_totals_json() + return super(SaleOrder, enriched_self)._compute_tax_totals() @api.model @api.depends("company_id", "partner_id", "partner_invoice_id", "state") @@ -22,7 +22,7 @@ def _compute_hide_exemption(self): hide_exemption = fields.Boolean( "Hide Exemption & Tax Based on shipping address", - compute=_compute_hide_exemption, # For past transactions visibility + compute="_compute_hide_exemption", # For past transactions visibility default=lambda self: self.env.company.get_avatax_config_company, help="Uncheck the this field to show exemption fields on SO/Invoice form view. " "Also, it will show Tax based on shipping address button", @@ -39,9 +39,7 @@ def onchange_partner_shipping_id(self): The setup for this is to add contact/addresses for the Invoicing Partner, for each of the states we can claim exepmtion for. """ - res = super(SaleOrder, self).onchange_partner_shipping_id() self.tax_on_shipping_address = bool(self.partner_shipping_id) - return res @api.depends("partner_invoice_id", "tax_address_id", "company_id") def _compute_onchange_exemption(self): @@ -94,13 +92,13 @@ def onchange_reset_avatax_amount(self): order.order_line.write({"tax_amt": 0}) @api.depends("order_line.price_total", "order_line.product_uom_qty", "tax_amount") - def _amount_all(self): + def _compute_amounts(self): """ Compute fields amount_untaxed, amount_tax, amount_total Their computation needs to be overriden, to use the amounts returned by Avatax service, stored in specific fields. """ - res = super()._amount_all() + res = super()._compute_amounts() for order in self: if order.tax_amount: order.update( @@ -236,8 +234,7 @@ def action_confirm(self): return addr.button_avatax_validate_address() if avatax_config: self.avalara_compute_taxes() - res = super(SaleOrder, self).action_confirm() - return res + return super(SaleOrder, self).action_confirm() @api.onchange( "order_line", diff --git a/account_avatax_sale_oca/readme/CONTRIBUTORS.rst b/account_avatax_sale_oca/readme/CONTRIBUTORS.rst index 329425fba..5c166973d 100644 --- a/account_avatax_sale_oca/readme/CONTRIBUTORS.rst +++ b/account_avatax_sale_oca/readme/CONTRIBUTORS.rst @@ -7,6 +7,8 @@ * Daniel Reis * Bhavesh Odedra * Sandip Mangukiya + * Nikul Chaudhary + * Serpent CS diff --git a/account_avatax_sale_oca/views/sale_order_view.xml b/account_avatax_sale_oca/views/sale_order_view.xml index 309c9f766..708dac392 100644 --- a/account_avatax_sale_oca/views/sale_order_view.xml +++ b/account_avatax_sale_oca/views/sale_order_view.xml @@ -5,6 +5,9 @@ form + + +