[imp] account, base_setup: move chart of accounts selection from base_setup installer to account's
Also remove it from account's config item as it's redundant Rationale: account can be installed due to dependency chains, not just direct installation from base_setup: project, stock, purchase and profile_auction all depend on account, mrp depends on stock which depends on account, so from base_setup's installer alone there are 5 different ways to end up with account installed and need to configure charts of accounts. Therefore having chart of accounts config in base_setup's installer is dumb (as we need a second one anyway), and since it's (in a way) a problem of module installation, the most coherent way is to move it to account/installer.py, and remove it from the config screen where it was (which becomes redundant). Made it required, because it was required in the config item, not sure it's actually mandatory to install a chart of accounts but whatever. bzr revid: xmo@tinyerp.com-20100126140830-h4c7hlvmzzos69ls
This commit is contained in:
@@ -1749,15 +1749,6 @@ class account_config_wizard(osv.osv_memory):
|
||||
_name = 'account.config.wizard'
|
||||
_inherit = 'res.config'
|
||||
|
||||
def _get_charts(self, cr, uid, context):
|
||||
module_obj=self.pool.get('ir.module.module')
|
||||
ids=module_obj.search(cr, uid, [('category_id', '=', 'Account Charts'),
|
||||
('state', '<>', 'installed')])
|
||||
res=[(m.id, m.shortdesc) for m in module_obj.browse(cr, uid, ids)]
|
||||
res.append((-1, 'None'))
|
||||
res.sort(key=lambda x: x[1])
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name':fields.char(
|
||||
'Name', required=True, size=64,
|
||||
@@ -1769,7 +1760,6 @@ class account_config_wizard(osv.osv_memory):
|
||||
'date2': fields.date('End Date', required=True),
|
||||
'period':fields.selection([('month','Month'), ('3months','3 Months')],
|
||||
'Periods', required=True),
|
||||
'charts' : fields.selection(_get_charts, 'Charts of Account',required=True)
|
||||
}
|
||||
_defaults = {
|
||||
'code': lambda *a: time.strftime('%Y'),
|
||||
@@ -1778,14 +1768,6 @@ class account_config_wizard(osv.osv_memory):
|
||||
'date2': lambda *a: time.strftime('%Y-12-31'),
|
||||
'period':lambda *a:'month',
|
||||
}
|
||||
def install_account_chart(self, cr, uid, ids, context=None):
|
||||
for res in self.read(cr,uid,ids):
|
||||
chart_id = res['charts']
|
||||
if chart_id > 0:
|
||||
mod_obj = self.pool.get('ir.module.module')
|
||||
mod_obj.button_install(cr, uid, [chart_id], context=context)
|
||||
cr.commit()
|
||||
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
|
||||
|
||||
def execute(self, cr, uid, ids, context=None):
|
||||
for res in self.read(cr,uid,ids):
|
||||
@@ -1805,7 +1787,6 @@ class account_config_wizard(osv.osv_memory):
|
||||
res_obj.create_period(cr,uid,[new_id])
|
||||
elif res['period']=='3months':
|
||||
res_obj.create_period3(cr,uid,[new_id])
|
||||
self.install_account_chart(cr,uid,ids)
|
||||
account_config_wizard()
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
<group colspan="8">
|
||||
<separator string="Accounting" colspan="4"/>
|
||||
<field name="charts"/>
|
||||
<field name="account_analytic_default"/>
|
||||
<field name="account_analytic_plans"/>
|
||||
<field name="account_payment"/>
|
||||
|
||||
@@ -1460,8 +1460,6 @@
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
<field name="period" colspan="4"/>
|
||||
<separator col="4" colspan="4" string="Select Chart of Accounts"/>
|
||||
<field name="charts"/>
|
||||
</group>
|
||||
<xpath expr='//button[@name="action_skip"]' position="replace"/>
|
||||
</data>
|
||||
|
||||
@@ -18,14 +18,30 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from operator import itemgetter
|
||||
|
||||
from osv import fields, osv
|
||||
import netsvc
|
||||
|
||||
class account_installer(osv.osv_memory):
|
||||
_name = 'account.installer'
|
||||
_inherit = 'res.config.installer'
|
||||
|
||||
def _get_charts(self, cr, uid, context=None):
|
||||
modules = self.pool.get('ir.module.module')
|
||||
ids = modules.search(cr, uid, [('category_id','=','Account Charts')])
|
||||
return list(
|
||||
sorted(((m.name, m.shortdesc)
|
||||
for m in modules.browse(cr, uid, ids)),
|
||||
key=itemgetter(1)))
|
||||
|
||||
_columns = {
|
||||
# Accounting
|
||||
'charts':fields.selection(_get_charts, 'Chart of Accounts',
|
||||
required=True,
|
||||
help="Installs localized accounting charts to match as closely as "
|
||||
"possible the accounting needs of your company based on your "
|
||||
"country."),
|
||||
'account_analytic_default':fields.boolean('Analytic Accounting',
|
||||
help="Automatically selects analytic accounts based on various "
|
||||
"criteria."),
|
||||
@@ -46,4 +62,17 @@ class account_installer(osv.osv_memory):
|
||||
_defaults = {
|
||||
'account_analytic_default':True,
|
||||
}
|
||||
|
||||
def modules_to_install(self, cr, uid, ids, context=None):
|
||||
modules = super(account_installer, self).modules_to_install(
|
||||
cr, uid, ids, context=context)
|
||||
|
||||
chart = self.read(cr, uid, ids, ['charts'],
|
||||
context=context)[0]['charts']
|
||||
self.logger.notifyChannel(
|
||||
'installer', netsvc.LOG_DEBUG,
|
||||
'Installing chart of accounts %s'%chart)
|
||||
return modules | set([chart])
|
||||
|
||||
|
||||
account_installer()
|
||||
|
||||
@@ -25,11 +25,10 @@ If you don't think you need any of these right now, you can easily install them
|
||||
<field name="crm"/> <field name="sale"/>
|
||||
<field name="project"/> <field name="knowledge"/>
|
||||
<field name="stock"/> <field name="mrp"/>
|
||||
<field name="account"/>
|
||||
<field name="charts" attrs="{'readonly':[('account','=',False)]}"/>
|
||||
<field name="purchase"/> <field name="hr"/>
|
||||
<field name="point_of_sale"/> <field name="marketing"/>
|
||||
<field name="misc_tools"/> <field name="report_designer"/>
|
||||
<field name="account"/> <field name="purchase"/>
|
||||
<field name="hr"/> <field name="point_of_sale"/>
|
||||
<field name="marketing"/> <field name="misc_tools"/>
|
||||
<field name="report_designer"/>
|
||||
<separator string="Vertical Modules" colspan="4"/>
|
||||
<field name="profile_association"/>
|
||||
<field name="profile_training"/>
|
||||
|
||||
@@ -19,31 +19,12 @@
|
||||
#
|
||||
##############################################################################
|
||||
from osv import fields, osv
|
||||
from itertools import chain
|
||||
from operator import itemgetter
|
||||
import netsvc
|
||||
|
||||
class base_setup_installer(osv.osv_memory):
|
||||
_name = 'base.setup.installer'
|
||||
_inherit = 'res.config.installer'
|
||||
|
||||
def _get_charts(self, cr, uid, context=None):
|
||||
modules = self.pool.get('ir.module.module')
|
||||
ids = modules.search(cr, uid, [('category_id','=','Account Charts'),
|
||||
('state','!=','installed')])
|
||||
return list(
|
||||
sorted(((m.name, m.shortdesc)
|
||||
for m in modules.browse(cr, uid, ids)),
|
||||
key=itemgetter(1)))
|
||||
|
||||
def _if_account(self, cr, uid, ids, context=None):
|
||||
chart = self.read(cr, uid, ids, ['charts'],
|
||||
context=context)[0]['charts']
|
||||
self.logger.notifyChannel(
|
||||
'installer', netsvc.LOG_DEBUG,
|
||||
'Addon "account" selected, installing chart of accounts %s'%chart)
|
||||
return [chart]
|
||||
|
||||
_install_if = {
|
||||
('sale','crm'): ['sale_crm'],
|
||||
('sale','project'): ['project_mrp'],
|
||||
@@ -73,10 +54,6 @@ class base_setup_installer(osv.osv_memory):
|
||||
'account':fields.boolean('Financial & Accounting',
|
||||
help="Helps you handle your accounting needs, as well as create "
|
||||
"and track your budgets."),
|
||||
'charts':fields.selection(_get_charts, 'Chart of Accounts',
|
||||
help="Installs localized accounting charts to match as closely as "
|
||||
"possible the accounting needs of your company based on your "
|
||||
"country."),
|
||||
'purchase':fields.boolean('Purchase Management',
|
||||
help="Helps you manage your purchase-related processes such as "
|
||||
"requests for quotations, supplier invoices, etc..."),
|
||||
|
||||
Reference in New Issue
Block a user