OdooJsonRpcClient
OdooJsonRpcClient copied to clipboard
How to write Many2Many fields? (ODOO V12)
Hi, i have a problem for write some fields that are many2many fields
In this case, i'm creating a Invoice That invoice has invoice lines where each line has an array of taxes lines Using the library i set the tax ids but after create the invoice line the taxes not appear
This is an example of Invoice created from ODOO V12 using web browser
And this is an example of Invoice created from ODOO V12 using library PortaCapena
I'm using this table "account.invoice"
with one2many relation to "account.invoice.line"
Then i set the tax_ids for this invoice lines in field "invoice_line_tax_ids" (This field is a many2many field type)
I'm setting the tax_id correctly
This is my code (My repo is here https://github.com/luke92/OdooNetFramework)
The variable taxesId is getting from the product model
First i create the invoice
After that i save each invoice line setting the id of invoice
How can i save the "account.invoice.line" with "invoice_line_tax_ids" ?
In case of doubt, I am at your disposal
Thanks, Regards,
Hi, I think I had once a similar issue and as I remember, you should use a different column for this, or add this tax to the product at first. I'll try to find some time on the weekend to check it.
Check this example with purchase order: PortaCapena.OdooJsonRpcClient.Example/OdooClientTests.cs - L654
Hi, I think I had once a similar issue and as I remember, you should use a different column for this, or add this tax to the product at first. I'll try to find some time on the weekend to check it.
Check this example with purchase order: PortaCapena.OdooJsonRpcClient.Example/OdooClientTests.cs - L654
Thanks Patrick!
I tried what you mention (even with your new column too) but it doesn't work
@patricoos I have a solution for this!
Here is my solution https://github.com/luke92/OdooNetFramework/blob/main/OdooIntegration/OdooIntegration.ConsoleApp/Many2ManyHelpers/OdooMany2ManyService.cs
Basicallly i authenticate with {baseUrl}/web/session/authenticate
Sending a json for authenticate and get session_id
{"jsonrpc":"2.0","params":{"db":"database","login":"username","password":"pass"}}
And then send a json structure to this url: {baseUrl}/web/dataset/call_kw
{ "jsonrpc": "2.0", "method": "call", "params": { "args": [ [ 60191 ], { "invoice_line_tax_ids": [ [ 6, false, [ 3 ] ] ] } ], "model": "account.invoice.line", "method": "write", "kwargs": { } }, "id": 12 }
The trick is replace the content of property args
Also for invoices, is necessary add taxline to invoice (add taxes in invoice line not generate taxes for invoice)
Congratulations! Good job, luke92 In the future, I will implement web client to my library, based on your example Thanks a lot!