Data reloading using on_write method


(Victor) #1

Hi!
There is a form action in our application. This action runs a wizard that can change multiple records, not just the current record. To reload the data, we set the attribute on_write = “on_write” in the tree tag and defined a method on_write. We also registered the method in trytond.model.Model._rpc_. But at change of records the method on_write is not called and the client does not reload the data.
What are we doing wrong?
Thank you.


(Cédric Krier) #2

What change? on_write works only with write change.


(Victor) #3

Sorry, if to mark changed records, then changes become visible in a tree view.
We save changes using the method write (or save).
However, the method on_write is still not called.


(Cédric Krier) #4

I do not understand what this means?

How are you using a method? Are you using a client? If yes which one? How to do you test?


(Victor) #5

Our wizard can change several records, even if only the current record is marked. In this case, the changes are not visible in the tree view.
If we pre-mark the changeable records, the changes are displayed in the tree view.

We change the required records and execute Model.save(records).

Desktop Client 4.6.

We inserted logger.info() into the method on_write and this logging does not work.


(Cédric Krier) #6

What does the wizard? Is it run as dialog?
The wizard call a reload with written set when it ends tryton: 7ab6b091a0b1 tryton/gui/window/wizard.py

I do not understand what mean “pre-mark”?


(Victor) #7

Yes, it is run as dialog.

I see, but written set must be marked (more precisely, selected).

“pre-mark” means “select before calling the wizard”.

But it is not clear why the method on_write is not called.


(Victor) #8

We solved the problem of data reloading without on_write method.
Here is our solution:

class OurWizard(Wizard):
    .....
    start = StateView(
        .....
        [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Run', 'run', 'tryton-ok', default=True),
        ]
    )

    run = StateTransition()

    def transition_run(self):
        .....
        return 'end'

    def end(self):
        return 'reload'

The ending state of the wizard may return one of the client side action keywords:
http://docs.tryton.org/projects/server/en/latest/ref/wizard.html?highlight=end_state#trytond.wizard.Wizard.end_state


(system) closed #9

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.