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.3 KiB

  1. # Copyright 2017-2019 Therp BV <https://therp.nl>
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from odoo import fields, models
  4. class ResConfigSettings(models.TransientModel):
  5. _inherit = "res.config.settings"
  6. partner_labels_width = fields.Float(
  7. related="company_id.partner_labels_width",
  8. required=True,
  9. readonly=False,
  10. )
  11. partner_labels_height = fields.Float(
  12. related="company_id.partner_labels_height",
  13. required=True,
  14. readonly=False,
  15. )
  16. partner_labels_padding = fields.Float(
  17. related="company_id.partner_labels_padding",
  18. required=True,
  19. readonly=False,
  20. )
  21. partner_labels_margin_top = fields.Float(
  22. related="company_id.partner_labels_margin_top",
  23. required=True,
  24. readonly=False,
  25. )
  26. partner_labels_margin_bottom = fields.Float(
  27. related="company_id.partner_labels_margin_bottom",
  28. required=True,
  29. readonly=False,
  30. )
  31. partner_labels_margin_left = fields.Float(
  32. related="company_id.partner_labels_margin_left",
  33. required=True,
  34. readonly=False,
  35. )
  36. partner_labels_margin_right = fields.Float(
  37. related="company_id.partner_labels_margin_right",
  38. required=True,
  39. readonly=False,
  40. )
  41. partner_labels_paperformat_id = fields.Many2one(
  42. "report.paperformat",
  43. string="Paperformat",
  44. required=True,
  45. default=lambda self: self.env.ref(
  46. "partner_label.report_res_partner_label"
  47. ).paperformat_id,
  48. compute="_compute_partner_labels_paperformat_id",
  49. inverse="_inverse_partner_labels_paperformat_id",
  50. )
  51. def _compute_partner_labels_paperformat_id(self):
  52. for this in self:
  53. this.partner_labels_paperformat_id = self.env.ref(
  54. "partner_label.report_res_partner_label"
  55. ).paperformat_id
  56. def _inverse_partner_labels_paperformat_id(self):
  57. for this in self:
  58. self.env.ref(
  59. "partner_label.report_res_partner_label"
  60. ).paperformat_id = this.partner_labels_paperformat_id
  61. def action_partner_labels_preview(self):
  62. return self.env.ref("partner_label.report_res_partner_label").report_action(
  63. self.env["res.partner"].search([], limit=100),
  64. )