__init__.py 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from . import models
  4. from . import controllers
  5. from odoo.api import Environment, SUPERUSER_ID
  6. from odoo.tools import column_exists, create_column
  7. def pre_init_hook(cr):
  8. """Do not compute the sale_order_template_id field on existing SOs."""
  9. if not column_exists(cr, "sale_order", "sale_order_template_id"):
  10. create_column(cr, "sale_order", "sale_order_template_id", "int4")
  11. def uninstall_hook(cr, registry):
  12. env = Environment(cr, SUPERUSER_ID, {})
  13. res_ids = env['ir.model.data'].search([
  14. ('model', '=', 'ir.ui.menu'),
  15. ('module', '=', 'sale')
  16. ]).mapped('res_id')
  17. env['ir.ui.menu'].browse(res_ids).update({'active': False})
  18. def post_init_hook(cr, registry):
  19. env = Environment(cr, SUPERUSER_ID, {})
  20. res_ids = env['ir.model.data'].search([
  21. ('model', '=', 'ir.ui.menu'),
  22. ('module', '=', 'sale'),
  23. ]).mapped('res_id')
  24. env['ir.ui.menu'].browse(res_ids).update({'active': True})