SOLR sort is not working - sorting

Adding sort criteria to SOLR query. First to sort by department_sortable and then by productname_sortable. Does get sorted by department_sortable but not by productname_sortable.
private List<SortField> getSortParameters() {
List<SortField> sortFields = new ArrayList<SortField>();
sortFields.add(generateSortField("department_sortable", SortDirection.ASC));
sortFields.add(generateSortField("productname_sortable", SortDirection.ASC));
return sortFields;
}
<field name="productname_sortable" type="text" indexed="true" stored="false" />
<field name="department_sortable" type="string" indexed="true" stored="false" multiValued="false"/>
<copyField source="productname" dest="productname_sortable"/>
<copyField source="department" dest="department_sortable"/>

I think, there is only one sort field is set to solrQuery. You can add multiple sort fields by using SolrQuery#addSortFieldMethod
solrQuery.addSortField( "department_sortable", org.apache.solr.client.solrj.SolrQuery.ORDER.asc );
solrQuery.addSortField( "productname_sortable",org.apache.solr.client.solrj.SolrQuery.ORDER.asc );
or
solrQuery.addOrUpdateSort( "department_sortable", org.apache.solr.client.solrj.SolrQuery.ORDER.asc );
Related post Sorting solr search results using multiple fields (solrj)

try
`solrQuery.setSort(new SortClause("department_sortable", "asc"));
solrQuery.setSort(new SortClause("productname_sortable", "asc"));`
or
`solrQuery.setSort(new SortClause("department_sortable", "asc"));
solrQuery.addSortField(new SortClause("productname_sortable", "asc"));`
or
solrQuery.setSort(new SortClause("department_sortable", "asc"));
solrQuery.addSortField("productname_sortable", "asc");

Related

Add total label to tree footer odoo 12

I need to add a Total label on the last row from a tree, the last row is for sum values, how can I edit a tree footer?
view.xml
<xpath expr="//field[#name='field_list']/tree/field[#name='name']" position="after">
<field name="field1" sum="Total Field 1"/>
<field name="field2" sum="Total Field 2"/>
<field name="field3" sum="Total Field 3"/>
</xpath>
screenshot
Is there a way to edit the tree footer?
The list footer is used to show aggregates (sum, avg), it is rendered in _renderFooter of the ListRenderer.
The method docstring:
/**
* Render the footer. It is a <tfoot> with a single row, containing all
* aggregates, if applicable.
*
* #private
* #returns {jQueryElement} a <tfoot> element
*/
The method that computes aggregates will check for the field type, the computation will be ignored if the field type is not one of the following integer, float or monetary.
You can alter the _renderFooter to be able to provide a static text to display in the footer using a field attribute.
Example:
var ListRenderer = require("web.ListRenderer");
ListRenderer.include({
_renderFooter: function () {
var res = this._super();
_.each(this.columns, function (column) {
if(!('aggregate' in column) && column.attrs.text) {
res.find('.'+column.attrs.name).text(column.attrs.text);
}
});
return res;
},
});
To add the above code, check the Assets Management documentation.
To display the text in the footer of the corresponding column, set the text attribute in the field tag ( if the field contain an aggregate, the text will be ignored).
<field name="total" text="Total"/>

Odoo duplicate many2many fields

A model [m] with a many2many field [m2m]
Field [m2m] have attribute [copy=False]
A form view [v] display the [m] and the field [m2m] with widget [many2many_tags]
I have tested that the python object did return a with False on field [m2m]
but the javascript, keep render the tags on web.
model.py
class model(models.Model):
_name = "m"
m2m = fields.Many2many('sale.order', string="SO", copy=False)
XML File
<record ...>
<form>
<group>
<field name="name"/>
<field name="ref"/>
<field name="so_m2m" widget="many2many_tags" options="{'no_create_edit': True}"/>
</group>
</form>
</record>
When I duplicate the current record, the field [m2m] is keeps the old tag from old record which is not expected.
After clicking the save button, the old tag will disappear.
Try one thing here :
Whatever your third table is there, both fields used in many2many relation, from third table keep them as a copy false.
i.e.
m2m = fields.Many2many('sale.order','sale_order_another_table_rel', 'sale_order_field','antother_table_field', string="SO", copy=False)
Into new table :
_name = 'sale.order.another.table.rel'
sale_order_field_id = // copy=false
another_table_field_id = //copy = false
Hopefully work.

Odoo 8 strange behavious using new api to inherit old api model

