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.

66 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 api, 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', required=True,
  8. readonly=False,
  9. )
  10. partner_labels_height = fields.Float(
  11. related='company_id.partner_labels_height', required=True,
  12. readonly=False,
  13. )
  14. partner_labels_padding = fields.Float(
  15. related='company_id.partner_labels_padding', required=True,
  16. readonly=False,
  17. )
  18. partner_labels_margin_top = fields.Float(
  19. related='company_id.partner_labels_margin_top',
  20. required=True, readonly=False,
  21. )
  22. partner_labels_margin_bottom = fields.Float(
  23. related='company_id.partner_labels_margin_bottom',
  24. required=True, readonly=False,
  25. )
  26. partner_labels_margin_left = fields.Float(
  27. related='company_id.partner_labels_margin_left',
  28. required=True, readonly=False,
  29. )
  30. partner_labels_margin_right = fields.Float(
  31. related='company_id.partner_labels_margin_right',
  32. required=True, readonly=False,
  33. )
  34. partner_labels_paperformat_id = fields.Many2one(
  35. 'report.paperformat', string='Paperformat', required=True,
  36. default=lambda self: self.env.ref(
  37. 'partner_label.report_res_partner_label'
  38. ).paperformat_id,
  39. compute='_compute_partner_labels_paperformat_id',
  40. inverse='_inverse_partner_labels_paperformat_id',
  41. )
  42. @api.multi
  43. def _compute_partner_labels_paperformat_id(self):
  44. for this in self:
  45. this.partner_labels_paperformat_id = self.env.ref(
  46. 'partner_label.report_res_partner_label'
  47. ).paperformat_id
  48. @api.multi
  49. def _inverse_partner_labels_paperformat_id(self):
  50. for this in self:
  51. self.env.ref(
  52. 'partner_label.report_res_partner_label'
  53. ).paperformat_id = this.partner_labels_paperformat_id
  54. @api.multi
  55. def action_partner_labels_preview(self):
  56. return self.env.ref(
  57. 'partner_label.report_res_partner_label'
  58. ).report_action(
  59. self.env['res.partner'].search([], limit=100),
  60. )