diff --git a/openerp/addons/base/__openerp__.py b/openerp/addons/base/__openerp__.py
index 937c9cbd20b..590d3b11a87 100644
--- a/openerp/addons/base/__openerp__.py
+++ b/openerp/addons/base/__openerp__.py
@@ -36,7 +36,7 @@ The kernel of OpenERP, needed for all installation.
'data': [
'base_data.xml',
'currency_data.xml',
- 'country_data.xml',
+ 'res/res_country_data.xml',
'security/base_security.xml',
'base_menu.xml',
'res/res_security.xml',
diff --git a/openerp/addons/base/base_data.xml b/openerp/addons/base/base_data.xml
index 2fa9910758d..4c429fe56ff 100644
--- a/openerp/addons/base/base_data.xml
+++ b/openerp/addons/base/base_data.xml
@@ -62,8 +62,6 @@
Your CompanyYour Company Slogan
- Web: http://www.yourcompany.com - Tel: +33 1 49 51 23 94
- Bank Accounts... to be configured in menu Settings > Accounting/Invoicing.
diff --git a/openerp/addons/base/ir/ir_translation.py b/openerp/addons/base/ir/ir_translation.py
index 3650f28d3f5..81afd857f18 100644
--- a/openerp/addons/base/ir/ir_translation.py
+++ b/openerp/addons/base/ir/ir_translation.py
@@ -267,7 +267,7 @@ class ir_translation(osv.osv):
# FIXME: should assert that `source` is unicode and fix all callers to always pass unicode
# so we can remove the string encoding/decoding.
if not lang:
- return u''
+ return tools.ustr(source or '')
if isinstance(types, basestring):
types = (types,)
if source:
diff --git a/openerp/addons/base/res/res_bank.py b/openerp/addons/base/res/res_bank.py
index 3bfbd822dae..3d6fce8113a 100644
--- a/openerp/addons/base/res/res_bank.py
+++ b/openerp/addons/base/res/res_bank.py
@@ -172,37 +172,35 @@ class res_partner_bank(osv.osv):
('required', field.required)]
return res
- def _prepare_name_get(self, cr, uid, bank_type_obj, bank_obj, context=None):
+ def _prepare_name_get(self, cr, uid, bank_dicts, context=None):
+ """ Format the name of a res.partner.bank.
+ This function is designed to be inherited to add replacement fields.
+ :param bank_dicts: a list of res.partner.bank dicts, as returned by the method read()
+ :return: [(id, name), ...], as returned by the method name_get()
"""
- Format the name of a res.partner.bank.
- This function is designed to be inherited to add replacement fields.
- :param browse_record bank_type_obj: res.partner.bank.type object
- :param browse_record bank_obj: res.partner.bank object
- :rtype: str
- :return: formatted name of a res.partner.bank record
- """
- return bank_type_obj.format_layout % bank_obj._data[bank_obj.id]
+ # prepare a mapping {code: format_layout} for all bank types
+ bank_type_obj = self.pool.get('res.partner.bank.type')
+ bank_types = bank_type_obj.browse(cr, uid, bank_type_obj.search(cr, uid, []), context=context)
+ bank_code_format = dict((bt.code, bt.format_layout) for bt in bank_types)
+
+ res = []
+ for data in bank_dicts:
+ name = data['acc_number']
+ if data['state'] and bank_code_format.get(data['state']):
+ try:
+ if not data.get('bank_name'):
+ data['bank_name'] = _('BANK')
+ name = bank_code_format[data['state']] % data
+ except Exception:
+ raise osv.except_osv(_("Formating Error"), _("Invalid Bank Account Type Name format."))
+ res.append((data.get('id', False), name))
+ return res
def name_get(self, cr, uid, ids, context=None):
if not len(ids):
return []
- bank_type_obj = self.pool.get('res.partner.bank.type')
- res = []
- for val in self.browse(cr, uid, ids, context=context):
- result = val.acc_number
- if val.state:
- type_ids = bank_type_obj.search(cr, uid, [('code','=',val.state)])
- if type_ids:
- t = bank_type_obj.browse(cr, uid, type_ids[0], context=context)
- try:
- # avoid the default format_layout to result in "False: ..."
- if not val._data[val.id]['bank_name']:
- val._data[val.id]['bank_name'] = _('BANK')
- result = self._prepare_name_get(cr, uid, t, val, context=context)
- except Exception:
- raise osv.except_osv(_("Formating Error"), _("Invalid Bank Account Type Name format."))
- res.append((val.id, result))
- return res
+ bank_dicts = self.read(cr, uid, ids, context=context)
+ return self._prepare_name_get(cr, uid, bank_dicts, context=context)
def onchange_company_id(self, cr, uid, ids, company_id, context=None):
result = {}
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index 83b24b55a93..b27476b2c92 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -111,8 +111,8 @@ class res_company(osv.osv):
'rml_header1': fields.char('Company Slogan', size=200, help="Appears by default on the top right corner of your printed documents (report header)."),
'rml_header2': fields.text('RML Internal Header', required=True),
'rml_header3': fields.text('RML Internal Header for Landscape Reports', required=True),
- 'rml_footer': fields.text('Report Footer', help="Footer text displayed at the bottom of all reports. Automatically set based on company details, "\
- "but may also be customized by directly editing it."),
+ 'rml_footer': fields.text('Report Footer', help="Footer text displayed at the bottom of all reports."),
+ 'rml_footer_readonly': fields.related('rml_footer', type='text', string='Report Footer', readonly=True),
'custom_footer': fields.boolean('Custom Footer', help="Check this to define the report footer manually. Otherwise it will be filled in automatically."),
'logo': fields.related('partner_id', 'image', string="Logo", type="binary"),
'currency_id': fields.many2one('res.currency', 'Currency', required=True),
@@ -138,36 +138,28 @@ class res_company(osv.osv):
('name_uniq', 'unique (name)', 'The company name must be unique !')
]
- def onchange_footer(self, cr, uid, ids, context=None):
- # when touched, the footer becomes custom
- return {'value': {'custom_footer': True}}
+ def onchange_footer(self, cr, uid, ids, custom_footer, phone, fax, email, website, vat, company_registry, bank_ids, context=None):
+ if custom_footer:
+ return {}
- def set_auto_footer(self, cr, uid, ids, context=None):
- # unset the flag 'custom_footer'; this will automatically compute the footer
- return self.write(cr, uid, ids, {'custom_footer': False}, context=context)
-
- def compute_footer(self, cr, uid, ids, context=None):
+ # first line (notice that missing elements are filtered out before the join)
+ res = ' | '.join(filter(bool, [
+ phone and '%s: %s' % (_('Phone'), phone),
+ fax and '%s: %s' % (_('Fax'), fax),
+ email and '%s: %s' % (_('Email'), email),
+ website and '%s: %s' % (_('Website'), website),
+ vat and '%s: %s' % (_('TIN'), vat),
+ company_registry and '%s: %s' % (_('Reg'), company_registry),
+ ]))
+ # second line: bank accounts
res_partner_bank = self.pool.get('res.partner.bank')
- for company in self.browse(cr, uid, ids, context):
- if not company.custom_footer:
- # first line (notice that missing elements are filtered out before the join)
- res = ' | '.join(filter(bool, [
- company.phone and '%s: %s' % (_('Phone'), company.phone),
- company.fax and '%s: %s' % (_('Fax'), company.fax),
- company.email and '%s: %s' % (_('Email'), company.email),
- company.website and '%s: %s' % (_('Website'), company.website),
- company.vat and '%s: %s' % (_('TIN'), company.vat),
- company.company_registry and '%s: %s' % (_('Reg'), company.company_registry),
- ]))
- # second line: bank accounts
- account_ids = [acc.id for acc in company.bank_ids if acc.footer]
- account_names = res_partner_bank.name_get(cr, uid, account_ids, context=context)
- if account_names:
- title = _('Bank Accounts') if len(account_names) > 1 else _('Bank Account')
- res += '\n%s: %s' % (title, ', '.join(name for id, name in account_names))
- # update footer
- self.write(cr, uid, [company.id], {'rml_footer': res}, context=context)
- return True
+ account_data = self.resolve_2many_commands(cr, uid, 'bank_ids', bank_ids, context=context)
+ account_names = res_partner_bank._prepare_name_get(cr, uid, account_data, context=context)
+ if account_names:
+ title = _('Bank Accounts') if len(account_names) > 1 else _('Bank Account')
+ res += '\n%s: %s' % (title, ', '.join(name for id, name in account_names))
+
+ return {'value': {'rml_footer': res, 'rml_footer_readonly': res}}
def on_change_country(self, cr, uid, ids, country_id, context=None):
currency_id = self._get_euro(cr, uid, context=context)
@@ -248,17 +240,11 @@ class res_company(osv.osv):
self.cache_restart(cr)
company_id = super(res_company, self).create(cr, uid, vals, context=context)
obj_partner.write(cr, uid, partner_id, {'company_id': company_id}, context=context)
- self.compute_footer(cr, uid, [company_id], context=context)
return company_id
def write(self, cr, uid, ids, values, context=None):
self.cache_restart(cr)
- if isinstance(ids, (int, long)):
- ids = [ids]
- super(res_company, self).write(cr, uid, ids, values, context=context)
- if 'rml_footer' not in values:
- self.compute_footer(cr, uid, ids, context=context)
- return True
+ return super(res_company, self).write(cr, uid, ids, values, context=context)
def _get_euro(self, cr, uid, context=None):
rate_obj = self.pool.get('res.currency.rate')
diff --git a/openerp/addons/base/res/res_company_view.xml b/openerp/addons/base/res/res_company_view.xml
index b92cfba19b6..cac53b7a76a 100644
--- a/openerp/addons/base/res/res_company_view.xml
+++ b/openerp/addons/base/res/res_company_view.xml
@@ -55,29 +55,26 @@