Skip to content

Commit

Permalink
[MIG] website_sale_checkout_country_vat: Migration to version 18.0
Browse files Browse the repository at this point in the history
TT54387
  • Loading branch information
pilarvargas-tecnativa committed Feb 25, 2025
1 parent 0aff28b commit df8a7fe
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 56 deletions.
1 change: 1 addition & 0 deletions website_sale_checkout_country_vat/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Contributors
- Alexandre Díaz
- Carlos Roca
- Ernesto Tejeda
- Pilar Vargas

Maintainers
-----------
Expand Down
4 changes: 2 additions & 2 deletions website_sale_checkout_country_vat/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Website Sale Checkout Country VAT",
"summary": "Autocomplete VAT in checkout process",
"version": "15.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand All @@ -16,7 +16,7 @@
"data": ["views/templates.xml"],
"assets": {
"web.assets_frontend": [
"/website_sale_checkout_country_vat/static/src/js/dropdown.js"
"/website_sale_checkout_country_vat/static/src/js/dropdown.esm.js"
]
},
}
1 change: 1 addition & 0 deletions website_sale_checkout_country_vat/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
- Alexandre Díaz
- Carlos Roca
- Ernesto Tejeda
- Pilar Vargas
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Alexandre Díaz</li>
<li>Carlos Roca</li>
<li>Ernesto Tejeda</li>
<li>Pilar Vargas</li>
</ul>
</li>
</ul>
Expand Down
41 changes: 41 additions & 0 deletions website_sale_checkout_country_vat/static/src/js/dropdown.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Copyright 2016-2017 Jairo Llopis <[email protected]>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
import publicWidget from "@web/legacy/js/public/public_widget";

publicWidget.registry.CheckoutCountryVatDropdown = publicWidget.Widget.extend({
selector:
".o_wsale_address_fill:has(.js_country_dropdown, select[name=country_id])",
events: {
"change select[name=country_id]": "_onChangeAddressCountry",
},
start: function () {
const result = this._super(...arguments);
this.$address_country = this.$("select[name=country_id]");
this.$vat_no_country_field = this.$("#no_country_field");
return result;
},

/**
* Change VAT flag when address country changes
* @private
*/
_onChangeAddressCountry: function () {
if (!this.$address_country || !this.$vat_no_country_field) return;
if (this.$address_country.val() && !this.$vat_no_country_field.val()) {
this._getCountryOption(
this.$address_country.find("option:selected").attr("code")
).click();
}
},

/**
* Get a country element inside the vat dropdown
*
* @private
* @param {String} country_code
* @returns {jQueryElement}
*/
_getCountryOption: function (country_code) {
return this.$(`.js_select_country_code[data-country_code='${country_code}']`);
},
});
41 changes: 0 additions & 41 deletions website_sale_checkout_country_vat/static/src/js/dropdown.js

This file was deleted.

17 changes: 4 additions & 13 deletions website_sale_checkout_country_vat/views/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,16 @@
<xpath expr="//input[@name='vat']" position="after">
<t t-call="website_snippet_country_dropdown.country_dropdown">
<t t-set="complete_field" t-value="'vat'" />
<t
t-set="default_value"
t-value="'vat' in checkout and checkout['vat'] or ''"
/>
<t
t-set="country_id"
t-value="'country_id' in checkout and checkout['country_id'] or False"
/>
<t t-set="no_country_field" t-value="'vat'" />
<t t-set="default_value" t-value="partner_sudo.vat or ''" />
<t t-set="country_id" t-value="country_sudo or False" />
<t
t-set="default_country"
t-value="countries.search(['|', ('code', '=', default_value[:2]), ('id', '=', country_id and int(country_id) or False)], limit=1)"
/>
<t
t-set="no_country_field_extra_classes"
t-value="error.get('vat') and 'is-invalid' or ''"
/>
<t
t-set="readonly"
t-value="'1' if 'vat' in checkout and checkout['vat'] and not can_edit_vat else None"
t-value="True if partner_sudo.vat and not can_edit_vat else None"
/>
</t>
</xpath>
Expand Down

0 comments on commit df8a7fe

Please sign in to comment.