Ir al contenido
Menú
Se marcó esta pregunta

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
Descartar

Please explain "Counterpart account". Perhaps with examples.

Autor

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.

Autor Mejor respuesta

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
Descartar

Hi Max,

Can you explain more from code level?

Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 24
2604
1
jun 24
1481
1
feb 24
1558
2
ene 17
11392
2
mar 15
7640