Guys,
I would like to add a field into the Quotation/Sale Order so I added it into report_saleorder.xml but either it's not correct place or I did something wrong.
Where should I add it to have it on printouts ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Guys,
I would like to add a field into the Quotation/Sale Order so I added it into report_saleorder.xml but either it's not correct place or I did something wrong.
Where should I add it to have it on printouts ?
First you need to create the fields you want to add. You can do this in developer mode (http://pulse7.net/openerp/odoo-9-how-to-activate-developer-mode/) or create your own module. (https://www.odoo.com/documentation/8.0/howtos/backend.html#build-an-odoo-module)
Developer Mode: Go to settings->technical->models and search for sale.order. Once you are on the sale model you can edit and add a field. It is good practice to name your field with the prefix "x_" (i.e. "x_mycustomfield") Use other fields as a means to determine what type of data (Field Type) you should choose. (i.e. char, integer, datetime etc).
Now that you have added your field you can now add it to the qweb view of the report. The one you will want to edit is "report_saleorder_document". FYI, the way to find the correct qweb views for any report is as follows:
Go to settings->technical->reports and search for the model (i.e. sale.order.) Open that and look click the link "search associated qweb views".
Once you have opened report_saleorder_document you can edit in your custom field. For example, if you wanted to add your field right after Unit Price you would look for
<th class="text-right">Unit Price</th>
and add
<th class="text-right">My Custom Field</th>
Then look below for
<td class="text-right">
<span t-field="l.price_unit"/> </td>
and add right after
<td class="text-right">
<span t-field="l.x_mycustomfield"/> </td>
If you get an error when saving it may be that your custom field is not registered yet or misspelled.
The better way to do this is with a custom module. It's not too hard to do and there are several good tutorials. You will need to search for how to create custom modules that extend models and how to create custom reports or modify reports.
Also, as the previous answer indicated, you can also easily add your custom field to the tree and form views if desired. As long as you are in developer mode just go to sales->sales orders and on the bottom of the window click view-edit tree view or if you click on an order you can click view -> edit form view. Use the existing fields as an example of how to add your field. It's a little different than the qweb.
Have fun.
Great thanks Will, works beautifully.
I was so close ... :)
Hi Dr Obx,
it is depend of your gool. Classicly you can follow these step :
Add the field into sale.py in object sale.order.
Add the field into sale_view.xml (form and tree view of sale.order)
Add the field into report_saleorder.xml
Good work
Before I posted my question I already did the steps you suggested but I cant see my custom field. Actually I can see my field but only on screen, I can't see it in PDF/printout
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up