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.

67 lines
1.8 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class NewMemberCardWizard(models.TransientModel):
  4. """
  5. A transient model for the creation of a new card.
  6. The user can only define the raison why a new card is
  7. needed and the eater/worker that is concerned.
  8. """
  9. _name = "membercard.new.wizard"
  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.one
  18. def create_new_card(self):
  19. client = self.partner_id.sudo()
  20. client._deactivate_active_cards()
  21. client._new_card(
  22. self.new_comment, self.env.uid, barcode=self.force_barcode
  23. )
  24. client.member_card_to_be_printed = True
  25. class RequestMemberCardPrintingWizard(models.TransientModel):
  26. _name = "membercard.requestprinting.wizard"
  27. def _get_selected_partners(self):
  28. return self.env.context["active_ids"]
  29. partner_ids = fields.Many2many(
  30. "res.partner", default=_get_selected_partners
  31. )
  32. @api.one
  33. def request_printing(self):
  34. self.partner_ids.write({"member_card_to_be_printed": True})
  35. class SetAsPrintedWizard(models.TransientModel):
  36. _name = "membercard.set_as_printed.wizard"
  37. def _get_selected_partners(self):
  38. return self.env.context["active_ids"]
  39. partner_ids = fields.Many2many(
  40. "res.partner", default=_get_selected_partners
  41. )
  42. @api.one
  43. def set_as_printed(self):
  44. self.partner_ids.write(
  45. {
  46. "member_card_to_be_printed": False,
  47. "last_printed": fields.Datetime.now(),
  48. }
  49. )