shopinvader / odoo-shopinvader

Odoo Modules. Sorry Magento, Shopinvader is coming
GNU Affero General Public License v3.0
119 stars 102 forks source link

[16.0] shopinvader_api_sale_loyalty: wrong write on GET /sales #1538

Open simahawk opened 4 months ago

simahawk commented 4 months ago

@marielejeune are we sure we need to call _update_programs_and_rewards here?

I'm investigating an issue w/ permission when calling /sales. This is the error I get

It is forbidden to modify the following fields in a locked order:\nUnit Price

This comes from the write caused by the call to _update_programs_and_rewards and it looks suspicious to me because it will happen on GET calls for ALL the orders every time.

Plus, I can imagine that this will happen twice at least when on sync and update rewards a cart because this method is called explicitly there.

IMO we should not call this method here at all an rely on the updates to refresh this info and - in any case - it should be avoided on locked orders.

WDYT?

simahawk commented 4 months ago

@marielejeune @lmignon gentle ping :innocent:

marielejeune commented 4 months ago

Hi @simahawk

It isn't fresh in my mind anymore, but as far as I remember, I needed to call it in from_sale_order to be able to get all claimable rewards, otherwise none of them appear. There may exist another solution and I'm open to it.

Unfortunately I won't have time to think about it now, I'm trying to finish what I have on my plate before my maternity leave coming in a few days now... 🐣

simahawk commented 4 months ago

Hi Marie :) Thanks for your feedback!

Hi @simahawk

It isn't fresh in my mind anymore, but as far as I remember, I needed to call it in from_sale_order to be able to get all claimable rewards, otherwise none of them appear. There may exist another solution and I'm open to it.

Ok, I'll do my research :wink:

Unfortunately I won't have time to think about it now, I'm trying to finish what I have on my plate before my maternity leave coming in a few days now... 🐣

Wow! Take care then! Wish you all the bests :hugs: