Browse Source

[FIX] flake8, relative import, unused context initialization

pull/103/head
Holger Brunn 11 years ago
committed by Sandy Carter
parent
commit
3500d55cd7
  1. 2
      partner_relations/__init__.py
  2. 8
      partner_relations/model/__init__.py
  3. 13
      partner_relations/model/res_partner.py
  4. 10
      partner_relations/model/res_partner_relation_type_selection.py

2
partner_relations/__init__.py

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

8
partner_relations/model/__init__.py

@ -18,8 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
import res_partner
import res_partner_relation
import res_partner_relation_type
import res_partner_relation_type_selection
from . import res_partner
from . import res_partner_relation
from . import res_partner_relation_type
from . import res_partner_relation_type_selection
from . import res_partner_relation_all from . import res_partner_relation_all

13
partner_relations/model/res_partner.py

@ -30,10 +30,7 @@ class ResPartner(orm.Model):
def _get_relation_ids( def _get_relation_ids(
self, cr, uid, ids, dummy_name, dummy_arg, context=None): self, cr, uid, ids, dummy_name, dummy_arg, context=None):
if context is None:
context = {}
#TODO: do a permission test on returned ids
# TODO: do a permission test on returned ids
cr.execute( cr.execute(
'''select id, left_partner_id, right_partner_id '''select id, left_partner_id, right_partner_id
from res_partner_relation from res_partner_relation
@ -90,7 +87,7 @@ class ResPartner(orm.Model):
result = [] result = []
for arg in args: for arg in args:
if isinstance(arg, tuple) and arg[0] == name: if isinstance(arg, tuple) and arg[0] == name:
#TODO: handle {<,>}{,=}
# TODO: handle {<,>}{,=}
if arg[1] != '=': if arg[1] != '=':
continue continue
@ -190,8 +187,8 @@ class ResPartner(orm.Model):
context=None, count=False): context=None, count=False):
if context is None: if context is None:
context = {} context = {}
#inject searching for current relation date if we search for relation
#properties and no explicit date was given
# inject searching for current relation date if we search for relation
# properties and no explicit date was given
date_args = [] date_args = []
for arg in args: for arg in args:
if is_leaf(arg) and arg[0].startswith('search_relation'): if is_leaf(arg) and arg[0].startswith('search_relation'):
@ -203,7 +200,7 @@ class ResPartner(orm.Model):
('search_relation_date', '=', time.strftime( ('search_relation_date', '=', time.strftime(
DEFAULT_SERVER_DATE_FORMAT))] DEFAULT_SERVER_DATE_FORMAT))]
#because of auto_join, we have to do the active test by hand
# because of auto_join, we have to do the active test by hand
active_args = [] active_args = []
if context.get('active_test', True): if context.get('active_test', True):
for arg in args: for arg in args:

10
partner_relations/model/res_partner_relation_type_selection.py

@ -55,9 +55,9 @@ class ResPartnerRelationTypeSelection(orm.Model):
def _auto_init(self, cr, context=None): def _auto_init(self, cr, context=None):
drop_view_if_exists(cr, self._table) drop_view_if_exists(cr, self._table)
#TODO: we lose field value's translations here.
#probably we need to patch ir_translation.get_source for that
#to get res_partner_relation_type's translations
# TODO: we lose field value's translations here.
# probably we need to patch ir_translation.get_source for that
# to get res_partner_relation_type's translations
cr.execute( cr.execute(
'''create or replace view %s as '''create or replace view %s as
select select
@ -91,7 +91,7 @@ class ResPartnerRelationTypeSelection(orm.Model):
for arg in args: for arg in args:
if isinstance(arg, tuple) and arg[0] == field_name\ if isinstance(arg, tuple) and arg[0] == field_name\
and (arg[1] == '=' or arg[1] == 'in'): and (arg[1] == '=' or arg[1] == 'in'):
#TODO don't we have an api function to eval that?
# TODO don't we have an api function to eval that?
for delta in arg[2]: for delta in arg[2]:
if delta[0] == 6: if delta[0] == 6:
category_ids.extend(delta[2]) category_ids.extend(delta[2])
@ -122,7 +122,7 @@ class ResPartnerRelationTypeSelection(orm.Model):
'res.partner.category', 'Current record\'s category'), 'res.partner.category', 'Current record\'s category'),
'partner_category_other': fields.many2one( 'partner_category_other': fields.many2one(
'res.partner.category', 'Other record\'s category'), 'res.partner.category', 'Other record\'s category'),
#search field to handle many2many deltas from the client
# search field to handle many2many deltas from the client
'search_partner_category_this': fields.function( 'search_partner_category_this': fields.function(
lambda self, cr, uid, ids, context=None: dict( lambda self, cr, uid, ids, context=None: dict(
[(i, False) for i in ids]), [(i, False) for i in ids]),

Loading…
Cancel
Save