FIX 4.4 FieldNotFound: Field not found - python-3.x

I receive the following message from counterparty:
8=FIX.4.4|9=219|35=W|34=4|49=id|52=20200618-14:34:20.738|56=id1|42=20200618-14:34:20.688|55=EUR/USD|262=1|268=2|269=0|270=1.12083|271=500000|269=1|270=1.12084|271=500000|10094=2020.06.18 14:34:20.688|10=141|
The message contains the field 268 = 2, and both groups begin with the field 269, and I am trying to extract fields 270. My code looks like this:
message= quickfix.Message('8=FIX.4.4\x019=219\x0135=W\x0134=4\x0149=id\x0152=20200618-14:34:20.738\x0156=id1\x0142=20200618-14:34:20.688\x0155=EURUSD\x01262=1\x01268=2\x01269=0\x01269=1\x01270=1.12083\x01270=1.12084\x01271=500000\x01271=500000\x0110094=2020.06.18 14:34:20.688\x0110=141\x01')
group = quickfix44.MarketDataSnapshotFullRefresh.NoMDEntries()
fix_no_entries = quickfix.NoMDEntries()
message.getField(fix_no_entries)
no_entries = fix_no_entries.getValue() # print = 2 as expected
message.getGroup(1, group)
However, when running the getGroup line, I get the error:
FieldNotFound: Field not found
Any idea on what is going wrong?
Thank you again guys!

Quickfix doesn't know about your message structure, so you need to provide some info about how to parse the message, otherwise it's just a bunch of fields without groups.
<message>
<header>
<field number="8"><![CDATA[FIX.4.4]]></field>
<field number="9"><![CDATA[183]]></field>
<field number="35"><![CDATA[W]]></field>
<field number="34"><![CDATA[4]]></field>
<field number="49"><![CDATA[id]]></field>
<field number="52"><![CDATA[20200618-14:34:20.738]]></field>
<field number="56"><![CDATA[id1]]></field>
</header>
<body>
<field number="42"><![CDATA[20200618-14:34:20.688]]></field>
<field number="55"><![CDATA[EURUSD]]></field>
<field number="262"><![CDATA[1]]></field>
<field number="268"><![CDATA[2]]></field>
<field number="269"><![CDATA[0]]></field>
<field number="269"><![CDATA[1]]></field>
<field number="270"><![CDATA[1.12083]]></field>
<field number="270"><![CDATA[1.12084]]></field>
<field number="271"><![CDATA[500000]]></field>
<field number="271"><![CDATA[500000]]></field>
<field number="10094"><![CDATA[2020.06.18 14:34:20.688]]></field>
</body>
<trailer>
<field number="10"><![CDATA[182]]></field>
</trailer>
</message>
Quickfix data dictionaries are the way to configure the message parser. Quickfix already comes along with some pre-configured dictionaries, you can customize it according with your needs.
data_dictionary = quickfix.DataDictionary("quickfix/FIX44.xml")
message= quickfix.Message('...', data_dictionary, True)
print(message.toXML())
Now the message is structured and it's possible to retrieve groups data:
<message>
<header>
<field number="8"><![CDATA[FIX.4.4]]></field>
<field number="9"><![CDATA[183]]></field>
<field number="35"><![CDATA[W]]></field>
<field number="34"><![CDATA[4]]></field>
<field number="49"><![CDATA[id]]></field>
<field number="52"><![CDATA[20200618-14:34:20.738]]></field>
<field number="56"><![CDATA[id1]]></field>
</header>
<body>
<field number="42"><![CDATA[20200618-14:34:20.688]]></field>
<field number="55"><![CDATA[EURUSD]]></field>
<field number="262"><![CDATA[1]]></field>
<field number="268"><![CDATA[2]]></field>
<field number="10094"><![CDATA[2020.06.18 14:34:20.688]]></field>
<group>
<field number="269"><![CDATA[0]]></field>
</group>
<group>
<field number="269"><![CDATA[1]]></field>
<field number="270"><![CDATA[1.12083]]></field>
</group>
<group>
<field number="270"><![CDATA[1.12084]]></field>
<field number="271"><![CDATA[500000]]></field>
</group>
<group>
<field number="271"><![CDATA[500000]]></field>
</group>
</body>
<trailer>
<field number="10"><![CDATA[182]]></field>
</trailer>
</message>

