Skip to Content
Menu
This question has been flagged

I have created a model "x_farmer" by going through steps in Settings -> Database Structure -> Models -> Create.

It created a table with it's own magic fields and I don't see any modifications to the Odoo 10 code base after this.

Questions:

1. Is there a way to create a model without magic fields ? Please point me to some useful resources on this.

2. If Odoo's code base is not modified then how do I add sql constraints to the model  as I can't use _sql_constraints list (no model class) ?

 

Avatar
Discard
Best Answer

It is similar but different.  You have less control over the model when you do it via the UI, but it is a great way to quickly extend Odoo without writing code.

Models created via the UI don't support SQL contraints.

I don't know of a way to create a model without magic fields - you'd have to teach Odoo a new way to persist data.

You can put code in Automated Actions so that when Model records are created or updated, that code stops the record being saved if the constraints are not met.

Avatar
Discard
Author

I saw some tables like 'account.account.account.tag' which don't have any corresponding model class in Odoo code and no magic fields in it. It also does not have any primary key. This indicated to me that there is some way to create a table without magic fields.

Any thoughts on this ?

I am very new to Odoo and thus could be making wrong conclusions.

Yes @sahil there no model with name account.account.account.tag, because the correct name is account.account.tag and this class table has the magic field.

Author

there are two tables 'account.account.account.tag' and 'account.account.tag'. 'account.account.tag' is defined by class AccountAccountTag in addons/account/models/account.py.

'account.account.account.tag' is generated by tag_ids field(Many2Many) in class AccountAccount in addons/account/models/account.py.

Related Posts Replies Views Activity
3
Aug 22
17480
2
Jun 20
3864
2
Dec 16
5619
2
May 23
5648
1
Aug 20
4997