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
Related
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"/>
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?
how can i pre load records from data by default_get method.
i have data file with this kind of records data/project_data.xml
<record id="project_document_type_gal" model="project.part.template">
<field name="code">ŪK</field>
<field name="sequence">49</field>
<field name="group_id" ref="project_custom.project_document_kv"/>
<field name="description">UK (UK)</field>
</record>
<record id="project_document_type_sem" model="project.part.template">
<field name="code">SEM</field>
<field name="sequence">50</field>
<field name="group_id" ref="project_custom.project_document_kv"/>
<field name="description">SEM (SEM)</field>
</record>
class ProjectPartTemplate(models.Model):
_name = 'project.part.template'
_inherit = 'project.object'
class ProjectObject(models.AbstractModel):
_name = 'project.object'
_rec_name = 'code'
sequence = fields.Integer('Sequence')
code = fields.Char('Code', required=True)
description = fields.Char(required=True)
project_default_stage = fields.Boolean(
'Default for new projects',
help='Will be used for new projects', default=True)
and wizard.
class ProjectPartWizard(models.TransientModel):
_name = 'project.part.wizard'
_description = 'Part wizard'
part_ids = fields.Many2many('project.part')
#api.model
def default_get(self, fields_list):
result = super(ProjectPartWizard, self).default_get(fields_list)
part_ids = []
if self._context.get('active_model') == 'project.project':
project = self.env['project.project'].browse(
self._context.get('active_id'))
project and part_ids.extend(project.project_part_ids.ids)
# TODO load all part from template
result.update(part_ids=[(6, 0, part_ids)])
return result
UPDATE
<xpath expr="//field[#name='task_count']/.." position="before">
<button string="Generate Parts" class="oe_stat_button"
name="%(project_part_wizard_action)d"
type="action" icon="fa-th">
</button>
</xpath>
here is button
so there is a templates and i need to that all templates would be in wizard pre-loaded when i open it. how can i do it with default_get
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"/>
I have an xml like this
<?xml version="1.0" encoding="utf-8"?>
<content>
<field title="Year">
<description>Numeric data</description>
<comment>1234</comment>
</field>
<field title="mail">
<description>Numeric data</description>
<comment>ABCD</comment>
</field>
<field title="Year">
<description>AlphNumeric Data</description>
<comment>ABCD1234</comment>
</field>
</content>
i tried below linq query to extract data based on the title attribute.
var Data = XDocument.Load(Xmlpath).Root
.Descendants("field")
.Where(element => element.Attribute("title").Value.Contains("Year"))
.Descendants()
.Where(element => element.Name == "description" || element.Name == "comment")
.Select(element => new { element.Name, element.Value }).ToList();
for eg i want to show all datas that comes under title "year", the output should be displayed into a datatable like this
Description Comment
numeric data 1234
Alphanumeric Data ABCD1234
But i dont know how to convert var data to datatable or iterarte though var data .Can somebody help me? is it possible to display the result from linq query by modifying the query itself?
DataTable's have a method (ReadXml) that reads XML. Have you tried using that?