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. 20
      base_contact/__openerp__.py
  3. 21
      base_contact/base_contact.py

3
base_contact/__init__.py

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

20
base_contact/__openerp__.py

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

21
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' _inherit = 'res.partner'
_contact_type = [ _contact_type = [
@ -45,7 +45,8 @@ class res_partner(osv.osv):
'other_contact_ids': fields.one2many('res.partner', 'contact_id', 'Others Positions'), 'other_contact_ids': fields.one2many('res.partner', 'contact_id', 'Others Positions'),
# Person specific fields # 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'), '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): 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: if context is None:
context = {} 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': if mode != 'search':
context.pop('search_show_all_positions', None) context.pop('search_show_all_positions', None)
return context return context
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): 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: if context is None:
context = {} context = {}
if context.get('search_show_all_positions') is False: 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) args = expression.normalize_domain(args)
attached_contact_args = expression.AND((args, [('contact_type', '=', 'attached')])) attached_contact_args = expression.AND((args, [('contact_type', '=', 'attached')]))
attached_contact_ids = super(res_partner, self).search(cr, user, attached_contact_args, 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} return {'value': values}
class ir_actions_window(osv.osv):
class ir_actions_window(orm.Model):
_inherit = 'ir.actions.act_window' _inherit = 'ir.actions.act_window'
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):

Loading…
Cancel
Save