Skip to Content
Menu
This question has been flagged

Greetings,

I'm currently trying to create a couple reports for my company, and one of the required fields is the counterpart field from the account.move.line model. Currently I'm writing a Python script for the PostgreSQL backend that Odoo uses, because my company requires some additional things in the report Odoo can't provide, and furthermore, I'm not comfortable with module development yet (and would like to avoid it anyways, for this task at least). The counterpart field is the only field that's missing, the report is otherwise finished completely.

So, my question is, how is the counterpart field calculated / chosen? If it's not too complicated, I'd like to do it myself for reasons stated above.

Thank you very much in advance!

Avatar
Discard

Please explain "Counterpart account". Perhaps with examples.

Author

The "Counterpart" can be found when you go to Accounting > Adviser > Journal Items. On the far right, perhaps some horizontal scrolling is needed, there is a field named counterpart. Its description says: "Compute the counter part accounts of this journal item for this journal entry. This can be needed in reports." The field shows the account number(s) related to a given journal item of a journal entry. https://i.imgur.com/nVlaQX6.png

I am unsure if I can easily replicate its function in a script, but my current idea is to just copy and store its content to a new field, that I can then access from postgres. I will keep this thread updated.

Author Best Answer

Update on the issue:

I managed to circumvent it by creating an external field that references the counterpart field, copies its content and saves it, which is just enough for my uses. I did this because I did not want to tamper with Odoo's base fields too much.

Avatar
Discard

Hi Max,

Can you explain more from code level?

Best Answer

The field counterpart in the model account.move.line got the information about the other account used in the journal entry. A journal entry must always balance Credit and Debit. So if the journal item is a credit posting, the counterpart field will have the debit account. 

In some cases there can be many counterpart accounts.   

If you need this information I think it is better to access it from Account.move

Avatar
Discard
Related Posts Replies Views Activity
1
Sep 24
334
1
Jun 24
483
1
Feb 24
655
2
Jan 17
9903
2
Mar 15
6705