Browse Source
[CHG] b_shift : shift status
[CHG] b_shift : shift status
To give better understanding of compensations given by each status. 'stage_id' is replaced by a selection field state to ease domain restrictions.pull/143/head
Elouan Le Bars
5 years ago
8 changed files with 139 additions and 105 deletions
-
3beesdoo_shift/__openerp__.py
-
44beesdoo_shift/data/stage.xml
-
66beesdoo_shift/migrations/9.0.1.3.0/post-migrate.py
-
16beesdoo_shift/migrations/9.0.1.3.0/pre-migrate.py
-
2beesdoo_shift/models/planning.py
-
96beesdoo_shift/models/task.py
-
2beesdoo_shift/security/ir.model.access.csv
-
11beesdoo_shift/views/task.xml
@ -1,44 +0,0 @@ |
|||
<odoo> |
|||
<record model="beesdoo.shift.stage" id="draft"> |
|||
<field name="name">Unconfirmed</field> |
|||
<field name="sequence">1</field> |
|||
<field name="color">0</field> |
|||
<field name="code">draft</field> |
|||
</record> |
|||
<record model="beesdoo.shift.stage" id="open"> |
|||
<field name="name">Confirmed</field> |
|||
<field name="sequence">2</field> |
|||
<field name="color">5</field> |
|||
<field name="code">open</field> |
|||
</record> |
|||
<record model="beesdoo.shift.stage" id="done"> |
|||
<field name="name">Attended</field> |
|||
<field name="sequence">3</field> |
|||
<field name="color">1</field> |
|||
<field name="code">done</field> |
|||
</record> |
|||
<record model="beesdoo.shift.stage" id="absent"> |
|||
<field name="name">Absent</field> |
|||
<field name="sequence">5</field> |
|||
<field name="color">2</field> |
|||
<field name="code">absent</field> |
|||
</record> |
|||
<record model="beesdoo.shift.stage" id="excused"> |
|||
<field name="name">Excused</field> |
|||
<field name="sequence">6</field> |
|||
<field name="color">4</field> |
|||
<field name="code">excused</field> |
|||
</record> |
|||
<record model="beesdoo.shift.stage" id="excused_necessity"> |
|||
<field name="name">Excused - Absolute Necessity</field> |
|||
<field name="sequence">7</field> |
|||
<field name="color">4</field> |
|||
<field name="code">excused_necessity</field> |
|||
</record> |
|||
<record model="beesdoo.shift.stage" id="cancel"> |
|||
<field name="name">Cancelled</field> |
|||
<field name="sequence">8</field> |
|||
<field name="color">8</field> |
|||
<field name="code">cancel</field> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,66 @@ |
|||
# coding: utf-8 |
|||
|
|||
|
|||
def migrate(cr, version): |
|||
""" |
|||
The Char field 'code' from shift stage is now a Selection Field |
|||
named 'state'. |
|||
""" |
|||
# Set new field state |
|||
cr.execute( |
|||
""" |
|||
UPDATE beesdoo_shift_shift |
|||
SET state = old_code |
|||
""" |
|||
) |
|||
# Map new stage from corresponding old stage |
|||
cr.execute( |
|||
""" |
|||
UPDATE beesdoo_shift_shift |
|||
SET state = 'absent_2' |
|||
FROM res_partner |
|||
WHERE beesdoo_shift_shift.worker_id = res_partner.id |
|||
AND ( |
|||
beesdoo_shift_shift.old_code = 'absent' |
|||
OR ( |
|||
beesdoo_shift_shift.old_code = 'excused' |
|||
AND res_partner.working_mode = 'irregular' |
|||
) |
|||
) |
|||
""" |
|||
) |
|||
cr.execute( |
|||
""" |
|||
UPDATE beesdoo_shift_shift |
|||
SET state = 'absent_1' |
|||
FROM res_partner |
|||
WHERE beesdoo_shift_shift.worker_id = res_partner.id |
|||
AND beesdoo_shift_shift.old_code = 'excused' |
|||
AND res_partner.working_mode = 'regular' |
|||
""" |
|||
) |
|||
cr.execute( |
|||
""" |
|||
UPDATE beesdoo_shift_shift |
|||
SET state = 'absent_0' |
|||
FROM res_partner |
|||
WHERE beesdoo_shift_shift.worker_id = res_partner.id |
|||
AND beesdoo_shift_shift.old_code = 'excused_necessity' |
|||
""" |
|||
) |
|||
cr.execute( |
|||
""" |
|||
UPDATE beesdoo_shift_shift |
|||
SET state = 'absent_0' |
|||
WHERE beesdoo_shift_shift.state = 'excused' |
|||
""" |
|||
) |
|||
cr.execute( |
|||
""" |
|||
DELETE FROM beesdoo_shift_shift |
|||
WHERE beesdoo_shift_shift.state = 'absent' |
|||
""" |
|||
) |
|||
|
|||
# Drop temporary columns |
|||
cr.execute("ALTER TABLE beesdoo_shift_shift DROP COLUMN old_code") |
@ -0,0 +1,16 @@ |
|||
# coding: utf-8 |
|||
|
|||
|
|||
def migrate(cr, version): |
|||
# Record information from old shift stage |
|||
cr.execute("ALTER TABLE beesdoo_shift_shift ADD old_code varchar") |
|||
cr.execute( |
|||
""" |
|||
UPDATE beesdoo_shift_shift |
|||
SET old_code = ( |
|||
SELECT code |
|||
FROM beesdoo_shift_stage |
|||
WHERE id = stage_id |
|||
) |
|||
""" |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue