Need some advices about the best way to check if a field keep domain rules…
Here’s the case:
In the purchase_request model, there’s a field preferred_quotation_line which is a many2one on supplier_quotation_lines with domain ‘state = received’ and ‘quotation.request=request’
In the quotation_supplier model you can switch in the workflow from state ‘received’ to state ‘rejected’.
But there’s no control if one of your quotation_line is selected as preferred_quotation_line, so you can have a preferred_quotation_line in state ‘rejected’ even if the domain doesn’t allow this state.
I’m aware that’s not possible to automatically check this kind of issue. So i’m intend to make a check when switching state in the workflow but would like to know the best way to implement it (is there any example of such a case ? I see a lot of case checking if there’s an origin but in my case it is just an id)
Is it better to loop over purchase_requests having a preferred_quotation_line and then check if id match to quotation ?
Or search for each quotation_line if there’s a purchase_request having a preferred quotation_line with the same id ?