Issue with User Warning on validate

Hi, I am having issue with saving a newly created record when using raise UserWarning in the validate method on the tryton server.

Using sao client, the record will be saved after confirming on the popup but the client still prompt me on modified changes when I try to leave the view. (no issue on tryton client).

Tried on 5.0 and 5.8 still having the same issue. Thank you.

Hi,

I’ve already encountered this problem, and it was caused by a setter field which triggered the validate a second time in the transaction.

My solution was to add a flag in the transaction inside the setter to ignore the warning, but I would love to know if a better solution existed.

This is because the read data has a value that is not canonical and so the client see it as a change. This happen often with Function field returning incorrect value like a Decimal with too much digits.

For me this has nothing to do with the warning.

I tried adding just the warning without any other fields or logic but the following code in Sao.Record.save() will always catch when the warning pop up (before selecting yes/no)

try {
    this.id = this.model.execute(
        'create', [[values]], context,  false)[0];
    } catch (e) {
        return jQuery.Deferred().reject();
}

and it return the error message and finish running the rest of the code.
Cannot read property '0' of undefined

I’m personally lost, I do not know anymore what is your problem.

its just that the raise user warning for creating new record does reflect correctly in sao than raise user warning for editing an existing record. I will take a look at it again as what you had suggested earlier. thank you

I still do not understand this sentence. What is exactly the problem?

  1. Create a new record
  2. Click save
  3. Prompt user warning
  4. Click “yes” on the warning
  5. Does not show that record is saved

What do you mean?
Please do not be scarce when describing your issue, otherwise nobody will be able to help you.

When I click on save record, it prompt the user warning that I added. After confirming that I would want to continue to save, it does not show that my record has been saved. And when I leave the page, it prompt “This record has been modified do you want to save it?” (even though I did not change anything after pressing the save button)

If I click on “Yes” to save, it will prompt me my user warning again and the process repeats itself. The sao client does show that the record has been saved.

But is it created or not on the server side?

Yes. Server side is created.

Edit: added video to show the issue

Indeed it is a bug with the synchronous RPC. It should be fixed with Issue 9938: Wrong error management with synchronous RPC call - Tryton issue tracker.