How to print "/" in report name odoo 14? - odoo-14

I want to download quotation with the name Quotation number as "SQ/001" but it prints "SQ_001". How to remove this underscore and print as it is in sale.
code:
print_report_name="(object.state in ('draft', 'sent') and 'Quotation - %s' % (object.name)) or 'Sale Order - %s' % (object.name)"

As I see,your issue is strange. Because while creating a file manually in Linux OS, it won't allow you to use these special symbole, I am not sure about the Windows OS. But normally "/" is not allowed as a valid character in file name.
So Odoo internelly replace it with "_" to avoid file name error.

Related

Ansible docker invalid character %

I am writing some ansible to automate my docker deployments.
I am trying to set an env variable to be % but I get this error:
ERROR! Syntax Error while loading YAML.
found character that cannot start any token
The error appears to have been in '/vagrant/roles/zoneminder_docker/tasks/main.yml': line 21, column 24, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
MYSQL_ROOT_PASSWORD: mysqlpsswd
MYSQL_ROOT_HOST: %
^ here
Is there any way to escape this character? As if I exclude this line, my deployment fails.
Is there any way to escape this character? As if I exclude this line, my deployment fails.
The thing you are looking for is to make that value a string literal:
MYSQL_ROOT_PASSWORD: mysqlpsswd
MYSQL_ROOT_HOST: '%'

Folder name with space in SQL*Plus script

I wrote the following script to create a new folder
column mn new_value _mn;
select '\\common\jds\Daily report\DailyReport2017\\'||tochar(sysdate,'mon')||'\';
host mkdir &_mn;
but it throws error
'The specified path is invalid.
Error occurred while processing \\common\jdfs\Daily',
since there is space in the name
How can I create the folder
Unlike in Windows, In Linux the default folder separator is the / and the spaces must be escaped with a backslash (\). Therefore I would try to use this instead:
select '/common/jds/Daily\ report/DailyReport2017/' || tochar(sysdate,'mon') || '/';

WMIC product where "name like..." - "no instances available" if run in batch file

I want to find what version of Outlook is running on specific workstations. If I manually run
wmic /node:"hostname" product where "Name like '%Office Outlook%'" get Name
in a command line, it works. But if I run it from a batch file, it returns "No instance(s) available". I've even stripped everything else out of the batch file, so only this line is left - and I still get the same result. Am I missing something?
In a batch script file, escape your %s by prefacing each with another % as follows:
wmic /node:"hostname" product where "Name like '%%Office Outlook%%'" get Name
For proof, try next in your batch file:
echo ON
wmic /node:"hostname" product where "Name like '%%Office Outlook%%'" get Name
pause
You should see next ECHOed command, the same as it would be typed from command prompt:
wmic /node:"hostname" product where "Name like '%Office Outlook%'" get Name
:::::::::::::::::::::::::::::
::: some wmic output here :::
:::::::::::::::::::::::::::::
Press any key to continue . . .
For explanation, read Syntax : Escape Characters, Delimiters and Quotes
Escaping Percents
The % character has a special meaning for command line parameters and
FOR parameters. To treat a percent in a batch script file as a
regular character, double it: %%
Read How does the Windows Command Interpreter (CMD.EXE) parse scripts? (entire thread) as well.

How to deal with spaces in group names when managing Weblogic roles with WLST?

