Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions openupgrade_scripts/scripts/hr_expense/19.0.2.1/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,60 @@ def hr_expense_approval_fields(env):
)


def hr_expense_sheet_compatibility(env):
"""
We update the statuses of the hr.expense.sheet records to match those of
hr_expense_sheet (to ensure consistency with the statuses of hr.expense)
"""
openupgrade.map_values(
env.cr,
openupgrade.get_legacy_name("state"),
"state",
[
("submit", "submitted"),
("approve", "approved"),
("cancel", "refused"),
],
table="hr_expense_sheet",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE hr_expense_sheet
SET state = 'posted'
WHERE state = 'post' AND payment_state = 'not_paid'
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE hr_expense_sheet
SET state = 'in_payment'
WHERE state = 'post' AND payment_state = 'partial'
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE hr_expense_sheet
SET state = 'paid'
WHERE state = 'post' AND payment_state IN ('paid', 'reversed')
""",
)
openupgrade.map_values(
env.cr,
openupgrade.get_legacy_name("approval_state"),
"approval_state",
[
("submit", "submitted"),
("approve", "approved"),
("post", "posted"),
("cancel", "refused"),
],
table="hr_expense_sheet",
)


def update_product_uoms(env):
"""
Set updated product uoms if possible
Expand Down Expand Up @@ -80,5 +134,6 @@ def migrate(env, version):
)
hr_expense_account_move_id(env)
hr_expense_approval_fields(env)
hr_expense_sheet_compatibility(env)
update_product_uoms(env)
openupgrade.delete_records_safely_by_xml_id(env, deleted_xmlids)
17 changes: 13 additions & 4 deletions openupgrade_scripts/scripts/hr_expense/19.0.2.1/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
("department_id", "hr.expense", "hr_expense", "many2one", None, "hr_expense"),
]

renamed_fields = [
("hr.expense", "hr_expense", "sheet_id", "former_sheet_id"),
]
renamed_fields = []

copied_columns = {
"hr_expense": [("state", None, None)],
"hr_expense": [
("state", None, None),
# It is important NOT to rename the sheet_id field because the hr_expense_sheet
# module will continue to use that field
("sheet_id", "former_sheet_id", None),
],
"hr_expense_sheet": [
("state", None, None),
("approval_state", None, None),
("user_id", "manager_id", None),
("total_tax_amount", "tax_amount", None),
],
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ hr_expense / hr.expense / state (selection) : select
# DONE: recompute state for records in states 'done', 'reported'

hr_expense / hr.expense / untaxed_amount (float) : NEW isfunction: function, stored

# DONE: hr_expense_sheet compatibility

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what has this column to do with the above?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am referring to everything that comes after that: hr.expense.sheet

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so put it after what you're referring to

hr_expense / hr.expense.sheet / account_move_ids (one2many) : DEL relation: account.move
hr_expense / hr.expense.sheet / accounting_date (date) : DEL
hr_expense / hr.expense.sheet / activity_ids (one2many) : DEL relation: mail.activity
Expand Down
Loading