How could I increase the width of a column in a tree view? - view

In odoo 13, I have inherited a tree view, and I want to increase the width of a view.
I tried with style = "width: 120px" in the <field>, but it does not worked.
click here to see the column to modify the width

Luis De la Cruz
Solution which doesn't work
xml <field width="100" /> or <field style="width: 100" /> or <field style="width:50 %%" />
xml <field class="custom_class" /> ; with css .custom_class { width: 1000px;}
xml : <field name="custom_field" /> with css : [data-id="custom_field"]{width: 100px;}
Solution Which Work:
xml : <tree string="XYZ" class="custom_class"> <field name="custom_field" />
css : .custom_class [data-id="custom_field"]{width: 1000px;}
Becuase the class attribute works on tree tag.
Also, you can apply the below thing to increase the column width
<field name="name" string=" Name "/>

Related

Solr dataimport jdbc multiple columns into one field

I am trying to implement a solr search for a project. Everything was fine so far, a first simple version worked. Now I try to import from a postgres data base where multiple columns should end up in the same field. My config:
<entity name="address" query="SELECT objectid, ags2, ags3, ags5, ags8, ags11, ags20, ags22, pt, stn, hnr_min, hnr_max, plz, ort, ortz, ot1, ot2 FROM variablen2018.ags22_tmp_solr LIMIT 10000;">
<field column="objectid" name="id" />
<field column="plz" name="plz" />
<field column="ort" name="ort" />
<field column="ortz" name="ort" />
<field column="ot1" name="ort" />
<field column="ot2" name="ort" />
<field column="ort" name="ort_res" />
<field column="stn" name="stn" />
<field column="stn" name="stn_res" />
<field column="ags2" name="ags2" />
<field column="ags3" name="ags3" />
<field column="ags5" name="ags5" />
<field column="ags8" name="ags8" />
<field column="ags11" name="ags11" />
<field column="ags20" name="ags20" />
<field column="ags22" name="ags22" />
<field column="pt" name="coord" />
<field column="hnr_min" name="hnr_min" />
<field column="hnr_max" name="hnr_max" />
</entity>
As you can see there are 4 columns from the DB (ort, ortz, ot1, ot2) going into one field (ort). Most of the times only one of the columns is populated at all, in which case the document is indexed normally. But when there are actually multiple entries the indexing of the document fails. The field is defined this way:
<field name="ort" type="text_de" uninvertible="true" indexed="true" required="true" stored="true"/>
DataImporthandler maps the result view of the query to a schema view and hence I don't think that you will be able to map multiple columns to one field. Instead you can assign each column to a new Solr field and then do a copy of them in your schema.
eg
<field name="ort" type="string" />
<field name="ortz" type="string" />
<field name="ot1" type="string" />
<field name="ot2" type="string" />
<field name="ortCombined" type="string" multiValued="true"/>
<copyField source="ort" dest="ortCombined" />
<copyField source="ortz" dest="ortCombined" />
<copyField source="ot1" dest="ortCombined" />
<copyField source="ot2" dest="ortCombined" />
Hope this helps !
you do it this way:
you concatenate all values into a single value in the Select:
select ...,ort||','||ortz||','||or1||','||ort2 AS ort_all FROM variablen2018.ags22_tmp_solr
and then split it into individual values when indexing into solr (this is done with RegexTransformer/splitBy)
< entity name="address" transformer="RegexTransformer"
...
< field column="ort_all" name="ort" splitBy=","/>
Note: inserted a space after < or the text does not show up here...
To watch out:
handle possible nulls, check concat_ws etc
handle possible , inside ort values (use another separator or replace , etc)

How to restrict/disable the form view, while click tree view of one2many field in Odoo

How to restrict/disable the form view, while click the tree view of one2many field in Odoo.
Use style:
<field name="your_o2m" style="pointer-events:none;" />
Try this on your field XML definition :
<field name="your_o2m" mode="tree" />
I think that no_open attribute set on the <tree> might work
<field name="o2m_field" widget="one2many" mode="tree">
<tree no_open="1">
<field name="name"/>
</tree>
</field>

Odoo - Change specific column color in one2many tree view

