[FIX] point_of_sale: make partner creation work

Since changes made in the ORM, we cannot pass anymore string of integer
to many2One. We are now parsing the fields from the formular to
reprensent the integer as integer.

Since changes made on image fields, the "image" field name was not
correct so we renamed it in imgage_1920.

TASK-ID: 2058650

closes odoo/odoo#36219

Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
Pierre Masereel
2019-08-29 14:15:52 +00:00
parent 82e3bd4326
commit def4acae20
+21 -15
View File
@@ -1139,6 +1139,7 @@ var ClientListScreenWidget = ScreenWidget.extend({
init: function(parent, options){
this._super(parent, options);
this.partner_cache = new DomCache();
this.integer_client_details = ['country_id', 'state_id', 'property_product_pricelist'];
},
auto_back: true,
@@ -1339,29 +1340,34 @@ var ClientListScreenWidget = ScreenWidget.extend({
// save was successfull.
save_client_details: function(partner) {
var self = this;
var fields = {};
this.$('.client-details-contents .detail').each(function(idx,el){
fields[el.name] = el.value || false;
if (self.integer_client_details.includes(el.name)){
var parsed_value = parseInt(el.value, 10);
if (isNaN(parsed_value)){
fields[el.name] = false;
}
else{
fields[el.name] = parsed_value
}
}
else{
fields[el.name] = el.value || false;
}
});
if (!fields.name) {
this.gui.show_popup('error',_t('A Customer Name Is Required'));
return;
}
if (this.uploaded_picture) {
fields.image = this.uploaded_picture;
fields.image_1920 = this.uploaded_picture;
}
fields.id = partner.id || false;
fields.country_id = fields.country_id || false;
fields.id = partner.id || false;
if (fields.property_product_pricelist) {
fields.property_product_pricelist = parseInt(fields.property_product_pricelist, 10);
} else {
fields.property_product_pricelist = false;
}
var contents = this.$(".client-details-contents");
contents.off("click", ".button.save");
@@ -1373,11 +1379,11 @@ var ClientListScreenWidget = ScreenWidget.extend({
})
.then(function(partner_id){
self.saved_client_details(partner_id);
},function(err,ev){
ev.preventDefault();
}).catch(function(error){
error.event.preventDefault();
var error_body = _t('Your Internet connection is probably down.');
if (err.data) {
var except = err.data;
if (error.message.data) {
var except = error.message.data;
error_body = except.arguments && except.arguments[0] || except.message || error_body;
}
self.gui.show_popup('error',{