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.

51 lines
1.7 KiB

  1. from odoo import models, fields, api
  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. def _get_default_partner(self):
  10. return self.env.context['active_id']
  11. new_comment = fields.Char('Reason', required=True)
  12. partner_id = fields.Many2one('res.partner', default=_get_default_partner)
  13. force_barcode = fields.Char('Force Barcode', groups="beesdoo_base.group_force_barcode")
  14. @api.one
  15. def create_new_card(self):
  16. client = self.partner_id.sudo()
  17. client._deactivate_active_cards()
  18. client._new_card(self.new_comment, self.env.uid, barcode=self.force_barcode)
  19. client.member_card_to_be_printed = True
  20. class RequestMemberCardPrintingWizard(models.TransientModel):
  21. _name = 'membercard.requestprinting.wizard'
  22. def _get_selected_partners(self):
  23. return self.env.context['active_ids']
  24. partner_ids = fields.Many2many('res.partner', default=_get_selected_partners)
  25. @api.one
  26. def request_printing(self):
  27. self.partner_ids.write({'member_card_to_be_printed' : True})
  28. class SetAsPrintedWizard(models.TransientModel):
  29. _name = 'membercard.set_as_printed.wizard'
  30. def _get_selected_partners(self):
  31. return self.env.context['active_ids']
  32. partner_ids = fields.Many2many('res.partner', default=_get_selected_partners)
  33. @api.one
  34. def set_as_printed(self):
  35. self.partner_ids.write({'member_card_to_be_printed' : False,
  36. 'last_printed' : fields.Datetime.now()})