Related

How to create odoo 12 website submenu through code?

I would like to create submenu under About Us main menu. I am trying with following code but it is adding main menu.
<!-- Main Menu ABOUT US -->
<record id="menu_about_us" model="website.menu">
<field name="name">ABOUT US</field>
<field name="page_id" ref="about-us" />
<field name="parent_id" ref="website.main_menu" />
<field name="sequence" type="int">10</field>
</record>
<!-- Sub Menu Under ABOUT US -->
<record id="menu_board_and_founders" model="website.menu">
<field name="name">BOARD AND FOUNDERS</field>
<field name="page_id" ref="board-and-founders" />
<field name="parent_id" ref="menu_about_us" />
<field name="sequence" type="int">10</field>
</record>

Ir.rule model for diferent groups odoo

I want to make different ir.rule models for different group of users
I have make the rule and work okay but dont know how to assign the group.
<record model="ir.rule" id="pupils_rule">
<field name="name">Tutor only view his pupils</field>
<field name="model_id" ref="model_res_users"/>
<field name="domain_force">[('tutor','=',user.id)]</field>
<field name="perm_read" eval="True"/>
<field name="perm_create" eval="False"/>
<field name="perm_write" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
My 2 security group group_tutor and group_pupil. Mymodel.acess.csv if u need something of the group.
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
tutor_activity,Model pupil
access,model_proyectosge_activity,group_tutor,1,0,0,0
pupil_activity,Model pupil
access,model_proyectosge_activity,group_pupil,1,1,1,1
you to have to add a line like
<field name="groups" eval="[(4, ref('XML ID OF TUTORS'))]"/>
as in the fourth line in the following
<record model="ir.rule" id="pupils_rule">
<field name="name">Tutor only view his pupils</field>
<field name="model_id" ref="model_res_users"/>
<field name="groups" eval="[(4, ref('XML ID OF TUTORS'))]"/>
<field name="domain_force">[('tutor','=',user.id)]</field>
<field name="perm_read" eval="True"/>
<field name="perm_create" eval="False"/>
<field name="perm_write" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>

Can you do a partial search on numbers in Odoo?

I have a search view created:
<record model="ir.ui.view" id="helpdesk_ticket_search_view">
<field name="name">helpdesk.ticket.search.view</field>
<field name="model">helpdesk.ticket</field>
<field name="arch" type="xml">
<search string="Owner Search">
<filter string="Owner" name="res_users" domain="[('res_users_id', '=', 'uid')]"/>
<field name="res_users_id"/>
<field name="name"/>
<field name="ticketnumber" />
<group string="Group by">
<filter string="Owner" name="res_users" domain="[]"
context="{'group_by':'res_users_id'}"/>
</group>
</search>
</field>
</record>
When I search by user, I don't need to type the full name out eg. instead of typing "user", I can just type "us" and get a list
However, with numbers if I am looking for "12345678" I have to type it all out and not just "123".
Is it possible to search for numbers just using part of the number? This is helpful to me with a helpdesk when i am looking for all ticket starting with 123.
Any advise?

Solr won't search on fields belonging to nested entities

