Browse Source

fix travis (flake8)

pull/94/head
Alexandre Fayolle 10 years ago
parent
commit
c4642df29f
  1. 23
      base_partner_merge/base_partner_merge.py
  2. 3
      firstname_display_name_trigger/res_partner.py
  3. 8
      partner_firstname/partner.py
  4. 9
      partner_relations/model/res_partner_relation.py

23
base_partner_merge/base_partner_merge.py

@ -123,8 +123,8 @@ class MergePartnerAutomatic(orm.TransientModel):
context = {} context = {}
res = super(MergePartnerAutomatic, self res = super(MergePartnerAutomatic, self
).default_get(cr, uid, fields, context) ).default_get(cr, uid, fields, context)
if (context.get('active_model') == 'res.partner'
and context.get('active_ids')):
if (context.get('active_model') == 'res.partner' and
context.get('active_ids')):
partner_ids = context['active_ids'] partner_ids = context['active_ids']
res['state'] = 'selection' res['state'] = 'selection'
res['partner_ids'] = partner_ids res['partner_ids'] = partner_ids
@ -212,8 +212,8 @@ class MergePartnerAutomatic(orm.TransientModel):
'%(column)s IN %%s') % query_dic '%(column)s IN %%s') % query_dic
cr.execute(query, (dst_partner.id, partner_ids,)) cr.execute(query, (dst_partner.id, partner_ids,))
if (column == proxy._parent_name
and table == 'res_partner'):
if (column == proxy._parent_name and
table == 'res_partner'):
query = """ query = """
WITH RECURSIVE cycle(id, parent_id) AS ( WITH RECURSIVE cycle(id, parent_id) AS (
SELECT id, parent_id FROM res_partner SELECT id, parent_id FROM res_partner
@ -316,8 +316,8 @@ class MergePartnerAutomatic(orm.TransientModel):
values = dict() values = dict()
for column, field in columns.iteritems(): for column, field in columns.iteritems():
if (field._type not in ('many2many', 'one2many')
and not isinstance(field, fields.function)):
if (field._type not in ('many2many', 'one2many') and
not isinstance(field, fields.function)):
for item in itertools.chain(src_partners, [dst_partner]): for item in itertools.chain(src_partners, [dst_partner]):
if item[column]: if item[column]:
values[column] = write_serializer(column, values[column] = write_serializer(column,
@ -381,8 +381,11 @@ class MergePartnerAutomatic(orm.TransientModel):
src_partners = ordered_partners[:-1] src_partners = ordered_partners[:-1]
_logger.info("dst_partner: %s", dst_partner.id) _logger.info("dst_partner: %s", dst_partner.id)
call_it = lambda function: function(cr, uid, src_partners,
dst_partner, context=context)
def call_it(function):
return function(cr, uid,
src_partners,
dst_partner,
context=context)
call_it(self._update_foreign_keys) call_it(self._update_foreign_keys)
call_it(self._update_reference_fields) call_it(self._update_reference_fields)
@ -612,8 +615,8 @@ class MergePartnerAutomatic(orm.TransientModel):
models['res.users'] = 'partner_id' models['res.users'] = 'partner_id'
if (self._model_is_installed(cr, uid, 'account.move.line', if (self._model_is_installed(cr, uid, 'account.move.line',
context=context)
and this.exclude_journal_item):
context=context) and
this.exclude_journal_item):
models['account.move.line'] = 'partner_id' models['account.move.line'] = 'partner_id'
return models return models

3
firstname_display_name_trigger/res_partner.py

@ -64,7 +64,8 @@ class ResPartner(orm.Model):
# indirection to avoid passing a copy of the overridable method when # indirection to avoid passing a copy of the overridable method when
# declaring the function field # declaring the function field
_display_name = lambda self, *a, **kw: self._display_name_compute(*a, **kw)
def _display_name(self, *args, **kwargs):
return self._display_name_compute(*args, **kwargs)
_columns = { _columns = {
# extra field to allow ORDER BY to match visible names # extra field to allow ORDER BY to match visible names

8
partner_firstname/partner.py

@ -68,10 +68,10 @@ class ResPartner(orm.Model):
In addition an heuristic avoids to keep a firstname without a In addition an heuristic avoids to keep a firstname without a
non-blank lastname non-blank lastname
""" """
field_value = (field_value
and not field_value.isspace()
and field_value
or False)
field_value = (field_value and
not field_value.isspace() and
field_value or
False)
vals = {'lastname': field_value, 'firstname': False} vals = {'lastname': field_value, 'firstname': False}
if field_value: if field_value:
flds = self.read( flds = self.read(

9
partner_relations/model/res_partner_relation.py

@ -44,8 +44,8 @@ class ResPartnerRelation(Model):
'''Determine wether functions are called in a situation where the '''Determine wether functions are called in a situation where the
active partner is the right partner. Default False! active partner is the right partner. Default False!
''' '''
if (context and 'active_ids' in context
and right_partner_id in context.get('active_ids', [])):
if (context and 'active_ids' in context and
right_partner_id in context.get('active_ids', [])):
return True return True
return False return False
@ -87,8 +87,9 @@ class ResPartnerRelation(Model):
((this.type_id.id) * 10) + (on_right_partner and 1 or 0)) ((this.type_id.id) * 10) + (on_right_partner and 1 or 0))
# partner_id_display # partner_id_display
values['partner_id_display'] = ( values['partner_id_display'] = (
on_right_partner and this.left_partner_id.id
or this.right_partner_id.id
this.left_partner_id.id
if on_right_partner # this is weird...
else this.right_partner_id.id
) )
# is_relation_expired # is_relation_expired
today = fields.date.context_today(self, cr, uid, context=context) today = fields.date.context_today(self, cr, uid, context=context)

Loading…
Cancel
Save