banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #00379
lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons.
Requested reviews:
Banking Addons Team (banking-addons-team)
For more details, see:
https://code.launchpad.net/~therp-nl/banking-addons/ba61-multicompany_safe_partner_search/+merge/146795
This branch fixes partner search in a multicompany database. As there are no multicompany rules on addresses, the module can trigger the 'Access prohibited by access rules' error when trying to read partners through their addresses.
Additionally:
- match by partner name is slightly improved by disregarding very short partner names.
- name of the database cursor has been standardized to 'cr' in this method.
- already disabled code for searching by address components has been removed
--
https://code.launchpad.net/~therp-nl/banking-addons/ba61-multicompany_safe_partner_search/+merge/146795
Your team Banking Addons Team is requested to review the proposed merge of lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons.
=== modified file 'account_banking/wizard/banktools.py'
--- account_banking/wizard/banktools.py 2012-12-18 14:41:15 +0000
+++ account_banking/wizard/banktools.py 2013-02-06 07:58:20 +0000
@@ -121,56 +121,45 @@
except KeyError:
return False
-def get_or_create_partner(pool, cursor, uid, name, address, postal_code, city,
+def get_or_create_partner(pool, cr, uid, name, address, postal_code, city,
country_code, log):
'''
Get or create the partner belonging to the account holders name <name>
If multiple partners are found with the same name, select the first and
add a warning to the import log.
+
+ TODO: revive the search by address components other than country
'''
partner_obj = pool.get('res.partner')
- partner_ids = partner_obj.search(cursor, uid, [('name', 'ilike', name)])
+ partner_ids = partner_obj.search(cr, uid, [('name', 'ilike', name)])
if not partner_ids:
# Try brute search on address and then match reverse
- address_obj = pool.get('res.partner.address')
- filter = [('partner_id', '<>', None)]
+ filter_ = []
if country_code:
country_obj = pool.get('res.country')
country_ids = country_obj.search(
- cursor, uid, [('code','=',country_code.upper())]
+ cr, uid, [('code','=',country_code.upper())]
)
country_id = country_ids and country_ids[0] or False
- filter.append(('country_id', '=', country_id))
- # disable for now. Apparently, address is an array of lines.
- if address and False:
- if len(address) >= 1:
- filter.append(('street', 'ilike', address[0]))
- if len(address) > 1:
- filter.append(('street2', 'ilike', address[1]))
- if city:
- filter.append(('city', 'ilike', city))
- if postal_code:
- filter.append(('zip', 'ilike', postal_code))
- address_ids = address_obj.search(cursor, uid, filter)
+ filter_.append(('address.country_id', '=', country_id))
+ partner_search_ids = partner_obj.search(
+ cr, uid, filter_)
key = name.lower()
-
- # Make sure to get a unique list
- partner_ids = list(set([x.partner_id.id
- for x in address_obj.browse(cursor, uid, address_ids)
- # Beware for dangling addresses
- if _has_attr(x.partner_id, 'name') and
- x.partner_id.name.lower() in key
- ]))
+ partners = partner_obj.read(cr, uid, partner_search_ids, ['name'])
+ partner_ids = [x['id'] for x in partners if (
+ len(x['name']) > 3 and
+ x['name'].lower() in key)]
+ print "Found partner_ids %s" % partner_ids
if not partner_ids:
if (not country_code) or not country_id:
- user = pool.get('res.user').browse(cursor, uid, uid)
+ user = pool.get('res.user').browse(cr, uid, uid)
country_id = (
user.company_id.partner_id.country and
user.company_id.partner_id.country.id or
False
)
- partner_id = partner_obj.create(cursor, uid, dict(
+ partner_id = partner_obj.create(cr, uid, dict(
name=name, active=True, comment='Generated from Bank Statements Import',
address=[(0,0,{
'street': address and address[0] or '',
Follow ups
-
lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: noreply, 2013-02-18
-
Re: lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: Alexandre Fayolle - camptocamp, 2013-02-11
-
Re: lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: Guewen Baconnier @ Camptocamp, 2013-02-11
-
lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: Stefan Rijnhart (Therp), 2013-02-07
-
Re: lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: Stefan Rijnhart (Therp), 2013-02-07
-
Re: lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: Alexandre Fayolle - camptocamp, 2013-02-06
-
Re: lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: Ronald Portier (Therp), 2013-02-06
-
Re: lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: Stefan Rijnhart (Therp), 2013-02-06
-
Re: lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: Ronald Portier (Therp), 2013-02-06
-
lp:~therp-nl/banking-addons/ba61-multicompany_safe_partner_search into lp:banking-addons
From: Stefan Rijnhart (Therp), 2013-02-06