Fix bank definition on partner

- add new object res.bank
- better file dependecies

bzr revid: ced-c62342f7b7c823aedc34bd3b4efceee06dc7d166
This commit is contained in:
ced
2007-09-14 13:42:06 +00:00
parent 6752e83938
commit 868024858f
8 changed files with 327 additions and 153 deletions
+2
View File
@@ -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",
+2
View File
@@ -28,6 +28,8 @@
import tools
import country
import bank
import partner
import res_currency
import res_company
+56
View File
@@ -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()
+60
View File
@@ -0,0 +1,60 @@
<?xml version="1.0"?>
<terp>
<data>
<menuitem name="Financial Management" icon="terp-account"/>
<menuitem name="Financial Management/Configuration"
groups="admin" sequence="1"/>
<record model="ir.ui.view" id="view_res_bank_form">
<field name="name">res.bank.form</field>
<field name="model">res.bank</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Bank">
<field name="name" colspan="4" select="1"/>
<field name="code" select="1"/>
<field name="active" select="2"/>
<field name="bic" select="1"/>
<newline/>
<field name="street" select="2"/>
<field name="street2" select="2"/>
<newline/>
<field name="zip"/>
<field name="city"/>
<newline/>
<field name="country" select="2"/>
<field name="state" select="2"/>
<newline/>
<field name="phone"/>
<field name="fax"/>
<newline/>
<field name="email"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_res_bank_tree">
<field name="name">res.bank.tree</field>
<field name="model">res.bank</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Banks">
<field name="name"/>
<field name="code"/>
<field name="country"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_res_bank_form">
<field name="res_model">res.bank</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Financial Management/Configuration/Banks"
action="action_res_bank_form" sequence="12"
id="menu_action_res_bank_form"/>
</data>
</terp>
+115
View File
@@ -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()
+87
View File
@@ -0,0 +1,87 @@
<?xml version="1.0"?>
<terp>
<data>
<!--
Country
-->
<record model="ir.ui.view" id="view_country_tree">
<field name="name">res.country.tree</field>
<field name="model">res.country</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Country">
<field name="name" />
<field name="code"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_country_form">
<field name="name">res.country.form</field>
<field name="model">res.country</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Country">
<field name="name" select="1"/>
<field name="code" select="1"/>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_country">
<field name="name">Country</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.country</field>
<field name="view_type">form</field>
</record>
<menuitem name="Partners/Configuration/Localisation/Countries"
groups="admin" action="action_country"
id="menu_country_partner"/>
<!--
State
-->
<record model="ir.ui.view" id="view_country_state_tree">
<field name="name">res.country.state.tree</field>
<field name="model">res.country.state</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="State">
<field name="country_id"/>
<field name="name"/>
<field name="code"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_country_state_form">
<field name="name">res.country.state.form</field>
<field name="model">res.country.state</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="State">
<field name="country_id" select="1"/>
<field name="name" select="1"/>
<field name="code" select="1"/>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_country_state">
<field name="name">States</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.country.state</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_country_state_tree"/>
</record>
<menuitem name="Partners/Configuration/Localisation/States"
groups="admin" action="action_country_state"
id="menu_country_state_partner"/>
</data>
</terp>
+1 -75
View File
@@ -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),
+4 -78
View File
@@ -28,80 +28,6 @@
</record>
<menuitem name="Partners/Configuration/Functions" groups="admin" action="action_partner_function_form" id="menu_partner_function_form"/>
<!--
================================
Country
================================
-->
<record model="ir.ui.view" id="view_country_tree">
<field name="name">res.country.tree</field>
<field name="model">res.country</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Country">
<field name="name" />
<field name="code"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_country_form">
<field name="name">res.country.form</field>
<field name="model">res.country</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Country">
<field name="name" select="1"/>
<field name="code" select="1"/>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_country">
<field name="name">Country</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.country</field>
<field name="view_type">form</field>
</record>
<menuitem name="Partners/Configuration/Localisation/Countries" groups="admin" action="action_country" id="menu_country_partner"/>
<!--
================================
State
================================
-->
<record model="ir.ui.view" id="view_country_state_tree">
<field name="name">res.country.state.tree</field>
<field name="model">res.country.state</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="State">
<field name="country_id"/>
<field name="name"/>
<field name="code"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_country_state_form">
<field name="name">res.country.state.form</field>
<field name="model">res.country.state</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="State">
<field name="country_id" select="1"/>
<field name="name" select="1"/>
<field name="code" select="1"/>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_country_state">
<field name="name">States</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.country.state</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_country_state_tree"/>
</record>
<menuitem name="Partners/Configuration/Localisation/States" groups="admin" action="action_country_state" id="menu_country_state_partner"/>
<!--
=====================
Partner Address
@@ -310,8 +236,8 @@
<newline/>
<field name="acc_number" select="1"/>
<newline/>
<field name="bank_id"/>
<field name="bank_address_id" domain="[('partner_id','=',bank_id)]"/>
<field name="bank"/>
<newline/>
<separator string="Bank account owner" colspan="4"/>
<field name="owner_name" colspan="4"/>
<field name="street" colspan="4"/>
@@ -416,8 +342,8 @@
<newline/>
<field name="acc_number" select="1"/>
<newline/>
<field name="bank_id"/>
<field name="bank_address_id" domain="[('partner_id','=',bank_id)]"/>
<field name="bank"/>
<newline/>
<separator string="Bank account owner" colspan="4"/>
<field name="owner_name" colspan="4" select="2"/>
<field name="street" colspan="4"/>