Skip to content

Commit

Permalink
[IMP] base_setup: add overridable method for company config wizard to…
Browse files Browse the repository at this point in the history
… decide whether default values are shown

bzr revid: odo@openerp.com-20101110160104-nj1raznas0w2jvbm
  • Loading branch information
odony committed Nov 10, 2010
1 parent f331f33 commit 548d093
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions addons/base_setup/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ def _get_all_states(self, cr, uid, context=None):
def _get_all_countries(self, cr, uid, context=None):
return self._get_all(cr, uid, 'res.country', context=context)

def _show_company_data(self, cr, uid, context=None):
# We only want to show the default company data in demo mode, otherwise users tend to forget
# to fill in the real company data in their production databases
return self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'module_meta_information').demo


def default_get(self, cr, uid, fields_list=None, context=None):
""" get default company if any, and the various other fields
from the company's fields
"""
base_mod = self.pool.get('ir.module.module').search(cr, uid, [('name','ilike','base')])
base_mod_rec = self.pool.get('ir.module.module').browse(cr, uid, base_mod)[0]
defaults = super(base_setup_company, self)\
.default_get(cr, uid, fields_list=fields_list, context=context)
companies = self.pool.get('res.company')
Expand All @@ -63,8 +67,10 @@ def default_get(self, cr, uid, fields_list=None, context=None):
return defaults
company = companies.browse(cr, uid, company_id[0])
defaults['company_id'] = company.id
if not base_mod_rec.demo:

if not self._show_company_data(cr, uid, context=context):
return defaults

defaults['currency'] = company.currency_id.id
for field in ['name','logo','rml_header1','rml_footer1','rml_footer2']:
defaults[field] = company[field]
Expand Down

0 comments on commit 548d093

Please sign in to comment.