Odoo Help

0

Call a model field in POS Receipt

By
Taher Giyori
on 9/29/16, 4:24 AM 700 views

I need to call a field of a different model into the POS Receipt (POS-Ticket), 'pos.xml' in  static folder.

So far, I've come to know that its possible through 'model.js', but a syntax or documentation would really help.

1
Bejaoui Souheil
On 9/29/16, 5:03 AM

Hi,

 To call new model in pos you must define it first in model.js like this:

odoo.define('your_module.models', function (require) {    
"use strict";
var models = require('point_of_sale.models');
models.load_models({   
model: 'your.model', # your model
fields: ['field1','field1'], // fields that will be used from your model
domain: [], // domain filter
loaded: function(self,objs){    
// a function that will be executed on loading   
self.objs = objs;},});
});

you can now call your model in PosTicket xml by :

<t t-esc="widget.pos.objs.field1" />
<t t-esc="widget.pos.objs.field2" />

 Best regards.

Thanks. Can you please let me know, where exactly to paste the above code in models.js?

Taher Giyori
on 10/1/16, 1:04 AM

If you are working on new module, create a file models.js under your_module/static/src/js.

After that inherit the point_of_sale.index to call it:

<template id="report_extend" name="POS Index" inherit_id="point_of_sale.index"><xpath expr="." position="inside">

<script type="text/javascript" src="/your_module/static/src/js/models.js"></script>

</xpath>

</template>

Welcome.

Bejaoui Souheil
on 10/1/16, 4:43 AM

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 E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 9/29/16, 4:24 AM
Seen: 700 times
Last updated: 9/29/16, 5:03 AM