ValidationError and AccessError

Hi,

Just curios only, what is the different between ValidationError and AccessError?
I saw many time using AccessError while doing validation.

Any circumstances can different those two errors?

best regards

AccessError should be raised when the user is not allowed to perform the action.
ValidationError should be raised when the modification of a record is not valid.

Normally validation methods should only raise ValidationError. Do you have an example?

Hi @ced,

Thank for fast respond.

Example as below, which I take from ShipmentIn delete.
Some others, we can see on Sales. Mostly use the AccessError for validation
(modules/stock: 765394e19ac2 shipment.py)

It is correctly an AccesError because the user has no right to perform the action. It would be wrong to have a ValidationError because it does not a validation.

I do not agree with this, you’re validating that the shipment has been cancelled or it’s in a cancelled state before being able to delete it.

What happens in the cancel method of Shipment or in the cancel method of Move, could be or could not be an AccessError, depending on the implementation, but the “dependency” of the delete method is wheter the shipment is cancelled or not. That for me is a validation.

Call it as you want. I made the design, I just explain it.