Ok, so this is extremely weird.
I have two references to the same pos_config:
1. From an inherited res.users model
class Users(models.Model):
_inherit = "res.users"
pos_config_default = fields.Many2one('pos.config')
2. From a custom model
class MyCustom(models.Model):
_name = "my.custom"
pos_config_default = fields.Many2one('pos.config')
Then in the GUI I can assign a pos_config to these.
When I then reference these in code, they each have what seems to be the exact same pos_config object, however each reference contains a different env.user
I'm logged in as "admin" (meaning user id 2)
Here is the debug output from code:
print(pos_config_user)
print(pos_config_user.env.user)
print(pos_config_user.env.user.display_name)
print(pos_config_user.env.uid)
print(pos_config_my_custom)
print(pos_config_my_custom.env.user)
print(pos_config_my_custom.env.user.display_name)
print(pos_config_my_custom.env.uid)
Result:
pos.config(1,)
res.users(1,)
OdooBot
1
pos.config(1,)
res.users(2,)
Administrator
2
So, what's going on here? Is there some special "env magic" when it comes to extending res.users?
The real problem here is that when opening/starting a pos_session from code using pos_config.open_session_cb() the one referenced from pos_config_user is opening the pos_session as OdooBot, which ofc is not what I want. I want the pos_session to be opened by the logged in user.