Browse Source

Fix Pylint warnings

pull/52/head
moylop260 10 years ago
committed by Alexandre Fayolle
parent
commit
9d295eecf7
  1. 2
      __unported__/base_address_category/__init__.py
  2. 1
      __unported__/base_address_category/base_address.py
  3. 5
      __unported__/partner_address_ldap/address.py
  4. 43
      base_partner_merge/base_partner_merge.py
  5. 1
      base_partner_merge/validate_email.py
  6. 10
      base_partner_sequence/partner.py
  7. 2
      firstname_display_name_trigger/__init__.py
  8. 2
      firstname_display_name_trigger/tests/__init__.py
  9. 2
      partner_auto_salesman/__init__.py
  10. 2
      partner_firstname/tests/__init__.py
  11. 12
      passport/res_passport.py
  12. 2
      res_partner_affiliate/__init__.py

2
__unported__/base_address_category/__init__.py

@ -20,4 +20,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import base_address
from . import base_address

1
__unported__/base_address_category/base_address.py

@ -27,6 +27,7 @@ from openerp.osv import fields, orm
class ResPartnerAdressCategory(orm.Model):
def name_get(self, cr, uid, ids, context=None):
if not len(ids):
return []

5
__unported__/partner_address_ldap/address.py

@ -174,7 +174,7 @@ class LDAPAddress(orm.Model):
# res = [x[0] for x in res]
# else:
# res = []
# # search in partner name to know if we are searching partner...
# search in partner name to know if we are searching partner...
# partner_obj=self.pool.get('res.partner')
# part_len = len(res)-limit
# if part_len > 0:
@ -184,7 +184,7 @@ class LDAPAddress(orm.Model):
# )
# for p in partner_res:
# addresses = partner_obj.browse(cursor, user, p).address
# # Take each contact and add it to
# Take each contact and add it to
# for add in addresses:
# res.append(add.id)
# return self.name_get(cursor, user, res, context)
@ -255,7 +255,6 @@ class LDAPAddress(orm.Model):
except UnicodeError:
logger.notifyChannel('LDAP encode', netsvc.LOG_DEBUG,
'cannot unicode ' + vals[val])
pass
if ids is not None:
if isinstance(ids, (int, long)):

43
base_partner_merge/base_partner_merge.py

@ -20,7 +20,7 @@ from openerp.osv import fields
from openerp.osv.orm import browse_record
from openerp.tools.translate import _
pattern = re.compile("&(\w+?);")
pattern = re.compile(r"&(\w+?);")
_logger = logging.getLogger('base.partner.merge')
@ -360,10 +360,11 @@ class MergePartnerAutomatic(orm.TransientModel):
"Administrator can merge contacts with different emails."))
if dst_partner and dst_partner.id in partner_ids:
src_partners = proxy.browse(cr, uid,
[id for id in partner_ids
if id != dst_partner.id],
context=context)
src_ids = [
partner_id for partner_id in partner_ids
if partner_id != dst_partner.id
]
src_partners = proxy.browse(cr, uid, src_ids, context=context)
else:
ordered_partners = self._get_ordered_partner(cr, uid, partner_ids,
context)
@ -427,15 +428,17 @@ class MergePartnerAutomatic(orm.TransientModel):
[('model', '=', 'res.partner'),
('ttype', 'like', '%2many')],
context=context)
fields = proxy_model.read(cr, uid, field_ids, context=context)
reset_fields = dict((field['name'], []) for field in fields)
field_list = proxy_model.read(cr, uid, field_ids, context=context)
reset_fields = dict((field['name'], []) for field in field_list)
proxy_partner = self.pool['res.partner']
context['active_test'] = False
ids = proxy_partner.search(cr, uid, [], context=context)
fields = ['name', 'var' 'partner_id' 'is_company', 'email']
partners = proxy_partner.read(cr, uid, ids, fields, context=context)
field_list = ['name', 'var' 'partner_id' 'is_company', 'email']
partners = proxy_partner.read(
cr, uid, ids, field_list, context=context
)
partners.sort(key=operator.itemgetter('id'))
partners_len = len(partners)
@ -471,11 +474,11 @@ class MergePartnerAutomatic(orm.TransientModel):
def close_cb(self, cr, uid, ids, context=None):
return {'type': 'ir.actions.act_window_close'}
def _generate_query(self, fields, maximum_group=100):
group_fields = ', '.join(fields)
def _generate_query(self, field_list, maximum_group=100):
group_fields = ', '.join(field_list)
filters = []
for field in fields:
for field in field_list:
if field in ['email', 'name']:
filters.append((field, 'IS NOT', 'NULL'))
@ -507,7 +510,7 @@ class MergePartnerAutomatic(orm.TransientModel):
group_by_str = 'group_by_'
group_by_len = len(group_by_str)
fields = [
field_list = [
key[group_by_len:]
for key in self._columns.keys()
if key.startswith(group_by_str)
@ -515,7 +518,7 @@ class MergePartnerAutomatic(orm.TransientModel):
groups = [
field
for field in fields
for field in field_list
if getattr(this, '%s%s' % (group_by_str, field), False)
]
@ -800,8 +803,8 @@ class MergePartnerAutomatic(orm.TransientModel):
]
for merge_value in list_merge:
id = self.create(cr, uid, merge_value, context=context)
self.automatic_process_cb(cr, uid, [id], context=context)
merge_id = self.create(cr, uid, merge_value, context=context)
self.automatic_process_cb(cr, uid, [merge_id], context=context)
cr.execute("""
UPDATE
@ -870,7 +873,7 @@ class MergePartnerAutomatic(orm.TransientModel):
ORDER BY COUNT(a.id) DESC
""")
re_email = re.compile(r".*@")
for id, email in cr.fetchall():
for partner_id, email in cr.fetchall():
# check email domain
email = re_email.sub("@", email or "")
if not email or email in partner_treated:
@ -886,7 +889,7 @@ class MergePartnerAutomatic(orm.TransientModel):
EXISTS (SELECT * FROM account_invoice as a
WHERE p.id = a.partner_id
AND a.state in ('open','paid'))
""" % (id, email))
""" % (partner_id, email))
if len(cr.fetchall()) > 1:
_logger.info("%s MORE OF ONE COMPANY", email)
@ -897,12 +900,12 @@ class MergePartnerAutomatic(orm.TransientModel):
FROM res_partner
WHERE parent_id != %s
AND id != %s AND email LIKE '%%%s'
""" % (id, id, email))
""" % (partner_id, partner_id, email))
_logger.info("%r", cr.fetchall())
# upgrade
cr.execute(""" UPDATE res_partner
SET parent_id = %s
WHERE id != %s AND email LIKE '%%%s'
""" % (id, id, email))
""" % (partner_id, partner_id, email))
return False

1
base_partner_merge/validate_email.py

@ -68,7 +68,6 @@ VALID_ADDRESS_REGEXP = '^' + ADDR_SPEC + '$'
def validate_email(email, check_mx=False, verify=False):
"""Indicate whether the given string is a valid email address
according to the 'addr-spec' portion of RFC 2822 (see section
3.4.1). Parts of the spec that are marked obsolete are *not*

