Skip to content

[13.0][OU-FIX] hr_contract: fix value of hr_employee.contract_id - #5989

Merged
pedrobaeza merged 1 commit into
OCA:13.0from
coopiteasy:13.0-ou-fix-hr_contract-hr_employee-contract_id
Sep 18, 2026
Merged

pedrobaeza merged 1 commit into
OCA:13.0from
coopiteasy:13.0-ou-fix-hr_contract-hr_employee-contract_id

Conversation

@huguesdk

Copy link
Copy Markdown
Member

fix the query setting the values of hr_employee.contract_id: have one row per employee instead of just one row in the sub-query.

another way to write it while keeping the limit 1 (using a lateral sub-query) could be:

        UPDATE hr_employee he
        SET contract_id = sub.contract_id
        FROM hr_employee he2, LATERAL (
            SELECT hc.id as contract_id
            FROM hr_contract hc
            WHERE he2.id = hc.employee_id AND hc.state = 'open'
            ORDER BY hc.date_start DESC
            LIMIT 1
        ) sub
        WHERE he2.id = he.id AND he.contract_id IS NULL

what do you prefer?

fix the query setting the values of hr_employee.contract_id: have one
row per employee instead of just one row in the sub-query.
@pedrobaeza pedrobaeza added this to the 13.0 milestone Sep 18, 2026
@pedrobaeza
pedrobaeza merged commit 489d722 into OCA:13.0 Sep 18, 2026
3 checks passed
@huguesdk

Copy link
Copy Markdown
Member Author

thanks @pedrobaeza!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants