You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 LasLabs Inc.
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp import api
  5. from lxml import etree
  6. from openerp.addons.base.res.res_config import \
  7. res_config_settings
  8. class ResConfigSettings(res_config_settings):
  9. @api.model
  10. def fields_view_get(self, view_id=None, view_type='form',
  11. context=None, toolbar=False, submenu=False):
  12. ret_val = super(ResConfigSettings, self).fields_view_get(
  13. view_id=view_id,
  14. view_type=view_type,
  15. context=context,
  16. toolbar=toolbar,
  17. submenu=submenu,
  18. )
  19. page_name = ret_val['name']
  20. doc = etree.XML(ret_val['arch'])
  21. queries = []
  22. if page_name == 'account settings':
  23. queries += [
  24. "//div[field[@name='module_account_reports' and \
  25. @widget='upgrade_boolean']]",
  26. "//div[field[@name='module_account_reports_followup' and \
  27. @widget='upgrade_boolean']]",
  28. "//div[field[@name='module_account_batch_deposit' and \
  29. @widget='upgrade_boolean']]",
  30. ]
  31. queries += [
  32. "//div[div[field[@widget='upgrade_boolean']]] \
  33. /preceding-sibling::label[1]",
  34. "//div[div[field[@widget='upgrade_boolean']]]",
  35. "//div[field[@widget='upgrade_boolean']] \
  36. /preceding-sibling::label[1]",
  37. "//div[field[@widget='upgrade_boolean']]",
  38. "//field[@widget='upgrade_boolean']",
  39. ]
  40. for query in queries:
  41. for item in doc.xpath(query):
  42. item.getparent().remove(item)
  43. ret_val['arch'] = etree.tostring(doc)
  44. return ret_val