- Task list view (bemade_fsm) cleaned up - Add equipment to service to task list view (bemade_fsm) - Give base.group_user access to read client application details - Add migration script for fsm_equipment to refactor components into a hierarchy of equipment. - Add the notion of equipment hierarchy instead of components. partner_id field is only to be filled on the root equipment, to facilitate viewing client equipment lists without the clutter of all the subcomponents. - Add the notion of "inherited partner id" to show the root's partner_id on child equipment (components) form view. - Improve the interventions list on the equipment form view. Added a custom embedded tree view with limited fields, ordered by date. - Make the default search for equipment only search for root equipments (parent_id = False)
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from odoo import SUPERUSER_ID, api, Command
|
|
from odoo.tools.sql import SQL
|
|
|
|
|
|
def migrate(cr, version):
|
|
sql = "select * from fsm_equipment_component"
|
|
cr.execute(SQL(sql))
|
|
components = cr.dictfetchall()
|
|
sql = "select * from fsm_equipment_component_purpose"
|
|
cr.execute(SQL(sql))
|
|
purposes = cr.dictfetchall()
|
|
|
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
|
tags = env["fsm.equipment.tag"].create(
|
|
[{"name": purpose["name"]} for purpose in purposes]
|
|
)
|
|
|
|
purpose_dict = {
|
|
purpose["id"]: tags.filtered(lambda tag: tag.name == purpose["name"]).id
|
|
for purpose in purposes
|
|
}
|
|
|
|
env["fsm.equipment"].create(
|
|
[
|
|
{
|
|
"name": component["name"],
|
|
"sequence": component["sequence"],
|
|
"tag_ids": [Command.link(purpose_dict[component["purpose_id"]])],
|
|
"parent_id": component["equipment_id"],
|
|
"description": component["note"],
|
|
"product_id": component["product_id"],
|
|
}
|
|
for component in components
|
|
]
|
|
)
|