This question has been flagged
2 Replies
10362 Views

Hey guys,

i have a problem with adding the shipping/delivery address from the sale_order to the invoice report. I already saw this post (link below) and edited the files as descripted, but it doesn't worked for me. Can someone please help me? I use openERP version 7. Best regards

Dyck

Link: help.openerp.com/question/10304/how-can-i-display-the-delivery-address-on-the-invoice

Avatar
Discard

Hi, have you check in settings/sales/ check Allow a different address for delivery and invoicing.

Author

Yes, this option is checked.

the delivery address is indicated on the order, no use to put in the invoice.

Best Answer

You can create a module that inherits invoice and add the shipping address field to the invoice this way. After, you can edit the print out from invoice with Open Office report editor to include the field you just added. That should do it

        'deli_add': fields.many2one('res.partner.address', 'Delivery Address', select=True) add this to the columns of python code

and add to the form view of the module you want this field to show just after the invoice address field

        <field name="deli_add" />

this will give you your field and you will be able to select the shipping address but it will not auto fill when you select a client name. This should give you an idea of what you need to do.

Avatar
Discard

Remember you have to reload the server when you make changes to .py files and upgrade when you make changes to the xml files for new changes to take effect

Author

Many thanks to you, that looks right :D I will check it tomorrow when I'm at work. Maybe it's the xml file, I forgot them. I will post tomorrow if it works or not.

Author Best Answer

I skipped the step to create a module and edited for testing the file addons/account/account_invoice.py. There I added this piece of code:

'partner_shipping_id': fields.many2one('res.partner', 'Delivery Address'),

Then I added following line in the account_print_invoice.rml:

<para style="tableAngebotContent">[[ display_address(o.partner_shipping_id) or 'No delivery address' ]]</para>

Now it's funny. Neither the street of the shipping address nor the text 'No delivery address' are visible. Is the code wrong or did I forgot something? Best regards

Dyck

Avatar
Discard

this is a very wrong move because if you mess up a base module the application may not open properly anymore. would advise to build a module with inherited invoice view and add you field there. You have to understand that there is an on_change function on the address in the python code and you need to add the shipping address to be affected by this function. Thus, the on_change function of address in invoice module should also change the shipping address which will also affect the view. This is why it is better to create a module of your own to incorporate all this

Author

I know it's not good to edit base modules. How I already wrote, only for testing. The openERP is installed on a developmentserver, so if it crashes, who cares ;). For me, it's important to know, what is wrong with the code above. When I get it to work, then we do it the "clean way". But thanks for your answer.

Ok then. Firstly, I believe you need to make changes to the _view.xml file to make your field visible in a module on webclient. The xml file manages the view. If your field is not declared in the xml then you will not see it eg <field name="name" position="after"> <field name="partner_shipping_id"/></field> or something like that need to be somewhere in the xml form view. That determine where the field is displayed since you said you cannot see your field