get current user's company id
in a model i defined a company_id this way:
company_id = fields.Many2one(
default=lambda self: self.env.user.company_id
In a new document edit form the company id is correctly selected, but when I click on "company id" selection, I get this error:
Uncaught Error: AttributeError: object has no attribute 'company_id'
The "self" object appears to be empty, when logged.
I copied the definition of company_id from one of many core or OCA modules that uses it.
Does it rely on context?
And how could I get the id of the current user and is company_id?