Odoo Help

Welcome!

This community 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.

0

Call a model field in POS Receipt

By
Taher Giyori
on 9/29/16, 4:24 AM 177 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

--Bejaoui Souheil--
808
| 2 1 4
Sousse, Tunisia
--Bejaoui Souheil--

Odoo developer,  functional and technical consultant

souheil_bejaoui@hotmail.fr

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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