Community mailing list archives

community@mail.odoo.com

Question about remote systems, atom transactions and Odoo cursors.

by
CRISTIAN S ROCHA
- 01/06/2015 11:09:37
Hi all,

I'm writing because I need to get a grasp on how to develop a batch process that executes various atom transactions in a remote system, with exception control.

I would like to develop a generic approach to do that, not an specific one. The logic behind this is I still need to use default Odoo processes, workflows and validations in the process.

Some facts to start:

1) Odoo transactions start when the RPC call begins.

2) Odoo transactions stop when the RPC call returns control to the web client.

3) When an exception occurs between points 1 y 2, all processes in Odoo are rolled back, but this does not happen in the remote system. Some times is impossible rollback in the remote system.

4) Usually, each call to remote systems returns values to store in Odoo.

5) It is required to keep same state in Odoo and the remote system. For example, If the remote system says the registry is valid, Odoo must say the same.

6) Odoo can execute batch processes in nested and parallel. I mean:

* Breadth model (BM):
do_A(cr, uid, ids)
do_B(cr, uid, ids)
do_C(cr, uid, ids)
do_R(cr, uid, ids)

* Depth model (DM):
for o in self:
   self.do_A()
   self.do_B()
   self.do_C()
   self.do_R()

and can mix them. It is really difficult to known in advance which model is used in a RPC call.

7) Being R the remote call. An exception occurs in one of the processes (A,B or C) the impact in the remote system is diferent. In the BM the remote system does not know the process but Odoo ignores them all. In the DM takes the half of the process, but Odoo ignore all.

8) Some times incremental commits to the remote system is required. I mean, when something happens, you prefer to not rollback, but yes accept complete remote transactions.

I was thinking in these ways to implement the request:

a) Use an alternative log file to identify finished transactions in remote and Odoo, and declare an action (button, menu, wizard, etc...) to commit finished operation in Odoo. Pro: Support the request. Cons: User need to execute the action to commit finished transactions.

b) Identifify finished transactions to force commit. Pro: Simple to code. Cons: Only works in a BM. In DM you will commit uncompleted process.

c) Open one cursor per object. Pro: Support the request. Cons: Need to change the Odoo API, and use a lot of resources (one cursor per object in a list of thouthands?)

Do you think in other posibilities?

Thanks,
Cristian.

--
Coop. de Trab. Moldeo Interactive Lmt.
Cristian Sebastian Rocha
Consultor Analista.
Bonpland 2363 Of 303
(C1425FWE) CABA, Argentina.
(+54-9-11).6800.0269
http://interactive.moldeo.coop