Odoo - View customization with colspan or may be col - odoo

I am using odoo 10-e . Earlier i asked a question how can we merge two or multiple header to show one header against multiple fields
Combine two fields heading in one2many
. So answer was good and it worked but now i want to do some more customization in the one2many tree view in form. I want something like this.
I want borders also in rows but for specific columns and also sub heading for only once per column.
I tried to add div in odoo view but its not supported. I also tried to add it under groups but that is also not working.

Add below code to the same file colspan.xml Combine two fields heading in one2many as i given answer of it.
And that's it you can use subheading and col_border attribute as i added conspan.
<field name="one2manyfield">
<tree>
<field name="field1" subheading="SubHeading"/>
<field name="field2" col_border="1"/>
</tree>
</field>
Code to add in colspan.xml
<t t-name="ListView.rows" >
<t t-set="first_column" t-value="1"/>
<t t-foreach="records.length" t-as="index">
<t t-call="ListView.row">
<t t-set="record" t-value="records.at(index)"/>
</t>
<t t-set="first_column" t-value="0"/>
</t>
</t>
<tr t-name="ListView.row"
t-att-data-id="record.get('id')"
t-attf-style="#{(view.fonts || view.colors) ? view.style_for(record) : ''}"
t-attf-class="#{view.compute_decoration_classnames(record)}">
<t t-set="asData" t-value="record.toForm().data"/>
<t t-foreach="columns" t-as="column">
<td t-if="column.meta"> </td>
</t>
<td t-if="options.selectable" class="o_list_record_selector">
<t t-set="checked" t-value="options.select_view_id == record.get('id') ? 'checked' : null"/>
<input t-if="options.radio" type="radio" name="radiogroup" t-att-checked="checked"/>
<div t-if="!options.radio" class="o_checkbox">
<input type="checkbox" name="radiogroup" t-att-checked="checked"/><span/>
</div>
</td>
<t t-foreach="columns" t-as="column">
<t t-set="number" t-value="column.type === 'integer' or column.type == 'float' or column.type == 'monetary'"/>
<t t-set="text" t-value="column.type === 'text'"/>
<t t-set="modifiers" t-value="column.modifiers_for(asData)"/>
<td t-if="!column.meta and column.invisible !== '1'" t-att-title="column.help"
t-attf-class="#{modifiers.readonly ? 'o_readonly' : ''} #{number ? 'o_list_number' : ''} #{text ? 'o_list_text' : ''} #{column.id === 'sequence' ? 'o_handle_cell' : ''} #{column.tag === 'button' ? 'o_list_button' : ''}"
t-att-style="column.col_border === 1 ? 'border-left:1px solid black!important;border-right:1px solid black!important' : ''"
t-att-data-field="column.id"
>
<t t-if="!column.subheading or first_column === 0">
<t t-raw="render_cell(record, column)"/>
</t>
<t t-if="first_column === 1 and column.subheading">
<div class="text-center"><span><b><t t-esc="column.subheading"/></b></span></div><br/><t t-raw="render_cell(record, column)"/>
</t>
</td>
</t>
<td t-if="options.deletable" class='o_list_record_delete'>
<span name="delete" class="fa fa-trash-o"/>
</td>
</tr>

Related

How to add commas to numbers over one thousand in a odoo pdf report?

I've created a module in odoo13 that shows deposits, withdraws and balance. I want that all amount over one thousand will be separated by commas. Now the report only shows 1000, what i want is 1,000. Thank you in advance. Maybe is a simple question but iḿ a beginner in all of this.
The amount that i want to have the commas are 'amount'and 'balance'. Here's a part of my code:
<tbody>
<t t-set = "num" t-value = "0"/>
<t t-set = "balance" t-value = "account.initial_amount"/>
<t t-set = "transaction" t-value = "0"/>
<t t-foreach = "movements_list" t-as= "move">
<tr>
<td>
<t t-set= "num" t-value = "num +1"/>
<t t-esc = "num"/>
</td>
<td>
<t t-esc = "move['date']"/>
</td>
<td class = "text-left">
<t t-if = "move['type_operation'] == 'withdraw'">
<span>Retiro</span>
</t>
<t t-else = "">
<span>Depósito</span>
</t>
</td>
<td>
<t t-if = "move['type_operation'] == 'withdraw'">
<t t-esc = "move['amount']"/>
<t t-set = "transaction" t-value = "move['amount']"/>
<t t-set = "balance" t-value = "balance - transaction"/>
</t>
</td>
<td>
<t t-if = "move['type_operation'] == 'deposit'">
<t t-esc = "move['amount']"/>
<t t-set = "transaction" t-value = "move['amount']"/>
<t t-set = "balance" t-value = "balance + transaction"/>
</t>
</td>
<td>
<span t-esc = "balance"/>
</td>
</tr>
</t>
</tbody>

how to hide the sidebar on saleorder formview odoo?

