2

it should be simple I think.

all I want is just to show a context into a field.

ex:

<span>the active_id is {context.get('active_id', false)}</span>

or

<button string="the active_id is: {context.get('active_id',false)}" />

I have spent days to look for this, yet no answer has been found. Any help would be very much appreciated. Thanks

Jacky Supit
  • 469
  • 3
  • 15

1 Answers1

1

You have to add this field in model definition, for example:

context_active_id = fields.Char(default=lambda self: self.env.context.get('active_id', False), store=False, readonly=True)

and add that field to the view.

<field name='context_active_id' />
arryph
  • 2,725
  • 10
  • 15
  • You are right that this can be added in a field as you've shown. However, the question seems to be asking how it can be displayed in a `string` (like the button's text). As far as I know that's not possible. If it's not ok to display the field normally, then it may be possible to display the field inline in the form with something like `The active_id is ` – travisw Jan 18 '19 at 04:25
  • yes, you are correct @travisw I want to show the value not as a field. I want to show it in a span or button, etc. Or may be, I need to change my point of view on achieving my goal. tks guys – Jacky Supit Jan 28 '19 at 09:59
  • im sorry for the late response. I have figured it out, and yes the answer is the same as your answer. Thus I set this as an accepted answer. thanks man. – Jacky Supit May 19 '20 at 07:08