Skip to Content
Menu
This question has been flagged
2 Replies
2323 Views

Hello guys, can you help me with the creation of a field?

Well, I need to create the company_id field with the dependency of the model res.config.settings, it turns out that I have already created it in the normal way, in a perhaps more complete way, but even so it still gives me the error message below ... does anyone know how to create this field? Thanks :)

I created it this way: company_id = fields.Many2one('res.company', string='Company')

And also like this, according to a search I did: company_id = fields.Many2one(

'res.company',

string='Company',

required=True,

default=lambda self: self.env.company.id

)

But it didn't work...

Avatar
Discard
Best Answer

Hi,

It appears that the field named 'company_id' that you created is not being recognized within the context of the 'res.config.settings' model.
 
1-Please make sure that the module containing the field definition is correctly installed and loaded in Odoo. Additionally, ensure that you have restarted the Odoo server after applying any modifications to the module.
2-Please ensure that the field is defined in the appropriate model, as you mentioned 'res.config.settings' in this case. Verify that the field is correctly defined within the intended model.
3-Double-check that the field name is accurately spelled and matches the name used in other sections of your code where you make references to this field.


Hope it helps

Avatar
Discard
Author

Yes, I have done these checks, even when I go to the res.config.settings model, it shows the company_id field inside the base and my model, but even so, it always comes back to this error, I honestly don't know what's going on....

Best Answer

Hi,

Can you make sure that the service has been restarted and module has been upgraded. Error is raised by saying that the field does not get added in the model res.config.settings


Thanks

Avatar
Discard
Author

Yes, I have already restarted, updated the module, it is in the init, I did all the procedure, but I still have this error.

i think, the service is not get restarted, can you stop the service and see if your odoo is still accessible ? if yes, service is not stopped, you may have to force stop.

then ensure python files are imported in init file

Author

I did it this way, restarted the system, updated the module, made sure that the field is created and being called by my module, and from what I saw it is in the base model and in my module, but for some reason, which I have not yet been able to figure out it returns to this error.

Related Posts Replies Views Activity
4
Jun 25
2013
1
Jun 25
846
0
Feb 25
896
1
Nov 24
1749
1
Nov 24
1011