Qweb report report_name not working - odoo

I can't change the default name for my pdf reports. It works if I do it in the settings but I don't want to do it this way. I tried by using report_name in my <report> but it says that report_name is not an element of report. I can't figure out how to do it.

For set-up custom name of qweb report you can set attachment attribute of report.
Example is available if for invoice:
<report
id="account_invoices"
model="account.invoice"
string="Invoices"
report_type="qweb-pdf"
name="account.report_invoice"
file="account.report_invoice"
attachment_use="True"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
/>
Try to use module : https://www.odoo.com/apps/modules/8.0/report_custom_filename/
Hope this helps.

Related

How to add custom field in Odoo Enterprise's reports

I have added some custom fields to the model account.move and I want to add these fields in the following Odoo Enterprise reports:
Accounting/Reporting/Partner ledger
Accounting/Reporting/Aged receivable
Accounting/Reporting/Aged payable
I did not find how to add fields to this kind of reports and they are way different than the regular views
Have a look at the official odoo documentation for qweb reports.
It looks roughly like this:
<t t-inherit="base.template" t-inherit-mode="extension">
<xpath expr="//tr[1]" position="after">
<tr><td>new cell</td></tr>
</xpath>
</t>
Set t-inherit-mode="extension" to modify an existing template. If you would set it to primary you would create a new template. From there on you can work with the familiar odoo xpath logic.
Keep in mind that this is a templating language with python support. So to actually print a field you first need to find the variable in the parent report (the mother recordset is usually called doc, order or something like this depending on the report). To display it you would do something like this:
<p><t t-out="order.name"/></p>
Also make sure to open the correct version of the documentation. There have been some changes to reports in recent versions.

report print dropdown odoo

I have to add an item in print menu from purchase order tree view in odoo 8.
i am unable to find where is current Purchase Order reports added in print menu. i researched and found there is a tag from below:
https://www.odoo.com/forum/help-1/question/how-to-add-an-item-to-the-more-drop-down-list-in-sales-module-61833
also tried below, but i am getting qweb error :
<act_window name="Print Receiving Wkst"
res_model = "purchase.order"
src_model = "purchase.order"
key = "action"
key2="client_print_multi"
value="ir.actions.act_window,action_report_print_receivePO"
id="act_print_recevg_wkst"
/>
my custom report is in "test" module with id "action_report_print_receivePO"
I am getting error for value tag i think.
Basically i have to add new entry in print menu from purchase order tree view. so that when ever it is clicked custom report is printed. moreover if more than one PO selected, it will create PDF of all the POs
Thanks,
You don't need to go through the stress of creating an action and then adding a new item to the "More dropdown". Odoo already provides a way for you do this. just set menu = True when you're registering your report and a Print option would appear in the "More dropdown" that prints your report.
<report
id="purchase_order_report"
string="Purchase order"
model="purchase.order"
report_type="qweb-pdf"
file="purchase.order.file"
name="purchase.order.report"
menu="True"
/>
For more information on what the other parameters mean please refer to the
docs
just in case you might want to generate reports of a different types not fully supported by Odoo, such as py3o you'll definitely need to create a report action as defined in the official doc. For example:
<record id="account.account_invoices" model="ir.actions.report">
<field name="report_type">py3o</field>
<field name="py3o_filetype">odt</field>
<field name="module">my_custom_module_base</field>
<field name="py3o_template_fallback">report/account_invoice.odt</field>
</record>
However for your action to appear in the Print dropdown list, you must add two more fields to the record
<field name="binding_model_id" ref="model_my_custom_module_base"/>
<field name="binding_type">report</field>
Hope this helps anyone in the future!!
NB: Here I'm using the py3o reporting engine. Check it out as an alternative to the native qweb engine.

How to define link text different in Odoo widget=url

I have made read only computed URL-field based on invoice number. It works nicely but I would like to produce text part only itself like 400:
400
Now it's producing whole link as text which is quite ugly
https://external_site_invoice?num=400
My Odoo fields are defined this way...
ext_invoice_number= fields.Integer(string="Ext number")
def _showlink(self):
for rec in self:
if rec.ext_invoice_number:
if rec.ext_invoice_number>0:
rec.ext_link="https://external site/invoice?num=%d" % (rec.ext_invoice_number,)
ext_link = fields.Char(string="Link",compute=_showlink,)
How can I define text part of URL in Odoo to be different than link? This is poorly documented or it's not possible?
you can define the text attribute in widget definition like that:
<field name="field_with_url" widget="url" readonly="1" text="My own text"/>
Regards

Hiding Field Value in XML & making it as href

I want to hide actual field value in xml and make it as href in my xml form.
Just like Visible Link ...
TIA
Odoo forms support an URL widget:
<field name="my_field" widget="url" />
See the field "Website" on the Partners/Customers form.

How to add report to the right side bar in Openerp

I would like to add a link to a new report link for a product on the right side bar of OpenERP, but i don't know where is the view. I modified the addons/product/report/init.py to add my new report but without success.
To add report to the right side bar, you have to add menu="True" attribute in your report tag.
For example:
<report
menu="True"
id="my_report_id"
string="My Report"
model="model_name"
name="service.name"
rml="your_rml_path.rml"
auto="False"
header="False"/>