odoo_dev 开发培训作业:图书管理系统
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.

27 lines
888B

  1. from odoo import api, exceptions, fields, models
  2. class CheckoutMassMessage(models.TransientModel):
  3. _name = 'library.checkout.massmessage'
  4. _description = 'Send Message to Borrowers'
  5. checkout_ids = fields.Many2many(
  6. 'library.checkout',
  7. string='Checkouts')
  8. message_subject = fields.Char()
  9. message_body = fields.Html()
  10. @api.model
  11. def default_get(self, field_names):
  12. defaults = super().default_get(field_names)
  13. checkout_ids = self.env.context.get('active_ids')
  14. defaults['checkout_ids'] = checkout_ids
  15. return defaults
  16. def button_send(self):
  17. self.ensure_one()
  18. for checkout in self.checkout_ids:
  19. checkout.message_post(
  20. body=self.message_body,
  21. subject=self.message_subject,
  22. subtype='mail.mt_comment',
  23. )
  24. return True
上海开阖软件有限公司 沪ICP备12045867号-1