hexadecimal format for message IS08583 in the server side - iso

Actually i'm working with iso 8583 messages, and library j8583 in java.
I created a echo (0800) message to probe connection with the server, the message looks good when is printed, but in the server side the message looks like hexadecimal encoding, something like this:
The devs in the server side told me is a format error for message, the correct message will be like this:
I see the correct message format are transmitted clearly like above image.
Factory from xml field:
this.messageFactory = ConfigParser.createFromClasspathConfig("j8583-config.xml");
Iso message setting binary flags
req.setBinaryFields(true);
req.setBinaryHeader(true);
XML configuration:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE j8583-config PUBLIC "-//J8583//DTD CONFIG 1.0//EN" "http://j8583.sourceforge.net/j8583.dtd">
<j8583-config>
<!-- These are the ISO headers to be prepended to the message types specified -->
<header type="0800">6000050000</header>
<header type="0810">6000050000</header>
<template type="0800">
<field num="3" type="NUMERIC" length="6" />
<field num="7" type="DATE10" />
<field num="11" type="NUMERIC" length="6" />
<field num="24" type="NUMERIC" length="3" />
<field num="41" type="ALPHA" length="8" />
<field num="42" type="ALPHA" length="15" />
<field num="60" type="LLLLVAR" length="" />
</template>
<parse type="0800">
<field num="3" type="NUMERIC" length="6" />
<field num="7" type="DATE10" />
<field num="11" type="NUMERIC" length="6" />
<field num="24" type="NUMERIC" length="3" />
<field num="41" type="ALPHA" length="8" />
<field num="42" type="ALPHA" length="15" />
<field num="60" type="LLLLVAR" length="" />
</parse>
</j8583-config>
IsoMessage build:
final IsoMessage req = this.messageFactory.newMessage(NET_INFO_REQUEST.getValue());
req.setValue(PROCESSING_CODE, ECHO.getValue(), IsoType.NUMERIC, 6);
req.setValue(TRANSMISSION_DATE_TIME, FormatUtils.formatDate10GMT0(new Date()), IsoType.DATE10, 0);
req.setValue(SYSTEM_TRACE_AUDIT_NO, leftPad(simpleTraceGenerator.nextTrace(), 6), IsoType.NUMERIC, 6);
req.setValue(INTERNATIONAL_NETWORK_ID, command.VISA.getCode(), IsoType.NUMERIC, 4);
req.setValue(TERMINAL_ID, "72024092", IsoType.ALPHA, 8);
req.setValue(CLIENT_CODE, "03659307 ", IsoType.ALPHA, 15);
req.setValue(SOFTWARE_VERSION, "OPv1", IsoType.LLLLVAR, 0);
req.setBinary(fale);
Can help me?

Seems there's more than one problem with the message you're generating:
You set fields and headers to binary, but the bitmap is still encoded in ASCII. You should probably just call setUseBinaryMessages instead, IIRC it sets all the messages flags to binary (bitmap, headers, fields). If it doesn't then you need to set binary bitmap programmatically (there's another method for that).
You have a message header for the 0800 but from the hexdump that the other side expects, it seems it's either very different (probary binary, BCD encoded) or they don't expect a header at all. If you need a binary header, specify it in the config (binary header content should be specified as hex, e.g. <header type="800" binary="true">60011200</header>) or you can set it programatically.
For the BCD-encoded fields, just use NUMERIC fields; the values will be BCD-encoded when using binary format. Same goes for DATE fields. LVAR fields are encoded as text; if you need binary data in those, then use LBIN instead. The binary equivalent of ALPHA is BINARY.
LBCDBIN fields are only useful if you message is ASCII-encoded but you need a LBIN field with BCD-encoded length header, because the length header encoding is otherwise chosen based on the encoding of the message (BCD for binary messages, ASCII otherwise).
Hope that helps!

Related

BeanIo/xsd not throwing exceptions with blank file / no records present

I want Bean.Io mapping to through exception when records are not present in file(Blank File). But it's not happening.Though it has validation occurs="0+" in place . Also tried minOccurs=1 maxOccurs=unbounded
My mapping file
<?xml version="1.0" encoding="UTF-8"?>
<beanio xmlns="http://www.beanio.org/2012/03">
<stream name="Records" format="fixedlength" strict="true">
<record name="SampleRecord" class="com.test.SampleRecord" **occurs="0+"**>
<field name="mobileNumber" type="string" position="0" length="10" regex="[0-9]*" required="true"/>
<field name="alternateMobileNumber" type="string" position="10" length="20" regex="[0-9]*" required="false"/>
</record>
</stream>
</beanio>
You can try this mapping.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<beanio xmlns="http://www.beanio.org/2012/03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">
<stream name="Records" format="fixedlength" strict="true" minOccurs="1">
<record name="SampleRecord" class="com.test.SampleRecord" occurs="0+">
<field name="mobileNumber" type="string" position="0" length="10" regex="[0-9]*" required="true"/>
<field name="alternateMobileNumber" type="string" position="10" length="20" regex="[0-9]*" required="false"/>
</record>
</stream>
</beanio>
Note the attribute minOccurs="1" on the stream element. The documentation states this:
minOccurs - The minimum number of times the record layout must be read
from an input stream. Defaults to 0.
Thus, changing minOccurs to 1 causes BeanIO to throw an exception with an empty string as input.

