Skip to Content
Menu
This question has been flagged

I have created a field "x_workorder" in Sale Order. Now, I want to transfer the field data to invoice on time of Invoice creation from SO. How can I do that...

Avatar
Discard
Best Answer

Hi Debashis,

First for transfer of any fields from one model to another create the field in both model here in your case you have create a field in sale.order so again create the same type of field in account.invoice table.

after that pass that value from sale.order to account.invoice, if you seen in the sale.py file you will see a def function while for creating invoice and values :

def _prepare_invoice(self, cr, uid, order, lines, context=None):

enter code here over here you may pass ur value which will go n store in fields define in account.invoice table ex . if you created a field in sale.order x_workorder create also field in account.invoice after that come in this def function and inside :

invoice_vals = {
                'yourfieldinaccount.invoice': order.x_workorder ,
               }

then you find the value in invoice as well and yep use proper xml too.

Hope this will help .

Avatar
Discard
Best Answer

 For creating "account.invoice" from "sale.order" there is four selection option

  • delivered

  • all

  • percentage

  • fixed

I tried a function "def action_invoice_create(self, grouped=False, final=False): " using super in inherited sale.order.

It works fine for sending a field value from sale.order to account.invoice, when the selection field is "delivered" or "all".

But it doesn't work for "percentage" and "fixed" selections.

So I used another function "def _create_invoice(self, order, so_line, amount):"  using super in inherited wizard/sale_make_invoice_advance.py

It propagated the field value from sale.order to account.invoice successfully.

I have tested it in debug also.

Does it right way to achieve? or any other way?

Note: I worked on ODOO9

Avatar
Discard

instead of "def action_invoice_create(self, grouped=False, final=False): " I tried with "def _prepare_invoice(self, cr, uid, order, lines, context=None):" also. But same happened it's not working for "percentage" and "fixed" selections.

Related Posts Replies Views Activity
0
Mar 15
4655
1
Mar 15
5846
0
Sep 21
2339
0
Aug 17
2221
3
Mar 17
9806