-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] hr_employee_catch_partner: When the partner of a employee was c…
…hanged the old one did not change the pointing to this employee, creating issues on contract assignations
- Loading branch information
Showing
3 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
hr_employee_catch_partner/migrations/8.0.1.2.0/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# © Copyright 2017 Mikel Arregi Etxaniz - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
|
||
def remove_duplicate_res_partner_employee_references(cr): | ||
sql = ("update res_partner " | ||
"set employee_id = null " | ||
"where id in " | ||
"(select r.id " | ||
"from res_partner r inner join hr_employee h " | ||
"on r.employee_id = h.id " | ||
"where h.address_home_id != r.id)") | ||
cr.execute(sql) | ||
sql2 = ("update res_partner res " | ||
"set employee_id = sub.id " | ||
"from " | ||
"(select h.id, h.address_home_id " | ||
"from res_partner r inner join hr_employee h on " | ||
"h.address_home_id = r.id " | ||
"where r.employee_id is null) as sub " | ||
"where res.id = sub.address_home_id") | ||
cr.execute(sql2) | ||
|
||
|
||
def migrate(cr, version): | ||
if not version: | ||
return | ||
remove_duplicate_res_partner_employee_references(cr) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters