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.

96 lines
3.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
  1. from odoo import api, fields, models
  2. class Partner(models.Model):
  3. _inherit = "res.partner"
  4. date_stamp = fields.Date(
  5. string="Timestamp", help="Date de remplissage du formulaire"
  6. )
  7. birthdate = fields.Date(string="Date d'anniversaire")
  8. payment_date = fields.Date(string="Date de paiement")
  9. certificate_sent_date = fields.Date(string="Certificat envoyé le")
  10. fiscal_certificate_sent_date = fields.Date(
  11. string="Attestation fiscale envoyée le"
  12. )
  13. coop_number = fields.Integer(string="Coop N°")
  14. share_qty = fields.Integer(string="Nombre de part")
  15. share_amount = fields.Float(
  16. string="Montant", compute="_compute_share_amount"
  17. )
  18. gender = fields.Selection(
  19. [("female", "Féminin"), ("male", "Masculin"), ("other", "Autre")],
  20. string="Genre",
  21. )
  22. cooperator_type = fields.Selection(
  23. [
  24. ("share_a", "Part A"),
  25. ("share_b", "Part B"),
  26. ("share_c", "Part C"),
  27. ("share_d", "Part D"),
  28. ],
  29. string="Type de Part",
  30. )
  31. state_request = fields.Selection(
  32. [
  33. ("ok", "En ordre"),
  34. ("waiting_payment", "En attente de paiement"),
  35. ("certificate_to_send", "Certificat à envoyer"),
  36. ("resigning", "Parts revendues"),
  37. ]
  38. ) # TODO should we use the cooperative.status model instead?
  39. national_register_number = fields.Char(
  40. string="Numéro de registre national"
  41. ) # TODO add constraint / check consistancy
  42. share_numbers = fields.Char(string="Numéro de parts")
  43. payment_details = fields.Char(string="Détail de paiement")
  44. iban = fields.Char(string="IBAN") # TODO remove. Temp for import purpose.
  45. comment_request = fields.Char(string="Commentaire")
  46. email_sent = fields.Boolean(string="Email envoyé")
  47. is_worker = fields.Boolean(
  48. compute="_compute_is_worker",
  49. search="_search_is_worker",
  50. string="is Worker",
  51. readonly=True,
  52. related="",
  53. )
  54. need_referent = fields.Boolean(
  55. compute="_compute_need_referent",
  56. search="_search_need_referent",
  57. string="Need Referent",
  58. readonly=True,
  59. )
  60. @api.depends("share_qty")
  61. def _compute_share_amount(self):
  62. for rec in self:
  63. rec.share_amount = (
  64. rec.share_qty * 25.0
  65. ) # TODO add ir.config_parameter to make this amount editable
  66. @api.depends("cooperator_type")
  67. def _compute_is_worker(self):
  68. for rec in self:
  69. rec.is_worker = rec.cooperator_type in ('share_a', 'share_b')
  70. def _search_is_worker(self, operator, value):
  71. if (operator == '=' and value) or (operator == '!=' and not value):
  72. return [('cooperator_type', 'in', ('share_a', 'share_b'))]
  73. else:
  74. return ['&', ('cooperator_type', '!=', 'share_a'), ('cooperator_type', '!=', 'share_b')]
  75. @api.depends("super")
  76. def _compute_need_referent(self):
  77. for rec in self:
  78. rec.need_referent = rec.super
  79. def _search_need_referent(self, operator, value):
  80. if (operator == '=' and value) or (operator == '!=' and not value):
  81. return [('super', '=', True)]
  82. else:
  83. return []