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
Related
I have a many2many field that represents a list of student. I want to only add student to that list but not remove any students from that list (in form view). Is it possible to implement that?
I think it's possible to do it. You need to override the #write method. Each time that an update will be made on your object, you need the compare the actual length of your many2many field current_length and the new length of students made by the update new_length.
If new_length > current_length, it's means that the update is an adding, so you can consider the changes. Otherwise, it's means that the update is a removing, so you just need to ignore the changes.
Please find below, an exemple of implementation :
#api.multi
def write(self, values):
current_length = len(self.student_list)
new_length = len(values['student_list'])
if current_length > new_length:
\* Removing of students *\
values['student_list'] = self.student_list
res = super(Object, self).write(values)
return res
Note that you can go further by making another comparaison between the ids of the current and new list, in order to be sure that the students are the same.
It s not possible using the many2many_tags widget, but using the xml tree view as part of your Form view, you can add the delete-attribute on the tree-node inside the scope of your own field:
<form>
<notebook>
<sheet>
<page string="Graduated" name="gratuated_students">
<field name="students_ids" >
<tree string="Students" editable="bottom" delete="0" >
<field name="name"/>
<field name="birthday"/>
<field name="score" readonly="1"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
If this view comes from an odoo's module (no custom module): you'd rather inherit this view and add the attribute "delete=0" to the existing student_ids field:
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[1]/field[#name='students_ids']/tree[1]" position="attributes">
<attribute name="delete">0</attribute>
</xpath>
Otherwise, if you really want to use the many2many_tags widget and if your are experienced with odoo's js-framework, you could develop your own option "no_delete" on the basis of the following OCA module:
https://odoo-community.org/shop/web-m2x-options-2661#attr=10772
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.
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.
Good Day! is it possible to disable pop of tree view in the form. I tried no_open="True" readonly="1" edit="False" both on field and tree view but didn't worked.
<field name="payment_line">
<tree editable="top" create="false">
<field name="product"/>
<field name="description"/>
<field name="account"/>
<field name="unit"/>
<field name="qty"/>
<field name="amount"/>
<field name="total"/>
</tree>
</field>
I've coped with the same issue in odoo 10, my one2many treeview always make a popup on click. No matter editable='bottom' option was set.
Suddenly I've found web_tree_no_open module from codingforfun, that adds a new option:
< tree open="false" >
It's for version 8 but it can be used in 10 just renaming openerp.py to manifest.py
It can be downloaded from here:
https://github.com/initOS/web/tree/8.0-tree-view-no-select/web_tree_no_open
Worked for me, I hope it helps
Use this style to disable click in read as well as edit mode:
<field name="your_o2m" style="pointer-events:none;" />
Use editable='bottom' in this case, like:
<field name='line_ids'>
<tree create='false' editable='bottom'>
<field name='so_line_id' readonly='1'/>
<tree>
</field>
Odoo Version 10.0
web_tree_no_open module adds a new option: <tree open="false">
Lists
The root element of list views is <tree> 3. The list view's root can have the following attributes:
editable
by default, selecting a list view's row opens the corresponding form view. The editable attributes makes the list view itself editable in-place.
Valid values are top and bottom, making new records appear respectively at the top or bottom of the list.
The architecture for the inline form view is derived from the list view. Most attributes valid on a form view's fields and buttons are thus accepted by list views although they may not have any meaning if the list view is non-editable
default_order
overrides the ordering of the view, replacing the model's default order. The value is a comma-separated list of fields, postfixed by desc to sort in reverse order:
<tree default_order="sequence,name desc">
create, edit, delete
allows disabling the corresponding action in the view by setting the corresponding attribute to false
on_write
only makes sense on an editable list. Should be the name of a method on the list's model. The method will be called with the id of a record after having created or edited that record (in database).
The method should return a list of ids of other records to load or update.
string
alternative translatable label for the view
Deprecated since version 8.0: not displayed anymore
Note
if the list view is editable, any field attribute from the form view is also valid and will be used when setting up the inline form
view
in the form and tree view you can add create='false' to disable the create button and edit='false' to disable the edit button.Also use editable="top" or editable="bottom" if you dont want the form view to popup. for example
<tree string="Sale Order" create="false" edit="false" editable="bottom">
...
...
...
</tree>
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