mirror of
https://github.com/NaN-tic/tryton-upgrades.git
synced 2023-12-14 03:32:55 +01:00
Project work status by language and workflow status lines
This commit is contained in:
parent
0c80ad2ba9
commit
b086c4fed9
|
@ -25,6 +25,7 @@ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(messag
|
|||
ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
|
||||
context['language'] = 'en'
|
||||
with Transaction().start(dbname, 0, context=context) as transaction:
|
||||
pool = Pool()
|
||||
Status = pool.get('project.work.status')
|
||||
|
@ -38,6 +39,7 @@ with Transaction().start(dbname, 0, context=context) as transaction:
|
|||
cursor.execute(query)
|
||||
|
||||
task_phases = {}
|
||||
phase2status = {}
|
||||
to_create = []
|
||||
to_write = []
|
||||
for row in cursor.fetchall():
|
||||
|
@ -45,13 +47,13 @@ with Transaction().start(dbname, 0, context=context) as transaction:
|
|||
# done
|
||||
if row[0] in [4]:
|
||||
status = Status(2)
|
||||
to_write.extend(([status], {
|
||||
'galatea': row[2],
|
||||
'sequence': row[3],
|
||||
'invoiceable': row[4],
|
||||
'role': row[5],
|
||||
'comment': row[6],
|
||||
}))
|
||||
status.galatea = row[2]
|
||||
status.sequence = row[3]
|
||||
status.invoiceable = row[4]
|
||||
status.role = row[5]
|
||||
status.comment = row[6]
|
||||
status.types = ['project', 'task']
|
||||
status.save()
|
||||
else:
|
||||
status = Status()
|
||||
status.name = row[1]
|
||||
|
@ -60,6 +62,7 @@ with Transaction().start(dbname, 0, context=context) as transaction:
|
|||
status.invoiceable = row[4]
|
||||
status.role = row[5]
|
||||
status.comment = row[6]
|
||||
status.types = ['project', 'task']
|
||||
|
||||
trackers = []
|
||||
query = 'select tracker from "project_work_task_phase-project_work_tracker" where task_phase = %s' % (row[0]);
|
||||
|
@ -69,22 +72,16 @@ with Transaction().start(dbname, 0, context=context) as transaction:
|
|||
trackers.append(tracker)
|
||||
if trackers:
|
||||
status.required_effort = trackers
|
||||
status.save()
|
||||
|
||||
# required_fields = []
|
||||
# query = 'select field from "project_task_phase-required_fields" where phase = %s' % (row[0]);
|
||||
# cursor.execute(query)
|
||||
# for row3 in cursor.fetchall():
|
||||
# field = Field(row3[0])
|
||||
# required_fields.append(field)
|
||||
# if required_fields:
|
||||
# status.required_fields = required_fields
|
||||
phase2status[row[0]] = status.id
|
||||
|
||||
to_create.append(status._save_values)
|
||||
|
||||
if to_create:
|
||||
Status.create(to_create)
|
||||
if to_write:
|
||||
Status.write(*to_write)
|
||||
query = 'select id, phase from project_work_workflow_line';
|
||||
cursor.execute(query)
|
||||
for row3 in cursor.fetchall():
|
||||
status_id = phase2status[row3[1]]
|
||||
query = 'UPDATE project_work_workflow_line set status = %s where id = %s' % (status_id, row3[0]);
|
||||
cursor.execute(query)
|
||||
|
||||
status = dict((x.name, x.id) for x in Status.search([]))
|
||||
for phase_id, phase_name in task_phases.items():
|
||||
|
@ -94,4 +91,35 @@ with Transaction().start(dbname, 0, context=context) as transaction:
|
|||
query = 'UPDATE project_work set status = %s where task_phase = %s' % (status_id, phase_id);
|
||||
cursor.execute(query)
|
||||
transaction.commit()
|
||||
logger.info('Done')
|
||||
|
||||
# locales
|
||||
for lang in ('ca', 'es'):
|
||||
context['language'] = lang
|
||||
with Transaction().start(dbname, 0, context=context) as transaction:
|
||||
pool = Pool()
|
||||
Status = pool.get('project.work.status')
|
||||
Tracker = pool.get('project.work.tracker')
|
||||
Field = pool.get('ir.model.field')
|
||||
|
||||
cursor = transaction.connection.cursor()
|
||||
|
||||
# reset values
|
||||
query = 'select id, name, galatea, sequence, invoiceable, role, comment from project_work_task_phase';
|
||||
cursor.execute(query)
|
||||
|
||||
to_write = []
|
||||
for row4 in cursor.fetchall():
|
||||
if row4[0] in [4]:
|
||||
continue
|
||||
status_id = phase2status[row4[0]]
|
||||
query = "select id, src, value, name res_id from ir_translation where name = 'project.work.task_phase,name' and res_id = %s and lang = '%s'" % (row4[0], lang);
|
||||
cursor.execute(query)
|
||||
vals = cursor.fetchone()
|
||||
if vals:
|
||||
status = Status(status_id)
|
||||
status.name = vals[2]
|
||||
status.save()
|
||||
|
||||
transaction.commit()
|
||||
|
||||
logger.info('Done')
|
||||
|
|
Loading…
Reference in a new issue