-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
-# $Id$
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import tools
import ir
import pooler
+from tools.translate import _
class res_partner_function(osv.osv):
_name = 'res.partner.function'
_description = 'Function of the contact'
_columns = {
- 'name': fields.char('Function name', size=64, required=True),
- 'code': fields.char('Code', size=8),
+ 'name': fields.char('Function Name', size=64, required=True),
+ 'code': fields.char('Code', size=8, required=True),
+ 'ref':fields.char('Notes', size=32,),
}
_order = 'name'
+ _sql_constraints = [
+ ('code_uniq', 'unique (code)', 'The Code of the Partner Function must be unique !')
+ ]
res_partner_function()
_description = 'Payment term'
_name = 'res.payterm'
_columns = {
- 'name': fields.char('Payment term (short name)', size=64),
+ 'name': fields.char('Payment Term (short name)', size=64),
}
res_payterm()
class res_partner_category(osv.osv):
- def name_get(self, cr, uid, ids, context={}):
+ def name_get(self, cr, uid, ids, context=None):
if not len(ids):
return []
- reads = self.read(cr, uid, ids, ['name','parent_id'], context)
+ reads = self.read(cr, uid, ids, ['name','parent_id'], context=context)
res = []
for record in reads:
name = record['name']
res.append((record['id'], name))
return res
- def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
- res = self.name_get(cr, uid, ids)
+ def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
+ res = self.name_get(cr, uid, ids, context=context)
return dict(res)
+
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
- cr.execute('select distinct parent_id from res_partner_category where id in ('+','.join(map(str,ids))+')')
+ cr.execute('select distinct parent_id from res_partner_category where id in ('+','.join(map(str, ids))+')')
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
_columns = {
'name': fields.char('Category Name', required=True, size=64, translate=True),
'parent_id': fields.many2one('res.partner.category', 'Parent Category', select=True),
- 'complete_name': fields.function(_name_get_fnc, method=True, type="char", string='Name'),
- 'child_ids': fields.one2many('res.partner.category', 'parent_id', 'Childs Category'),
- 'active' : fields.boolean('Active', help="The active field allows you to hide the category, without removing it."),
+ 'complete_name': fields.function(_name_get_fnc, method=True, type="char", string='Full Name'),
+ 'child_ids': fields.one2many('res.partner.category', 'parent_id', 'Child Categories'),
+ 'active' : fields.boolean('Active', help="The active field allows you to hide the category without removing it."),
}
_constraints = [
(_check_recursion, 'Error ! You can not create recursive categories.', ['parent_id'])
return [(r['code'], r['name']) for r in res] + [('','')]
+
+
class res_partner(osv.osv):
_description='Partner'
_name = "res.partner"
'customer': lambda *a: 1,
'category_id': _default_category,
}
- _sql_constraints = [
- ('name_uniq', 'unique (name)', 'The name of the partner must be unique !')
- ]
-
def copy(self, cr, uid, id, default=None, context={}):
name = self.read(cr, uid, [id], ['name'])[0]['name']
- default.update({'name': name+' (copy)'})
+ default.update({'name': name+' (copy)', 'events':[]})
return super(res_partner, self).copy(cr, uid, id, default, context)
def _check_ean_key(self, cr, uid, ids):
return True
def address_get(self, cr, uid, ids, adr_pref=['default']):
- cr.execute('select type,id from res_partner_address where partner_id in ('+','.join(map(str,ids))+')')
+ cr.execute('select type,id from res_partner_address where partner_id in ('+','.join(map(str,map(int, ids)))+')')
res = cr.fetchall()
adr = dict(res)
# get the id of the (first) default address if there is one,
'street2': fields.char('Street2', size=128),
'zip': fields.char('Zip', change_default=True, size=24),
'city': fields.char('City', size=128),
- 'state_id': fields.many2one("res.country.state", 'Fed. State', change_default=True, domain="[('country_id','=',country_id)]"),
- 'country_id': fields.many2one('res.country', 'Country', change_default=True),
+ 'state_id': fields.many2one("res.country.state", 'Fed. State', domain="[('country_id','=',country_id)]"),
+ 'country_id': fields.many2one('res.country', 'Country'),
'email': fields.char('E-Mail', size=240),
'phone': fields.char('Phone', size=64),
'fax': fields.char('Fax', size=64),
return []
res = []
for r in self.read(cr, user, ids, ['name','zip','city','partner_id', 'street']):
- if context.get('contact_display', 'contact')=='partner':
+ if context.get('contact_display', 'contact')=='partner' and r['partner_id']:
res.append((r['id'], r['partner_id'][1]))
else:
addr = r['name'] or ''
if context.get('contact_display', 'contact')=='partner':
ids = self.search(cr, user, [('partner_id',operator,name)], limit=limit, context=context)
else:
- ids = self.search(cr, user, [('zip','=',name)] + args, limit=limit, context=context)
+ if not name:
+ ids = self.search(cr, user, args, limit=limit, context=context)
+ else:
+ ids = self.search(cr, user, [('zip','=',name)] + args, limit=limit, context=context)
if not ids:
ids = self.search(cr, user, [('city',operator,name)] + args, limit=limit, context=context)
if name:
_description='Bank type fields'
_name = 'res.partner.bank.type.field'
_columns = {
- 'name': fields.char('Field name', size=64, required=True, translate=True),
- 'bank_type_id': fields.many2one('res.partner.bank.type', 'Bank type', required=True, ondelete='cascade'),
+ 'name': fields.char('Field Name', size=64, required=True, translate=True),
+ 'bank_type_id': fields.many2one('res.partner.bank.type', 'Bank Type', required=True, ondelete='cascade'),
'required': fields.boolean('Required'),
'readonly': fields.boolean('Readonly'),
'size': fields.integer('Max. Size'),
result = []
type_ids = bank_type_obj.search(cr, uid, [])
- bank_types = bank_type_obj.browse(cr, uid, type_ids)
+ bank_types = bank_type_obj.browse(cr, uid, type_ids, context=context)
for bank_type in bank_types:
result.append((bank_type.code, bank_type.name))
return result
_columns = {
'name': fields.char('Description', size=128),
- 'acc_number': fields.char('Account number', size=64, required=False),
+ 'acc_number': fields.char('Account Number', size=64, required=False),
'bank': fields.many2one('res.bank', 'Bank'),
- 'owner_name': fields.char('Account owner', size=64),
+ 'owner_name': fields.char('Account Owner', size=64),
'street': fields.char('Street', size=128),
'zip': fields.char('Zip', change_default=True, size=24),
'city': fields.char('City', size=128),
change_default=True, domain="[('country_id','=',country_id)]"),
'partner_id': fields.many2one('res.partner', 'Partner', required=True,
ondelete='cascade', select=True),
- 'state': fields.selection(_bank_type_get, 'Bank type', required=True,
+ 'state': fields.selection(_bank_type_get, 'Bank Type', required=True,
change_default=True),
'sequence': fields.integer('Sequence'),
}