odoo (V11) add a new search button to control panel view - html

I want to add a new search button to the odoo control panel view. I am using odoo V11 and the screenshot of the view is pasted here so you can understand what I am talking about. I want to add this button next to the search box indicated as a black circle in the image. The new search box will provide Spatial data search function. That is why I want to create a new search button instead of using the existing search options.
Thanks
odoo control panel view

I would not complicate myself adding that button, just use the existing search box to enter the data to search and add a new option "Spatial data" to the menu shown when you enter text. That is added with xml, similar to this example taken from the bank views:
<field name="arch" type="xml">
<search string="Bank Accounts">
<field name="bank_name" filter_domain="['|', ('bank_name','ilike',self), ('acc_number','ilike',self)]" string="Bank Name"/>
<field name="company_id" invisible="context.get('company_hide', True)"/>
<field name="partner_id"/>
</search>
</field>
You may also need to do some coding in the .py files if it is not enough with just the domain filter, in that case override the name_search method of the model. You have many examples of that in the Odoo code itself.

Related

Disable Popup Form Many2many field in Odoo

How to disable the popup adding form when adding a new line in many2many field tree view? Everytime I add a line, it always open a popup form, I just want to add a line directly in tree view only.
I've tried editable="bottom" and editable="top" in tree view but it's not working for me.
You can try with following option:
widget="many2many_tags"
For example:
<field name="many2many_field_name"
widget="many2many_tags"
options="{'color_field': 'color', 'no_create_edit': True}"
placeholder="XYZ..."/>
EDIT
For the tree view:
widget="one2many_list"

Can we use widget="guage" in form view in odoo 10.0 and in master branch?

I want to make gauge view in form view of wizard can i use same structure as we use in kanban view? and yes then how?
You can use it like the following in Kanban view
<div class="o_assignation_leads_count">
<field name="maximum_user_leads" invisible="1"/>
<field name="leads_count" widget="gauge" options="{'max_field': 'maximum_user_leads'}"/>
</div>

Office Ribbon Control SizeString

Im trying to create a custom ribbon for ms access, and everything works fine, but when i try to increase the combo box with the SizeString attribute, the ribbon does not display at all, any help please.
<comboBox id="cmbClient" label="Clients List" screentip="Select Client" supertip=" " onChange="OnChangeCombobox" getVisible="GetVisible" getEnabled="GetEnabled"
getItemCount="PIGetItemCount"
getItemLabel="PIGetItemLabel"
getItemID="PIGetItemID"
SizeString="xxxxxxxxxxxxxxxxxxxxx"
tag="RibbonName:=YCClientForm;inMenu:=;CustomTagValue1:=Client;CustomTagValue2:=;CustomTagValue3:=;DefaultValue:=;CustomPicture:=;CustomPicturePath:=">
</comboBox>
xml attributes are case sensitive; use sizeString

Work Item HTMLFieldControl Content

I am trying to pre-populate some a few different objects in a User Story in my TFS2012 work items list. The HTMLFieldControl is can be found in the Work Item Types section and I can see that it's created here:
<Tab Label="Details">
<Control FieldName="System.Description" Type="HtmlFieldControl" Dock="Fill" />
</Tab>
I've been looking on Google but I just can't seem to find anything around adding text into this field so that it is always available, perhaps I'm just doing something wrong.
Would doing something similar to this give me the results I require? I can't really just try it and potentially break the system (which is unfortunate) so I need some guidance so that I could quickly fix any formatting / spelling without having to roll back any changes.
<Tab Label="Details">
<Control FieldName="System.Description" Type="HtmlFieldControl" Dock="Fill" >
<FIELD name="Description" refname="System.Description" type="Text" Content="Hello there"/>
</Control>
</Tab>
Obviously the above is purely made up (from the FIELD section) but I included here just along the lines of what I was thinking and hopefully to show what I'm trying to do.
You were looking in the wrong place; those are the definitions for the form (aka, how the Work Item is displayed graphically). You need to scroll up to the top, under FIELDS, and find this:
<FIELD name="Description" refname="System.Description" type="HTML" />
...then change it to this:
<FIELD name="Description" refname="System.Description" type="HTML">
<DEFAULT from="value" value="Hello there" />
</FIELD>

