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.

50 lines
1.8 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 = fields.Float(
  17. related='company_id.partner_labels_margin', required=True,
  18. )
  19. partner_labels_paperformat_id = fields.Many2one(
  20. 'report.paperformat', string='Paperformat', required=True,
  21. default=lambda self: self.env.ref(
  22. 'partner_label.report_res_partner_label'
  23. ).paperformat_id,
  24. compute='_compute_partner_labels_paperformat_id',
  25. inverse='_inverse_partner_labels_paperformat_id',
  26. )
  27. @api.multi
  28. def _compute_partner_labels_paperformat_id(self):
  29. for this in self:
  30. this.partner_labels_paperformat_id = self.env.ref(
  31. 'partner_label.report_res_partner_label'
  32. ).paperformat_id
  33. @api.multi
  34. def _inverse_partner_labels_paperformat_id(self):
  35. for this in self:
  36. self.env.ref(
  37. 'partner_label.report_res_partner_label'
  38. ).paperformat_id = this.partner_labels_paperformat_id
  39. @api.multi
  40. def action_partner_labels_preview(self):
  41. return self.env['report'].get_action(
  42. self.env['res.partner'].search([], limit=100),
  43. 'partner_label.view_res_partner_label',
  44. )