Bahmni Demo site OpenERP Custom Field error

When I try to add a new custom field as explained here I get the following error on Demo site (demo.mybahmni.org).

Will also investigate on local machine.

As a work around fields can be imported through CSV

Just took a look at this issue. Even if you get past this error and manually add the column, person attributes will not sync. See here for more details.

We added the required columns in /usr/lib/python2.6/site-packages/openerp-7.0_20130301_002301-py2.6.egg/openerp/addons/bahmni_atom_feed/res_partner.py And now it syncs properly.

class res_partner_attributes(osv.osv): _name = ‘res.partner.attributes’

_columns = {
    'partner_id': fields.many2one('res.partner', 'Partner', required=True, select=True, readonly=False),
    'x_secondaryContact': fields.char('Secondary Contact', size=128, readonly=False),
    'x_mobileno': fields.char('Mobile No.', size=128, readonly=False),
    'x_Consultant Dr': fields.char('Consultant Dr.', size=128, readonly=False)
}

image

Thats a risky change. If you upgrade to a newer version of Bahmni, the file will be replaced, and your changes lost. I would rather have a permanent fix in the bahmni_atom_feed module than having to keep a custom version with me.

I agree that a local copy will have to be maintained if the change to create columns in person_attributes is done either in the database or in the code but this is a temporary fix till the column can be created through OpenERP UI. I had also reported that in earlier version (<0.88) person_attributes were stored as name, value pair but now getting stored as columns. I don’t know when this design change happened - please check for details Data sent to OpenERP/oodo

0.90-302 resolves this issue as there is no error while adding custom field in res.partner.attributes.

1 Like

Hello everyone, I managed to added a new custom field in openerp but i cant see field on the patient data in openerp
Though it created the column in the res.partner attributes in the openerp database which is still indicating null

New custom field in res.partner.attributes will not appear on ERP quotation or customer form unless it is added in the view.

But could you please elaborate which patient data are you checking - Bahmni or ERP?

In my EMR, am capturing telephone number and using primaryContact attribute in OpenMRS. So i added x_primaryContact attribute in OpenERP but it doesnt appear on the quotation.

The process involves Syncing->Place holder and Storing the value in quotation object->Fetching->Displaying->

Syncing - Adding x_primaryContact in res_partner_attributes will only ensure syncing of OpenMRS data with ERP data through bahmni-erp-connect Relation betweeb res_partner and res_partner_attributes is partner_id which is ERP’s the customer (patient) id.

Fetching - Depending on the customer (patient) name on the quotation res_partner_attribute table need to be searched for the specific partner_id and the respective x_primaryContact need to be fetched.

Displaying - The fetched value then need to be displayed on quoation.

How to Sync - Assuming that creation of x_primaryContact in res_partner_attributes is helping to sync the OpenMRS - ERP

When to fetch -

At the time of quotation getting generated due to order sync from Bahmni

At the time of selection (changing) of customer manually (Assuming that it is view only on quotation and user cannot modify mobile number)

How to fetch - Add the following functions (with proper indentation) in /usr/lib/python2.6/site-packages/openerp-7.0_20130301_002301-py2.6.egg/openerp/addons/bahmni_sale_discount/sale_order.py (This is for quotation getting generated from order sync from Bahmni)

def _get_primarycontact_details(self, cr, uid, ids, name, args, context=None):
    res = {}
    for order in self.browse(cr, uid, ids, context=context):
        existing_attribute_search = self.pool.get('res.partner.attributes').search(cr, uid, [('partner_id' , '=', order.partner_id.id)])
	existing_attribute = self.pool.get('res.partner.attributes').browse(cr, uid, existing_attribute_search)
	if existing_attribute:
 	        res[order.id] = {'primaryContact': existing_attribute[0].x_primaryContact}
    return res

(this is for selection (changing) of customer manually)

def onchange_partner_id(self, cr, uid, ids, part, context=None):
vals = super(sale_order,self).onchange_partner_id(cr, uid, ids, part, context=context)
    existing_attribute_search = self.pool.get('res.partner.attributes').search(cr, uid, [('partner_id' , '=', part)])
existing_attribute = self.pool.get('res.partner.attributes').browse(cr, uid, existing_attribute_search)
if existing_attribute:
	vals['value'].update({'primaryContact':existing_attribute[0].x_referredby})
return vals	

How to display -

To make it visitble on the quotation header add the following line in /usr/lib/python2.6/site-packages/openerp-7.0_20130301_002301-py2.6.egg/openerp/addons/bahmni_sale_discount/sale_discount_price_view.xml at suitable place (e.g. after care_setting)

< field name=“care_setting” position=“after”> < field name=“primaryContact”/> < /field >

Place holder and Storing the value in Quotation object Add the following line in /usr/lib/python2.6/site-packages/openerp-7.0_20130301_002301-py2.6.egg/openerp/addons/bahmni_sale_discount/sale_order.py under _columns = { } as the last column.

‘primaryContact’:fields.function(_get_primarycontact_details, type=‘char’, string =‘Mobile No.’, readonly=True, multi=True, store=True)

(please note store=True decides if this value gets stored in quotation object or not)

There may be typo as I haven’t run the above code in my setup as I have different field name (referredBy) used in similar manner.

Please can you explain in detail because am getting “No Handle found” when i restart erp after your configuration, maybe screenshot of your configuration will help us understand. Thanks