Skip to Content
Menu
This question has been flagged

I have created a custom JavaScript file to modify the get_full_product_name function in the Odoo Point of Sale (PoS) module. However, the changes made in the custom JavaScript file are not taking effect as expected.

Problem Details:

  • Custom JavaScript File Location: My custom JavaScript file is located at point_of_sale/static/src/js/custom_pos_models.js.

  • JavaScript File Content:

odoo.define('pos_custom.models', function (require) {

"use strict";


var Orderline = require('point_of_sale.models');


Orderline.models = Orderline.include({


get_full_product_name: function () {


console.log(this.full_product_name);

if (this.full_product_name) {

return this.full_product_name;

}

var full_name = this.product.display_name;

console.log(full_name);

if (this.description && this.description !== "with") {

full_name += ` (${this.description})`;

}

console.log(full_name);

return full_name;

},

});

return Orderline;

});



Expected Behavior: The expected behavior is that the get_full_product_name function in the Orderline class should be modified as per the changes made in the custom JavaScript file.


Actual Behavior: Despite the custom JavaScript file being correctly defined and included in the assets, the changes to the get_full_product_name function are not having any effect in the Odoo PoS system.


.

Avatar
Discard
Best Answer

Hi Salah Saeed,


Here is a sample code that shows how to override the method "get_full_product_name" of POS for odoo version 15. You can use this code as a reference for your task.


Please find code in comment. 

Thanks & Regards,
Email:  odoo@aktivsoftware.com      

Skype: kalpeshmaheshwari

Avatar
Discard

Please find code here :-

odoo.define('pos_custom.models', function (require) {
"use strict";

var models = require('point_of_sale.models');
var _super_orderline = models.Orderline.prototype;
models.Orderline = models.Orderline.extend({

get_full_product_name: function () {
var line = _super_orderline.get_full_product_name.apply(this,arguments);
console.log(this.full_product_name);
return line
},

});
});

Remember to add your js file to the "point_of_sale.assets"!

Related Posts Replies Views Activity
1
Apr 24
1508
0
Nov 23
38
1
May 23
2093
1
Dec 17
4269
0
Feb 16
5199