FIX supplier price duplicate entry on update supplier product ref #29290
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FIX supplier price duplicate entry on update supplier product ref
To reproduce
You have this product supplier price :
You edit this supplier price and set a new product supplier reference : "PROD1FOURN1"
Then when you save this product supplier price, you got this error :
Remarks
This fix is only for products with no supplier reference : the supplier reference of product is empty in database.
The field of "ref_fourn" is not mandatory in database and can be NULL.
So you can have a database with this case.
And for an update you don't need to use 'add_fournisseur()" method because you know the rowid of "product_supplier_price" table. And no need to check if the unique key for supplier reference already exist : it will be return by the SQL server such as "mysql".