I have been trying many different ways for hiding the sidebar button. Below code is working on all forms. However, i just want to hide it on sale order form. Widget.modelName seems not working because it is before the form declaration. I also tried doc_model in [sale.order'] and not working as well. How can I solve it? thanks
<t t-jquery = ".o_cp_left" t-operation = "replace">
<t t-if = "widget.modelName == 'sale.order'">
<div class="o_cp_left hiddenManagerSO">
<div class="o_cp_buttons" role="toolbar" aria-label="Control panel toolbar"/>
<aside class="o_cp_sidebar"/>
</div>
</t>
<t t-if = "widget.modelName !== 'sale.order'">
<div class="o_cp_left hiddenManagerKOO">
<div class="o_cp_buttons" role="toolbar" aria-label="Control panel toolbar"/>
<aside class="o_cp_sidebar"/>
</div>
</t>
</t>
</t>

Hide the "Create" Button in a specific module only in odoo11

i want to hide the create and import button in the header of my treeview my Odoo version is odoo11
I tried using the inserting create="false" edit="false" in my treeview tag but it hides all the button and I also tried replacing the t-operation="after" to t-operation="replace" but it affects all the other application
<template xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery="button.o_list_button_add" t-operation="replace">
<button t-if="widget.modelName == 'hr.timeinout'" type="button" class="btn btn-primary btn-sm oe_refresh_button" accesskey="f">
Refresh List
</button>
</t>
</t>
</template>
I only want to hide the "Create" and "Import" button in that specific treeview thank you
Try this code to remove the create button:
<t t-extend="ListView.buttons">
<!-- this will hide create button for model 'hr.timeinout' -->
<t t-jquery="button.o_list_button_add" t-operation="attributes">
<attribute name="t-if">widget.modelName != 'hr.timeinout'</attribute>
</t>
<!-- this will add refresh button for model 'hr.timeinout' -->
<t t-jquery="div.o_list_buttons" t-operation="prepend">
<button t-if="widget.modelName == 'hr.timeinout'" type="button" class="btn btn-primary oe_refresh_button" accesskey="f">
Refresh List
</button>
</t>
</t>
And to remove the import button for this model:
<t t-extend="ImportView.import_button">
<!-- this will remove button import for model 'hr.timeinout' -->
<t t-jquery="button.o_button_import" t-operation="attributes">
<attribute name="t-if">widget.modelName != 'hr.timeinout'</attribute>
</t>
</t>

Odoo - Change create button text

I am using Odoo 10e. In tree view or in form view for my particular model, i want to change the create button text to Add New User. How can we achieve this?
I tried to use Xpath for this, but as far as i know Xpath is use to inherit from a view and add something in the view not to change the item in the parent view
Create one xml file and write this below code in it.
For listview and formview it will change the name of create button as per your custom string.
Add this xml file path to qweb section in manifest file.
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery=".o_list_button_add" t-operation="replace">
<button type="button" class="btn btn-primary btn-sm o_list_button_add" accesskey="c">
<t t-if="widget.model === 'sale.order'">
Your String
</t>
<t t-if="widget.model !== 'sale.order'">
<t t-esc="widget.options.addable"/>
</t>
</button>
</t>
</t>
<t t-extend="FormView.buttons">
<t t-jquery=".o_form_button_create" t-operation="replace">
<button t-if="widget.is_action_enabled('create')" type="button"
class="btn btn-default btn-sm o_form_button_create" accesskey="c">
<t t-if="widget.model === 'sale.order'">
Your String
</t>
<t t-if="widget.model !== 'sale.order'">
Create
</t>
</button>
</t>
</t>
</templates>
I hope this answer will help you.
Simply just xpath to that button.
Then give position replace and change the string to Add New User from Create.
Try the code like this.
But remember the name of the button will be as it is.
Thanks
<xpath expr="//button[#name='action_set_create']" position="replace">
<button name="action_set_create" string="Add New User"/>
</xpath>

Hide EXPORT option in more button in OPENERP 7

How to hide the EXPORT Option in the more button for specific user group, and how to hide the 'MORE' button for specific user group in openerp 7.
Hide "Export in More Option"
in OpenERP-7
Create XML File Under static/src/base.xml in your module and add this code:
<templates>
<t t-extend="Sidebar">
<t t-jquery="a.oe_sidebar_action_a" t-operation="replace">
<t t-if="widget.session.uid !== 1">
<a t-if="item.label !== 'Export'" class="oe_sidebar_action_a" t-att-title="item.title or ''" t-att-data-section="section.name" t-att-data-index="item_index" t-att-href="item.url" target="_blank">
<t t-raw="item.label"/>
</a>
</t>
<t t-if="widget.session.uid === 1">
<a class="oe_sidebar_action_a" t-att-title="item.title or ''" t-att-data-section="section.name" t-att-data-index="item_index" t-att-href="item.url" target="_blank">
<t t-raw="item.label"/>
</a>
</t>
</t>
</t>
</templates>
Add this in File __openerp__.py:
'qweb': [
"static/src/base.xml",
]
Now restart the server and update your database and refresh the page.