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.

1

How to choose different pos.xml according to login user or company?

By
Pascal Tremblay
on 3/2/15, 12:26 PM 817 views

Hello guys,

In my custom module __openerp__.py file, I have this entry :

       "qweb" : [
        'static/src/xml/pos_as.xml',
    ],

Is it possible to change this declaration in the python code? How?

My goal : I would want to choose the pos.xml file according to the user company.

Thanks

Still need it! WOuld you have some suggestions?

Pascal Tremblay
on 10/8/15, 7:32 PM
2

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 10/8/15, 10:21 PM

You could extend that function in a module(let's call it pos_test) with a js file like:

openerp.pos_test = function (instance) {
    var _t = instance.web._t,
    _lt = instance.web._lt;
    var QWeb = instance.web.qweb;

    instance.point_of_sale.ReceiptScreenWidget.include({
refresh: function() {
var order = this.pos.get('selectedOrder');
var user_template = 'PosTicket';

if(instance.session.uid == 1){
user_template = 'PosTicket_cf';
}
$('.pos-receipt-container', this.$el).html(QWeb.render(user_template,{
widget:this,
order: order,
orderlines: order.get('orderLines').models,
paymentlines: order.get('paymentLines').models,
}));

},
});
}

Axel, you are a real beast. I try it tomorrow and i come back! Thanks 11111 times

Pascal Tremblay
on 10/8/15, 10:41 PM

Thanks, happy to help

Axel Mendoza
on 10/8/15, 10:42 PM

you need to change the pos_test with the name of the module, register the file to be loaded with the assets_backend template and a depend with point_of_sale in the __openerp__.py

Axel Mendoza
on 10/8/15, 11:42 PM
0

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 7
Alma, Canada
--Pascal Tremblay--


Pascal Tremblay
On 10/8/15, 8:06 PM

Ok, here is the complet solution.

I have defined two differents file : pos_as.xml and pos_cf.xml

I have declared those two files in __openerp__.py file (https://www.odoo.com/fr_FR/forum/help-1/question/could-we-define-multiple-files-in-the-qweb-section-of-the-openerp-py-91576)

In the pos_as.xml, I have declared <t t-name="PosTicket_as">
In the pos_cf.xml, I have declared <t t-name="PosTicket_cf">


I have created a new file : /pos_lapagept/static/src/js/screens_all.js

I have included this file with :

    <template id="pos_lapagept.assets_backend_all" name="point_of_sale assets" inherit_id="point_of_sale.assets_backend">

        <xpath expr="//script[contains(@src,'models.js')]" position="replace">

            <script type="text/javascript" src="/pos_lapagept/static/src/js/models_all.js"></script>

            <script type="text/javascript" src="/pos_lapagept/static/src/js/screens_all.js"></script>

            </xpath>

    </template>


In the file screens_all.js :

            openerp.pos_lapagept = function (instance) {

                    var _t = instance.web._t,

                    _lt = instance.web._lt;

                    var QWeb = instance.web.qweb;

                    instance.point_of_sale.ReceiptScreenWidget.include({

                            refresh: function() {

                                    var order = this.pos.get('selectedOrder');

                                    var user_template = 'PosTicket';

                                    if(instance.session.uid == 21){

                                            user_template = 'PosTicket_as';

                                    } else if (instance.session.uid == 53 || instance.session.uid == 55 || instance.session.uid == 56 || instance.session.uid == 57 ) {

                                            user_template = 'PosTicket_cf';

                                    }

                                    $('.pos-receipt-container', this.$el).html(QWeb.render(user_template,{

                                                        widget:this,

                                                        order: order,

                                                        orderlines: order.get('orderLines').models,

                                                        paymentlines: order.get('paymentLines').models,

                                        }));

                            },

                    });

            }


THANKS TO AXEL!!!

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

2 follower(s)

Stats

Asked: 3/2/15, 12:26 PM
Seen: 817 times
Last updated: 11/26/15, 1:37 AM