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.

32 lines
1.3 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. caisse_id = fields.Char("Identifiant de la caisse")
  15. logo_path = fields.Char(
  16. "URL Logo", compute="_compute_image_path")
  17. is_comptoir = fields.Boolean("Est une balance comptoir")
  18. allow_without_container = fields.Boolean("Autoriser les pesées sans contenant")
  19. def _compute_image_path(self):
  20. for pos in self:
  21. if pos.logo_balance:
  22. attachment_id = self.env['ir.attachment'].search([
  23. ('res_field', '=', 'logo_balance'),
  24. ('res_model', '=', 'pos.config'),
  25. ('res_id', '=', self.id)])
  26. attachment_id.generate_access_token()
  27. pos.logo_path = '/web/content/' + str(attachment_id.id) + '?access_token=' + attachment_id.access_token