Data reloading using on_write method

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.

What change? on_write works only with write change.

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.

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?

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.

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

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

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.

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

2 Likes

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