fsm_equipment/bemade_fsm: fix migration script and move a relation to fsm_equipment
This commit is contained in:
parent
629eb83d57
commit
eb6e46b5b6
4 changed files with 25 additions and 15 deletions
|
|
@ -12,29 +12,33 @@ def migrate(cr, version):
|
|||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
_logger.info("Moving FSM equipment...")
|
||||
# Move the old equipment over to the new table
|
||||
sql = """
|
||||
cr.execute(
|
||||
"""
|
||||
INSERT INTO fsm_equipment
|
||||
(id, code, name, description, partner_id, location_notes, active)
|
||||
SELECT id, pid_tag code, name, description, partner_location_id, location_notes,
|
||||
active
|
||||
FROM bemade_fsm_equipment
|
||||
"""
|
||||
cr.execute(sql)
|
||||
)
|
||||
|
||||
_logger.info("Moving FSM equipment tags...")
|
||||
# Move the tags
|
||||
sql = """
|
||||
cr.execute(
|
||||
"""
|
||||
INSERT INTO fsm_equipment_tag (id, name, color)
|
||||
SELECT id, name, color FROM bemade_fsm_equipment_tag
|
||||
"""
|
||||
cr.execute(sql)
|
||||
)
|
||||
|
||||
_logger.info("Re-creating equipment to tag relations.")
|
||||
# Add the relations
|
||||
sql = """
|
||||
cr.execute(
|
||||
"""
|
||||
INSERT INTO fsm_task_equipment_rel (equipment_id, task_id)
|
||||
SELECT equipment_id, task_id from bemade_fsm_equipment_rel
|
||||
SELECT equipment_id, task_id from bemade_fsm_task_equipment_rel
|
||||
"""
|
||||
)
|
||||
|
||||
_logger.info("Deleting menu items.")
|
||||
cr.execute(
|
||||
|
|
|
|||
|
|
@ -6,15 +6,6 @@ import re
|
|||
class Task(models.Model):
|
||||
_inherit = "project.task"
|
||||
|
||||
equipment_ids = fields.Many2many(
|
||||
comodel_name="fsm.equipment",
|
||||
relation="bemade_fsm_task_equipment_rel",
|
||||
column1="task_id",
|
||||
column2="equipment_id",
|
||||
string="Equipment to Service",
|
||||
tracking=True,
|
||||
)
|
||||
|
||||
work_order_contacts = fields.Many2many(
|
||||
comodel_name="res.partner",
|
||||
relation="task_work_order_contact_rel",
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ from . import equipment_tag
|
|||
from . import equipment
|
||||
from . import res_partner
|
||||
from . import equipment_component
|
||||
from . import task
|
||||
|
|
|
|||
14
fsm_equipment/models/task.py
Normal file
14
fsm_equipment/models/task.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from odoo import fields, models
|
||||
|
||||
|
||||
class Task(models.Model):
|
||||
_inherit = "project.task"
|
||||
|
||||
equipment_ids = fields.Many2many(
|
||||
comodel_name="fsm.equipment",
|
||||
relation="fsm_task_equipment_rel",
|
||||
column1="task_id",
|
||||
column2="equipment_id",
|
||||
string="Equipment to Service",
|
||||
tracking=True,
|
||||
)
|
||||
Loading…
Reference in a new issue