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.

112 lines
5.2 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp import api, fields, models
  3. class ResCompany(models.Model):
  4. _inherit = 'res.company'
  5. def _get_base_logo(self):
  6. base_url = self.env['ir.config_parameter'].get_param('web.base.url')
  7. self.logo_url = base_url + "/logo.png"
  8. coop_email_contact = fields.Char(string="Contact email address for the"
  9. " cooperator")
  10. subscription_maximum_amount = fields.Float(string="Maximum authorised"
  11. " subscription amount")
  12. default_country_id = fields.Many2one('res.country',
  13. string="Default country",
  14. default=lambda self: self.country_id)
  15. default_lang_id = fields.Many2one('res.lang',
  16. string="Default lang")
  17. allow_id_card_upload = fields.Boolean(string="Allow ID Card upload")
  18. create_user = fields.Boolean(string="Create user for cooperator",
  19. default=True)
  20. board_representative = fields.Char(string="Board representative name")
  21. signature_scan = fields.Binary(string="Board representative signature")
  22. property_cooperator_account = fields.Many2one('account.account',
  23. company_dependent=True,
  24. string="Cooperator Account",
  25. domain=[('internal_type', '=', 'receivable'),
  26. ('deprecated', '=', False)],
  27. help="This account will be"
  28. " the default one as the"
  29. " receivable account for the"
  30. " cooperators",
  31. required=True)
  32. unmix_share_type = fields.Boolean(string="Unmix share type",
  33. default=True,
  34. help="If checked, A cooperator will be"
  35. " authorised to have only one type"
  36. " of share")
  37. display_logo1 = fields.Boolean(string="Display logo 1")
  38. display_logo2 = fields.Boolean(string="Display logo 2")
  39. bottom_logo1 = fields.Binary(string="Bottom logo 1")
  40. bottom_logo2 = fields.Binary(string="Bottom logo 2")
  41. logo_url = fields.Char(string="logo url",
  42. compute="_get_base_logo")
  43. display_internal_rules_approval = fields.Boolean(
  44. help="Choose to display an internal rules checkbox on the"
  45. " cooperator website form."
  46. )
  47. internal_rules_approval_required = fields.Boolean(
  48. string="Is internal rules approval required?"
  49. )
  50. internal_rules_approval_text = fields.Html(
  51. translate=True,
  52. help="Text to display aside the checkbox to approve internal rules."
  53. )
  54. display_data_policy_approval = fields.Boolean(
  55. help="Choose to display a data policy checkbox on the cooperator"
  56. " website form."
  57. )
  58. data_policy_approval_required = fields.Boolean(
  59. string="Is data policy approval required?"
  60. )
  61. data_policy_approval_text = fields.Html(
  62. translate=True,
  63. help="Text to display aside the checkbox to approve data policy."
  64. )
  65. display_financial_risk_approval = fields.Boolean(
  66. help="Choose to display a financial risk checkbox on the"
  67. " cooperator website form."
  68. )
  69. financial_risk_approval_required = fields.Boolean(
  70. string="Is financial risk approval required?"
  71. )
  72. financial_risk_approval_text = fields.Html(
  73. translate=True,
  74. help="Text to display aside the checkbox to approve financial risk."
  75. )
  76. @api.onchange('internal_rules_approval_required')
  77. def onchange_internal_rules_approval_required(self):
  78. if self.internal_rules_approval_required:
  79. self.display_internal_rules_approval = True
  80. @api.onchange('data_policy_approval_required')
  81. def onchange_data_policy_approval_required(self):
  82. if self.data_policy_approval_required:
  83. self.display_data_policy_approval = True
  84. @api.onchange('financial_risk_approval_required')
  85. def onchange_financial_risk_approval_required(self):
  86. if self.financial_risk_approval_required:
  87. self.display_financial_risk_rules_approval = True
  88. _sql_constraints = [(
  89. 'approval_constraint',
  90. """CHECK (((internal_rules_approval_required=FALSE
  91. AND display_internal_rules_approval=FALSE)
  92. OR display_internal_rules_approval=TRUE)
  93. AND ((data_policy_approval_required=FALSE
  94. AND display_data_policy_approval=FALSE)
  95. OR display_data_policy_approval=TRUE)
  96. AND ((financial_risk_approval_required=FALSE
  97. AND display_financial_risk_approval=FALSE)
  98. OR display_financial_risk_approval=TRUE))
  99. """,
  100. "Approval can't be mandatory and not displayed."
  101. )]