I added two fields to stock.picking using new api:
class StockPicking(models.Model):
_inherit = "stock.picking"
address = fields.Char(related='partner_id.street', string="Address")
sector = fields.Char(related="partner_id.sector", string="Sector")
Then I added onchange method to load stock pickings in One2Many field defined using tree:
<field name="line_ids" >
<tree>
<field name="name" />
<field name="partner_id" />
<field name="address"/>
<field name="sector"/>
<field name="state" />
</tree>
</field>
I used a simple domain with search [('id', '<', '10')] then I changed line_ids value but no line was loaded in the web view.
After many times trying to find a log error with no success I changed the code from the new API to the old API:
class StockPicking(osv.osv):
_inherit = "stock.picking"
_columns = {
'address': fields.related('partner_id', 'street', type='char', relation='res.partner', string='Address'),
'sector': fields.related('partner_id', 'sector', type='many2one', relation='sector', string='Sector')
}
For a reason that I do not know It worked.
Did someone know why this did not work using the new API?

Unable to use related field in domain filter

Field declaration in odoo v8, team_manager is a new class:
class team_manager(osv.osv):
_name = "team.manager"
_columns = {
'is_manager': fields.related('manager_id', 'manager', type='boolean', relation="hr.employee", string='Managers', readonly=True, store=True)
}
The xml file code for 'Form View'
<separator string="Team Work" attrs="{'invisible':[('is_manager','=',False)]}"/>
<field name="child_line" context="{'manager_id':id}" attrs="{'invisible':[('is_manager','=',False)]}">
<tree editable="=top">
<field name="employee_id"/>...
</tree>
</field>
While opening the form I am getting the error like
Odoo Client Error
Error: Unknown field is_manager in domain [["is_manager","=",false]]
http://localhost:8069/web/static/src/js/view_form.js:1702
Can't we use related filed in domain? or Does my syntax need changes?
You need to add is_manager field to the form view.
Add the following line before child_line field:
<field name="is_manager" invisible="True"/>

SharePoint 2013 customize custom field filter

I've created a custom field in SharePoint 2013.
<FieldTypes>
<FieldType>
<Field Name="TypeName">CrossSiteLookupField</Field>
<Field Name="ParentType">Text</Field>
<Field Name="TypeDisplayName">Cross-Site Lookup Field</Field>
<Field Name="TypeShortDescription"> Cross-Site Lookup Field </Field>
<Field Name="UserCreatable">TRUE</Field>
<Field Name="ShowOnColumnTemplateCreate">TRUE</Field>
<Field Name="ShowOnListCreate">TRUE</Field>
<Field Name="ShowOnDocumentLibraryCreate">TRUE</Field>
<Field Name="ShowOnSurveyCreate">FALSE</Field>
<Field Name="ShowInFileDlg">FALSE</Field>
<Field Name="Sortable">TRUE</Field>
<Field Name="Filterable">TRUE</Field>
<Field Name="AllowBaseTypeRendering">FALSE</Field>
<Field Name="CAMLRendering">TRUE</Field>
<Field Name="AllowGridEditing">FALSE</Field>
<Field Name="FieldTypeClass">CrossSiteLookupField.CrossSiteLookupField,$SharePoint.Project.AssemblyFullName$</Field>
<Field Name="FieldEditorUserControl">/_controltemplates/15/CrossSiteLookupFieldAdminTemplate.ascx</Field>
</FieldType>
</FieldTypes>
My CrossSiteLookupField class inherits from SPFieldText. The method 'public override string GetValidatedString(object value)' returns e.g. '4;#Test' (like a SPFieldLookup). Now the filter shows '4;#Test' but I would like the have 'Test' displayed only.
The second question is: If I have a multivalue separated with '; ', I would like to have two filter rows.
The functionality should be equal to Lookup and LookupMulti.
How can I do this?
Thx
I had the same problem.
You can change the Filter.aspx page in C: \ Program Files \ Common Files \ microsoft shared \ Web Server Extensions \ 15 \ TEMPLATE \ LAYOUTS.
This page creates the option of select the filter.
Adding the javascript you can change these options.
With this code:
$(document).ready(function ()
{
var presentText;
$("select > options").each(function ()
{
var originalText = $(this).text();
if (originalText.indexOf("#") >= 0)
{
var textElement = originaltext;
if (textElement == presentText)
$(this).remove();
else {
var newText = originalText.substring(2, originalText.indexOf("#", 2));
if (newText == "")
newText = "Empty";
if (originalText.indexOf("true") >= 0)
newText += "(Validated)";
else
newText += "(not valid)";
$(this).text(newText);
}
presentText = textElement;
}
});
});
Edit the voices of the filters:
original option
to :
modified option

Resources