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.

102 lines
4.0 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 odoo import api, models
  5. from lxml import etree
  6. class ResConfigSettings(models.TransientModel):
  7. _inherit = 'res.config.settings'
  8. @api.model
  9. def fields_view_get(self, view_id=None, view_type='form', toolbar=False,
  10. submenu=False):
  11. ret_val = super(ResConfigSettings, self).fields_view_get(
  12. view_id=view_id,
  13. view_type=view_type,
  14. toolbar=toolbar,
  15. submenu=submenu,
  16. )
  17. page_name = ret_val['name']
  18. doc = etree.XML(ret_val['arch'])
  19. queries = []
  20. if page_name == 'account settings':
  21. queries += [
  22. "//div[field[@name='module_account_reports' and \
  23. @widget='upgrade_boolean']]",
  24. "//div[field[@name='module_account_deferred_revenue' and \
  25. @widget='upgrade_boolean']]",
  26. "//div[field[@name='module_account_yodlee' and \
  27. @widget='upgrade_boolean']]",
  28. "//div[field[@name='module_account_plaid' and \
  29. @widget='upgrade_boolean']]",
  30. "//div[field[@name='module_account_bank_statement_import_qif' "
  31. "and @widget='upgrade_boolean']]",
  32. "//div[field[@name='module_account_bank_statement_import_ofx' "
  33. "and @widget='upgrade_boolean']]",
  34. "//div[field[@name='module_account_bank_statement_import_csv' "
  35. "and @widget='upgrade_boolean']]",
  36. "//div[field[@name='module_account_sepa' and \
  37. @widget='upgrade_boolean']]",
  38. "//div[field[@name='module_l10n_us_check_printing' and \
  39. @widget='upgrade_boolean']]",
  40. "//div[field[@name='module_account_reports_followup' and \
  41. @widget='upgrade_boolean']]",
  42. "//div[field[@name='module_account_batch_deposit' and "
  43. "@widget='upgrade_boolean']]",
  44. ]
  45. elif page_name == 'sale settings':
  46. queries += [
  47. "//div[field[@name='module_crm_voip' and "
  48. "@widget='upgrade_boolean']]/preceding-sibling::label[1]",
  49. "//div[field[@name='module_crm_voip' and "
  50. "@widget='upgrade_boolean']]",
  51. "//group[@name='config_sign']",
  52. "//div[field[@name='module_sale_contract' and "
  53. "@widget='upgrade_boolean']]/preceding-sibling::label[1]",
  54. "//div[field[@name='module_sale_contract' and "
  55. "@widget='upgrade_boolean']]",
  56. ]
  57. elif page_name == 'stock settings':
  58. queries += [
  59. "//group[@name='shipping']",
  60. "//group[5]",
  61. "//div[field[@name='module_stock_barcode' and "
  62. "@widget='upgrade_boolean']]",
  63. ]
  64. elif page_name == 'project settings':
  65. queries += [
  66. "//label[@for='id']",
  67. "//field[@name='module_project_forecast']/ancestor::div[2]",
  68. ]
  69. elif page_name == 'mrp settings':
  70. queries += [
  71. "//group[3]",
  72. ]
  73. elif page_name == 'General Settings':
  74. queries += [
  75. "//label[@for='module_inter_company_rules']",
  76. "//div[@name='inter_company']",
  77. ]
  78. elif page_name == 'Configure Mass Mailing':
  79. queries += [
  80. "//group[@name='mass_mailing_group']/"
  81. "label[@for='module_mass_mailing_themes']",
  82. "//group[@name='mass_mailing_group']/div",
  83. ]
  84. for query in queries:
  85. for item in doc.xpath(query):
  86. item.getparent().remove(item)
  87. ret_val['arch'] = etree.tostring(doc)
  88. return ret_val