|
There are set of embedded functions defined for user convenience. These represent generic functionality that is commonly used for creating reports. Listing of these functions is not to be considered as complete, we may introduce more functions over time. Do not hesitate to ask, if you want some function to appear among them. All requests will be treated as a wish-list, and if the requested function will appear as commonly required item we will gladly include it in the embedded function list. You may place your motivated request on launchpad project bugs/blueprints sections. You can use our dedicated forum, if you are not familiar with launchpad. Reports with attached source code will receive somehow better attention, so may be implemented more sooner. You may vote for functionality by donating funds to this project and naming the functionality you would like to be implemented.
For better reference we decided to split listing of functions by domains. Language related functions SetLang  Where: language – language code; Description: This function changes default language used on template. It may affect other functions if specific language for them has not been set. Default language is effecive till the end of the report or next occurrence of setLang. You may want to use setLang function, to override default language used, for example, when you print invoice for the customer. Example:  In this code snippet we take language from the partner of particular invoice or default to English if no language has been set. gettext  Where: text_to_translate – text to be translated; Description: Similar to gettext function, is being used to create multi language reports. This function has alias - an underscore. Example:  currency_to_text  Where: amount – sum of money to express in words; currency – code of the currency. This is optional parameter. If not set, defaults to a currency of the company; language – language code. This is optional parameter. If not set, defaults to the language of the report. Description: Provides functionality for expressing sum of money in words, which is commonly required on reports. Currently supports three languages – English (“en_US”), Latvian (“lv_LV”) and Russian (“ru_RU”). Currently function is able to work with three currencies – EUR, USD and LVL. Boundaries of amount of currency - 0 to 999999999999.99. Example:  getLang  Description: Returns current default language for template. Mathematical functions sum  Where: list_of_objects – list of objects that have field to sum; field_name – name of the numeric field to sum, expressed as string; Description: Returns sum of named field from all objects in a list. sumif  Where: list_of_objects – list of objects that have field to sum; field_name – name of the numeric field to sum, expressed as string; condition – condition on which objects should be selected, expressed as string; Description: Returns sum of named field from conditionally selected objects in a list. Statistical functions average  Where: list_of_objects – list of objects that have field; field_name – name of the numeric field, expressed as string; Description: Returns the average (arithmetic mean) of fields from all objects in a list. count  Where: list_of_objects – list of objects to count; Description: Returns total count of objects in a list. count_blank  Where: list_of_objects – list of objects that have field; field_name – name of the field to check for emptiness; Description: Returns total count of objects in a list, where named field is empty. countif  Where: list_of_objects – list of objects that have field; condition – condition on which objects should be selected, expressed as string; Description: Returns count of objects from a list, where fields meet condition. large  Where: list_of_objects – list of objects that have field; field_name – name of the numeric field to evaluate, expressed as string; k – which value to return; Description: Returns k-th largest numeric value in a list of objects. max  Where: list_of_objects – list of objects that have field; field_name – name of the numeric field to evaluate, expressed as string; Description: Returns largest numeric value in a list of objects. min  Where: list_of_objects – list of objects that have field; field_name – name of the numeric field to evaluate, expressed as string; Description: Returns smallest numeric value in a list of objects. small  Where: list_of_objects – list of objects that have field; field_name – name of the numeric field to evaluate, expressed as string; k – which value to return; Description: Returns k-th smallest numeric value in a list of objects. Time related functions dec_to_time  Where: time_amount – amount of time in numeric representation; hour_fmt – format for hours, as string; min_fmt – format for minutes, as string; Description: Converts time, supplied in numeric representation, to time in hour:min string representation. For example, “1.5” can be expressed as “1 h 30 min” or “1:30”. Example:  This example will return string - “7 h 15 min”. Barcode related functions Barcode  Where: Description: Helper functions asarray  Where: list_of_objects – list of OpenObject objects; field_name – name of the field which should be returned as list; Description: Returns named field from all objects as a list. asimage  Where: image – image content; rotate – rotation aspect in degrees; Description: Returns binary field as image. This function is required to place image from OpenObject binary field or attachment to a template. Example:  Expression in this example takes image from attachment of first object and places it on a document. debugit  Where: object – object which value you want to print to console. Description: Helps debugging templates. Run the server from command line and call 'debugit' from the template to inspect variables. get_attachments  Where: object – OpenObject object from which attachment(s) should be extracted. index - ; name - ; Description: Returns attachment(s) from an object. When no index or name is get_label  Where: object – OpenObject object which has named field. field_name – name of the field, as string, which label to retrieve. Description: Returns human readable name for the field, which is usually displayed on forms or tree views as a label for widget. Current default language is effective on output. Please see setLang() function. Example:  For report on partners, this will return “Total Payable”. get_name  Where: object – OpenObject object which string representation to be returned. Description: Returns string representation for object as it would appear on form in many2one relation. This output from OpenObject name_get function. Current default language is effective on output. Please see setLang() function. get_selection_item  Where: object – OpenObject object which has named selection field. field_name – name of the selection type field, as string. Description: Returns human readable name which would be displayed on form for selection field item instead of it's code. Current default language is effective on output. Please see setLang() function. safe  Where: expression – expression to evaluate, as string. object – object which provides data for expression. Description: Tries to safely evaluate expression. If an exception occurs, empty string will be returned. If expression evaluates without problems it's result will be returned. |