Browse Source

[FIX] PEP8, 7.0 ORM imports

pull/2/head
EL HADJI DEM 11 years ago
committed by Sandy Carter
parent
commit
de8195744e
  1. 3
      base_contact/__init__.py
  2. 22
      base_contact/__openerp__.py
  3. 25
      base_contact/base_contact.py

3
base_contact/__init__.py

@ -19,5 +19,4 @@
#
##############################################################################
import base_contact
from . import base_contact

22
base_contact/__openerp__.py

@ -22,6 +22,8 @@
{
'name': 'Contacts Management',
'version': '1.0',
'author': 'OpenERP SA',
'website': 'http://www.openerp.com',
'category': 'Customer Relationship Management',
'complexity': "expert",
'description': """
@ -32,21 +34,23 @@ It lets you define groups of contacts sharing some common information, like:
* Birthdate
* Nationality
* Native Language
""",
'author': 'OpenERP SA',
'website': 'http://www.openerp.com',
'depends': ['base', 'process', 'contacts'],
'init_xml': [],
'update_xml': [
""",
'depends': [
'base',
'process',
'contacts'
],
'external_dependencies': {},
'data': [
'base_contact_view.xml',
],
'demo_xml': [
'demo': [
'base_contact_demo.xml',
],
'test': [],
'installable': True,
'auto_install': False,
#'certificate': '0031287885469',
'images': [],
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

25
base_contact/base_contact.py

@ -19,10 +19,10 @@
#
##############################################################################
from openerp.osv import fields, osv, expression
from openerp.osv import fields, orm, expression
class res_partner(osv.osv):
class res_partner(orm.Model):
_inherit = 'res.partner'
_contact_type = [
@ -41,11 +41,12 @@ class res_partner(osv.osv):
'contact_type': fields.function(_get_contact_type, type='selection', selection=_contact_type,
string='Contact Type', required=True, select=1, store=True),
'contact_id': fields.many2one('res.partner', 'Main Contact',
domain=[('is_company','=',False),('contact_type','=','standalone')]),
domain=[('is_company', '=', False), ('contact_type', '=', 'standalone')]),
'other_contact_ids': fields.one2many('res.partner', 'contact_id', 'Others Positions'),
# Person specific fields
'birthdate_date': fields.date('Birthdate'), # add a 'birthdate' as date field, i.e different from char 'birthdate' introduced v6.1!
# add a 'birthdate' as date field, i.e different from char 'birthdate' introduced v6.1!
'birthdate_date': fields.date('Birthdate'),
'nationality_id': fields.many2one('res.country', 'Nationality'),
}
@ -54,22 +55,22 @@ class res_partner(osv.osv):
}
def _basecontact_check_context(self, cr, user, mode, context=None):
""" Remove 'search_show_all_positions' for non-search mode.
Keeping it in context can result in unexpected behaviour (ex: reading
one2many might return wrong result - i.e with "attached contact" removed
even if it's directly linked to a company). """
if context is None:
context = {}
# Remove 'search_show_all_positions' for non-search mode.
# Keeping it in context can result in unexpected behaviour (ex: reading
# one2many might return wrong result - i.e with "attached contact" removed
# even if it's directly linked to a company).
if mode != 'search':
context.pop('search_show_all_positions', None)
return context
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
""" Display only standalone contact matching ``args`` or having
attached contact matching ``args`` """
if context is None:
context = {}
if context.get('search_show_all_positions') is False:
# display only standalone contact matching ``args`` or having
# attached contact matching ``args``
args = expression.normalize_domain(args)
attached_contact_args = expression.AND((args, [('contact_type', '=', 'attached')]))
attached_contact_ids = super(res_partner, self).search(cr, user, attached_contact_args,
@ -163,7 +164,7 @@ class res_partner(osv.osv):
return {'value': values}
class ir_actions_window(osv.osv):
class ir_actions_window(orm.Model):
_inherit = 'ir.actions.act_window'
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
@ -177,7 +178,7 @@ class ir_actions_window(osv.osv):
action_context = action.get('context', '{}') or '{}'
if 'search_show_all_positions' not in action_context:
action['context'] = action_context.replace('{',
"{'search_show_all_positions': False,", 1)
"{'search_show_all_positions': False,", 1)
if isinstance(ids, (int, long)):
if actions:
return actions[0]

Loading…
Cancel
Save