While debugging a module I have the need to inspect a many2one field directly in postgres.
How can I find the account_move rows in database that belong to a given hr_expense_sheet row? Is ir_model_data table used to implement the many2one relation?
class HrExpenseSheet(models.Model):
....
account_move_id = fields.Many2one('account.move', string='Journal Entry', copy=False)
You don't really provide quite enough information for me to know the exact relationships between each of the models, but here's a general idea.
The
Many2one
relation is managed with a foreign key. So, on theHrExpenseSheet
model, it stores theaccount_move_id
as an ID. If you want theAccountMove
information directly from the database, you must search theaccount_move
for that given ID.Assuming the models a related something like this:
Basically, the query you will run is going to find all account moves for any line that belongs to a given expense.
If you just want to find for a specific
HrExpenseSheet
, you can use: