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.

29 lines
1.1 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. def _compute_image_path(self):
  17. for pos in self:
  18. if pos.logo_balance:
  19. attachment_id = self.env['ir.attachment'].search([
  20. ('res_field', '=', 'logo_balance'),
  21. ('res_model', '=', 'pos.config'),
  22. ('res_id', '=', self.id)])
  23. attachment_id.generate_access_token()
  24. pos.logo_path = '/web/content/' + str(attachment_id.id) + '?access_token=' + attachment_id.access_token