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 execute a funtion in JS file?

By
Nausif Maredia
on 5/12/16, 2:54 AM 347 views

I have succesfully extended the "PosTicket" template from Point_of_Sale module and included couple of fields in that existing template. I have also written the function similar to that in screen.js (render_reciept) to get the values of the newly added fields. The problem I'm facing is, I am not able to call that function. How to execute that function?

This is the template that was extended:

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

<template>

<t t-extend="PosTicket">

<t t-jquery=".receipt-orderlines"

t-operation="before">

customer name:<t t-esc="customer_name"/><br />

customer street:<t t-esc="street"/><br />

customer city:<t t-esc="city"/><br />

</t>

</t>

</template>


And this is the js file :

odoo.define('custom_module.print_cust_details_pos_bill', function (require) {

"use strict";

var core = require('web.core');

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

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

var QWeb = core.qweb;

var BillScreenWidget = screens.ReceiptScreenWidget.extend({

template: 'BillScreenWidget',

show: function(){

this._super();

var self = this;

this.render_receipt();

},

render_receipt: function(){

console.log("Render Reciept funtion called");

this._super();

//RKD-Start

var customer = this.pos.get_order().get_client();

var street = '';

var city ='';

var customer_name='';

if (customer != undefined)

{

customer_name = customer.name;

street = customer.street;

city=customer.city;

}

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

widget:this,

order: order,

receipt: order.export_for_printing(),

orderlines: order.get_orderlines(),

paymentlines: order.get_paymentlines(),

customer_name:customer_name,

customer_street:street,

city:city,

}));

//RKD-End

}

});

gui.define_screen({name:'receipt', widget: custom_module.BillScreenWidget});

});

0
ayman mohammed adam
On 5/19/16, 8:00 AM

Hi,


var mod = new instance.web.Model("account.budget.plan.budget"); // your Model name

mod.call("get_check", []).then(function(result) { // call your function

alert(result);

if (result== true) {

var e= self.add_records();

alert('U R IN');

}

  });

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: 5/12/16, 2:54 AM
Seen: 347 times
Last updated: 5/19/16, 8:00 AM