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.

70 lines
2.0 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
  1. from odoo import api, fields, models
  2. class NewMemberCardWizard(models.TransientModel):
  3. """
  4. A transient model for the creation of a new card.
  5. The user can only define the raison why a new card is
  6. needed and the eater/worker that is concerned.
  7. """
  8. _name = "membercard.new.wizard"
  9. _description = "Member Card"
  10. def _get_default_partner(self):
  11. return self.env.context["active_id"]
  12. new_comment = fields.Char("Reason", required=True)
  13. partner_id = fields.Many2one("res.partner", default=_get_default_partner)
  14. force_barcode = fields.Char(
  15. "Force Barcode", groups="beesdoo_base.group_force_barcode"
  16. )
  17. @api.multi
  18. def create_new_card(self):
  19. self.ensure_one()
  20. client = self.partner_id.sudo()
  21. client._deactivate_active_cards()
  22. client._new_card(
  23. self.new_comment, self.env.uid, barcode=self.force_barcode
  24. )
  25. client.member_card_to_be_printed = True
  26. class RequestMemberCardPrintingWizard(models.TransientModel):
  27. _name = "membercard.requestprinting.wizard"
  28. _description = "Member Card - Request Print Wizard"
  29. def _get_selected_partners(self):
  30. return self.env.context["active_ids"]
  31. partner_ids = fields.Many2many(
  32. "res.partner", default=_get_selected_partners
  33. )
  34. @api.multi
  35. def request_printing(self):
  36. self.ensure_one()
  37. self.partner_ids.write({"member_card_to_be_printed": True})
  38. class SetAsPrintedWizard(models.TransientModel):
  39. _name = "membercard.set_as_printed.wizard"
  40. _description = "Member card - Set as printed wizard"
  41. def _get_selected_partners(self):
  42. return self.env.context["active_ids"]
  43. partner_ids = fields.Many2many(
  44. "res.partner", default=_get_selected_partners
  45. )
  46. @api.multi
  47. def set_as_printed(self):
  48. self.ensure_one()
  49. self.partner_ids.write(
  50. {
  51. "member_card_to_be_printed": False,
  52. "last_printed": fields.Datetime.now(),
  53. }
  54. )