Odoo modules about association management
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.

129 lines
4.5 KiB

  1. # -*- coding: utf-8 -*-
  2. from odoo import models, fields, api
  3. class ResPartner(models.Model):
  4. _inherit = "res.partner"
  5. association = fields.Boolean(string="Is an association")
  6. is_french = fields.Boolean(
  7. string="French partner", compute="partner_is_french", store=True
  8. )
  9. constituent_ga_date = fields.Date(
  10. string="Consitutent GA",
  11. tracking="80",
  12. help="Constituent General Assembly date",
  13. )
  14. prefecture_date = fields.Date(
  15. string="Declaration date",
  16. tracking="82",
  17. help="Prefecture declaration date",
  18. )
  19. prefecture = fields.Char(
  20. string="Prefecture",
  21. tracking="81",
  22. help="Prefecture (city) of declaration",
  23. )
  24. official_journal_date = fields.Date(
  25. string="Official Journal",
  26. tracking="83",
  27. help="Official Journal publication date",
  28. )
  29. official_journal_dept_id = fields.Many2one(
  30. comodel_name="res.country.department",
  31. string="OJ department",
  32. tracking="81",
  33. help="Official Journal publication department",
  34. domain=[
  35. (
  36. "country_id.code",
  37. "in",
  38. (
  39. "FR",
  40. "GP",
  41. "MQ",
  42. "GF",
  43. "RE",
  44. "YT",
  45. ),
  46. )
  47. ],
  48. )
  49. official_journal = fields.Char(
  50. string="OJ reference",
  51. tracking="81",
  52. help="Official Journal reference",
  53. )
  54. company_registry_date = fields.Date(
  55. string="Registration date",
  56. help="Association National Register declaration date",
  57. tracking="83",
  58. )
  59. company_registry = fields.Char(tracking="83")
  60. naf_ape = fields.Char(string="NAF/APE code", tracking="83")
  61. last_ga_date = fields.Date(string="Last general assembly", tracking="81")
  62. # Documents fields
  63. statuses_file = fields.Binary("Statuses file")
  64. statuses_filename = fields.Char("Statuses filename", tracking="83")
  65. statuses_update_date = fields.Date("Statuses update", tracking="83")
  66. internal_regul_file = fields.Binary("Internal Regulations file")
  67. internal_regul_filename = fields.Char(
  68. "Internal Regulations filename", tracking="83"
  69. )
  70. internal_regul_update_date = fields.Date("Internal Reg. update", tracking="85")
  71. asso_project_file = fields.Binary("Assocation project")
  72. asso_project_filename = fields.Char("Assocation project filename", tracking="83")
  73. asso_project_update_date = fields.Date("Project update", tracking="83")
  74. @api.depends("country_id")
  75. def partner_is_french(self):
  76. for partner in self:
  77. partner.is_french = partner.country_id and partner.country_id.code in (
  78. "FR",
  79. "GP",
  80. "MQ",
  81. "GF",
  82. "RE",
  83. "YT",
  84. )
  85. @api.onchange("is_company", "country_id")
  86. def onchange_asso_is_french_company(self):
  87. if self.association and (not self.is_company or not self.is_french):
  88. self.association = False
  89. # @api.onchange("association")
  90. # def onchange_association(self):
  91. # if not self.association:
  92. # values = {}
  93. # if self.statuses_file:
  94. # values.update(
  95. # {
  96. # "statuses_file": False,
  97. # "statuses_filename": False,
  98. # "statuses_update_date": False,
  99. # }
  100. # )
  101. # if self.internal_regul_file:
  102. # values.update(
  103. # {
  104. # "internal_regul_file": False,
  105. # "internal_regul_filename": False,
  106. # "internal_regul_update_date": False,
  107. # }
  108. # )
  109. # for field in [
  110. # "association",
  111. # "asso_creation_date",
  112. # "prefecture_date",
  113. # "prefecture",
  114. # "official_journal_date",
  115. # "company_registry_date",
  116. # "company_registry",
  117. # "naf_ape",
  118. # "last_ga_date",
  119. # ]:
  120. # if getattr(self, field) != False:
  121. # values.update({field: False})
  122. # if values:
  123. # self.update(values)