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.

30 lines
1.2 KiB

4 years ago
4 years ago
  1. # © 2020 Le Filament (<http://www.le-filament.com>)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import api, fields, models
  4. class PosConfig(models.Model):
  5. _inherit = 'pos.config'
  6. is_balance_free = fields.Boolean(
  7. string='Balance libre service')
  8. logo_balance = fields.Binary(
  9. string='Logo Balance',
  10. attachment=True)
  11. explication_header = fields.Char(string='Explication')
  12. weight_default = fields.Char(string='Poids par défault (kg)')
  13. balance_id = fields.Char("Identifiant de la balance")
  14. logo_path = fields.Char(
  15. "URL Logo", compute="_compute_image_path")
  16. is_comptoir = fields.Boolean("Est une balance comptoir")
  17. def _compute_image_path(self):
  18. for pos in self:
  19. if pos.logo_balance:
  20. attachment_id = self.env['ir.attachment'].search([
  21. ('res_field', '=', 'logo_balance'),
  22. ('res_model', '=', 'pos.config'),
  23. ('res_id', '=', self.id)])
  24. attachment_id.generate_access_token()
  25. pos.logo_path = '/web/content/' + str(attachment_id.id) + '?access_token=' + attachment_id.access_token