OCA reporting engine fork for dev and update.
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.

57 lines
1.8 KiB

  1. from odoo import api, models, fields
  2. class IrActionsServer(models.Model):
  3. _inherit = "ir.actions.server"
  4. state = fields.Selection(
  5. selection_add=[("report_label", "Print self-adhesive labels")]
  6. )
  7. label_template = fields.Char(
  8. "Label QWeb Template",
  9. help="The QWeb template key to render the labels",
  10. states={
  11. "report_label": [("required", True)]
  12. }
  13. )
  14. label_paperformat_id = fields.Many2one(
  15. "report.paperformat.label",
  16. "Label Paper Format",
  17. states={
  18. "report_label": [("required", True)]
  19. }
  20. )
  21. @api.multi
  22. def report_label_associated_view(self):
  23. """ View the associated qweb templates """
  24. self.ensure_one()
  25. action = self.env.ref('base.action_ui_view', raise_if_not_found=False)
  26. if not action or len(self.label_template.split('.')) < 2:
  27. return False
  28. res = action.read()[0]
  29. res['domain'] = [
  30. ('type', '=', 'qweb'),
  31. '|',
  32. ('name', 'ilike', self.label_template.split('.')[1]),
  33. ('key', '=', self.label_template),
  34. ]
  35. return res
  36. @api.model
  37. def run_action_report_label_multi(self, action, eval_context=None):
  38. """ Show report label wizard """
  39. context = dict(self.env.context)
  40. context.update({
  41. "label_template": action.label_template,
  42. "label_paperformat_id": action.label_paperformat_id.id,
  43. "res_model_id": action.model_id.id,
  44. })
  45. return {
  46. "name": action.name,
  47. "type": "ir.actions.act_window",
  48. "res_model": "report.label.wizard",
  49. "context": str(context),
  50. "view_mode": "form",
  51. "target": "new",
  52. }