String matching on 'region' field is not strict enough

Bug #1250136 reported by Brendan Clune (Logic Supply) on 2013-11-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenERP Connector - Magento
Medium
Brendan Clune (Logic Supply)

Bug Description

When importing 'region' information from Magento into OpenERP, the connector uses 'ilike' matching on the region name:

@mapping
      def state(self, record):
          if not record.get('region'):
              return
          state_ids = self.session.search('res.country.state',
                                          [('name', 'ilike', record['region'])])
          if state_ids:
              return {'state_id': state_ids[0]}

In the case where there are regions with similar names, (e.g. 'California' and 'Baja California'), the search will return both, and the connector will pick the one which is first alphabetically. Thus, importing a sale order for 'California' will always return 'Baja California'.

There are two possible fixes:

The first is to use '=ilike' as the domain operator, forcing a full (case-insensitive) match on region name. The second is to continue to use 'ilike', but add country information to the domain search. This is perhaps more flexible, but less elegant.

The proposed branch simply changes 'ilike' to '=ilike'.

Thanks for the analysis and proposal.
I prefer the exact insensitive match (=ilike) too.

Changed in openerp-connector-magento:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Brendan Clune (Logic Supply) (brendan-clune)
Changed in openerp-connector-magento:
status: Confirmed → Fix Committed

Fix released en 2.2.1

Changed in openerp-connector-magento:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers