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.

81 lines
2.7 KiB

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