diff --git a/base_partner_merge/base_partner_merge.py b/base_partner_merge/base_partner_merge.py index baa9d90ec..6127808b3 100644 --- a/base_partner_merge/base_partner_merge.py +++ b/base_partner_merge/base_partner_merge.py @@ -123,8 +123,8 @@ class MergePartnerAutomatic(orm.TransientModel): context = {} res = super(MergePartnerAutomatic, self ).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'] res['state'] = 'selection' res['partner_ids'] = partner_ids @@ -212,8 +212,8 @@ class MergePartnerAutomatic(orm.TransientModel): '%(column)s IN %%s') % query_dic 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 = """ WITH RECURSIVE cycle(id, parent_id) AS ( SELECT id, parent_id FROM res_partner @@ -316,8 +316,8 @@ class MergePartnerAutomatic(orm.TransientModel): values = dict() 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]): if item[column]: values[column] = write_serializer(column, @@ -381,12 +381,15 @@ class MergePartnerAutomatic(orm.TransientModel): src_partners = ordered_partners[:-1] _logger.info("dst_partner: %s", dst_partner.id) - call_it = lambda function: function(cr, uid, src_partners, - dst_partner, context=context) - - call_it(self._update_foreign_keys) - call_it(self._update_reference_fields) - call_it(self._update_values) + self._update_foreign_keys( + cr, uid, src_partners, dst_partner, context=context + ) + self._update_reference_fields( + cr, uid, src_partners, dst_partner, context=context + ) + self._update_values( + cr, uid, src_partners, dst_partner, context=context + ) _logger.info('(uid = %s) merged the partners %r with %s', uid, @@ -612,8 +615,8 @@ class MergePartnerAutomatic(orm.TransientModel): models['res.users'] = 'partner_id' 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' return models diff --git a/firstname_display_name_trigger/res_partner.py b/firstname_display_name_trigger/res_partner.py index e8fa642ae..83d470e1a 100644 --- a/firstname_display_name_trigger/res_partner.py +++ b/firstname_display_name_trigger/res_partner.py @@ -62,14 +62,12 @@ class ResPartner(orm.Model): ) } - # indirection to avoid passing a copy of the overridable method when - # declaring the function field - _display_name = lambda self, *a, **kw: self._display_name_compute(*a, **kw) - _columns = { # extra field to allow ORDER BY to match visible names 'display_name': fields.function( - _display_name, + # indirection to avoid passing a copy of the overridable method + # when declaring the function field + lambda self, *a, **kw: self._display_name_compute(*a, **kw), type='char', string='Name', store=_display_name_store_triggers diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index d06930bb6..278848fab 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -68,10 +68,9 @@ class ResPartner(orm.Model): In addition an heuristic avoids to keep a firstname without a non-blank lastname """ - field_value = (field_value - and not field_value.isspace() - and field_value - or False) + field_value = ( + field_value if field_value and not field_value.isspace() else False + ) vals = {'lastname': field_value, 'firstname': False} if field_value: flds = self.read( diff --git a/partner_relations/model/res_partner_relation.py b/partner_relations/model/res_partner_relation.py index 0c2733eb3..f969ad26e 100644 --- a/partner_relations/model/res_partner_relation.py +++ b/partner_relations/model/res_partner_relation.py @@ -44,8 +44,8 @@ class ResPartnerRelation(Model): '''Determine wether functions are called in a situation where the 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 False @@ -77,30 +77,31 @@ class ResPartnerRelation(Model): self, cr, uid, ids, field_names, arg, context=None): '''Return a dictionary of dictionaries, with for every partner for ids, the computed values.''' - def get_values(this, dummy_field_names, dummy_arg, context=None): + def get_values(self, dummy_field_names, dummy_arg, context=None): '''Get computed values for record''' values = {} on_right_partner = self._on_right_partner( - cr, uid, this.right_partner_id.id, context=context) + cr, uid, self.right_partner_id.id, context=context) # type_selection_id values['type_selection_id'] = ( - ((this.type_id.id) * 10) + (on_right_partner and 1 or 0)) + ((self.type_id.id) * 10) + (on_right_partner and 1 or 0)) # partner_id_display values['partner_id_display'] = ( - on_right_partner and this.left_partner_id.id - or this.right_partner_id.id + self.left_partner_id.id + if on_right_partner + else self.right_partner_id.id ) # is_relation_expired today = fields.date.context_today(self, cr, uid, context=context) values['is_relation_expired'] = ( - this.date_end and (this.date_end < today)) + self.date_end and (self.date_end < today)) # is_relation_future - values['is_relation_future'] = this.date_start > today + values['is_relation_future'] = self.date_start > today return values return dict([ - (this.id, get_values(this, field_names, arg, context=context)) - for this in self.browse(cr, uid, ids, context=context) + (i.id, get_values(i, field_names, arg, context=context)) + for i in self.browse(cr, uid, ids, context=context) ]) def write(self, cr, uid, ids, vals, context=None):