Edxz
Edxz

Reputation: 823

Insert data into database using Javascript in OpenERP POS module

currently I'm modifying point of sale module in OpenERP 7.
I want to insert data into my new model(ex: res.cashier),
but I don't understand how to do it at all as I have no experience in javascript,
as far as I know it use Backbone.JS to connect into database.
please guide me by giving me an example or explanation, any help will be greatly appreciated..

Upvotes: 1

Views: 508

Answers (1)

Edxz
Edxz

Reputation: 823

figured it out myself, I'm wrong to think that JS directly access the database, instead it call python function first and then execute the insert,here's the example:

self.$('#insertcashier').click(function(){
    (new instance.web.Model('res.cashier')).call('cashier_funct',[[param]],undefined,{ shadow:true })
                .fail(function(unused, event){
                    event.preventDefault();
                    console.error('Failed');
                })
                .done(function(){
                    console.info('success');
                });
            });

Upvotes: 1

Related Questions