0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.