Skip to Content
Menu
This question has been flagged
7 Replies
3026 Views

Can somebody tell me what tables make up the product moves report

Avatar
Discard
Author

Paresh,

Just one table?

Author

I'm not trying to manipulate data. I'm using Tableau as my report writer.

Hi Daryl: I have edited my earlier answer and posted more details based on your clarification.

Author

Paresh,

Your example, stock.move.line has a Many2one field called company_id which is a relation with the res.company model. You will find a column called company_id in the stock_move_line table which stores the data for this field and is a foreign key to the res_company table.

I'm new to oddoo. What are the steps to give me such data? For example when I look at stock.move.line under models, then click fields, I do not see a company id under fields. Hope that makes sense.

Best Answer

Hi Daryl:

It's based on the stock.move.line model.


EDIT:

Odoo follows a naming convention that is useful in figuring out the tables in which the data is stored. The table name is the model name with the "."'s being replaced by "_".

For example, in our case, the model name is stock.move.line  Therefore, the main database table name will be stock_move_line 


Similarly, the relational fields like Many2one, One2many and Many2many are essentially foreign keys that map to other tables. The names of the columns are easier to figure out since they typically map directly to the field name. The easiest way to figure out all the tables is to go through each relational field and to see which models they are based on. This in turn will tell you which tables you need to perform a "join" on.

For example, stock.move.line has a Many2one field called company_id which is a relation with the res.company model. You will find a column called company_id in the stock_move_line table which stores the data for this field and is a foreign key to the res_company table. If you need to retrieve the details of the company in your report, you will need to do a join between stock_move_line and res_company where stock_move_line.company_id = res_company.id 

The same principle applies to One2many fields - the id of the parent table will be stored in the foreign key column of the child table. For Many2many fields, Odoo creates a "join" table whose name is a concatenation of the names of the 2 tables with a suffix of _rel and contains 2 foreign key columns that store the id's of the 2 parent tables that are a part of the relationship.


Hope this provides you sufficient pointers to be in a position to move forward. Feel free to ask more questions, if required.

Avatar
Discard
Author Best Answer

Just one table?

Avatar
Discard

That's the "model". You will need to look at all the fields in the model recursively to identify all the tables.

Just curious, why are you interested in the physical tables ? As a best practice, one should never manipulate data directly in the database. You can end up corrupting the database if all the dependencies are not taken care of.