comment migration position employee to contract
This commit is contained in:
parent
95ba4ef9d3
commit
b9d0402deb
48
contract.py
48
contract.py
|
@ -72,30 +72,30 @@ class StaffContract(Workflow, ModelSQL, ModelView):
|
|||
'finish_contract_out_date': ('You can not to finish a contract with end date on future!'),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
super(StaffContract, cls).__register__(module_name)
|
||||
pool = Pool()
|
||||
Employee = pool.get('company.employee')
|
||||
cursor = Transaction().connection.cursor()
|
||||
sql_table = cls.__table__()
|
||||
employee = Employee.__table__()
|
||||
|
||||
# Migration:
|
||||
# - Migration position from employee into contract
|
||||
sub_query = employee.select(
|
||||
employee.id, employee.position,
|
||||
where=(employee.position != Null)
|
||||
)
|
||||
cursor.execute(*sub_query)
|
||||
|
||||
for employee_id, position in cursor.fetchall():
|
||||
cursor.execute(*sql_table.update(
|
||||
columns=[sql_table.position],
|
||||
values=[position],
|
||||
where=(sql_table.employee == employee_id)
|
||||
& (sql_table.position == Null)
|
||||
))
|
||||
# @classmethod
|
||||
# def __register__(cls, module_name):
|
||||
# super(StaffContract, cls).__register__(module_name)
|
||||
# pool = Pool()
|
||||
# Employee = pool.get('company.employee')
|
||||
# cursor = Transaction().connection.cursor()
|
||||
# sql_table = cls.__table__()
|
||||
# employee = Employee.__table__()
|
||||
#
|
||||
# # Migration:
|
||||
# # - Migration position from employee into contract
|
||||
# sub_query = employee.select(
|
||||
# employee.id, employee.position,
|
||||
# where=(employee.position != Null)
|
||||
# )
|
||||
# cursor.execute(*sub_query)
|
||||
#
|
||||
# for employee_id, position in cursor.fetchall():
|
||||
# cursor.execute(*sql_table.update(
|
||||
# columns=[sql_table.position],
|
||||
# values=[position],
|
||||
# where=(sql_table.employee == employee_id)
|
||||
# & (sql_table.position == Null)
|
||||
# ))
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
|
|
Loading…
Reference in New Issue