Odoo 10 - Qweb - Testing boolean field for false - odoo-10

This question deals with testing a specific field to conditionally display information in a qweb view.
The example uses default_code from product.template.
What shall be done to test if sale_ok is false?

To check the boolean field is false you can use below condition
<t t-if="!record.sale_ok.raw_value">

Related

SRRS how to check if there is a certain value in dataset

I am trying to make a new ssrs report:
There is a details group that prints lines from datasource detailsDS.
I also want to make a textbox in the footer(or anywhere, doesn't matter) where if there was any(or more than one) line in detailDS with value that equals "Red" that textbox should be set invisible.
I already tried:
iif(first(Fields!Color.Value, "detailsDS") = "Red", True, false)
of course this doesn't work because it only searches for first record and textbox is out of scope of details.
Is it possible to solve this in report layer?
EDIT:
Seems like lookup function is not supported for ms dynamics.
As B.Seberie noted, you could use the lookup function.
=IIF(Lookup("Red", Fields!Color.Value, Fields!Color.Value, "detailsDS") = "Red", True, False)
You would want to use your static value of "Red" for the first argument. This is the value that will be searched for.
The second argument is for the field in the dataset that you want to check for the first argument's (Arg1) value.
The third argument (Arg3) is the field to return when it finds Arg1 in Arg2 - in this case you can just use the same color field. If the color is found, it will be TRUE otherwise it will be FALSE.

Salesforce Opportunity Validation Rule

I am working on a validation rule on the Opportunity object. The goal is to bypass a validation rule if an item from a Multi-Select picklist is selected, otherwise the code should fire
Here's what I have so far - everything works except the exception portion - NOT(CONTAINS('Campaign_Tactic__c','Call Monitoring')))
So the validation rule should fire unless the Call Monitoring multi-select is chosen.
The Validation Rule should prevent an Opportunity Save if:
Opportunity Record Type = True
Opportunity Stage = Closed Won or Proposal Request
Landing Page Setup Field = blank/no data
Campaign Tactic Multi-Select field = does not contain the Call Monitoring Option
AND (
RecordType.DeveloperName = "New_Opportunity",
OR (
ISPICKVAL(StageName, "Closed Won"),
ISPICKVAL(StageName, "Proposal Request")
),
AND (
ISBLANK(TEXT(Landing_Page_Setup__c))
),
(!CONTAINS('Campaign_Tactic__c','Call Monitoring'))
)
From the Salesforce Formula Function Reference, it's important to note
The CONTAINS function does not support multi-select picklists. Use INCLUDES to see if a multi-select picklist has a specific value.
Additionally, the first argument you're providing to CONTAINS() is a quoted string literal, not a field reference, and the outer parentheses are extraneous:
(!CONTAINS('Campaign_Tactic__c','Call Monitoring'))
Your final clause should use INCLUDES(), as:
!INCLUDES(Campaign_Tactic__c, 'Call Monitoring')
Note also that AND() with a single argument can be replaced by the argument alone, so
AND (
ISBLANK(TEXT(Landing_Page_Setup__c))
),
reduces to
ISBLANK(TEXT(Landing_Page_Setup__c)),
You need the TEXT() call only if that field is a picklist.

How to set in Report the TextBox visibility by expression in VisualStudio?

I have a simple TextBox in my Precision Design related to a Field in Temporary Table.
I need to show this TextBox only If the it value under Temporary Table is pupulated : so if the value field is pupulated (is a string) I show the Text Box , otherwise I don't show the text Box.
I need to set Visibility by Expression :
Which is the best way forward over ?
Thanks!
You can use iif function. Press fx button, here you can writte your code.
iif function evaluate a condition and return 1 of 2 options, for example, in your case you need show one value only if exist.
check this code:
=iif(fields!YourFieldName.value = "", true, false)
if your field is a number
=iif(fields!YourFieldName.value = 0, true, false)
This code evaluate the value of your field and only populate the value if is complete.

XPath: Default to "Master" node, select current node if specified (in third node)

My problem:
I need to select the value in the "Master_Node" only if the "Sub_Node_Checker" is set to "false".
If "Sub_Node_Checker" is set to "true" then the value must be set to "Sub_Node".
Current node is "Sub_Node"
I am using InfoPath 2010.
Here is my sample XML:
<my:myFields xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-07-02T14:58:05" xml:lang="en-us">
<my:Master_Node>123456</my:Master_Node>
<my:Repeater>
<my:Sub_Node_Checker>false</my:Sub_Node_Checker>
<my:Sub_Node></my:Sub_Node>
</my:Repeater>
</my:myFields>
Refer to the following forum thread to download my XSN template.
Here is the XPath that I have been attempting to use, to no avail (line breaks added for legibility):
//my:Master_Node[../my:Sub_Node_Checker = "false"]
|
../my:Sub_Node[../my:Sub_Node_Checker = "true"]
This does not seem to return anything whatsoever, and I'm not sure why.
The following question accompanies "Sub_Node_Checker" in my XML form: "Does the sub node differ from the master node?"
If the user selects "Yes" (true) then the Sub_Node field should be set to its own value.
If the user selects "No" (false) then the Sub_Node field should default to the Master_Node.
Edit & Additional XML
My Repeater section repeats (as per the name) and seems to cause additional chaos with the XPath selectors.
<my:myFields xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-07-02T14:58:05" xml:lang="en-us">
<my:Master_Node>123123</my:Master_Node>
<my:Repeater>
<my:Sub_Node_Checker>false</my:Sub_Node_Checker>
<my:Sub_Node></my:Sub_Node>
</my:Repeater>
<my:Repeater>
<my:Sub_Node_Checker>false</my:Sub_Node_Checker>
<my:Sub_Node></my:Sub_Node>
</my:Repeater>
</my:myFields>
A much cleaner solution would be to move the predicate to the <my:myFields/> element.
/my:myFields[my:Repeater/my:Sub_Node_Checker = "false"]/my:Master_Node
If you insist on your approach, you're missing a / to jump over the <my:Repeater/> element or reference that:
//my:Master_Node[..//my:Sub_Node_Checker = "false"]
//my:Master_Node[../my:Repeater/my:Sub_Node_Checker = "false"]
Relating to your xpath question you may try something like this.
(self::*[../my:Sub_Node_Checker = "true"]
|
//my:Master_Node)[last()]
Which should work if Master_Node is always before Sub_Node (in document order).
Ok, I got this one worked out a bit differently than my original approach. The following article on MSDN has an example of using the substring() function to return different values based on outside conditions. Also have to thank Hilary Stoupa at InfoPath Dev for helping me come to the solution.
I will also mention that I could not use the "current" node and had to create a third node which housed my XPath expression and evaluated the conditions to return the appropriate value.
Here is the source XML roughly as InfoPath might interpret it (note the "location" of the xpath expression in the 3rd repeater group - this is how InfoPath evaluates default values):
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-07-02T14:58:05" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
<my:Master_Node>123456</my:Master_Node>
<my:Repeater>
<my:Sub_Node_Checker>true</my:Sub_Node_Checker>
<my:Sub_Node>9870</my:Sub_Node>
<my:Sub_Node_Stored>9870</my:Sub_Node_Stored>
</my:Repeater>
<my:Repeater>
<my:Sub_Node_Checker>false</my:Sub_Node_Checker>
<my:Sub_Node></my:Sub_Node>
<my:Sub_Node_Stored>123456</my:Sub_Node_Stored>
</my:Repeater><
my:Repeater>
<my:Sub_Node_Checker>false</my:Sub_Node_Checker>
<my:Sub_Node></my:Sub_Node>
<my:Sub_Node_Stored>concat(substring(../../my:Master_Node, 1, (../my:Sub_Node_Checker != "true") * string-length(../../my:Master_Node)), substring(../my:Sub_Node, 1, (../my:Sub_Node_Checker != "false") * string-length(../my:Sub_Node)))</my:Sub_Node_Stored>
</my:Repeater>
</my:myFields>
Note that the following XPath expression was instrumental in causing the appropriate node to be selected:
concat(substring(../../my:Master_Node, 1, (../my:Sub_Node_Checker != "true") * string-length(../../my:Master_Node)), substring(../my:Sub_Node, 1, (../my:Sub_Node_Checker != "false") * string-length(../my:Sub_Node)))
The substring function returns the number of characters from the target string as specified by the user. When a boolean value is evaluated inside the substring function (at the location given for number of characters to return) it returns either a "1" or a "0".
When multiplied by the length of the target string this boolean check causes any conditions that would exempt a particular target node from selection to return a length of "0" characters from that node. (0*X=0) This effectively allows for different default values within the node without the use of the | operator.

Validation of phone numbers containing '+' and '-' characters

In CodeIgniter, how do i validate phone numbers containing '+' and '-' symbols?
You cannot enter a number with "-" since you defined integer as the validation rule. Therefore, the validation will fail. You need to work with RegEx so that you can create more complex validation. See the topic on validations in the CI manual for more info.
Your validation rule:
$this->form_validation->set_rules('foo', 'Number', 'callback_number_validation');
Note how the keyword callback_ is used to identify CI your function for validation.
Your callback function:
//$str will be the value you want to verify
function number_validation($str) {
return preg_match("your_regex", $str) ? true: false;
}

Resources