Avoid cancelled sales by disabling cancel button on unsaved sale order

Rational

I have seen my salesperson is posting a lot of cancelled sales. I asked what the reason is. For her it was obvious that pressing the Cancel button on an unsaved sale order was the way to not create this sale.
Of course I recommended that she simply not save the record, but I think we can avoid some confusion.

Proposal

Check that the sale order is saved before enabling the cancel button.
Another option would be to change the function of the button to maybe something like the last saved record if the sale order is not saved, however I think this is the wrong approach.

If some core developer thinks this is useful I can create the issue+codereview.

The cancel button is just a plain button and all buttons have the same behaviour:

  • Save the current record
  • And then execute the button code.

Having said that probably you can hide the button by having an invisible state when the id is negative (the record is not shown).

Not sure if this is the way to go or maybe better to teach users to not use the cancel button to unsave a record. But for sure if we go this way all cancel buttons should behave equal (and not just only the sales one).

Maybe it even a good thing my user made this mistake, now she will most likely have a better understanding of how records work in Tryton. I guess you can judge this better than I can.

However I can not fault the users logic even if I would not make this mistake.

You are right, it is a bigger undertaking than a few lines of code in one module.

I guess everyone can agree that this case is one which does not make sense: you have an unsaved record, and press cancel in order to save the record with a cancelled status. This is not something anyone needs to do.

So the question is do we add a little bit of code/complexity in order to eliminate this, or do we prefer to avoid complexity and focus on more important issues.

I do not agree. You can want to register a failure to close a deal.

I see no hurt in having cancelled sale record like that. At some point as the user started to create the sale, there was a potential sale.
More over having the proposed behavior on the cancel button will create also confusion to user who understand what is happening when he click on the button. So for them having the button read-only or hidden will be also confusing.
So for me there is no point to add complexity here.

I had not considered this usage pattern.

No feature then.