Skip to content

Commit

Permalink
BAH-3411 | Fixed. Address issues and email issue (#41)
Browse files Browse the repository at this point in the history
* [Hari] | BAH-3411 | Fixed. Address issues and email issue has been fixed.

* [Hari] | BAH-3411-1 | Refactor. Sudo access was removed
  • Loading branch information
Hari Prasath A authored Jan 4, 2024
1 parent 2ff60fe commit 3217197
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bahmni_api_feed/models/api_event_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _get_address_details(self, address):

@api.model
def _find_country(self, address):
return self.env['res.company'].search([], limit=1).partner_id.country_id
return self.env['res.country'].search([('name', '=', address.get('country'))], limit=1)

@api.model
def _find_or_create_level3(self, state, district, level_name, auto_create_customer_address_levels):
Expand Down Expand Up @@ -138,7 +138,8 @@ def _get_customer_vals(self, vals):
res.update({'ref': vals.get('ref'),
'name': vals.get('name'),
'local_name': vals.get('local_name') if vals.get('local_name') else False,
'uuid': vals.get('uuid')})
'uuid': vals.get('uuid'),
'customer_rank': 1})
address_data = vals.get('preferredAddress')
# get validated address details
address_details = self._get_address_details(address_data)
Expand All @@ -162,11 +163,10 @@ def _create_or_update_person_attributes(self, cust_id, vals):
created_village = village_master.create({'name': address_data.get('cityVillage')})
customer_master.village_id = created_village.id

if attributes['email'] and cust_id:
if attributes.get('email') and cust_id:
customer_master = self.env['res.partner'].search([('id', '=', cust_id)])
if customer_master:
customer_master.email = attributes['email']
customer_master.customer_rank = 1 ##Make a partner as a customer

if address_data.get('country') and cust_id:
country_master = self.env['res.country']
Expand Down

0 comments on commit 3217197

Please sign in to comment.