Skip to content

[18.0][IMP] shopfloor_base: Allow changing the way locks are acquired#24

Open
grindtildeath wants to merge 2 commits intoOCA:18.0from
camptocamp:18.0-imp-for_update_locks_custom
Open

[18.0][IMP] shopfloor_base: Allow changing the way locks are acquired#24
grindtildeath wants to merge 2 commits intoOCA:18.0from
camptocamp:18.0-imp-for_update_locks_custom

Conversation

@grindtildeath
Copy link
Copy Markdown
Contributor

This commit adds two new system parameters:

  • shopfloor.lock.for_update.no_key: Can be defined with a True-ish value to use FOR NO KEY UPDATE in the select to acquire a lock on selected rows

  • shopfloor.lock.for_update.no_wait: Can be defined with a True-ish value to use NOWAIT and raise an error instead of waiting for the lock to be acquired.

Note that NOWAIT keyword cannot be use in conjunction with SKIP LOCKED, hence, if skip_locked arg is used, the value of no_wait parameter will be ignored.

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @simahawk, @guewen, @sebalix,
some modules you are maintaining are being modified, check this out!

@grindtildeath grindtildeath changed the title [IMP] shopfloor_base: Allow changing the way locks are acquired [18.0][IMP] shopfloor_base: Allow changing the way locks are acquired Feb 10, 2026
@grindtildeath grindtildeath force-pushed the 18.0-imp-for_update_locks_custom branch from f862414 to 3753515 Compare February 10, 2026 23:36
@grindtildeath
Copy link
Copy Markdown
Contributor Author

grindtildeath commented Feb 13, 2026

Logging testing on odoo shell:

>>> from odoo.addons.shopfloor_base.actions.lock import LockAction
>>> records = env["res.partner"].browse([1,2])
>>> action = LockAction(records)
>>> action.for_update(records)
2026-02-13 17:34:23,058 1 DEBUG demo_shopfloor odoo.addons.shopfloor_base.actions.lock: Trying to acquire  FOR UPDATE  lock on res_partner for IDs [1, 2] 
2026-02-13 17:34:23,059 1 DEBUG demo_shopfloor odoo.addons.shopfloor_base.actions.lock: Lock was acquired on res_partner for IDs [1, 2] in 0.0007 seconds 
True
>>> env.cr.rollback()
2026-02-13 17:34:29,714 1 DEBUG demo_shopfloor odoo.addons.shopfloor_base.actions.lock: Lock was released on res_partner for IDs [1, 2] 

@grindtildeath grindtildeath force-pushed the 18.0-imp-for_update_locks_custom branch from 153a6dd to 8f360c1 Compare February 16, 2026 15:25
Copy link
Copy Markdown
Member

@gurneyalex gurneyalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-commit is complaining. But LGTM otherwise

This commit adds two new system parameters:

* shopfloor.lock.for_update.no_key: Can be defined with a True-ish
value to use FOR NO KEY UPDATE in the select to acquire a lock on
selected rows

* shopfloor.lock.for_update.no_wait: Can be defined with a True-ish
value to use NOWAIT and raise an error instead of waiting for the
lock to be acquired.

Note that NOWAIT keyword cannot be use in conjunction with SKIP LOCKED,
hence, if skip_locked arg is used, the value of no_wait parameter
will be ignored.
@grindtildeath grindtildeath force-pushed the 18.0-imp-for_update_locks_custom branch from 8f360c1 to d8c8c20 Compare February 24, 2026 19:24
@grindtildeath grindtildeath marked this pull request as ready for review February 24, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants