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.

79 lines
2.6 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
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 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. @api.depends("share_qty")
  55. def _compute_share_amount(self):
  56. for rec in self:
  57. rec.share_amount = (
  58. rec.share_qty * 25.0
  59. ) # TODO add ir.config_parameter to make this amount editable
  60. @api.depends("cooperator_type")
  61. def _compute_is_worker(self):
  62. for rec in self:
  63. rec.is_worker = rec.cooperator_type == "share_b"
  64. def _search_is_worker(self, operator, value):
  65. if (operator == "=" and value) or (operator == "!=" and not value):
  66. return [("cooperator_type", "=", "share_b")]
  67. else:
  68. return [("cooperator_type", "!=", "share_b")]