Skip to Content
Menu
This question has been flagged

Hello, 

I have a new field in sale_order named: myfield

Now when I create a invoice from the sale_order , the myfield value is empty in invoice.

How can I move the value from my new field to invoice, when it creates a new invoice from the sale_order.


I tried something like this:


I see that the _prepare_invoice function is used to put values from sale_order to invoice.

Now when I make something like this it's not working.

I have the same field in invoice like "myfield" in sale_order:

def _prepare_invoice(self, cr, uid, order, lines, context=None):
"""Prepare the dict of values to create the new invoice for a
sales order. This method may be overridden to implement custom
invoice generation (making sure to call super() to establish
a clean extension chain).

:param browse_record order: sale.order record to invoice
:param list(int) line: list of invoice line IDs that must be
attached to the invoice
:return: dict of value to create() the invoice
"""
if context is None:
context = {}
journal_ids = self.pool.get('account.journal').search(cr, uid,
[('type', '=', 'sale'), ('company_id', '=', order.company_id.id)],
limit=1)
if not journal_ids:
raise osv.except_osv(_('Error!'),
_('Please define sales journal for this company: "%s" (id:%d).') % (order.company_id.name, order.company_id.id))
invoice_vals = {
'myfield': order.myfield,

}

Avatar
Discard
Related Posts Replies Views Activity
2
Jan 16
8166
1
Oct 22
2821
3
Mar 18
4757
1
Feb 17
2344
2
Jan 17
5807