Hi and thanks for all help :) I ' solved it by edtiting the sale.py in sale module. I just had to edit _prepare_invoice function and add my custom fields to its invoice_vals like this:
invoice_vals = {
'name': order.client_order_ref or '',
'origin': order.name,
'type': 'out_invoice',
'reference': order.client_order_ref or order.name,
'account_id': order.partner_id.property_account_receivable.id,
'partner_id': order.partner_invoice_id.id,
'journal_id': journal_ids[0],
'invoice_line': [(6, 0, lines)],
'currency_id': order.pricelist_id.currency_id.id,
'comment': order.note,
'payment_term': order.payment_term and order.payment_term.id or False,
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
'date_invoice': context.get('date_invoice', False),
'company_id': order.company_id.id,
'user_id': order.user_id and order.user_id.id or False,
'x_destplace': order.x_destplace,
'x_loadplace': order.x_loadplace,
'x_vehivle': order.x_vehicle
}
Then I created those fileds in both models and my problem solved :)
First add the field you want to the invoice the same way you did the partner and create an onchange function on the customer name in the invoice.
hi and thanks for the answer but... what u mean with "the same way"? are there any parameters i gotta add?
You have to create an onchange function based on another field, e.g, the partner name or the sales order id
can u please explain me? in which file do i have to create that function and how? Also, does it matters what type of field it is? I mean can I send the value of a char field in sales.order form to a field in invoice form? Thanks for the answers :)