Skip to content

Commit

Permalink
[IMP] mrp_multi_level: mrp cleanup performance
Browse files Browse the repository at this point in the history
- Index the planned_order_id column on mrp.production model
- Delete from mrp.planned.order before deleting from mrp.inventory
  • Loading branch information
matt454357 committed Oct 21, 2024
1 parent 160867c commit a7751f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion mrp_multi_level/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ class MrpProduction(models.Model):

_inherit = "mrp.production"

planned_order_id = fields.Many2one(comodel_name="mrp.planned.order")
planned_order_id = fields.Many2one(
comodel_name="mrp.planned.order",
index=True,
)
5 changes: 3 additions & 2 deletions mrp_multi_level/wizards/mrp_multi_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,10 @@ def _mrp_cleanup(self, mrp_areas):
domain += [("mrp_area_id", "in", mrp_areas.ids)]
with mute_logger("odoo.models.unlink"):
self.env["mrp.move"].search(domain).unlink()
self.env["mrp.planned.order"].search(
domain + [("fixed", "=", False)]
).unlink()
self.env["mrp.inventory"].search(domain).unlink()
domain += [("fixed", "=", False)]
self.env["mrp.planned.order"].search(domain).unlink()
logger.info("End MRP Cleanup")
return True

Expand Down

0 comments on commit a7751f9

Please sign in to comment.