10
base_partner_sequence/partner.py

@ -39,14 +39,14 @@ class ResPartner(orm.Model):
def copy(self, cr, uid, id, default=None, context=None):
default = default or {}
if self._needsRef(cr, uid, id=id, context=context):
if self._needsRef(cr, uid, source_id=id, context=context):
default['ref'] = self.pool.get('ir.sequence')\
.next_by_code(cr, uid, 'res.partner',
context=context)
return super(ResPartner, self).copy(cr, uid, id, default,
context=context)
def _needsRef(self, cr, uid, id=None, vals=None, context=None):
def _needsRef(self, cr, uid, source_id=None, vals=None, context=None):
"""
Checks whether a sequence value should be assigned to a partner's 'ref'
@ -57,11 +57,11 @@ class ResPartner(orm.Model):
:return: true iff a sequence value should be assigned to the\
partner's 'ref'
"""
if not vals and not id:
if not vals and not source_id:
raise Exception('Either field values or an id must be provided.')
# only assign a 'ref' to commercial partners
if id:
vals = self.read(cr, uid, id, ['parent_id', 'is_company'],
if source_id:
vals = self.read(cr, uid, source_id, ['parent_id', 'is_company'],
context=context)
return vals.get('is_company') or not vals.get('parent_id')

2
firstname_display_name_trigger/__init__.py

@ -19,4 +19,4 @@
#
##############################################################################
import res_partner
from . import res_partner

2
firstname_display_name_trigger/tests/__init__.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import test_display_name
from . import test_display_name
checks = [
test_display_name

2
partner_auto_salesman/__init__.py

@ -19,4 +19,4 @@
#
##############################################################################
import res_partner
from . import res_partner

2
partner_firstname/tests/__init__.py

@ -28,7 +28,7 @@
#
##############################################################################
import test_partner_firstname
from . import test_partner_firstname
checks = [
test_partner_firstname

12
passport/res_passport.py

@ -48,11 +48,11 @@ class res_passport(orm.Model):
if type(ids) in (int, long):
ids = [ids]
res = []
for res_passport in self.browse(cr, uid, ids, context=context):
for passport in self.browse(cr, uid, ids, context=context):
name_elements = []
if res_passport.country_id and res_passport.country_id.name:
name_elements.append(res_passport.country_id.name)
if res_passport.name:
name_elements.append(res_passport.name)
res.append((res_passport.id, ' | '.join(name_elements)))
if passport.country_id and passport.country_id.name:
name_elements.append(passport.country_id.name)
if passport.name:
name_elements.append(passport.name)
res.append((passport.id, ' | '.join(name_elements)))
return res

2
res_partner_affiliate/__init__.py

@ -19,4 +19,4 @@
#
##############################################################################
import res_partner
from . import res_partner
Loading…
Cancel
Save