urrency_id = fields.Many2one('res.currency', default=lambda self: self.env.company.currency_id, readonly=True)
I need to understand what is company refer to in this code?
is it a model?
and how can i see this model and fields in this model?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
urrency_id = fields.Many2one('res.currency', default=lambda self: self.env.company.currency_id, readonly=True)
I need to understand what is company refer to in this code?
is it a model?
and how can i see this model and fields in this model?
Hi,
company is the object of res.company in the odoo environment, which will return you the active company in the current environment.
Similarly you have self.env.user which will return the current user.
To know more about odoo environment variables, see this: Odoo Environment Variables
Thanks
Hi,
In the code you provided, company is a reference to the current company in the Odoo environment. In Odoo, you can have multiple companies configured within the same instance, and each company can have its own currency.
The company.currency_id field returns the default currency of the current company.
self.env.company is an Odoo environment object that provides access to the current company's data. You can use this object to access fields and methods related to the company.
To see the model and fields of the company object, you can follow these steps:
Go to the Odoo backend and open the "Settings" app.
Under the "Users & Companies" section, select the company -> choose a company to view the fields.
Click on the "debug icon" dropdown menu and select "view fields".
From here, you can see the fields of the res.company model, including currency_id.
Regards
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Oct 23
|
1455 | ||
|
2
Jul 24
|
2215 | ||
|
3
Dec 23
|
2469 | ||
|
2
Mar 15
|
5293 | ||
|
2
Aug 24
|
3456 |