summaryrefslogtreecommitdiff
path: root/addons/partner_autocomplete
diff options
context:
space:
mode:
authorlen-odoo <len@odoo.com>2018-11-30 13:41:08 +0000
committerlen-odoo <len@odoo.com>2018-12-03 09:23:33 +0000
commit8f3ac2530f0771b2a18b5bc00f286d38407bcdb5 (patch)
treeccd95ca3718e2f341d2bb4df4679df708fb21405 /addons/partner_autocomplete
parent9d1aa41bfbafce072bae672b3a329da99fca712f (diff)
[FIX] base, partner_autocomplete: remove vat from the partner selection field
Commit a6e1eb9f0ad285fac7d0ca0b9f89f046d78ec9c7 introduced the show_vat context key, that displays the Tax ID of a customer after its name when present, similarly to show_address. However it appears on the field when being edited, then disappears at save, which is confusing. Other unclean things tended to happen: you would have "name - taxid" on customer field, but "name" on invoice address and delivery address. Furthermore a client could edit the name manually to erase the Tax ID, and thus recreate a new record for the same customer. We introduce a method to clean the name from the Tax ID, and use it so that it is directly the client's name that is selected at edit. Note that we also replace the standard dash in the 'name - taxid' by a figuredash (‒, U+2012) so as to avoid potential egregious splits because of legitimate customer names. Similar to commit: 3cbfc40303dcc4e5f668050326beb6ff014bf72a (same thing for show_address) opw 1911954 closes odoo/odoo#29189
Diffstat (limited to 'addons/partner_autocomplete')
-rw-r--r--addons/partner_autocomplete/static/src/js/partner_autocomplete_many2one.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/partner_autocomplete/static/src/js/partner_autocomplete_many2one.js b/addons/partner_autocomplete/static/src/js/partner_autocomplete_many2one.js
index 059629010b8..83f2ce9ce0b 100644
--- a/addons/partner_autocomplete/static/src/js/partner_autocomplete_many2one.js
+++ b/addons/partner_autocomplete/static/src/js/partner_autocomplete_many2one.js
@@ -58,6 +58,19 @@ var PartnerField = FieldMany2One.extend({
},
/**
+ * Returns the display_name from a string which contains it but was altered
+ * as a result of the show_vat option.
+ * Note that the split is done on a 'figuredash', not a standard dash.
+ *
+ * @private
+ * @param {string} value
+ * @returns {string} display_name without TaxID
+ */
+ _getDisplayNameWithoutVAT: function (value) {
+ return value.split(' ‒ ')[0];
+ },
+
+ /**
* Modify autocomplete results rendering
* Add logo in the autocomplete results if logo is provided
*
@@ -91,6 +104,7 @@ var PartnerField = FieldMany2One.extend({
* @private
*/
_renderEdit: function (){
+ this.m2o_value = this._getDisplayNameWithoutVAT(this.m2o_value);
this._super.apply(this, arguments);
this._modifyAutompleteRendering();
},