Validation Error in ODOO - odoo-10

How to stop raising validation error in ODOO 10
For example in project.py file I want to stop raising this validation error :
#api.constrains('date_start', 'date_end')
def _check_dates(self):
if any(self.filtered(lambda task: task.date_start and task.date_end and task.date_start > task.date_end)):
raise ValidationError(_('Error ! Task starting date must be lower than its ending date.'))

You can disable that warning by overriding the function. Try below code,
#api.constrains('date_start', 'date_end')
def _check_dates(self):
if any(self.filtered(lambda task: task.date_start and task.date_end and task.date_start > task.date_end)):
pass;
#raise ValidationError(_('Error ! Task starting date must be lower than its ending date.'))
Hope it will help you.

Related

How to raise timeout error in unittesting

This is first time i am touching ruby, so no sure about correct terminology. I have tried searching for mulitple things, but couldn't find a solution.
I have this code block
domain_response = MyDomain::Api::MyApi::Api.new(parameters: message.to_domain_object, timeout: 1000)
# :nocov:
case (response = domain_response.response)
when MyDomain::Api::MyApi::SuccessResponse
## do something
when Domain::ErrorResponses::TimeoutResponse
## do something.
now i am trying to testing TimeoutResponse, I have written(tried) this
it "when api call timesout" do
expect(MyDomain::Api::MyApi::Api).to{
receive(:new)
} raise_error(MyDomain::ErrorResponses::TimeoutResponse)
end
this gave me error that unexpected identifier.
I have also tried by not providing receive, and it gave me error that block is expected.
Whats the proper way to raise an error that i can test?
Update:
Here is where i am stuck now
it "when api call timesout" do
# 1
expect(MyDomain::Api::MyApi::Api).to(
receive(:new),
).and_return(domain_api_instance)
# 2
expect(domain_api_instance.response).to receive(:response).and_raise(Domain::ErrorResponses::TimeoutResponse)
expect(domain_api_instance.response).to eq(ApiError::Timeout)
end
But with this code i am getting this error
1) Rpc::Package::SubPackage::V1::PackageService#first_test testing when api call timesout
Failure/Error: expect(domain_api_instance.response).to receive(:response).and_raise(Domain::ErrorResponses::TimeoutResponse)
#<InstanceDouble(MyDomain::Api::MyApi::Api) (anonymous)> received unexpected message :response with (no args)

Mulesoft EC2 *describeInstances* with *filter* option

