From 868024858f8fc8ff6f844efb6e78f74b2fa57161 Mon Sep 17 00:00:00 2001
From: ced <>
Date: Fri, 14 Sep 2007 13:42:06 +0000
Subject: [PATCH] Fix bank definition on partner
- add new object res.bank
- better file dependecies
bzr revid: ced-c62342f7b7c823aedc34bd3b4efceee06dc7d166
---
bin/addons/base/__terp__.py | 2 +
bin/addons/base/res/__init__.py | 2 +
bin/addons/base/res/bank.py | 56 +++++++++
bin/addons/base/res/bank_view.xml | 60 ++++++++++
bin/addons/base/res/country.py | 115 +++++++++++++++++++
bin/addons/base/res/country_view.xml | 87 ++++++++++++++
bin/addons/base/res/partner/partner.py | 76 +-----------
bin/addons/base/res/partner/partner_view.xml | 82 +------------
8 files changed, 327 insertions(+), 153 deletions(-)
create mode 100644 bin/addons/base/res/bank.py
create mode 100644 bin/addons/base/res/bank_view.xml
create mode 100644 bin/addons/base/res/country.py
create mode 100644 bin/addons/base/res/country_view.xml
diff --git a/bin/addons/base/__terp__.py b/bin/addons/base/__terp__.py
index f1a6ce05420..a200188e453 100644
--- a/bin/addons/base/__terp__.py
+++ b/bin/addons/base/__terp__.py
@@ -28,6 +28,8 @@
"res/partner/partner_report.xml",
"res/partner/partner_view.xml",
"res/partner/partner_wizard.xml",
+ "res/bank_view.xml",
+ "res/country_view.xml",
"res/res_currency_view.xml",
"res/partner/crm_view.xml",
"res/partner/partner_data.xml",
diff --git a/bin/addons/base/res/__init__.py b/bin/addons/base/res/__init__.py
index b11b846ccef..bff90b8e1d5 100644
--- a/bin/addons/base/res/__init__.py
+++ b/bin/addons/base/res/__init__.py
@@ -28,6 +28,8 @@
import tools
+import country
+import bank
import partner
import res_currency
import res_company
diff --git a/bin/addons/base/res/bank.py b/bin/addons/base/res/bank.py
new file mode 100644
index 00000000000..4fd2c913147
--- /dev/null
+++ b/bin/addons/base/res/bank.py
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# Copyright (c) 2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# 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 2
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+from osv import fields, osv
+
+
+class Bank(osv.osv):
+ _description='Bank'
+ _name = 'res.bank'
+ _columns = {
+ 'name': fields.char('Name', size=128, required=True),
+ 'code': fields.char('Code', size=64),
+ 'street': fields.char('Street', size=128),
+ 'street2': fields.char('Street2', size=128),
+ 'zip': fields.char('Zip', change_default=True, size=24),
+ 'city': fields.char('City', size=128),
+ 'state': fields.many2one("res.country.state", 'State',
+ domain="[('country_id', '=', country_id)]"),
+ 'country': fields.many2one('res.country', 'Country'),
+ 'email': fields.char('E-Mail', size=64),
+ 'phone': fields.char('Phone', size=64),
+ 'fax': fields.char('Fax', size=64),
+ 'active': fields.boolean('Active'),
+ 'bic': fields.char('BIC/Swift code', size=11,
+ help="Bank Identifier Code"),
+ }
+ _defaults = {
+ 'active': lambda *a: 1,
+ }
+
+Bank()
diff --git a/bin/addons/base/res/bank_view.xml b/bin/addons/base/res/bank_view.xml
new file mode 100644
index 00000000000..1406f6b6dc0
--- /dev/null
+++ b/bin/addons/base/res/bank_view.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+ res.bank.form
+ res.bank
+ form
+
+
+
+
+
+
+ res.bank.tree
+ res.bank
+ tree
+
+
+
+
+
+
+
+
+
+
+ res.bank
+ form
+ tree,form
+
+
+
+
+
+
diff --git a/bin/addons/base/res/country.py b/bin/addons/base/res/country.py
new file mode 100644
index 00000000000..d74817b22ad
--- /dev/null
+++ b/bin/addons/base/res/country.py
@@ -0,0 +1,115 @@
+##############################################################################
+#
+# Copyright (c) 2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# 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 2
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+from osv import fields, osv
+
+
+class Country(osv.osv):
+ _name = 'res.country'
+ _description = 'Country'
+ _columns = {
+ 'name': fields.char('Country Name', size=64,
+ help='The full name of the country.'),
+ 'code': fields.char('Country Code', size=2,
+ help='The ISO country code in two chars.\n'
+ 'You can use this field for quick search.'),
+ }
+ _sql_constraints = [
+ ('name_uniq', 'unique (name)',
+ 'The name of the country must be unique !'),
+ ('code_uniq', 'unique (code)',
+ 'The code of the country must be unique !')
+ ]
+
+ def name_search(self, cr, user, name='', args=None, operator='ilike',
+ context=None, limit=80):
+ if not args:
+ args=[]
+ if not context:
+ context={}
+ ids = self.search(cr, user, [('code','=',name)]+ args, limit=limit,
+ context=context)
+ if not ids:
+ ids = self.search(cr, user, [('name',operator,name)]+ args,
+ limit=limit, context=context)
+ return self.name_get(cr, user, ids, context)
+ _order='code'
+
+ def create(self, cursor, user, vals, context=None):
+ if 'code' in vals:
+ vals['code'] = vals['code'].upper()
+ return super(Country, self).create(cursor, user, vals,
+ context=context)
+
+ def write(self, cursor, user, ids, vals, context=None):
+ if 'code' in vals:
+ vals['code'] = vals['code'].upper()
+ return super(Country, self).write(cursor, user, ids, vals,
+ context=context)
+
+Country()
+
+
+class CountryState(osv.osv):
+ _description="Country state"
+ _name = 'res.country.state'
+ _columns = {
+ 'country_id': fields.many2one('res.country', 'Country'),
+ 'name': fields.char('State Name', size=64),
+ 'code': fields.char('State Code', size=3),
+ }
+
+ def name_search(self, cr, user, name='', args=None, operator='ilike',
+ context=None, limit=80):
+ if not args:
+ args = []
+ if not context:
+ context = {}
+ ids = self.search(cr, user, [('code', '=', name)] + args, limit=limit,
+ context=context)
+ if not ids:
+ ids = self.search(cr, user, [('name', operator, name)] + args,
+ limit=limit, context=context)
+ return self.name_get(cr, user, ids, context)
+ _order = 'code'
+
+ def create(self, cursor, user, vals, context=None):
+ if 'code' in vals:
+ vals['code'] = vals['code'].upper()
+ return super(CountryState, self).create(cursor, user, vals,
+ context=context)
+
+ def write(self, cursor, user, ids, vals, context=None):
+ if 'code' in vals:
+ vals['code'] = vals['code'].upper()
+ return super(CountryState, self).write(cursor, user, ids, vals,
+ context=context)
+
+CountryState()
+
+
diff --git a/bin/addons/base/res/country_view.xml b/bin/addons/base/res/country_view.xml
new file mode 100644
index 00000000000..95668b3ef1e
--- /dev/null
+++ b/bin/addons/base/res/country_view.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+ res.country.tree
+ res.country
+ tree
+
+
+
+
+
+
+
+
+
+ res.country.form
+ res.country
+ form
+
+
+
+
+
+
+ Country
+ ir.actions.act_window
+ res.country
+ form
+
+
+
+
+
+
+
+ res.country.state.tree
+ res.country.state
+ tree
+
+
+
+
+
+
+
+
+
+
+ res.country.state.form
+ res.country.state
+ form
+
+
+
+
+
+
+ States
+ ir.actions.act_window
+ res.country.state
+ form
+
+
+
+
+
+
+
diff --git a/bin/addons/base/res/partner/partner.py b/bin/addons/base/res/partner/partner.py
index 7b8926dd8e4..28c856e1fb4 100644
--- a/bin/addons/base/res/partner/partner.py
+++ b/bin/addons/base/res/partner/partner.py
@@ -45,77 +45,6 @@ class res_partner_function(osv.osv):
res_partner_function()
-class res_country(osv.osv):
- _name = 'res.country'
- _description = 'Country'
- _columns = {
- 'name': fields.char('Country Name', size=64, help='The full name of the country.'),
- 'code': fields.char('Country Code', size=2, help='The ISO country code in two chars. You can use this field for quick search.'),
- }
- _sql_constraints = [
- ('name_uniq', 'unique (name)', 'The name of the country must be unique !'),
- ('code_uniq', 'unique (code)', 'The code of the country must be unique !')
- ]
-
- def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
- if not args:
- args=[]
- if not context:
- context={}
- ids = self.search(cr, user, [('code','=',name)]+ args, limit=limit, context=context)
- if not ids:
- ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
- return self.name_get(cr, user, ids, context)
- _order='code'
-
- def create(self, cursor, user, vals, context=None):
- if 'code' in vals:
- vals['code'] = vals['code'].upper()
- return super(res_country, self).create(cursor, user, vals,
- context=context)
-
- def write(self, cursor, user, ids, vals, context=None):
- if 'code' in vals:
- vals['code'] = vals['code'].upper()
- return super(res_country, self).write(cursor, user, ids, vals,
- context=context)
-
-res_country()
-
-class res_country_state(osv.osv):
- _description="Country state"
- _name = 'res.country.state'
- _columns = {
- 'country_id': fields.many2one('res.country', 'Country'),
- 'name': fields.char('State Name', size=64),
- 'code': fields.char('State Code', size=3),
- }
-
- def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
- if not args:
- args = []
- if not context:
- context = {}
- ids = self.search(cr, user, [('code', '=', name)] + args, limit=limit, context=context)
- if not ids:
- ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context)
- return self.name_get(cr, user, ids, context)
- _order = 'code'
-
- def create(self, cursor, user, vals, context=None):
- if 'code' in vals:
- vals['code'] = vals['code'].upper()
- return super(res_country_state, self).create(cursor, user, vals,
- context=context)
-
- def write(self, cursor, user, ids, vals, context=None):
- if 'code' in vals:
- vals['code'] = vals['code'].upper()
- return super(res_country_state, self).write(cursor, user, ids, vals,
- context=context)
-
-res_country_state()
-
class res_payterm(osv.osv):
_description = 'Payment term'
_name = 'res.payterm'
@@ -124,7 +53,6 @@ class res_payterm(osv.osv):
}
res_payterm()
-
class res_partner_category(osv.osv):
def name_get(self, cr, uid, ids, context={}):
if not len(ids):
@@ -428,9 +356,7 @@ class res_partner_bank(osv.osv):
_columns = {
'name': fields.char('Description', size=128),
'acc_number': fields.char('Account number', size=64, required=False),
- 'bank_id': fields.many2one('res.partner', 'Bank'),
- 'bank_address_id': fields.many2one('res.partner.address', 'Bank address'),
-
+ 'bank': fields.many2one('res.bank', 'Bank'),
'owner_name': fields.char('Account owner', size=64),
'street': fields.char('Street', size=128),
'zip': fields.char('Zip', change_default=True, size=24),
diff --git a/bin/addons/base/res/partner/partner_view.xml b/bin/addons/base/res/partner/partner_view.xml
index cdcd46cc543..fe4d9d40f1a 100644
--- a/bin/addons/base/res/partner/partner_view.xml
+++ b/bin/addons/base/res/partner/partner_view.xml
@@ -28,80 +28,6 @@
-
-
-
- res.country.tree
- res.country
- tree
-
-
-
-
-
-
-
-
- res.country.form
- res.country
- form
-
-
-
-
-
- Country
- ir.actions.act_window
- res.country
- form
-
-
-
-
-
- res.country.state.tree
- res.country.state
- tree
-
-
-
-
-
-
-
-
-
- res.country.state.form
- res.country.state
- form
-
-
-
-
-
- States
- ir.actions.act_window
- res.country.state
- form
-
-
-
-