I need to tweak some role assignments in weblogic 12 using WLST. In this case I want to assign a role to all members of a group.
Here is a python script that works like a charm, provided said group name doesn't contain spaces ( I know, I know ...)
connect('XXXXXXXXXX', 'XXXXXXXXXXXXX', 't3://XXXXXXXX:XXXXXX')
cd ('SecurityConfiguration/weblogic/Realms/DecalogRealm/RoleMappers/DefaultRoleMapper')
print 'Setting condition for role "%s"...' % 'ComplianceSourceReader' ,
cmo.setRoleExpression(None,'ComplianceSourceReader',"Grp('ASSET MANAGER')")
print 'Done'
print "post edit report :"
print "=================="
print 'Role condition for "ComplianceSourceReader" role = %s' % (cmo.getRoleExpression(None,'ComplianceSourceReader'))
print
print "Done."
I tried several common ways of escaping the space char in the policy expression's group name, with no success so far. I always get the same error
Caused by: weblogic.entitlement.data.EnCreateException: Missing ',' delimiter. for 'Grp("ASSET MANAGER")' at position:11
at weblogic.entitlement.engine.EEngine.setRoleEntitlements(EEngine.java:1150)
at weblogic.security.providers.authorization.DefaultRoleMapperImpl.setRoleExpression(DefaultRoleMapperImpl.java:328)
... 53 more
Is there a way around this, or will we have to change those group names ?
You can check this using weblogic.entitlement.parser.Parser class. WLST shell:
wls:/offline> from weblogic.entitlement.parser import Parser
wls:/offline> groups = ['ASSET MANAGER']
wls:/offline> print Parser.groups2Expr(groups)
{Grp(ASSET#KMANAGER)}

WebLogic - Using environment variable / double quotes in "Arguments" in "Server Start"

I have an admin server, NodeManager, and 1 managed server, all on the same machine.
I am trying to enter something similar to this to the arguments field in the Server Start tab:
-Dmy.property=%USERPROFILE%\someDir\someJar.jar
But when the managed server is started it throws this exception:
Error opening zip file or JAR manifest missing : %USERPROFILE%\someDir\someJar.jar
It appears that the environment variable is not being translated into it's value. It is just passed on to the managed server as plain-text.
I tried surrounding the path with double quotes (") but the console validates the input and does not allow this: "Arguments may not contain '"'"
Even editing the config.xml file manually cannot work, as the admin server fails to startup after this:
<Critical> <WebLogicServer> <BEA-000362> <Server failed. Reason: [Management:141266]Parsing failure in config.xml: java.lang
.IllegalArgumentException: Arguments may not contain '"'.>
I also tried using %20 to no avail, it is just passed as %20.
I thought that perhaps this had something to do with the spaces in the value of %USERPROFILE% (which is "C:\documents and settings.."), but the same thing happens with other env. variables which point to other directories with no spaces.
My question:
Is there any supported way of :
using double quotes? what if i have to reference a folder with spaces in it's name?
reference an environment variable? What if i have to rely on it's value for distributed servers where i do not know in advance the variable's value?
Edit based on comments:
Approach 1:
Open setDomainEnv.cmd and search for export SERVER_NAME in Linux or for set SERVER_NAME in Windows. Skip to next to next line (i.e skip current and the next line)
On the current line, insert:
customServerList="server1,server2" #this serverList should be taken as input
isCurrServerCustom=$(echo ${customServerList} | tr ',' '\n' | grep ${SERVER_NAME} | wc -l)
if [ $isCurrServerCustom -gt 0 ]; then
# add customJavaArg
JAVA_OPTIONS="-Dmy.property=${USERPROFILE}/someDir/someJar.jar"
fi
Save the setDomainEnv.sh file and re-start servers
Note that I have only given logic for Linux , for Windows similar logic can be used but with batch scripting syntax.
Approach 2:
Assuming domain is already installed and user provides the list of servers to which the JVM argument -Dmy.property need to be added. Jython script (use wlst.sh to execute). WLST Reference.
Usage: wlst.sh script_name props_file_location
import os
from java.io import File
from java.io import FileInputStream
# extract properties from properties file.
print 'Loading input properties...'
propsFile = sys.argv[1]
propInputStream = FileInputStream(propsFile)
configProps = Properties()
configProps.load(propInputStream)
domainDir = configProps.get("domainDir")
# serverList in properties file should be comma seperated
serverList = configProps.get("serverList")
# The current machine's logical name as mentioned while creating the domain has to be given. Basically the machine name on which NM for current host is configured on.
# This param may not be required as an input if the machine name is configured as same as the hostname , in which case , socket module can be imported and socket.getHostName can be used.
currMachineName = configProps.get("machineName")
jarDir = os.environ("USERPROFILE")
argToAdd = '-Dmy.property=' + jarDir + File.separator + 'someDir' + File.separator + 'someJar.jar'
readDomain(domainDir)
for srvr in serverList.split(",") :
cd('/Server/' + srvr)
listenAddr = get('ListenAddress')
if listenAddr != currMachineName :
# Only change current host's servers
continue
cd('/Server/' + srvr + '/ServerStart/' + srvr)
argsOld = get('Arguments')
if argsOld is not None :
set('Arguments', argsOld + ' ' + argToAdd)
else:
set('Arguments', argToAdd)
updateDomain()
closeDomain()
# now restart all affected servers (i.e serverList)
# one way is to connect to adminserver and shutdown them and then start again
Script has to be run from all hosts where the managed servers are going to be deployed in order to have the host specific value of "USERPROFILE" in the JVM argument.
BTW, to answer your question in a line : looks like the JVM arguments have to be supplied with the literal text eventually. But looks like WLS doesn't translate the environment variables if provided as JVM arguments. It gives an impression that it is translating when its done from startWebLogic.cmd (ex: using %DOMAIN_HOME% etc.) but its the shell/cmd executor that translates and then starts the JVM.