I'm having problems using the EC2 connector with filters for DescribeInstances. Specifically, I'm trying to find all instances that have the tag "classId" set.
I've also tried to find all instances that have the classId tag with specific string, e.g. "123".
Below are the XMLs of the describeInstance for both scenarios.
tag-key ------
<ec2:describe-instances doc:name="Describe instances" doc:id="ca64b7d4-99bb-4045-bbb4-16c0c27b1df5" config-ref="Amazon_EC2_Configuration">
<ec2:filters>
<ec2:filter name="tag-key" values="#[['classId']]">
</ec2:filter>
</ec2:filters>
</ec2:describe-instances>
tag:classId:----
<ec2:describe-instances doc:name="Describe instances" doc:id="ca64b7d4-99bb-4045-bbb4-16c0c27b1df5" config-ref="Amazon_EC2_Configuration">
<ec2:filters>
<ec2:filter name="tag:classId">
<ec2:values >
<ec2:value value="#['123']" />
</ec2:values>
</ec2:filter>
</ec2:filters>
</ec2:describe-instances>
Each time I receive an error like the following (for tag:classId):
ERROR 2021-03-29 08:32:49,693 [[MuleRuntime].uber.04: [ec2-play].ec2-playFlow.BLOCKING #1092a5bc] [processor: ; event: df5e2df0-908a-11eb-94b5-38f9d38da5c3] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler: 
********************************************************************************
Message        : The filter 'null' is invalid (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue; Request ID: 33e3bbfb-99ea-4382-932f-647662810c92; Proxy: null)
Element        : ec2-playFlow/processors/0 # ec2-play:ec2-play.xml:33 (Describe instances)
Element DSL      : <ec2:describe-instances doc:name="Describe instances" doc:id="ca64b7d4-99bb-4045-bbb4-16c0c27b1df5" config-ref="Amazon_EC2_Configuration">
<ec2:filters>
<ec2:filter name="tag:classId">
<ec2:values>
<ec2:value value="#['123']"></ec2:value>
</ec2:values>
</ec2:filter>
</ec2:filters>
</ec2:describe-instances>
Error type      : EC2:INVALID_PARAMETER_VALUE
FlowStack       : at ec2-playFlow(ec2-playFlow/processors/0 # ec2-play:ec2-play.xml:33 (Describe instances))
 (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
NOTE: The code works without a filter, returning all instances. But, that isn't what I want or need. The more filtering I can do the faster the response.
Does anyone have samples of the filter option working? Can you tell me what I'm doing wrong?
Thanks!
This surely is a bug. I tried the same and it was not working for me as well. I enabled debug logging and found that the connector is not sending the filter.1.Name=tag:classId as a query parameter in the request. Here is the debug log that I found. (Notice there is no filter.1.Name=tag:classId in the query string)
DEBUG 2021-04-02 21:55:17,198 [[MuleRuntime].uber.03: [test-aws-connector].test-aws-connectorFlow.BLOCKING #2dff3afe] [processor: ; event: 91a34891-93d0-11eb-af49-606dc73d31d1] org.apache.http.wire: http-outgoing-0 >> "Action=DescribeInstances&Version=2016-11-15&Filter.1.Value.1=123"
However, I tried to use the Expression or Bean Reference option and set the expression directly as [{name: 'tag:classId', values:['123']}] like this:
and it worked correctly. Here is the same debug log after this change
DEBUG 2021-04-02 21:59:17,198 [[MuleRuntime].uber.03: [test-aws-connector].test-aws-connectorFlow.BLOCKING #2dff3afe] [processor: ; event: 91a34891-93d0-11eb-af49-606dc73d31d1] org.apache.http.wire: http-outgoing-0 >> "Action=DescribeInstances&Version=2016-11-15&Filter.1.Name=tag%3AclassId&Filter.1.Value.1=123"
Also, I want to point out very weird behaviour, this does not work if you try to format [{name: 'tag:classId',values: ['123']}] across multiple lines in the expression and will give an error during deployment.

Trailblazer: Which step caused my operation to fail?

Given an operation like
class MyOperation < Trailblazer::Operation
step :do_a!
step :do_b!
def do_a(options, **)
false
end
def do_b(options, **)
true
end
end
and the result of run(MyOperation), how can I tell which step of the operation failed?
If the result object doesn't contain this info by default, what's a good way to add it?
There is this gem now which provides operation specific debugging utilities - https://github.com/trailblazer/trailblazer-developer
It allows you to see exactly which step raised the exception or which step caused the track to change from success to failure.
Trailblazer::Developer.wtf?(MyOperation, options)
It will print the trace of steps on STDOUT/Logger.

Setting Cron using chef

I have a question about ruby/chef, I am creating a recipe that will setup a cron job once we chef-client the node and I am getting a syntax error when I run my kitchen test
The following block of code is part of my recipe
action node["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["enabled"] = ? :create : :delete
minute node["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["minute"]
hour node["hadoop_temp"]["scripts"]["cron"]["clean_teamp"]["hour"]
day node["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["day"]
month node["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["month"]
weekday node["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["weekday"]
the following block is part of my attributes.
#Run the cron every day at 12AM cleans /temp
default["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["enabled"] = false
default["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["minute"] = "0"
default["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["hour"] = "0"
default["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["day"] = "*"
default["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["month"] = "*"
default["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["weekday"] = "*"
when I run my kitchen test I am getting the following error.
SyntaxError
-----------
/tmp/kitchen/cache/cookbooks/hadoop_temp/recipes/clean_temp.rb:25: syntax error, unexpected '?'
..."hadoop_temp"]["enabled"] = ? :create : :delete
I do not understand boolean 100% in ruby what I want to accomplish is if the entry exist create but if in the future I want to delete I just have to switch the attribute to true.
You could learn about the ternary operator in rubylearn about the ternary operator in ruby
I did took the = sign out of the recipe action. now it looks like:
action node["hadoop_temp"]["scripts"]["cron"]["clean_temp"]["enabled"] ? :create : :delete
Thank you #StephenKing the test passed

Migration to CRM 2016: Unable to get property 'getPageData' of undefined or null reference

After migration from CRM 2013 to CRM 2016 (On Premise), we have error messages in the browser like:
Unable to get property 'getPageData' of undefined or null reference
Unable to get property 'className' of undefined or null reference
Unable to get property 'firstChild' of undefined or null reference
The error happens in components of CRM. Any idea, what the reason could be?
<ReportVersion>1.0</ReportVersion>
<ScriptErrorDetails>
<Message>Unable to get property 'getPageData' of undefined or null reference</Message>
<Line>2083</Line>
<URL>/_static/form/formcontrols.js?ver=1804820318</URL>
<PageURL>/form/page.aspx?lcid=1033&themeId=f499443d-2082-4938-8842-e7ee62de9a23&tstamp=197130723&updateTimeStamp=635905304768102438&userts=131002784247688030&ver=1804820318#etc=2&extraqs=%3fetc%3d2%26id%3d%257b7DE4DCC6-207F-E511-9528-005056A03927%257d&pagemode=iframe&pagetype=entityrecord&counter=1455804831411</PageURL>
<Function>anonymousr:Unabletogetproperty'getPageData'ofundefinedornullreference</Function>
<FunctionRaw>TypeError: Unable to get property 'getPageData' of undefined or null reference</FunctionRaw>
<CallStack>
<Function>anonymousr:Unabletogetproperty'getPageData'ofundefinedornullreference</Function>
</CallStack>
</ScriptErrorDetails>
Try suggestion provided at the end of thread - https://community.dynamics.com/crm/f/117/p/190275/482107
When do errors occur?
I' v had similar error [1] on 8.2.2.112 when pressing Next Stage on Business Process Flow. Much effort was put into debugging so wanted to document it somwhere.
Rollup field
The error was caused by rollup fields that provides SUM for Money fields. The HTML generated by CRM and javascript function didn't match.
Guilty line is within /_static/form/formcontrols.js called on line 28871:
XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetNextSibling(this.get_controlValue().parentNode)))))).innerHTML = CrmEncodeDecode.CrmHtmlDecode((this.$5_1.$3_2).get_currencySymbol());
This one returns null and it therefore spits error: XUI.Html.DomUtils.GetNextSibling(this.get_controlValue().parentNode
Solution
FIX 1: Enable "Use legacy form rendering" under System Settings
OR Fix 2: Remove Currency rollup fields from form.
OR Fix 3: Create non-rollup fields that get calculated with workflow or plugin.
OR Fix 4: You may do some jQuery stuff and add some empty siblings which it -
expects. Except it may show duplicate currency symbol (at least for EUR currency) - one as prefix the other one as suffix.
OR Fix 5: Most undesirable way: patch that .js yourself if you're on-premises.
Replace line 28871:
XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetNextSibling(this.get_controlValue().parentNode)))))).innerHTML = CrmEncodeDecode.CrmHtmlDecode((this.$5_1.$3_2).get_currencySymbol());
With:
if (XUI.Html.DomUtils.GetNextSibling(this.get_controlValue().parentNode) !== null) {
XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetFirstChild(XUI.Html.DomUtils.GetNextSibling(this.get_controlValue().parentNode)))))).innerHTML = CrmEncodeDecode.CrmHtmlDecode((this.$5_1.$3_2).get_currencySymbol());
}
[1] Error:
<ScriptErrorDetails>
<Message>Cannot read property 'firstChild' of null</Message>
<Line>0</Line>
<URL>/form/page.aspx?lcid=1033&themeId=2cf54f8a-be4d-477c-a1f5-29b894a487ca&tstamp=53798526&updateTimeStamp=636392540341784672&userts=131546192871874626&ver=-1991520363#etc=3&extraqs=%3f_gridType%3d3%26etc%3d3%26id%3d%257b586C2C21-E8F8-E611-80F5-005056BD19EE%257d%26opened%3dgrid%26process%3dc9426a91-9fc0-4c2d-a21c-4b9d2a38a6d5%26processts%3d51389819%26rskey%3d%257b00000000-0000-0000-00AA-000010003001%257d&pagemode=iframe&pagetype=entityrecord&rskey=%7b00000000-0000-0000-00AA-000010003001%7d&counter=1510145890205</URL>
<PageURL>/form/page.aspx?lcid=1033&themeId=2cf54f8a-be4d-477c-a1f5-29b894a487ca&tstamp=53798526&updateTimeStamp=636392540341784672&userts=131546192871874626&ver=-1991520363#etc=3&extraqs=%3f_gridType%3d3%26etc%3d3%26id%3d%257b586C2C21-E8F8-E611-80F5-005056BD19EE%257d%26opened%3dgrid%26process%3dc9426a91-9fc0-4c2d-a21c-4b9d2a38a6d5%26processts%3d51389819%26rskey%3d%257b00000000-0000-0000-00AA-000010003001%257d&pagemode=iframe&pagetype=entityrecord&rskey=%7b00000000-0000-0000-00AA-000010003001%7d&counter=1510145890205</PageURL>
<Function>anonymous(dirtyVisiblePropertyData){var$v_0=dirtyVisiblePropertyData.getKeys();for(var$v_1=0;$v_1<$v_0.length;$v_1++){var$v_2=$v_0[$v_1];if(IsNull(this.get_viewMap().get_item($v_2))){}else{try{this.get_viewMap().get_item($v_2).update(dirtyVisiblePropertyD</Function>
<FunctionRaw>function (dirtyVisiblePropertyData) {
var $v_0 = dirtyVisiblePropertyData.getKeys();
for (var $v_1 = 0; $v_1 < $v_0.length; $v_1++) {
var $v_2 = $v_0[$v_1];
if (IsNull(this.get_viewMap().get_item($v_2))) {
</FunctionRaw>
<CallStack>
<Function>anonymous(dirtyVisiblePropertyData){var$v_0=dirtyVisiblePropertyData.getKeys();for(var$v_1=0;$v_1<$v_0.length;$v_1++){var$v_2=$v_0[$v_1];if(IsNull(this.get_viewMap().get_item($v_2))){}else{try{this.get_viewMap().get_item($v_2).update(dirtyVisiblePropertyData.get_item($v_2));}catch($v_3){Mscrm.CrmDebug.fail(String.format('ExceptionencounteredupdatingUIelement{0}:{1}',$v_2,$v_3.message));catchError($v_3.message,window.location.href,0,true);}}}}</Function>
<Function>anonymous(){if(this.$AV_1){var$v_0=this.$4h_1;this.$4h_1=new(Mscrm.TurboForm.Control.TypedDictionary$1.$$(Mscrm.TurboForm.Control.PropertyBag))();this.ui.updateUI($v_0);}}</Function>
<Function>anonymous(){this.$7A_1++;var$v_0=null;if(!this.$AE_1){setPerformanceMarkerTimestamp(String.format('UIUpdate{0}StartTime',this.$7A_1));$v_0=Xrm.Internal.startMetricsStopwatch(String.format('UIUpdate{0}',this.$7A_1));$v_0.start();}this.$8w_1=false;for(var$v_1=0;$v_1<this.$2F_1.length;$v_1++){var$v_2=this.$2F_1[$v_1];if(!IsNull($v_2)){$v_2.flushVisibilityChanges();}}if($v_0){$v_0.stop();setPerformanceMarkerTimestamp(String.format('UIUpdate{0}EndTime',this.$7A_1));}window.top.TurboFormLoadStartTime=null;}</Function>
<Function>anonymous(){Mscrm.Performance.PerformanceMarkerManager.get_instance().addMarker('MDDEnd',1);try{var$v_0=Xrm.Internal.startMetricsStopwatch('PostOnLoadUIUpdate');$v_0.start();this.finishUIUpdate();$v_0.stop();}finally{this.$Ih_1();this.updateFormDirtyState();try{if(isOutlookHostedWindow()){getOutlookHostedWindow().handlePostOnLoad();}}catch($$e_1){}}}</Function>
<Function>anonymous(){var$v_0=Xrm.Internal.startMetricsStopwatch('HandlePostOnLoad');$v_0.start();if(Mscrm.TurboForm.Control.PageManager.get_instance().$L_1===this){this.get_pidRequestManager().clearRecords();Mscrm.TurboForm.Control.PageManager.get_instance().handlePostOnLoad();var$v_1=Mscrm.TurboForm.Control.PageBootstrapper.getPageState();if(!IsNull($v_1)&&$v_1.formType!==7&&!$v_1.recordId.equals(Microsoft.Crm.Client.Core.Framework.Guid.get_empty())){Mscrm.TurboForm.Control.PageBootstrapper.requestSubGridData();}this.get_pidRequestManager().requestPidPtsWithLookupService();setAttributeInWindow('FormEntityLogicalName',(this.data.getEntity())?this.data.getEntity().getEntityName()||'':'');setAttributeInWindow('FormEntityTypeCode',(this.data.getEntity()&&!Mscrm.InternalUtilities.JSTypes.isNull(this.data.getEntity().getEntityTypeCode()))?this.data.getEntity().getEntityTypeCode().toString():'');if(!Mscrm.InternalUtilities.JSTypes.isNullOrEmptyString(window.CUSTOM_ETC_LIST)&&JSON.parse(window.CUSTOM_ETC_LIST).indexOf(this.data.getEntity().getEntityTypeCode())>-1){setAttributeInWindow('IsCustomEntity','true');}else{setAttributeInWindow('IsCustomEntity','false');}if(!IsNull(window.turboHeaderScriptIncludes)){if(this.scriptIncludesSearch(window.turboHeaderScriptIncludes,'/_static/cs/articlesearchribbon/articlesearchribbon.js')){Mscrm.CrmHeader.setScriptFileForTurboForm(Mscrm.CrmUri.create('/_static/CS/ArticleSearchRibbon/ArticleSearchRibbon.js'));}}Mscrm.TurboForm.Control.PageManager.get_instance().loadActionHubIframe();window.setTimeout(this.$$d_$Ff_1,15);if(!IsNull($v_1)&&$v_1.formType!==7){Mscrm.MetricsCollector.collectAndReportClientMetrics(2);}}else{Mscrm.TurboForm.Control.PageManager.get_instance().finishUIUpdate();}$v_0.stop();}</Function>
<Function>anonymous(){returnb.apply(a,arguments)}</Function>
<Function>anonymous(c,d){for(varb=0,e=a.length;b<e;b++)a[b](c,d)}</Function>
<Function>anonymous(message){switch(message){case'TurboFormPostOnloadTimestamp':setPerformanceMarkerTimestamp('TurboFormPostOnloadTimestamp');Mscrm.Performance.PerformanceMarkerManager.get_instance().addMarker('TurboFormPostOnloadTimestamp',1);var$v_0=Mscrm.TurboForm.Control.CustomScriptsManager.get_instance().$7d_1.getHandler(String.format('MessageEventFormat_{0}',message));if(!IsNull($v_0)){$v_0();window.pageLoadedCheckForNavigateApi=true;if(!IsNull(window.parent)&&!IsNull(window.parent.parent)){window.parent.pageLoadedCheckForNavigateApi=true;window.parent.parent.pageLoadedCheckForNavigateApi=true;}}break;case'ScriptsAreLoaded':if(Mscrm.TurboForm.Control.CustomScriptsManager.get_instance().$57_1){Mscrm.TurboForm.Control.CustomScriptsManager.get_instance().$57_1=false;}var$v_1=Mscrm.TurboForm.Control.CustomScriptsManager.get_instance().$7d_1.getHandler(String.format('ScriptsAreLoaded',message));if(!IsNull($v_1)){$v_1();}break;}}</Function>
<Function>SendMessageToPageManager(message)</Function>
<Function>RunHandlerInternal(method,parameters,executionContext,executeIfAvailableOnly)</Function>
<Function>RunHandlers()</Function>
<Function>OnScriptTagLoaded(url)</Function>
<Function>anonymous(){OnScriptTagLoaded(url);}</Function>
</CallStack>
</ScriptErrorDetails>
Thanks to Andrii!
Removing a composite control in the header did the trick.
It seems to be a bug in CRM 2016, but our customers can live without this information in the header. All fine!
Kind regards,
Matthias

Resources