user5504568
user5504568

Reputation: 11

Odoo invoice print with shipping address

I'm trying to print an invoice with shipping address and invoicing address in Odoo. For delivery slip, I'm able to get a customer reference from the sales order using 'o.sale_id.client_order_ref'. It gives me an error when I tried 'o.sale_id.partner_shipping_id'.

I think this is because invoice needs sale_id with many2one relation to sale.order. Is there another way instead of using sale_id to get the shipping address?

Upvotes: 0

Views: 834

Answers (1)

Vikash Mishra
Vikash Mishra

Reputation: 144

Invoice do not have relation with sale order. you need to override the model "account.invoice" and add a field to hold the "partner_shipping_id" and then override the following method which supplies values for invoice creation:

class sale_order_line_make_invoice(osv.Model):
    _inherit = 'sale.order.line.make.invoice'

    def _prepare_invoice(self, cr, uid, order, lines, context=None):
        vals={}
        vals = super(sale_order_line_make_invoice, self)._prepare_invoice(cr, uid, order, lines, context=context)
        vals.update({'partner_shipping_id':order.partner_shipping_id.id})
        return vals

add the partner_shipping_id in this method. Then you can get this in invoice.

Upvotes: 1

Related Questions