Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions addons/hr_contract/migrations/13.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ def fill_employee_contract_id(env):
UPDATE hr_employee he
SET contract_id = sub.contract_id
FROM (
SELECT he.id AS employee_id, hc.id as contract_id
FROM hr_contract hc, hr_employee he
WHERE he.id = hc.employee_id AND hc.state = 'open'
LIMIT 1
SELECT DISTINCT ON (hc.employee_id)
hc.employee_id, hc.id AS contract_id
FROM hr_contract hc
WHERE hc.state = 'open'
ORDER BY hc.employee_id, hc.id
) sub
WHERE sub.employee_id = he.id AND he.contract_id IS NULL
"""
Expand Down
Loading