I am using apache solr for bulding search for a website.
I am using nested entities to import data from different tables. Dataimport is successfull and all the documents are being added to the index. My dataConfig goes like this :
<dataConfig>
<dataSource type="JdbcDataSource" driver ="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/purplle_purplle2" user="purplle_purplle" password="purplle123" />
<document name="doc">
<entity name="offer" query="SELECT * FROM service_offering WHERE module LIKE 'location' ">
<field column="name" name="name"/>
<field column="id" name="id" />
<field column="type_id" name="type_id" />
<entity name="offer_type" query=" select name from service_offeringtype where id='${offer.type_id}'" >
<field column="name" name="offer_type" />
</entity>
<entity name="offer_location" query=" select name from service_location where id='${offer.module_id}'" >
<field column="name" name="location_name" />
</entity>
<entity name="offer_address" query=" select * from service_address where module_id='${offer.module_id}' AND module LIKE 'location'" >
<entity name="loc_city" query=" select name from loc_city where id='${offer_address.city}'" >
<field column="name" name="loc_city" />
</entity>
<entity name="loc_area" query=" select name from loc_area where id='${offer_address.area}'" >
<field column="name" name="loc_area" />
</entity>
<entity name="loc_zone" query=" select name from loc_zone where id='${offer_address.zone}'" >
<field column="name" name="loc_zone" />
</entity>
</entity>
</entity>
</document>
</dataConfig>
Now if i directly do a search on this index. The results are fetched only for "name" field. It returns null for other fields namely "loc_area","location_name","loc_city" etc.
My schema looks like this
<field name="id" type="int" indexed="true" stored="true" />
<field name="name" type="string" indexed="true" stored="true" />
<field name="offer_type" type="string" indexed="true" stored="true" />
<field name="location_name" type="string" indexed="true" stored="true" />
<field name="type_id" type="string" indexed="true" stored="true" />
<field name="loc_city" type="string" indexed="true" stored="true" />
<field name="loc_area" type="string" indexed="true" stored="true" />
<field name="loc_zone" type="string" indexed="true" stored="true" />
However if i copy these fields into a "text" field which is present by default in the schema.xml. Then by searching on "text" field i easily get the relevant results.
<copyField source="name" dest="text"/>
<copyField source="offer_type" dest="text"/>
<copyField source="location_name" dest="text"/>
<copyField source="loc_city" dest="text"/>
<copyField source="loc_area" dest="text"/>
<copyField source="loc_zone" dest="text"/>
But i cannot do it like this because i have to assign boost levels to different fields for calcuation of score. The moment i append this in the query syntax "&defType=edismax&qf=name^1.0+location_name^10.0+loc_area^50.0" it returns null results.
What is wrong?
My guess is that your problem is the type of your fields. I don't know exactly what your fields contain, but there is a difference between type="string" and type = "text".
The String type indexes an untokenized String value of the entire field input. Text type tokenizes and analyzes the the field. For example, if I search for "john" against a string field containing "John Smith" I would not expect a hit, where if the field were a text field, I would get a hit.
Since your query seems to work against a text field, and not a string field, changing the types and reindexing seems to be a likely solution.

Facet + Query on Text in order to get an autocomplete

I would like to get an auto-suggest / auto-complete field in my application and I am able to get that on a string field, but faceting or querying is not "working" on a text field as on a string field, specially with spaced words.
For now my request is q=cleared_keywords:piso\%20e*&facet=on&facet.field=cleared_keywords&facet.sort=result_count&facet.mincount=1&version=2.2&start=0&rows=0&indent=on&facet.limit=10
and my schema is :
<fields>
<field name="id" type="integer" indexed="true" stored="true" required="true"/>
<field name="country" type="string" indexed="true" stored="true" required="true"/>
<field name="city_id" type="integer" indexed="true" stored="true" required="false"/>
<field name="ad_type" type="integer" indexed="true" stored="true" required="true"/>
<field name="keywords" type="text" indexed="true" stored="true" required="true"/>
<field name="result_count" type="sint" indexed="true" stored="true" required="true"/>
<field name="hash" type="integer" indexed="true" stored="true" required="true"/>
<field name="cleared_keywords" type="string" indexed="true" stored="true" required="false"/>
<field name="keywords_score" type="sfloat" indexed="true" stored="true" required="true"/>
<field name="sorted_keywords" type="string" indexed="true" stored="true" required="true"/>
<field name="links_to" type="integer" indexed="true" stored="true" multiValued="true"/>
<field name="keywordsAsSuggestion" type="string" indexed="true" stored="true" />
<dynamicField name="random*" type="rand" indexed="true" stored="true"/>
<copyField source="keywords" dest="keywordsAsSuggestion" />
</fields>
If I try same query on text (keywords) field it's not working because of text.
I don't understand how copyField is working, do I need to reload / recreate the index ?
I wanted to skip the "recreate index" step, but if I can't I'll just load all Solr Document and recreate new ones with a String field with the keywords text field values ... I just don't like that idea.
Regards,
Alexis
The analyzers and tokenizers defined for field type text is different from that of string in the default schema.xml. If you want to try providing phrases for auto suggest, then it would be better to define your own field type with necessary analyzers and tokenizers. This gives detailed information about them.

Resources