Odoo Ayuda

0

0
1 Answer
1

You have some errors in the code, check this

odoo.define('pos_custom.pos_custom', function (require) {
"use strict";
var models = require('point_of_sale.models');
var _super_orderline = models.Orderline.prototype;
models.Orderline = models.Orderline.extend({
get_display_price: function () {
var price = _super_orderline.get_display_price.call(this);//old_price
return price*2;//custom price
}
});
});
9 Comments
LaoThai
4/6/19 1:27

When i run, it still give me the error: Uncaught TypeError: Cannot read property 'get_display_price' of undefined. How can i defined this function?

Raciel Perdomo Gómez
4/6/19 2:29

check first that the var models that you are importing is not undefined,

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

console.log(models);

LaoThai
4/6/19 2:34

when i run this ( like you say ), on my console log have this: {PosModel: ƒ, load_fields: ƒ, load_models: ƒ, Product: ƒ, Orderline: ƒ, …}, I think that Oderline is defined, but the function into Orderline is not

Raciel Perdomo Gómez
4/6/19 2:50

and the var _super_orderline is defined?

LaoThai
4/6/19 2:57

yes, absolutely it is defined. console log js show me that. It doesn't make sense how XML file can't call this

Raciel Perdomo Gómez
4/6/19 3:39

It seems that the css selector is matching some element outside of an orderline.

Try this

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">

<t t-extend="PosTicket">

<t t-jquery=".receipt-orderlines > tr > td:nth-child(3)" t-operation="replace">

<td class="pos-right-align" ><span t-esc="orderline.get_display_price()"></span></td>

</t>

</t>

</templates>

LaoThai
4/6/19 4:30

woa, you are my hero. you make my day perfect. Thank you so much

LaoThai
4/6/19 4:44

Can I ask you something? It have a lot of field price I need to fix like this, Subtotal, total,etc... So I just dont understand this code <t t-jquery=".receipt-orderlines > tr > td:nth-child(3)", can you spend a little time to explan it for me :( thank you

LaoThai
4/6/19 4:49

ah ah, I got it, thank you so much, wish you have a good day

Realizar una pregunta
Writer
Keep Informed
1 seguidor(es)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now