odoo-14point-of-sale

Load extended field into POS from session doesn't work


I have a session:

class POSSession(models.Model):
    _inherit = 'pos.session'

    access_token = fields.Char(string="Access Token", readonly=True)

I'm trying to get access to the that field from POS:

odoo.define('your_module_name.some_js_file', function (require) {
"use strict";

var models = require('point_of_sale.models');
models.load_fields('pos.session', ['access_token']);

const ReceiptCheckboxRegistration = (ReceiptScreen) =>
  class extends ReceiptScreen {

    mounted() {
      super.mounted();
    
      var access_token = this.env.pos.session.checkbox_token;
      console.log(access_token);

});

The console prints out undefined. What am I doing wrong?


Solution

  • It seems to me, that the following lines are missing at the end of your script:

        Registries.Component.extend(ReceiptScreen, ReceiptCheckboxRegistration);
    
        return ReceiptScreen;
    });
    

    Moreover, you should check that the path to your js file is correctly defined in your assets file (xml), which should be added to your manifest file.