I am using odoo 10. I have a customer view and in that customer form view i am also showing all order that are associated with that specific customer in one2many tree view (editable).
What i want to do is i want to show a button in one2many tree view but i want to change that button's color only based on condition.
Here is what i tried but its not working.
<record id="amgl.customer_form" model="ir.ui.view">
<field name="name">Customer</field>
<field name="model">amgl.customer</field>
<field name="arch" type="xml">
<form string="Create New Customer" duplicate="0">
<sheet>
<group colspan="4">
<group>
<field name="is_admin" invisible="1"/>
<field name="is_custodian" invisible="1"/>
<field name="is_vault" invisible="1"/>
<field name="is_o2m" invisible="1"/>
<field name="is_goldstar" invisible="1"/>
<field name="custodian_edit" invisible="1"/>
<field name="first_name"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="last_name"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="account_number"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="gst_account_number" string="GoldStar Account Number"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)], 'invisible':[('is_goldstar','=',False)]}"/>
</group>
<group>
<field name="date_opened"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="account_type"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="custodian_id" options='{"no_open": True}'
attrs="{'readonly':[('is_admin','=', False)]}"/>
<field name="customer_notes"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
</group>
</group>
<notebook>
<!--CURRENT INVENTORY-->
<page string="CURRENT INVENTORY">
<field name="customer_order_lines2"
attrs="{'readonly':['|',('is_custodian','=', True),('is_o2m','=', False)]}"
context="{'default_is_deposit_related': True,'group_by':'products'}"
groups="amgl.group_amark_admins,amgl.group_amark_vault,amgl.group_amark_custodian,amgl.group_amark_sub_admins"
domain="[('state','=','completed')]" default_order='state desc'
widget="one2many_list">
<h4 style="float:right;">
<field name="total_received_quantity"/>
</h4>
<tree open="false" editable="bottom"
groups="amgl.group_amark_admins,amgl.group_amark_vault,amgl.group_amark_custodian,amgl.group_amark_sub_admins">
<field name="is_deposit_related" invisible="1"/>
<field name="is_vault_edit" invisible="1"/>
<field name="is_admin" invisible="1"/>
<field style="color:red !important;" name="products" attrs="{'readonly':[('is_vault_edit','=', True)]}"/>
<field name="commodity"/>
<field name="total_received_quantity"
attrs="{'readonly':[('is_vault_edit','=', True)]}" class="oe_edit_only"
col_border="1" string="Received"/>
<field name="temp_received_weight" class="oe_edit_only" col_border="1"/>
<field name="date_received" attrs="{'readonly':[('is_vault_edit','=', True)]}"
class="oe_edit_only" col_border="1"/>
<field name="state" invisible="1"/>
<field name="notes_boolean" invisible="1"/>
<button attrs="{'invisible':[('notes_boolean','=', False)]}" type="object" name="add_notes" class="btn btn-primary btn-sm o_list_button_add">
<i class="fa-lg fa-pencil-square"></i>
</button>
<button attrs="{'invisible':[('notes_boolean','=', True)]}" type="object" name="add_notes" class="btn btn-default">
<i class="fa-lg fa-pencil-square"></i>
</button>
<!--<button colors="red: notes_boolean is True" name="add_notes" type="object"-->
<!--string="Add Notes" icon="fa-lg fa-pencil-square" class="btn btn-primary btn-sm o_list_button_addhlight"/>-->
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
What you are doing is the right solution you cannot change attributes of button using attrs
so you need to create two button with the same name and label and show or hide one of them
based on condition.
but this code will not work on tree because Odoo will not take your class attribute or style attribute
in consideration no matter what you put there if you inspect the button element in your browser you will find that
the two buttons are the same and the classes are the same and your classes are not there and there is no style attribute.
I don't know why Odoo developer decided to do so.
I needed something like this before what I did is to add css in backend_assets that select a button in tree
view with data-field attribute equal the name of the method because that attribute will not change in translation.
/* make button color red in temporary exit tree view.*/
.openerp .oe_list_content [data-field='cancel_entry'] button{
background-color: red !important;
color: white !important;
}
you will notice that only this attribute change in the buttons that are in the tree view.
so if you want to do something like this you need to to create two method
#api.multi
def add_notes_red(self): # i added _red to make sure no one else will name he's method like this
pass
#api.multi
def add_notes_green(self):
return self.add_notes_red() # because it does the same thing just call the orignal method
And in your custom css file
/* make button color red.*/
.openerp .oe_list_content [data-field='add_notes_red'] button{
background-color: red !important;
color: white !important;
}
/* make button color green.*/
.openerp .oe_list_content [data-field='add_notes_green'] button{
background-color: green !important;
color: white !important;
}
Note: Don't forget to css file in backend_assets template.

