report print dropdown odoo - 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.

Related

Odoo: How to add custom category name to app module's search panel?

For example i have app with
category = "custom_category"
How can i add this category to my search panel in app module ?
When I created a category, I thought it would come here automatically, but it didn't.
I found the file, where these categories are defined:
15.0/odoo/odoo/addons/base/data/ir_module_category_data.xml
But something is not right here! When I delete a record from here, for example:
<!-- <record model="ir.module.category" id="module_category_human_resources">-->
<!-- <field name="name">Human Resources</field>-->
<!-- <field name="sequence">45</field>-->
<!-- </record>-->
And update the base module, this (Human Resources) field is still in this menu !?
Why it is not deleted? Any advice?
Model 'ir.module.category' doesn't have delete access rights (ref https://github.com/odoo/odoo/blob/a7f7233e0eae8ee101d745a9813cba930fd03dcb/odoo/addons/base/security/ir.model.access.csv#L20). So once a record is created from the xml file, it will not delete if you comment that code line.
You can directly delete it from the database using delete query.
Odoo will only show categories that do not have a parent and that one of the subcategories is linked to a module.
If the category_id field is defined in the search panel, Odoo will use a custom domain:
domain = [('parent_id', '=', False), ('child_ids.module_ids', '!=', False)]
To show the custom category in the search panel:
First, define the module category as follows:
<record model="ir.module.category" id="module_custom_category">
<field name="name">custom_category</field>
<field name="sequence">99</field>
</record>
<record model="ir.module.category" id="module_child_category">
<field name="name">child_category</field>
<field name="parent_id" ref="module_custom_category"/>
</record>
Then set it in a module __manifest__.py file:
'category': 'custom_category/child_category',
Why Odoo did not remove the category after commenting the XML definition?
Odoo will create two categories with the same name (custom_category) with the following XML IDS:
base.module_category_custom_category
stack15.module_custom_category
And use the first one to show it in the search panel.
When you comment record XML definition and upgrade the module, Odoo will remove the category using the module name as a prefix in its XML id (stack15.module_custom_category) and keep the base category (base.module_category_custom_category), so the custom category will be visible even if you uninstall the module.

Odoo Custom Tree Control

If you create new quotation in the Sales module, there are some control buttons:
Add a product
Add a section
Add a note
I want to create those custom control for my tree view. But when I search from the source code, I can't find where is the python method is called.
...
<tree string="Sales Order Lines" editable="bottom">
<control>
<create name="add_product_control" string="Add a product"/>
<create name="add_section_control" string="Add a section" context="{'default_display_type': 'line_section'}"/>
<create name="add_note_control" string="Add a note" context="{'default_display_type': 'line_note'}"/>
</control>
...
I search the add_product_control keyword, but there is nothing I found.
Because odoo is not calling any python method it will trigger from javascript side and it will add new record and hide other fields using display_type
display-types
line_section
line_note
and you can find code in
/addons/account/static/src/js/section_and_note_fields_backend.js

Can't add items to Many2many in Odoo 12 EE

I defined a Many2many field for ir.attachemnt. The problem is i can' see the Add an item link to add the records.
*.py
attachment_ids = fields.Many2many('ir.attachment', string='Attachments')
*.xml
<notebook>
<page string='Attachments'>
<field name="attachment_ids"/>
</page>
</notebook>
I also tried this:
<field name="attachment_ids" widget="many2many" />
Any idea?
There is only two thing that make Odoo behave like this.
Your view is in edit mode but I think I'm seeing a place holder comments this means it's not the case
Your user is not allowed to create an ir.attachment which is more likely not the case
Your field is readonly.
If not one of this cases these is wired but if you didn't understand what happen you can force that link to appear by using embedded tree with create attribute set to true
<field..... >
<tree create='1'>
....
It'a a bug. If you have more many2many fields in the some class and for one of this you haven't right access rules, all the many2many fields are showed in readonly mode.

How to make tabindex in openerp fields

I want to change the tabindex in a form in opererp
how can I change it in the xml file or the python code
I am using openerp 6.1
example to what I need
in sales order form ,user want to change the focus of the element using tab button
he need to write first the order reference field then go to customer service field using a tab button,but when I press tab I go to the date button not the custom service even that the date button has a default value
Thanks
You can inherit and change both the models (defined in python files) and views (defined in xml files). More details about inheritance can be found here Object Inheritance
and Inheritance in Views
you can overwrite the original xml arch in your view and change the sequence of pages as per your requirement
like:
<record id="**account.invoice_supplier_form**" model="ir.ui.view">
<field name="name">account.invoice.supplier.form</field>
<field name="model">account.invoice</field>
<field name="priority">2</field>
<field name="arch" type="xml">
<form string="Supplier Invoice" version="7.0">
as shown above you can write the same xml arch as define in account for supplier invoice,
and you can now change sequence of pages
hope this help

OpenERP custom module on mobile

I am making a custom module in OpenERP. I have a list(tree) view and a form view. I can view and edit records.
When I take the mobile view of the same module, I can see the main menu and browse to the sub menu, but no list view or form view is visible. All I can see is a blank page. Is my list definition worng?
<?xml version="1.0"?>
<tree string = "Camera">
<field name = "a"/>
<field name = "b"/>
</tree>
I believe that after a menu option is selected, the following menu is a simple list with the name of each record.
It may be that you don't have any record yet.
Or it may be that you don't have a name field on the object model and views. Add that field (make it required) or, alternatively, set the object's _rec_name attribute (example: _rec_name = 'a').
OE Mobile View is read-only mode
It does not have any type of view(like, tree or for, or kanban), It just show the view of record and show you have value. It hos wht name filed valeu on list then if you click on it it open detail view which show thw other detail. and yes try and add the record on your model.
Thank You