# © 2020 Le Filament () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models class PosConfig(models.Model): _inherit = 'pos.config' is_balance_free = fields.Boolean( string='Balance libre service') logo_balance = fields.Binary( string='Logo Balance', attachment=True) explication_header = fields.Char(string='Explication') weight_default = fields.Char(string='Poids par défault (kg)') balance_id = fields.Char("Identifiant de la balance") logo_path = fields.Char( "URL Logo", compute="_compute_image_path") is_comptoir = fields.Boolean("Est une balance comptoir") def _compute_image_path(self): for pos in self: if pos.logo_balance: attachment_id = self.env['ir.attachment'].search([ ('res_field', '=', 'logo_balance'), ('res_model', '=', 'pos.config'), ('res_id', '=', self.id)]) attachment_id.generate_access_token() pos.logo_path = '/web/content/' + str(attachment_id.id) + '?access_token=' + attachment_id.access_token