Disable System Ribbon in CRM 2011

I would like to conditionally disable a System Ribbon = AddNew in a CRM 2011 form with javascript. That means if the statusCode is X or Y disable the Ribbon, how could I do this?
I tryed to get the ID of the Ribbon in order to change the classname of the Ribbon to disabled, but I got Null because the Ribbons are loaded asychronously!
To expand on Anwar's answer, the key to getting this to work is to intercept and repurpose the functionality of the AddNew ribbon button, but once you do, there won't be any need for hacking the Ribbon DOM. Below are a few steps that you can take to get there.
1) Create a solution with the Application Ribbon included.
2) Find in the SDK the sample ribbon for the Application Ribbon or build it yourself using the solution included in the SDK.
\sdk\resources\exportedribbonxml
\sdk\samplecode\cs\client\ribbon\exportribbonxml\exportedribbonxml
3) Find in the Application Ribbon template the control you're interested in, which I assume in this case is the AddNew button in entity subgrids. Repurpose this control in a CustomAction and make the location of the CustomAction the same name as the control you want to repurpose.
<CustomAction Id="YourOrg.SubGrid.{!EntityLogicalName}.AddNewStandard"
Location="Mscrm.SubGrid.{!EntityLogicalName}.AddNewStandard">
<CommandUIDefinition>
<Button Id="Mscrm.SubGrid.{!EntityLogicalName}.AddNewStandard"
Command="Mscrm.AddNewRecordFromSubGridStandard" Sequence="20"
LabelText="$Resources(EntityDisplayName):Ribbon.SubGrid.AddNew"
Alt="$Resources(EntityDisplayName):Ribbon.SubGrid.AddNew"
Image16by16="/_imgs/ribbon/NewRecord_16.png"
Image32by32="/_imgs/ribbon/newrecord32.png" TemplateAlias="o1"
ToolTipTitle="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipTitle"
ToolTipDescription="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipDescription" />
</CommandUIDefinition>
</CustomAction>
4) Find in the Application Ribbon template the definition of the command of this button, and using the exact definition as the basis of a new CommandDefinition, add in your own custom rule (in this case, a new EnableRule).
<CommandDefinition Id="Mscrm.AddNewRecordFromSubGridStandard">
<EnableRules>
<EnableRule Id="Mscrm.AppendToPrimary" />
<EnableRule Id="Mscrm.EntityFormIsEnabled" />
<EnableRule Id="YourOrg.DisableNewStuff" /> <!--your custom rule-->
</EnableRules>
<DisplayRules>
<DisplayRule Id="Mscrm.ShowForOneToManyGrids" />
<DisplayRule Id="Mscrm.AppendToPrimary" />
<DisplayRule Id="Mscrm.CreateSelectedEntityPermission" />
<DisplayRule Id="Mscrm.AppendSelected" />
<DisplayRule Id="Mscrm.HideAddNewForChildEntities" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.addNewFromSubGridStandard"
Library="/_static/_common/scripts/RibbonActions.js">
<CrmParameter Value="SelectedEntityTypeCode" />
<CrmParameter Value="PrimaryEntityTypeCode" />
<CrmParameter Value="FirstPrimaryItemId" />
<CrmParameter Value="PrimaryControl" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
5) Here is where Anwar's answer comes in: using both the OrRule and the ValueRule, define your EnableRule to check on the statuscodes of the entity. The linked demonstration relates to a new ribbon button, but the same rules work for repurposed ribbon controls as well.
Publish your changes when you're done and your ribbon should be all set. Because I'm not sure how familiar you are with RibbonXml, I'll also mention that Microsoft has some comprehensive walkthroughs that are pretty helpful (after much time studying them!) in picking it up.
This article explains exactly what your are looking for.
Please follow this link
How To Use "ValueRule" and "OrRule" in Ribbon Customizations - CRM 2011
This is how i hide the delete button on invoice form, based on status code, onload of the form:
var statusVal = Xrm.Page.getAttribute("statuscode").getValue();
if (statusVal==4 || statusVal==6) {
//Disable delete button
var x =top.document.getElementById("invoice|NoRelationship|Form|Mscrm.Form.invoice.Delete-Medium");
x.style.display='none';
You can get the id of the element span, which you want to hide from the source of the page.