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.

2

Is it possible to create a script / command to make the point of sale recognize new products without refresh?

By
matheus
on 4/10/13, 12:25 AM 2,749 views

And how hard would be such implementation? Right now if you create a new product while the point of sale is open it doesn't recognize the product, so i'm considering doing some code to make the point of sale continuosly look for new products WHILE it is working. Thanks in advance!

It could probably be done but I can't help asking myself how common of a use case it is. Do the benefits warrant the added complexity/risk of bugs? How often do you introduce new products while your POS terminals are active? But, then again, I could be wrong.

Lorenzo Cabrini
on 4/10/13, 1:13 AM

Grazie mille per la attenzione Lorenzo.. and yes the benefits exceeds the risks involved, this is more a need than a desire actually. Please I don't say this in a arrogant way, but I know quite a lot of business owners like me so i can confidentelly say that this is necessary. Most stores receives products on a daily basis and if there's a way, at least a kickstart on how to update the current products on the point of sale without having to refresh the page I would gladly try to develop such feature and in the future share with the community. Thanks again!

matheus
on 4/10/13, 2:56 PM
0
Matthew Fournier
On 6/28/13, 1:45 PM

Felt like this warranted an answer, rather than a comment.

First, in screens.js, in the finishOrder function, add this line after the destroy() call that's already there:

$.when(this.pos.load_server_data());

This will cause the program to wait until the server data is all loaded before continuing. This kills the null errors, but causes a few quirks. The first and most annoying is that the categories get added in again whenever you make a new order, so go into db.js, and find the add_categories function. At the top of the function (Just after the self declaration) add this:

this.category_childs = {};

To reset them. Another problem is that the view doesn't refresh automatically. After you go to the products page, there will be a bit of a delay, a loading circle, and then you'll still be on the same page. This solution is a bit of a hackjob, but I'll update it if I find a more elegant solution.

First step is find every line of "this.product_categories_widget" and replace it with "this.pos.product_categories_widget" This will let us find the widget through the pos object in the FinishOrder button. There, replace your finishOrder function with this one:

       finishOrder: function() {
        var self = this;
        this.pos.get('selectedOrder').destroy();
        $.when(this.pos.load_server_data())
        .done(function() {  
            self.pos.product_categories_widget.reset_category();
            }).fail(function() {
        });
        },

There's still a gap between making a sale and the view updating, but it will refresh with no button presses from you, and you're ready to sell again right away. As fast as I tried, I couldn't "beat" the loading with a new sale, so that might be a problem with the solution, but it should reload properly every time in normal use.

From Matthew to Matthew, thanks very much! I'm terribly sorry for taking so long for marking this brilliant suggestion as an answer, this is a very good solution. I tottaly forgot my profile here after a few delusions, now faith in help.openerp is restored!

matheus
on 8/8/13, 6:23 PM
1

swapnil wagh

--swapnil wagh--
1559
| 6 5 8
Pune, India
--swapnil wagh--

My name is Swapnil A. Wagh. I studied Master Of computer Science and work as a Software Engineer. I’m a technology enthusiast and always eager to learn new and exciting technologies. I’m constantly looking for innovative solutions to age-old problems that push the limits of what we conceive to be possible.

swapnil wagh
On 4/27/13, 7:45 AM

Hi matheus,

Write this this.pos = new module.PosModel(this.session); line on Next Order button click code it will fetch newly added Products, Partners for next order.

Hi swapnil, it's a brilliant idea! And for me as it looks it would work right away, but guess i must be doing something wrong.. you're talking about the screen.js file right? My line after the modification looks like this

> click: function() { self.finishOrder(); this.pos = new module.PosModel(this.session); },

But it's not doing anything, i've trying all kinds of syntax variations.. is this working for you? Thanks a lot for your help!

matheus
on 4/27/13, 11:45 AM

Hi Matheus,

You just write the code on wrong place there is method finishOrder() just below the click: function() { self.finishOrder();}, this put the code this.pos = new module.PosModel(this.session); in that function... Hope this will work for you

Cheers, swapnil

swapnil wagh
on 4/27/13, 12:15 PM

I've made the correction now it looks like this: finishOrder: function() { this.pos.get('selectedOrder').destroy(); this.pos = new module.PosModel(this.session); }, BUT i get this error whenenever i press any button on the screen 'Uncaught Error: QWeb2 - template['PosTicket']: Runtime Error: TypeError: Cannot read property 'attributes' of null' and still it's not loading recently add products.. any suggestion swapnil?

matheus
on 4/27/13, 12:54 PM

If you're still around, I am also having trouble getting your code to work. Getting the same error.

Matthew Fournier
on 6/24/13, 4:58 PM

Okay, so, I've done more research, and even though I haven't gotten it working, maybe if I post my findings it could help you.

The problem is in the loading of the database. The program keeps running while it waits for the data to load, so when it reloads the XML file, there's no data. I've tried to block the function until it's done loading, then manually reload the XML file, but I've been unsuccessful. I'm not sure how to wait on making the POS object, as it doesn't return a deferred, but calls a function that does. I need to do more research on asynchronous javascript.

Matthew Fournier
on 6/27/13, 3:40 PM
1

Acespritech

--Acespritech--
839
| 3 2 6
India
--Acespritech--

Having 8+ years of OpenERP Experience. We are Specialized in OpenERP/CRM Solutions, software development, Web development, E commerce solutions & other open source solutions.


Skype : acespritech

Email : info@acespritech.com

Acespritech
On 5/23/13, 7:18 AM

Hello !

It is possible to update product list but we have to reload it manually.
As you can see in attached image, we are updating Quantity on Hand run time after completion of order process.

pos.png

Thanks,
Acespritech Solutions Pvt. Ltd.
www.acespritech.com
Blog: acespritechblog.wordpress.com
Mail: info@acespritech.com
Skype: acespritech
Gtalk: acespritech

I see you guys post on a bunch of different questions but you never seem to explain how to do anything. You just direct people to your blog which pretty much says "we did this" but you don't post code or anything. I get that you guys figured out how to solve this problem, but it's not really helping us with the same problem, now is it?

Matthew Fournier
on 6/24/13, 4:45 PM
0
matheus
On 4/27/13, 11:44 AM

Hi swapnil, it's a brilliant idea! And for me as it looks it would work right away, but guess i must be doing something wrong.. you're talking about the screen.js file right? My line after the modification looks like this

click: function() { self.finishOrder(); this.pos = new module.PosModel(this.session); },

But it's not doing anything, i've trying all kinds of syntax variations.. is this working for you? Thanks a lot for your help!

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: 4/10/13, 12:25 AM
Seen: 2749 times
Last updated: 3/16/15, 8:10 AM