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.

63 lines
2.2 KiB

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