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

How to add a new button in point of sale interface and want to call a python function from the button? I tried to inherit screens.js but it didnt work.

By
rosey
on 2/24/15, 12:19 AM 1,160 views

I want to add new button in the point of sale interface and also want to call a python function from that button. I tried to inherit screens.js file in the point of sale module. But didnt work. I posted my module structure below.

pos_button

      __init__.py

      __openerp__.py

      views

         pos_button.xml

      static

         src

            js

            img

 

Code

pos_button.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <!-- Inherit the js template in the module and include js file there.  -->
        <template id="assets_backend" name="pos_print" inherit_id="web.assets_backend">
            <xpath expr="." position="inside">
                <script type="text/javascript" src="/pos_button/static/src/js/pos_button.js"></script>               
            </xpath>
        </template>
    </data>
</openerp>

 

{
    'name': 'POS Print',
    'category': 'Hidden',
    'version': '1.0',
    'author': 'Exuberant Services & Solutions',
    'description':
        """
Add new print button in POS
========================

This module provides the color change of the main menu.
        """,
    'depends' : [
               'web','point_of_sale'
    ],
    'auto_install': True,
    'data': [
           'views/pos_button.xml'
     ],
    'js' : [
           'static/src/js/pos_button.js',

    ],
}

 

pos_button.js

module.ReceiptScreenWidget = module.ScreenWidget.extend({
      template: 'ReceiptScreenWidget',

      show_numpad:     true,
      show_leftpane:   true,

      init: function(parent, options) {
      this._super(parent,options);
      this.model = options.model;
      this.user = this.pos.get('user');
      this.company = this.pos.get('company');
      this.shop_obj = this.pos.get('shop');
      },
      renderElement: function() {
      this._super();
      this.pos.bind('change:selectedOrder', this.change_selected_order, this);
      this.change_selected_order();
      },
      show: function(){
      this._super();
      var self = this;

      this.add_action_button({
         label: _t('Print Receipt'),
         icon: '/pos_print/static/src/img/icons/printer.png',
        click: function(){ self.print(); },
                });

        },

    

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: 2/24/15, 12:19 AM
Seen: 1160 times
Last updated: 3/16/15, 8:10 AM