Odoo 10 - Qweb PDF report header_spacing and margin_top properties

I am defining my own report.paperformat. I am trying differnet configurations for margin_top and header_space but I can not manage to undersand what does each parameter.
When a given value is used inmargin_top and header_space, which are the units being used by wlkhtmltopdf?
What are exactly each value?
A value of 15 in margin_top and a value of 5 is used in header_line, what does that mean?
Please see below image.
if you increase the Header spacing you also need to adjust the top margin as well. above image was using
Top Margin (mm) = 40.00
Header Spacing = 35.00
hope this helps to understand Top Margin and Header Spacing parameter!
For more add this to your report.
<record id="paperformat_sales" model="report.paperformat">
<field name="name">A4 Sale Order</field>
<field name="default" eval="True" />
<field name="format">A4</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<field name="orientation">Portrait</field>
<field name="margin_top">8</field>
<field name="margin_bottom">0</field>
<field name="margin_left">3</field>
<field name="margin_right">0</field>
<field name="header_line" eval="False" />
<field name="header_spacing">5</field>
<field name="dpi">90</field>
</record>
<record id="action_sale_order" model="ir.actions.report.xml">
<field name="paperformat_id" ref="your_module_name.paperformat_sales"/>
</record>

Odoo v9 edit record with view_type=tree

I have to show the records of a custom module in a tree view (not list)
<field name="view_type">tree</field>
Instead of
<field name="view_type">form</field>
However, I would also like to be able to go to the records' corresponding forms when I click on them. Based on what I read, it's not possible, at least not by default. Is there any workaround to 'fix' it?
Here is my code:
<!-- Estrutura de Redes -->
<record id="edit_estrutura" model="ir.ui.view">
<field name="name">gestao.rede.estrutura.form</field>
<field name="model">gestao.rede.estrutura</field>
<field name="arch" type="xml">
<form string="Estrutura da Rede">
<header>
<!--<button name="" string="Desabilitar" type="object" states="habilitado"/>-->
<!--<button name="" string="Habilitar" type="object" states="desabilitado"/>-->
</header>
<sheet string="Estrutura da Rede">
<div class="oe_nome">
<label for="razao_social" class="oe_edit_only" string="Nome"/>
<h1>
<field name="name" string="Nome:"/>
</h1>
<label string="Pasta Acima:"/>
<field name="parent_id" options="{'no_create': True}"/>
<label string="Variável:"/>
<field name="variavel"/>
<label string="Pastas Abaixo:" class="oe_read_only"/>
<field name="pastas_filho" options="{'no_create': True}" class="oe_read_only"/>
</div>
</sheet>
</form>
</field>
</record>
<record id="view_estrutura_tree" model="ir.ui.view">
<field name="name">gestao.rede.estrutura.tree</field>
<field name="model">gestao.rede.estrutura</field>
<field name="field_parent">pastas_filho</field>
<field name="arch" type="xml">
<tree string="Estrutura da Rede" delete="true" editable="bottom/top" toolbar="1">
<field name="name"/>
<field name="pastas_filho"/>
<field name="parent_id"/>
<field name="variavel"/>
</tree>
</field>
</record>
<record id="open_view_gestao_estrutura_all" model="ir.actions.act_window">
<field name="name">Estrutura da Rede</field>
<field name="res_model">gestao.rede.estrutura</field>
<field name="view_type">tree</field>
<field name="domain">[]</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_estrutura_tree"/>
</record>
<menuitem action="open_view_gestao_estrutura_all" id="menu_action_estrutura" parent="menu_gestao_redes" sequence="20"/>
Thanks!
Editable Tree View
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
Example:
<tree editable="bottom/top">
<field name="xyz"/>
</tree>
Try this
<tree editable="bottom">
Add your fields
</tree>

Resources