how to run the cron job in odoo

Created the cron job for fetching weather information on every 1 minute but it not work. Here, I attach the code (.py function).
#api.model
def weather_cron(self):
weather_location_ids =self.env['weather_location.weather_location'].search([])
for weather_location_id in weather_location_ids:
url_cron = weather_location_id.api_address + weather_location_id.name
json_data = requests.get(url_cron).json()
formatted_data = json_data['weather'][0]['main']
formatted_data1 = json_data['main']['temp']
formatted_data2 = json_data['main']['temp_min']
formatted_data3 = json_data['main']['temp_max']
formatted_data4 = json_data['main']['humidity']
self.env['current_weather.current_weather'].create({
'weather_id':weather_location_id.id,
'main':formatted_data,
'temp':formatted_data1,
'temp_min':formatted_data2,
'temp_max':formatted_data3,
'humidity':formatted_data4,
})
Cron Job (.xml file):
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="1">
<record forcecreate="True" id="create_weather_info_cron" model="ir.cron">
<field name="name">Weather Information</field>
<field name="user_id" ref="base.user_root"/>
<field name="active" eval="False" />
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
<field name="model" eval="'weather_location.weather_location'"/>
<field name="function" eval="'weather_cron'"/>
</record>
</data>
</odoo>
You made the cron job inactive. Since it is not active this will not trigger the function you wrote. Please change the value to active as True
<field name="active" eval="True"/>
All your field are correct add this two:
<field name="args" eval="'()'"/>
<!-- delay the call 2 minutes just to make sure but it's optional -->
<field name="nextcall" eval="(DateTime.now() + timedelta(minutes=2)).strftime('%Y-%m-%d 00:00:00')" />
Now if the code sill not working you need to make sure of it.
#1- check that your file is in the __openerp__.py or __manifest__.py
#2- if you don't know how to use debug mode in your IDE just use logging to see if Odoo calls your methodname
Hope this Helps you
One thing if you used noupdate="1" in your xml file odoo will not update the record that it's inserted in first time no matter what you change in the code this will not effect the recrod in database.
just change the id and delete the ir.cron record manually from setting menu
EDITS:
every model with "model.name" have an xml_id like this model_model_name
when you see mode_id remember to prefix the name with _model
<field name="model_id" ref="weather_location.model_weather_location"/>
and they are in the same module just put ref="model_weather_location"
But for ir.cron just give the name of the model because it's a Char field not many2one:
<field name="model" eval="'weathe.location'"/>

Raise warning in cron method

I have created a cron which executes a method. Now in that method i want to raise a warning if some value is missing.
Right now my method raise warning(tried Warning and except_orm) but it will log warning to terminal only no warning message appear on GUI.
Am i missing something?
Here is sample code:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="ir_cron_test_warning" model="ir.cron">
<field name="name">Test Warning</field>
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
<field name="numbercall">1</field>
<field name="active" eval="True"/>
<field name="model">test.warning</field>
<field name="function">test_warning_exception</field>
<field name="args">()</field>
</record>
</data>
</openerp>
Method:
class test_warning(models.Model):
_name = 'test.warning'
#api.model
def test_warning_exception(self):
aurl = self.env['ir.config_parameter'].get_param('my_path')
if not aurl:
raise Warning(_('Please add mypath to System Parameters1111'))
Regards,
errors and warnings from the cron job will be bypassed by the orm. so you should either make sure only the correct data is taken in the cron function or it should be avoided.

OpenERP field attributes - invisible attribute in tree view

