On Tuesday, September 3, 2013 1:20:59 PM UTC+5:30, Cédric Krier wrote: > > On 03/09/13 00:28 -0700, Kaushik S wrote: > > > > > > On Tuesday, September 3, 2013 12:13:28 PM UTC+5:30, Cédric Krier wrote: > > > > > This is for GNU Health, hospital management. The database table has a > list > > of people with their address and phone numbers. This is a privileged > list. > > These are people who would have 'some' free access to the hospital. > The > > hospital has its own database of all the patients. Some of these > patients > > will be from the privileged list. Sometimes existing patients might go > on > > the privileged list. Whenever a new entry has been added to the > > privileged list or an existing patient goes on the privileged list, we > need > > to update our records so that billing etc happens correctly. I do not > > wish to spend so much resource checking every 1 or 2 minutes. But, I > > wouldn't want any human intervention and it should all happen > > automatically. *I am open to any suggestion that is a Tryton way of > doing > > this. It doesn't have to be cron. * > > > > There is a delete in the privileged list but it happens very very > rarely. > > When a delete happens, there is a delete flag that is turned on. You are > > right, there is indeed the delete case. > > > > *Perhaps the ideal way to do this is to have an external daemon that > > maintains a connection to the database and constantly polls looking for > > additions and deletions. * > > > > *Alternatively, we could just decide to do this manually. This > possibility > > is not ruled out. * > > > > However, purely from the technical point of view I would like to know > the > > options available and how you would do this. Is this is a rare scenario > for > > ERP where you have to constantly poll for changes in an external > database? > > If that is so, please let us know. I have not worked with ERP before. > > Polling shoud always be the last solution. > From your example, I think I will write a Function field on the patient > that will read the value in the other DB. I guess the cost of such read > on the fly is not too high. > > >
ok, thanks. That would be the way to go for the delete case alone. But when a new entry has been added to the externalDB.privileged_list, there will be no existing patient. So, we can't do the same. I think I should be able to set up a notification for change in the externalDB.privileged_list. Perhaps thats a good idea. For that I would need to run a separate thread which would make an asynchronous request to the database and waits.
