Linking historical invoices via the api #125
-
I have seen similar questions asked before but the I am unable to replicate the solutions given, I am currently adding historical orders into an Odoo.sh test instance and I am struggling to link my sale.orders with Invoices I have written to account.move. I have tried, like other posts have suggested, writing my invoice id to the sale.order 'invoice_ids' list and setting my order's invoice_status to 'invoiced' upon creation. Neither of these seem to successfully write but the requests themselves do not return any errors for this, this leads me to believe that something is blocking my bad practice (maybe a record rule?). Does anyone know what could be blocking this? (my instance is default Odoo 16) Or could anyone recommend me a better approach? I have considered posting the invoices first and then using their ids in the initial sale.order creation as a work around but this didn't work with a quick test either. The other option I can think of is using the auto generation feature here and then editing it's field values, the main issue with this is that many orders have multiple invoices attached to them; will it create issues if I try to call the auto generation method multiple times for one order? (I am also unsure if Odoo will let me edit the fields I want in a auto gened invoice, critically, having the correct 'name' is very important for our use case). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I would encourage you to read the source of Odoo to understand how things work. It can and does differ massively between versions.
If you really want to do this, you’ll need to link the As for forcing the invoice status, I’d becareful here. If you don’t have an ‘in-code’ override in place simply unlocking the order, or any number of other things may be enough for it to “slip out” of the invoice status you’re attempting to force. I would encourage you to use sale_force_invoiced module (https://github.com/OCA/sale-workflow/tree/16.0/sale_force_invoiced) personally. |
Beta Was this translation helpful? Give feedback.
I would encourage you to read the source of Odoo to understand how things work. It can and does differ massively between versions.
invoice_ids
on 16.0 is computed without an inverse. This means that writing toinvoice_ids
has no effect (see https://github.com/odoo/odoo/blob/16.0/addons/sale/models/sale_order.py#L220).If you really want to do this, you’ll need to link the
sale.order.line
to specificaccount.move.line
(read: invoice line) records. The reason being is that this is how the computed method determines how…