Considering the following objects and a corresponding view:
class first_object(osv.osv):
_name = "first.object"
_columns = {
'id': fields.integer ('First ID'),
'flag': fields.boolean ('Flag'),
'second_object_id': fields.one2many('second.object','first_object_id')
}
class second_object(osv.osv):
_name = "second.object"
_columns = {
'id': fields.integer ('Second ID'),
'first_object_id': fields.many2one('first.object','random field'),
'field_x': fields.float('x',size=128),
'field_y': fields.float('y',size=128),
}
<record model="ir.ui.view" id="first_object_view_id">
<field name="name">Frist Object</field>
<field name="model">first.object</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<notebook>
<page>
<field name="id"></field>
<field name="flag"></field>
<field name="second_object_id">
<tree editable="top">
<field name="field_x" attrs="{'invisible':[('flag','=',True)]}"/>
<field name="field_y"/>
</tree>
<form>
<field name="field_x"/>
<field name="field_y"/>
</form>
</field>
</page>
</notebook>
</form>
</field>
</record>
Notice the attrs I have now for the field of the second object named field_x in the tree which is based on the field of the first object named flag.
First of all, the attribute in this case is ignored completely. I dont know why it wont work. Second, assuming this can't work and the attributes MUST refer to local fields, the invisible attribute does not work for the tree view, just the form view. However, if you set a simple invisible="1" in the tree it would work just fine (I cant rely on that, I need the rule I provide with attributes). Any ideas?
EDIT:
The problem seems to be making fields invisible via attributes (and not invisible="1") in the TREE view. It works fine in the form. If this can be done it would solve my problem.
EDIT 2:
I tried with separated view definitions and local fields instead of many2one and one2many to no avail. However, I managed to somehow achieve this with invisible="context.get('xxx',True/False)". The problem is once the condition is matched, it remains invisible even after creating a new record where the condition is not matched.
please look in stock_move_tree from stock.move
<field name="prodlot_id" groups="base.group_extended"/>
<button name="%(track_line)d" string="Split in production lots" type="action"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('prodlot_id','<>',False)]}"
states="draft,waiting,confirmed,assigned,done"
groups="base.group_extended"/>
<field groups="base.group_extended" name="tracking_id"/>
<button name="setlast_tracking" string="Put in current pack" type="object"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','<>',False)]}"
states="draft,assigned,confirmed,done"/>
Is the same solution, but for button, not for regular field. And yes, remove field but show empty column.
it seems trying to set an conditional invisible attribute will not affect the true view. only invisible="1". which makes sense since i can't imagine a tree view with some invisible field of which the entire column itself is not invisible.
add a related field to flag in second.oject
class second_object(osv.osv):
_name = "second.object"
_columns = {
'id': fields.integer ('Second ID'),
'flag': fields.related('first_object_id', 'flag', type='boolean', relation='first.object', string='Flag'),
'first_object_id': fields.many2one('first.object','random field'),
'field_x': fields.float('x',size=128),
'field_y': fields.float('y',size=128),
}
an then add field flag in your view as invisible and attrs:
<record model="ir.ui.view" id="first_object_view_id">
<field name="name">Frist Object</field>
<field name="model">first.object</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<notebook>
<page>
<field name="id"></field>
<field name="flag"></field>
<field name="second_object_id">
<tree editable="top">
<field name="flag" invisible="1"/>
<field name="field_x" attrs="{'invisible':[('flag','=',True)]}"/>
<field name="field_y"/>
</tree>
<form>
<field name="field_x"/>
<field name="field_y"/>
</form>
</field>
</page>
</notebook>
</form>
</field>
You have take 1 extra new field (i.e boolean type field) in Object2.
and create onchnage on "flag" field of object1.
in that onchnage you set-reset the value of this new field according to value of Flag field.
and put attrs on this new_field instead of Flag.
Hope This will help you
Please define the view for the model 'second.object' seperately. The same example is in stock_partial_picking.py file inside wizard folder in stock module. please check that. you may need to define a field as user user1888049 told in his answer

How to set default value for a column of content type in Sharepoint

i create a content type using feature as below
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field ID ="{4C939423-2090-413d-B241-724D9B66F74B}"
Name="VersionNumer"
DisplayName="Version Number"
Type="Text"
Required="TRUE"
Group="CT" >
<Default>0</Default>
</Field>
<Field ID ="{33E51B7A-FEE2-4995-B4BB-9F3F909C1015}"
Name="DocumentType"
DisplayName="Document Type"
Type="Choice"
Required="TRUE"
Group="CT">
<Default>Other</Default>
<CHOICES>
<CHOICE>Document</CHOICE>
<CHOICE>Excel</CHOICE>
<CHOICE>PowerPoint</CHOICE>
<CHOICE>Other</CHOICE>
</CHOICES>
</Field>
<ContentType ID="0x0101000728167cd9c94899925ba69c4af6743e"
Name="myCT"
Group="myCT"
Description="myCT"
Version="0">
<FieldRefs>
<FieldRef ID="{4C939423-2090-413d-B241-724D9B66F74B}" Name="VersionNumber" DisplayName="Version Number" Required="TRUE" />
<FieldRef ID="{33E51B7A-FEE2-4995-B4BB-9F3F909C1015}" Name="DocumentType" DisplayName="Document Type" Required="TRUE" />
</FieldRefs>
</ContentType>
</Elements>
How can i set default value for VersionNumer is 0 and default value for DocumentType is Other? I used default tag but it was not efficent.
And another question, how to force user to input VersionNumer and DocumentType. I used atrtibute required="true" but it was not successful.
Thanks in advance.
I've tried this in my environment, it works perfectly. I copy 'n' pasted the contents of elements.xml and didn't make a single modification.
Try this:
Delete your existing site columns and content type (in that order)
Deactivate your feature
IISRESET
Activate your feature again and check if the default values are ok, they should be
Add your choices field and after that put the default tag
enter code here
<CHOICES>
<CHOICE>Document</CHOICE>
<CHOICE>Excel</CHOICE>
<CHOICE>Other</CHOICE>
</CHOICES>
<Default>Other</Default>

Resources