Example #1
0
 def execute(self, cr, uid, ids, context=None):
     """Override of code in order to be able to link journal with account in XML"""
     res = super(WizardMultiChartsAccounts, self).execute(cr, uid, ids, context)
     path = addons.get_module_resource('l10n_ch','sterchi_chart','account_journal_rel.xml')
     tools.convert_xml_import(cr, 'l10n_ch', path, idref=None, mode='init', noupdate=True, report=None)
     res.update({'type': 'ir.actions.act_window_close'})
     return res
Example #2
0
 def execute_simple(self, cr, uid, ids, context=None):
     if context is None:
         context = {}
     fy_obj = self.pool.get('account.fiscalyear')
     for res in self.read(cr, uid, ids, context=context):
         if 'charts' in res and res['charts'] == 'configurable':
             #load generic chart of account
             fp = tools.file_open(opj('account', 'configurable_account_chart.xml'))
             tools.convert_xml_import(cr, 'account', fp, {}, 'init', True, None)
             fp.close()
         if 'date_start' in res and 'date_stop' in res:
             f_ids = fy_obj.search(cr, uid, [('date_start', '<=', res['date_start']), ('date_stop', '>=', res['date_stop']), ('company_id', '=', res['company_id'][0])], context=context)
             if not f_ids:
                 name = code = res['date_start'][:4]
                 if int(name) != int(res['date_stop'][:4]):
                     name = res['date_start'][:4] +'-'+ res['date_stop'][:4]
                     code = res['date_start'][2:4] +'-'+ res['date_stop'][2:4]
                 vals = {
                     'name': name,
                     'code': code,
                     'date_start': res['date_start'],
                     'date_stop': res['date_stop'],
                     'company_id': res['company_id'][0]
                 }
                 fiscal_id = fy_obj.create(cr, uid, vals, context=context)
                 if res['period'] == 'month':
                     fy_obj.create_period(cr, uid, [fiscal_id])
                 elif res['period'] == '3months':
                     fy_obj.create_period3(cr, uid, [fiscal_id])
Example #3
0
 def load_demo_xml(cr, m, idref, mode):
     for xml in package.data.get('demo_xml', []):
         name, ext = os.path.splitext(xml)
         logger.notifyChannel('init', netsvc.LOG_INFO,
                              'module %s: loading %s' % (m, xml))
         fp = tools.file_open(opj(m, xml))
         try:
             if ext == '.csv':
                 tools.convert_csv_import(cr,
                                          m,
                                          os.path.basename(xml),
                                          fp.read(),
                                          idref,
                                          mode=mode,
                                          noupdate=True)
             elif ext == '.yml':
                 tools.convert_yaml_import(cr,
                                           m,
                                           fp,
                                           idref,
                                           mode=mode,
                                           noupdate=True,
                                           **kwargs)
             else:
                 tools.convert_xml_import(cr,
                                          m,
                                          fp,
                                          idref,
                                          mode=mode,
                                          noupdate=True,
                                          **kwargs)
         finally:
             fp.close()
Example #4
0
 def _run_test(self, cr, module_name, filename):
     _, ext = os.path.splitext(filename)
     pathname = os.path.join(module_name, filename)
     open_file = tools.file_open(pathname)
     if ext == '.sql':
         queries = open_file.read().split(';')
         for query in queries:
             new_query = ' '.join(query.split())
             if new_query:
                 cr.execute(new_query)
     elif ext == '.csv':
         tools.convert_csv_import(cr,
                                  module_name,
                                  pathname,
                                  open_file.read(),
                                  idref=None,
                                  mode='update',
                                  noupdate=False)
     elif ext == '.yml':
         tools.convert_yaml_import(cr,
                                   module_name,
                                   open_file,
                                   idref=None,
                                   mode='update',
                                   noupdate=False)
     else:
         tools.convert_xml_import(cr,
                                  module_name,
                                  open_file,
                                  idref=None,
                                  mode='update',
                                  noupdate=False)
Example #5
0
    def install_report(self, cr, uid, ids, context=None):
        report_obj = self.pool.get('ir.actions.report.xml')
        this = self.browse(cr, uid, ids[0], context=context)
        if report_obj.search(cr, uid, [('report_name','=',this.name)], context=context):
            raise osv.except_osv(_('Warning!'), _('Report with service name "%s" already exist in system!') % this.name)
        fd = StringIO()
        fd.write(base64.decodestring(this.file))
        fd.seek(0)
        convert_xml_import(cr, 'report_aeroo', fd, {}, 'init', noupdate=True)
        fd.close()
        self.write(cr, uid, ids, {'state':'done'}, context=context)
        report_id = report_obj.search(cr, uid, [('report_name','=',this.name)], context=context)[-1]
        report = report_obj.browse(cr, uid, report_id, context=context)
        event_id = self.pool.get('ir.values').set_action(cr, uid, report.report_name, 'client_print_multi', report.model, 'ir.actions.report.xml,%d' % report_id)
        if report.report_wizard:
            report._set_report_wizard(report.id)

        mod_obj = self.pool.get('ir.model.data')
        act_obj = self.pool.get('ir.actions.act_window')

        mod_id = mod_obj.search(cr, uid, [('name', '=', 'action_aeroo_report_xml_tree')])[0]
        res_id = mod_obj.read(cr, uid, mod_id, ['res_id'])['res_id']
        act_win = act_obj.read(cr, uid, res_id, [])
        act_win['domain'] = [('id','=',report_id)]
        return act_win
Example #6
0
 def load_init_update_xml(cr, m, idref, mode, kind):
     for filename in package.data.get('%s_xml' % kind, []):
         logger.notifyChannel('init', netsvc.LOG_INFO,
                              'module %s: loading %s' % (m, filename))
         _, ext = os.path.splitext(filename)
         fp = tools.file_open(opj(m, filename))
         try:
             if ext == '.csv':
                 noupdate = (kind == 'init')
                 tools.convert_csv_import(cr,
                                          m,
                                          os.path.basename(filename),
                                          fp.read(),
                                          idref,
                                          mode=mode,
                                          noupdate=noupdate)
             elif ext == '.sql':
                 process_sql_file(cr, fp)
             elif ext == '.yml':
                 tools.convert_yaml_import(cr,
                                           m,
                                           fp,
                                           idref,
                                           mode=mode,
                                           **kwargs)
             else:
                 tools.convert_xml_import(cr,
                                          m,
                                          fp,
                                          idref,
                                          mode=mode,
                                          **kwargs)
         finally:
             fp.close()
Example #7
0
 def init(self, cr):
     """
     Load msf_cross_docking_data.xml before self
     """
     if hasattr(super(stock_picking, self), 'init'):
         super(stock_picking, self).init(cr)
     logging.getLogger('init').info('HOOK: module msf_cross_docking: loading data/msf_msf_cross_docking_data.xml')
     pathname = path.join('msf_cross_docking', 'data/msf_cross_docking_data.xml')
     file = tools.file_open(pathname)
     tools.convert_xml_import(cr, 'msf_cross_docking', file, {}, mode='init', noupdate=False)
Example #8
0
 def action_create(self, cr, uid, ids, *args):
     res=super(crm_menu_config_wizard, self).action_create(cr, uid, ids, *args)
     for res in self.read(cr,uid,ids):
         res.__delitem__('id')
         for section in res :
             if res[section]:
                 file_name = 'crm_'+section+'_vertical_view.xml'
                 try:
                     tools.convert_xml_import(cr, 'crm_configuration', tools.file_open(os.path.join('crm_vertical',file_name )),  {}, 'init', *args)
                 except Exception, e:
                     raise osv.except_osv(_('Error !'), str(e))
Example #9
0
 def load_demo_xml(cr, m, idref, mode):
     for xml in package.data.get('demo_xml', []):
         name, ext = os.path.splitext(xml)
         logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, xml))
         fp = tools.file_open(opj(m, xml))
         if ext == '.csv':
             tools.convert_csv_import(cr, m, os.path.basename(xml), fp.read(), idref, mode=mode, noupdate=True)
         elif ext == '.yml':
             tools.convert_yaml_import(cr, m, fp, idref, mode=mode, noupdate=True, **kwargs)
         else:
             tools.convert_xml_import(cr, m, fp, idref, mode=mode, noupdate=True, **kwargs)
         fp.close()
Example #10
0
    def init(self, cr):
        """
        Load setup_data.xml before self
        """
        if hasattr(super(unifield_setup_configuration, self), 'init'):
            super(unifield_setup_configuration, self).init(cr)

        mod_obj = self.pool.get('ir.module.module')
        logging.getLogger('init').info('HOOK: module unifield_setup: loading setup_data.xml')
        pathname = path.join('unifield_setup', 'setup_data.xml')
        file = tools.file_open(pathname)
        tools.convert_xml_import(cr, 'unifield_setup', file, {}, mode='init', noupdate=False)
    def execute(self, cr, uid, ids, context=None):
        res = self.read(cr, uid, ids)
        if res and res[0]:
            if res[0]['create']:
                fp = tools.file_open(opj('msf_chart_of_account', 'data/journal_data.xml'))
                tools.convert_xml_import(cr, 'msf_chart_of_account', fp, {}, 'init', True, None)
                fp.close()

            if res[0]['import_invoice_default_account']:
                self.pool.get('res.users').browse(cr, uid, uid).company_id.write({'import_invoice_default_account': res[0]['import_invoice_default_account']})
            if res[0]['counterpart_hq_entries_default_account']:
                self.pool.get('res.users').browse(cr, uid, uid).company_id.write({'counterpart_hq_entries_default_account': res[0]['counterpart_hq_entries_default_account']})
        return {}
 def create_zipcodes(self, cr, uid, ids, res, context):
     """Import Spanish cities and zip codes (15000 zip codes can take several minutes)"""
     if res['city_module'] == 'uninstalled': # city module no installed
         self._create_defaults(cr, uid, context)
     else:                                   # city module installed
         try:
             fp = tools.file_open(os.path.join('l10n_es_toponyms', 'l10n_es_toponyms_zipcodes.xml'))
         except IOError, e:
             fp = None
         if fp:
             idref = {}
             tools.convert_xml_import(cr, 'l10n_es_toponyms', fp,  idref, 'init', noupdate=True)
             if res['city_info_recover'] == 'yes':
                 res= self._recover_zipcodes(cr, uid, context)
Example #13
0
    def init(self, cr):
        """
        Load data (msf_doc_import_data.xml) before self
        """
        if hasattr(super(sale_order, self), 'init'):
            super(sale_order, self).init(cr)

        mod_obj = self.pool.get('ir.module.module')
        mode = mod_obj.search(cr, 1, [('name', '=', 'msf_doc_import'), ('state', '=', 'to install')]) and 'init' or 'update'
        logging.getLogger('init').info('HOOK: module msf_doc_import: loading data/msf_doc_import_data.xml')
        pathname = path.join('msf_doc_import', 'data/msf_doc_import_data.xml')
        file = tools.file_open(pathname)
        # mode to force noupdate=True when reloading this module
        tools.convert_xml_import(cr, 'msf_doc_import', file, {}, mode=mode, noupdate=True)
Example #14
0
 def load_init_update_xml(cr, m, idref, mode, kind):
     for filename in package.data.get('%s_xml' % kind, []):
         logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, filename))
         _, ext = os.path.splitext(filename)
         fp = tools.file_open(opj(m, filename))
         if ext == '.csv':
             noupdate = (kind == 'init')
             tools.convert_csv_import(cr, m, os.path.basename(filename), fp.read(), idref, mode=mode, noupdate=noupdate)
         elif ext == '.sql':
             process_sql_file(cr, fp)
         elif ext == '.yml':
             tools.convert_yaml_import(cr, m, fp, idref, mode=mode, **kwargs)
         else:
             tools.convert_xml_import(cr, m, fp, idref, mode=mode, **kwargs)
         fp.close()
Example #15
0
 def execute(self, cr, uid, ids, context=None):
     """Override of code in order to be able to link journal with account in XML"""
     res = super(WizardMultiChartsAccounts,
                 self).execute(cr, uid, ids, context)
     path = addons.get_module_resource(
         os.path.join('l10n_ch', 'sterchi_chart',
                      'account_journal_rel.xml'))
     tools.convert_xml_import(cr,
                              'l10n_ch',
                              path,
                              idref=None,
                              mode='init',
                              noupdate=True,
                              report=None)
     return res
Example #16
0
 def _run_test(self, cr, module_name, filename):
     _, ext = os.path.splitext(filename)
     pathname = os.path.join(module_name, filename)
     open_file = tools.file_open(pathname)
     if ext == '.sql':
         queries = open_file.read().split(';')
         for query in queries:
             new_query = ' '.join(query.split())
             if new_query:
                 cr.execute(new_query)
     elif ext == '.csv':
         tools.convert_csv_import(cr, module_name, pathname, open_file.read(), idref=None, mode='update', noupdate=False)
     elif ext == '.yml':
         tools.convert_yaml_import(cr, module_name, open_file, idref=None, mode='update', noupdate=False)
     else:
         tools.convert_xml_import(cr, module_name, open_file, idref=None, mode='update', noupdate=False)
Example #17
0
    def init(self, cr):
        """
        Load data (product_data.xml) before self
        """
        if hasattr(super(purchase_order, self), 'init'):
            super(purchase_order, self).init(cr)

        logging.getLogger('init').info('HOOK: module product: loading product_data.xml')
        pathname = path.join('product', 'product_data.xml')
        file = tools.file_open(pathname)
        tools.convert_xml_import(cr, 'product', file, {}, mode='init', noupdate=False)

        logging.getLogger('init').info('HOOK: module product_attributes: loading data/sale_data.yml')
        pathname = path.join('product_attributes', 'data', 'sale_data.yml')
        file = tools.file_open(pathname)
        tools.convert_yaml_import(cr, 'product_attributes', file, {}, mode='init', noupdate=False)
Example #18
0
 def _load_data(cr, module_name, id_map, mode, kind):
     noupdate = (kind == 'demo')
     for filename in package.data.get(kind, []):
         _, ext = os.path.splitext(filename)
         log.info("module %s: loading %s", module_name, filename)
         pathname = os.path.join(module_name, filename)
         file = tools.file_open(pathname)
         # TODO manage .csv file with noupdate == (kind == 'init')
         if ext == '.sql':
             process_sql_file(cr, file)
         elif ext == '.csv':
             noupdate = (kind == 'init')
             tools.convert_csv_import(cr, module_name, pathname, file.read(), id_map, mode, noupdate)
         elif ext == '.yml':
             tools.convert_yaml_import(cr, module_name, file, id_map, mode, noupdate)
         else:
             tools.convert_xml_import(cr, module_name, file, id_map, mode, noupdate)
         file.close()
Example #19
0
    def init(self, cr):
        """
        Load reason_type_data.xml brefore product
        """
        if hasattr(super(stock_reason_type, self), 'init'):
            super(stock_reason_type, self).init(cr)

        mod_obj = self.pool.get('ir.module.module')
        demo = False
        mod_id = mod_obj.search(cr, 1, [('name', '=', 'reason_types_moves')])
        if mod_id:
            demo = mod_obj.read(cr, 1, mod_id, ['demo'])[0]['demo']

        if demo:
            logging.getLogger('init').info('HOOK: module reason_types_moves: loading reason_type_data.xml')
            pathname = path.join('reason_types_moves', 'reason_type_data.xml')
            file = tools.file_open(pathname)
            tools.convert_xml_import(cr, 'reason_types_moves', file, {}, mode='init', noupdate=False)
Example #20
0
    def init(self, cr):
        """
            Create a instance for yml test
        """
        if hasattr(super(res_company, self), 'init'):
            super(res_company, self).init(cr)

        mod_obj = self.pool.get('ir.module.module')
        demo = False
        mod_id = mod_obj.search(cr, 1, [('name', '=', 'msf_instance')])
        if mod_id:
            demo = mod_obj.read(cr, 1, mod_id, ['demo'])[0]['demo']
        if demo:
            current_module = 'msf_instance'
            file_to_load = '%s/data/instance_data.xml' % (current_module, )

            logging.getLogger('init').info('HOOK: module msf_instance: loading %s' % file_to_load)
            file = tools.file_open(file_to_load)
            tools.convert_xml_import(cr, current_module, file, {}, mode='init', noupdate=False)
Example #21
0
 def action_create(self, cr, uid, ids, context=None):
     module_proxy = self.pool.get('ir.module.module')
     modid = module_proxy.search(cr, uid, [('name', '=', 'crm_configuration')])
     moddemo = module_proxy.browse(cr, uid, modid[0]).demo
     lst = ('data', 'menu')
     if moddemo:
         lst = ('data', 'menu', 'demo')
     res = self.read(cr, uid, ids)[0]
     idref = {}
     for section in ['meeting', 'lead', 'opportunity', 'jobs', 'bugs', 'fund', 'helpdesk', 'claims', 'phonecall']:
         if (not res[section]):
             continue
         for fname in lst:
             file_name = 'crm_' + section + '_' + fname + '.xml'
             try:
                 fp = tools.file_open(os.path.join('crm_configuration', file_name))
             except IOError, e:
                 fp = None
             if fp:
                 tools.convert_xml_import(cr, 'crm_configuration', fp, idref, 'init', noupdate=True)
Example #22
0
def load_data(cr, module_name, filename, idref=None, mode="init"):
    """
    Load an xml or csv data file from your post script. The usual case for this is the
    occurrence of newly added essential or useful data in the module that is
    marked with "noupdate='1'" and without "forcecreate='1'" so that it will
    not be loaded by the usual upgrade mechanism. Leaving the 'mode' argument to
    its default 'init' will load the data from your migration script.
    
    Theoretically, you could simply load a stock file from the module, but be 
    careful not to reinitialize any data that could have been customized.
    Preferably, select only the newly added items. Copy these to a file
    in your migrations directory and load that file.
    Leave it to the user to actually delete existing resources that are
    marked with 'noupdate' (other named items will be deleted
    automatically).


    :param module_name: the name of the module
    :param filename: the path to the filename, relative to the module \
    directory.
    :param idref: optional hash with ?id mapping cache?
    :param mode: one of 'init', 'update', 'demo'. Always use 'init' for adding new items \
    from files that are marked with 'noupdate'. Defaults to 'init'.

    """
    import tools

    if idref is None:
        idref = {}
    logger.info("%s: loading %s" % (module_name, filename))
    _, ext = os.path.splitext(filename)
    pathname = os.path.join(module_name, filename)
    fp = tools.file_open(pathname)
    try:
        if ext == ".csv":
            noupdate = True
            tools.convert_csv_import(cr, module_name, pathname, fp.read(), idref, mode, noupdate)
        else:
            tools.convert_xml_import(cr, module_name, fp, idref, mode=mode)
    finally:
        fp.close()
Example #23
0
    def init(self, cr):
        """
        Load demo.xml before addons
        """
        if hasattr(super(account_journal, self), 'init'):
            super(account_journal, self).init(cr)

        mod_obj = self.pool.get('ir.module.module')
        demo = False
        mod_id = mod_obj.search(cr, 1, [('name', '=', 'account_journal')])
        if mod_id:
            demo = mod_obj.read(cr, 1, mod_id, ['demo'])[0]['demo']

        if demo:
            # Search if an engagement journal exists
            eng_ids = self.pool.get('account.analytic.journal').search(cr, 1, [('type', '=', 'engagement')])
            if not len(eng_ids):
                logging.getLogger('init').info('HOOK: module account_journal: loading account_journal_demo.xml')
                pathname = path.join('account_journal', 'account_journal_demo.xml')
                file = tools.file_open(pathname)
                tools.convert_xml_import(cr, 'account_journal', file, {}, mode='init', noupdate=False)
Example #24
0
 def _load_data(cr, module_name, id_map, mode, kind):
     noupdate = (kind == 'demo')
     for filename in package.data.get(kind, []):
         _, ext = os.path.splitext(filename)
         log.info("module %s: loading %s", module_name, filename)
         pathname = os.path.join(module_name, filename)
         file = tools.file_open(pathname)
         # TODO manage .csv file with noupdate == (kind == 'init')
         if ext == '.sql':
             process_sql_file(cr, file)
         elif ext == '.csv':
             noupdate = (kind == 'init')
             tools.convert_csv_import(cr, module_name, pathname,
                                      file.read(), id_map, mode, noupdate)
         elif ext == '.yml':
             tools.convert_yaml_import(cr, module_name, file, id_map, mode,
                                       noupdate)
         else:
             tools.convert_xml_import(cr, module_name, file, id_map, mode,
                                      noupdate)
         file.close()
Example #25
0
class config_es_toponyms(osv.osv_memory):
    _name = 'config.es.toponyms'
    _inherit = 'res.config.installer'

    _columns = {
        'name':
        fields.char('Name', size=64),
        'state':
        fields.selection(
            [('official', 'Official'), ('spanish', 'Spanish'),
             ('both', 'Both')],
            'State names',
            required=True,
            help=
            "Toponym version of the spanish states. For example: Official (Girona), Spanish (Gerona), Both (Gerona / Girona)"
        ),
        'city_info':
        fields.selection(
            [('yes', 'Yes'), ('no', 'No')],
            'City information',
            required=True,
            help=
            "Do you want to add city and state information associated to the zip codes for all the spanish cities? This allows to fill automatically the city and states fields of partner and contact forms from the zip code."
        ),
    }

    _defaults = {
        'state': lambda *args: 'official',
        'city_info': lambda *args: 'yes',
    }

    def create_states(self, cr, uid, state_type, context=None):
        """It imports spanish states information trough an XML file."""
        file_name = 'l10n_es_toponyms_states_%s.xml' % state_type
        try:
            fp = tools.file_open(
                os.path.join('l10n_es_toponyms',
                             os.path.join('wizard', file_name)))
        except IOError, e:
            fp = None
        if fp:
            idref = {}
            tools.convert_xml_import(cr,
                                     'l10n_es_toponyms',
                                     fp,
                                     idref,
                                     'init',
                                     noupdate=True)
            cr.commit()
            return True
        return False
Example #26
0
 def create_zipcodes(self, db_name, uid, ids, res, context):
     # Import Spanish cities and zip codes (15000 zip codes can take several minutes)
     db, pool = pooler.get_db_and_pool(db_name)
     cr = db.cursor()
     if res['city_module'] == 'uninstalled':  # city module no installed
         self._create_defaults(cr, uid, context)
     else:  # city module installed
         try:
             fp = tools.file_open(
                 os.path.join('l10n_es_toponyms',
                              'l10n_es_toponyms_zipcodes.xml'))
         except IOError, e:
             fp = None
         if fp:
             idref = {}
             tools.convert_xml_import(cr,
                                      'l10n_es_toponyms',
                                      fp,
                                      idref,
                                      'init',
                                      noupdate=True)
             if res['city_info_recover'] == 'yes':
                 res = self._recover_zipcodes(cr, uid, context)
Example #27
0
class l10n_es_partner_import_wizard(osv.osv_memory):
    _name = 'l10n.es.partner.import.wizard'

    def action_import(self, cr, uid, ids, context=None):
        try:
            fp = tools.file_open(
                os.path.join('l10n_es_partner', 'data_banks.xml'))
        except IOError, e:
            return {}
        idref = {}
        tools.convert_xml_import(cr,
                                 'l10n_es_partner',
                                 fp,
                                 idref,
                                 'init',
                                 noupdate=True)
        return {}
class config_es_toponyms(osv.osv_memory):
    _name = 'config.es.toponyms'
    _inherit = 'res.config.installer'

    _columns = {
        'name':
        fields.char('Name', size=64),
        'state':
        fields.selection([('official', 'Official'), ('spanish', 'Spanish'),
                          ('both', 'Both')],
                         'State names',
                         required=True),
        'city_info':
        fields.selection([('yes', 'Yes'), ('no', 'No')],
                         'City information',
                         required=True),
    }

    _defaults = {
        'state': lambda *args: 'official',
        'city_info': lambda *args: 'yes',
    }

    def create_states(self, cr, uid, state_type, context=None):
        """Import spanish states information through an XML file."""
        file_name = 'l10n_es_toponyms_states_%s.xml' % state_type
        try:
            fp = tools.file_open(
                os.path.join('l10n_es_toponyms',
                             os.path.join('wizard', file_name)))
        except IOError, e:
            fp = None
        if fp:
            idref = {}
            tools.convert_xml_import(cr,
                                     'l10n_es_toponyms',
                                     fp,
                                     idref,
                                     'init',
                                     noupdate=True)
            cr.commit()
            return True
        return False
Example #29
0
    def execute(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        fy_obj = self.pool.get('account.fiscalyear')
        mod_obj = self.pool.get('ir.model.data')
        obj_acc_temp = self.pool.get('account.account.template')
        obj_tax_code_temp = self.pool.get('account.tax.code.template')
        obj_tax_temp = self.pool.get('account.tax.template')
        obj_acc_chart_temp = self.pool.get('account.chart.template')
        record = self.browse(cr, uid, ids, context=context)[0]
        for res in self.read(cr, uid, ids, context=context):
            if record.charts == 'configurable':
                fp = tools.file_open(opj('account', 'configurable_account_chart.xml'))
                tools.convert_xml_import(cr, 'account', fp, {}, 'init', True, None)
                fp.close()
                s_tax = (res.get('sale_tax', 0.0))/100
                p_tax = (res.get('purchase_tax', 0.0))/100
                pur_temp_tax = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_base_purchases')
                pur_temp_tax_id = pur_temp_tax and pur_temp_tax[1] or False

                pur_temp_tax_paid = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_output')
                pur_temp_tax_paid_id = pur_temp_tax_paid and pur_temp_tax_paid[1] or False

                sale_temp_tax = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_base_sales')
                sale_temp_tax_id = sale_temp_tax and sale_temp_tax[1] or False

                sale_temp_tax_paid = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_input')
                sale_temp_tax_paid_id = sale_temp_tax_paid and sale_temp_tax_paid[1] or False

                chart_temp_ids = obj_acc_chart_temp.search(cr, uid, [('name','=','Configurable Account Chart Template')], context=context)
                chart_temp_id = chart_temp_ids and chart_temp_ids[0] or False
                if s_tax * 100 > 0.0:
                    tax_account_ids = obj_acc_temp.search(cr, uid, [('name', '=', 'Tax Received')], context=context)
                    sales_tax_account_id = tax_account_ids and tax_account_ids[0] or False
                    vals_tax_code_temp = {
                        'name': _('TAX %s%%') % (s_tax*100),
                        'code': _('TAX %s%%') % (s_tax*100),
                        'parent_id': sale_temp_tax_id
                    }
                    new_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_tax_code_temp, context=context)
                    vals_paid_tax_code_temp = {
                        'name': _('TAX Received %s%%') % (s_tax*100),
                        'code': _('TAX Received %s%%') % (s_tax*100),
                        'parent_id': sale_temp_tax_paid_id
                    }
                    new_paid_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_paid_tax_code_temp, context=context)
                    sales_tax_temp = obj_tax_temp.create(cr, uid, {
                                            'name': _('TAX %s%%') % (s_tax*100),
                                            'amount': s_tax,
                                            'base_code_id': new_tax_code_temp,
                                            'tax_code_id': new_paid_tax_code_temp,
                                            'ref_base_code_id': new_tax_code_temp,
                                            'ref_tax_code_id': new_paid_tax_code_temp,
                                            'type_tax_use': 'sale',
                                            'type': 'percent',
                                            'sequence': 0,
                                            'account_collected_id': sales_tax_account_id,
                                            'account_paid_id': sales_tax_account_id,
                                            'chart_template_id': chart_temp_id,
                                }, context=context)
                if p_tax * 100 > 0.0:
                    tax_account_ids = obj_acc_temp.search(cr, uid, [('name', '=', 'Tax Paid')], context=context)
                    purchase_tax_account_id = tax_account_ids and tax_account_ids[0] or False
                    vals_tax_code_temp = {
                        'name': _('TAX %s%%') % (p_tax*100),
                        'code': _('TAX %s%%') % (p_tax*100),
                        'parent_id': pur_temp_tax_id
                    }
                    new_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_tax_code_temp, context=context)
                    vals_paid_tax_code_temp = {
                        'name': _('TAX Paid %s%%') % (p_tax*100),
                        'code': _('TAX Paid %s%%') % (p_tax*100),
                        'parent_id': pur_temp_tax_paid_id
                    }
                    new_paid_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_paid_tax_code_temp, context=context)
                    purchase_tax_temp = obj_tax_temp.create(cr, uid, {
                                             'name': _('TAX %s%%') % (p_tax*100),
                                             'description': _('TAX %s%%') % (p_tax*100),
                                             'amount': p_tax,
                                             'base_code_id': new_tax_code_temp,
                                             'tax_code_id': new_paid_tax_code_temp,
                                             'ref_base_code_id': new_tax_code_temp,
                                             'ref_tax_code_id': new_paid_tax_code_temp,
                                             'type_tax_use': 'purchase',
                                             'type': 'percent',
                                             'sequence': 0,
                                             'account_collected_id': purchase_tax_account_id,
                                             'account_paid_id': purchase_tax_account_id,
                                             'chart_template_id': chart_temp_id,
                                    }, context=context)

            if 'date_start' in res and 'date_stop' in res:
                f_ids = fy_obj.search(cr, uid, [('date_start', '<=', res['date_start']), ('date_stop', '>=', res['date_stop']), ('company_id', '=', res['company_id'][0])], context=context)
                if not f_ids:
                    name = code = res['date_start'][:4]
                    if int(name) != int(res['date_stop'][:4]):
                        name = res['date_start'][:4] +'-'+ res['date_stop'][:4]
                        code = res['date_start'][2:4] +'-'+ res['date_stop'][2:4]
                    vals = {
                        'name': name,
                        'code': code,
                        'date_start': res['date_start'],
                        'date_stop': res['date_stop'],
                        'company_id': res['company_id'][0]
                    }
                    fiscal_id = fy_obj.create(cr, uid, vals, context=context)
                    if res['period'] == 'month':
                        fy_obj.create_period(cr, uid, [fiscal_id])
                    elif res['period'] == '3months':
                        fy_obj.create_period3(cr, uid, [fiscal_id])
        super(account_installer, self).execute(cr, uid, ids, context=context)
Example #30
0
        if context is None:
            context = {}
        super(config_es_toponyms, self).execute(cr, uid, ids, context=context)
        res = self.read(cr, uid, ids)[0]

        # Import Spanish states (official, Spanish or both)
        file_name = 'l10n_es_toponyms_states_' + res['state'] + '.xml'
        try:
            fp = tools.file_open(os.path.join('l10n_es_toponyms', file_name))
        except IOError, e:
            fp = None
        if fp:
            idref = {}
            tools.convert_xml_import(cr,
                                     'l10n_es_toponyms',
                                     fp,
                                     idref,
                                     'init',
                                     noupdate=True)

        # Import Spanish cities and zip codes in other thread (15000 zip codes can take several minutes)
        if res['city_info'] == 'yes':
            cr.commit()
            thread1 = threading.Thread(target=self.create_zipcodes,
                                       args=(cr.dbname, uid, ids, res,
                                             context))
            thread1.start()


config_es_toponyms()
Example #31
0
    def execute(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        super(account_installer, self).execute(cr, uid, ids, context=context)
        fy_obj = self.pool.get('account.fiscalyear')
        mod_obj = self.pool.get('ir.model.data')
        obj_acc = self.pool.get('account.account')
        obj_tax_code = self.pool.get('account.tax.code')
        obj_temp_tax_code = self.pool.get('account.tax.code.template')
        obj_tax = self.pool.get('account.tax')
        obj_product = self.pool.get('product.product')
        ir_values = self.pool.get('ir.values')
        record = self.browse(cr, uid, ids, context=context)[0]
        company_id = record.company_id
        for res in self.read(cr, uid, ids, context=context):
            if record.charts == 'configurable':
                fp = tools.file_open(opj('account', 'configurable_account_chart.xml'))
                tools.convert_xml_import(cr, 'account', fp, {}, 'init', True, None)
                fp.close()
                self.generate_configurable_chart(cr, uid, ids, context=context)
                s_tax = (res.get('sale_tax', 0.0))/100
                p_tax = (res.get('purchase_tax', 0.0))/100
                tax_val = {}
                default_tax = []

                pur_temp_tax = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_base_purchases')
                pur_temp_tax_id = pur_temp_tax and pur_temp_tax[1] or False

                pur_temp_tax_names = obj_temp_tax_code.read(cr, uid, [pur_temp_tax_id], ['name'], context=context)
                pur_tax_parent_name = pur_temp_tax_names and pur_temp_tax_names[0]['name'] or False
                pur_taxcode_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', pur_tax_parent_name)], context=context)
                if pur_taxcode_parent_id:
                    pur_taxcode_parent_id = pur_taxcode_parent_id[0]
                else:
                    pur_taxcode_parent_id = False
                pur_temp_tax_paid = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_input')
                pur_temp_tax_paid_id = pur_temp_tax_paid and pur_temp_tax_paid[1] or False
                pur_temp_tax_paid_names = obj_temp_tax_code.read(cr, uid, [pur_temp_tax_paid_id], ['name'], context=context)
                pur_tax_paid_parent_name = pur_temp_tax_names and pur_temp_tax_paid_names[0]['name'] or False
                pur_taxcode_paid_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', pur_tax_paid_parent_name)], context=context)
                if pur_taxcode_paid_parent_id:
                    pur_taxcode_paid_parent_id = pur_taxcode_paid_parent_id[0]
                else:
                    pur_taxcode_paid_parent_id = False

                sale_temp_tax = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_base_sales')
                sale_temp_tax_id = sale_temp_tax and sale_temp_tax[1] or False
                sale_temp_tax_names = obj_temp_tax_code.read(cr, uid, [sale_temp_tax_id], ['name'], context=context)
                sale_tax_parent_name = sale_temp_tax_names and sale_temp_tax_names[0]['name'] or False
                sale_taxcode_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', sale_tax_parent_name)], context=context)
                if sale_taxcode_parent_id:
                    sale_taxcode_parent_id = sale_taxcode_parent_id[0]
                else:
                    sale_taxcode_parent_id = False

                sale_temp_tax_paid = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_output')
                sale_temp_tax_paid_id = sale_temp_tax_paid and sale_temp_tax_paid[1] or False
                sale_temp_tax_paid_names = obj_temp_tax_code.read(cr, uid, [sale_temp_tax_paid_id], ['name'], context=context)
                sale_tax_paid_parent_name = sale_temp_tax_paid_names and sale_temp_tax_paid_names[0]['name'] or False
                sale_taxcode_paid_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', sale_tax_paid_parent_name)], context=context)
                if sale_taxcode_paid_parent_id:
                    sale_taxcode_paid_parent_id = sale_taxcode_paid_parent_id[0]
                else:
                    sale_taxcode_paid_parent_id = False

                if s_tax*100 > 0.0:
                    tax_account_ids = obj_acc.search(cr, uid, [('name', '=', 'Tax Received')], context=context)
                    sales_tax_account_id = tax_account_ids and tax_account_ids[0] or False
                    vals_tax_code = {
                        'name': 'TAX%s%%'%(s_tax*100),
                        'code': 'TAX%s%%'%(s_tax*100),
                        'company_id': company_id.id,
                        'sign': 1,
                        'parent_id': sale_taxcode_parent_id
                    }
                    new_tax_code = obj_tax_code.create(cr, uid, vals_tax_code, context=context)

                    vals_paid_tax_code = {
                        'name': 'TAX Received %s%%'%(s_tax*100),
                        'code': 'TAX Received %s%%'%(s_tax*100),
                        'company_id': company_id.id,
                        'sign': 1,
                        'parent_id': sale_taxcode_paid_parent_id
                        }
                    new_paid_tax_code = obj_tax_code.create(cr, uid, vals_paid_tax_code, context=context)

                    sales_tax = obj_tax.create(cr, uid,
                                           {'name': 'TAX %s%%'%(s_tax*100),
                                            'amount': s_tax,
                                            'base_code_id': new_tax_code,
                                            'tax_code_id': new_paid_tax_code,
                                            'type_tax_use': 'sale',
                                            'account_collected_id': sales_tax_account_id,
                                            'account_paid_id': sales_tax_account_id
                                            }, context=context)
                    default_account_ids = obj_acc.search(cr, uid, [('name', '=', 'Product Sales')], context=context)
                    if default_account_ids:
                        obj_acc.write(cr, uid, default_account_ids, {'tax_ids': [(6, 0, [sales_tax])]}, context=context)
                    tax_val.update({'taxes_id': [(6, 0, [sales_tax])]})
                    default_tax.append(('taxes_id', sales_tax))
                if p_tax*100 > 0.0:
                    tax_account_ids = obj_acc.search(cr, uid, [('name', '=', 'Tax Paid')], context=context)
                    purchase_tax_account_id = tax_account_ids and tax_account_ids[0] or False
                    vals_tax_code = {
                        'name': 'TAX%s%%'%(p_tax*100),
                        'code': 'TAX%s%%'%(p_tax*100),
                        'company_id': company_id.id,
                        'sign': 1,
                        'parent_id': pur_taxcode_parent_id
                    }
                    new_tax_code = obj_tax_code.create(cr, uid, vals_tax_code, context=context)
                    vals_paid_tax_code = {
                        'name': 'TAX Paid %s%%'%(p_tax*100),
                        'code': 'TAX Paid %s%%'%(p_tax*100),
                        'company_id': company_id.id,
                        'sign': 1,
                        'parent_id': pur_taxcode_paid_parent_id
                    }
                    new_paid_tax_code = obj_tax_code.create(cr, uid, vals_paid_tax_code, context=context)

                    purchase_tax = obj_tax.create(cr, uid,
                                            {'name': 'TAX%s%%'%(p_tax*100),
                                             'description': 'TAX%s%%'%(p_tax*100),
                                             'amount': p_tax,
                                             'base_code_id': new_tax_code,
                                            'tax_code_id': new_paid_tax_code,
                                            'type_tax_use': 'purchase',
                                            'account_collected_id': purchase_tax_account_id,
                                            'account_paid_id': purchase_tax_account_id
                                             }, context=context)
                    default_account_ids = obj_acc.search(cr, uid, [('name', '=', 'Expenses')], context=context)
                    if default_account_ids:
                        obj_acc.write(cr, uid, default_account_ids, {'tax_ids': [(6, 0, [purchase_tax])]}, context=context)
                    tax_val.update({'supplier_taxes_id': [(6 ,0, [purchase_tax])]})
                    default_tax.append(('supplier_taxes_id', purchase_tax))
                if tax_val:
                    product_ids = obj_product.search(cr, uid, [], context=context)
                    for product in obj_product.browse(cr, uid, product_ids, context=context):
                        obj_product.write(cr, uid, product.id, tax_val, context=context)
                    for name, value in default_tax:
                        ir_values.set(cr, uid, key='default', key2=False, name=name, models =[('product.product', False)], value=[value])

            if 'date_start' in res and 'date_stop' in res:
                f_ids = fy_obj.search(cr, uid, [('date_start', '<=', res['date_start']), ('date_stop', '>=', res['date_stop']), ('company_id', '=', res['company_id'])], context=context)
                if not f_ids:
                    name = code = res['date_start'][:4]
                    if int(name) != int(res['date_stop'][:4]):
                        name = res['date_start'][:4] +'-'+ res['date_stop'][:4]
                        code = res['date_start'][2:4] +'-'+ res['date_stop'][2:4]
                    vals = {
                        'name': name,
                        'code': code,
                        'date_start': res['date_start'],
                        'date_stop': res['date_stop'],
                        'company_id': res['company_id']
                    }
                    fiscal_id = fy_obj.create(cr, uid, vals, context=context)
                    if res['period'] == 'month':
                        fy_obj.create_period(cr, uid, [fiscal_id])
                    elif res['period'] == '3months':
                        fy_obj.create_period3(cr, uid, [fiscal_id])
			idref = {}
			tools.convert_xml_import(cr, 'l10n_es_toponyms', fp,  idref, 'init', noupdate=True)
			cr.commit()
			return True
		return False
	
    def create_zipcodes(self, cr, uid, context=None):
        """Import spanish zipcodes information through an XML file."""
        file_name = 'l10n_es_toponyms_zipcodes.xml'
        try:
            fp = tools.file_open(os.path.join('l10n_es_toponyms', os.path.join('wizard', file_name)))
        except IOError, e:
            fp = None
        if fp:
            idref = {}
            tools.convert_xml_import(cr, 'l10n_es_toponyms', fp,  idref, 'init', noupdate=True)
            cr.commit()
            return True
        return False

    def execute(self, cr, uid, ids, context=None):
		if context is None: context = {}
		super(config_es_toponyms, self).execute(cr, uid, ids, context=context)
		res = self.read(cr, uid, ids)[0]
		# Import spanish states (official, Spanish or both)
		self.create_states(cr, uid, res['state'], context=context)
		# Import spanish cities and zip codes
		if res['city_info'] == 'yes':
			self.create_zipcodes(cr, uid, context=context)

config_es_toponyms()
Example #33
0
    def execute(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        fy_obj = self.pool.get("account.fiscalyear")
        mod_obj = self.pool.get("ir.model.data")
        obj_acc_temp = self.pool.get("account.account.template")
        obj_tax_code_temp = self.pool.get("account.tax.code.template")
        obj_tax_temp = self.pool.get("account.tax.template")
        obj_acc_chart_temp = self.pool.get("account.chart.template")
        record = self.browse(cr, uid, ids, context=context)[0]
        for res in self.read(cr, uid, ids, context=context):
            if record.charts == "configurable":
                fp = tools.file_open(opj("account", "configurable_account_chart.xml"))
                tools.convert_xml_import(cr, "account", fp, {}, "init", True, None)
                fp.close()
                s_tax = (res.get("sale_tax", 0.0)) / 100
                p_tax = (res.get("purchase_tax", 0.0)) / 100
                pur_temp_tax = mod_obj.get_object_reference(cr, uid, "account", "tax_code_base_purchases")
                pur_temp_tax_id = pur_temp_tax and pur_temp_tax[1] or False

                pur_temp_tax_paid = mod_obj.get_object_reference(cr, uid, "account", "tax_code_output")
                pur_temp_tax_paid_id = pur_temp_tax_paid and pur_temp_tax_paid[1] or False

                sale_temp_tax = mod_obj.get_object_reference(cr, uid, "account", "tax_code_base_sales")
                sale_temp_tax_id = sale_temp_tax and sale_temp_tax[1] or False

                sale_temp_tax_paid = mod_obj.get_object_reference(cr, uid, "account", "tax_code_input")
                sale_temp_tax_paid_id = sale_temp_tax_paid and sale_temp_tax_paid[1] or False

                chart_temp_ids = obj_acc_chart_temp.search(
                    cr, uid, [("name", "=", "Configurable Account Chart Template")], context=context
                )
                chart_temp_id = chart_temp_ids and chart_temp_ids[0] or False
                if s_tax * 100 > 0.0:
                    tax_account_ids = obj_acc_temp.search(cr, uid, [("name", "=", "Tax Received")], context=context)
                    sales_tax_account_id = tax_account_ids and tax_account_ids[0] or False
                    vals_tax_code_temp = {
                        "name": _("TAX %s%%") % (s_tax * 100),
                        "code": _("TAX %s%%") % (s_tax * 100),
                        "parent_id": sale_temp_tax_id,
                    }
                    new_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_tax_code_temp, context=context)
                    vals_paid_tax_code_temp = {
                        "name": _("TAX Received %s%%") % (s_tax * 100),
                        "code": _("TAX Received %s%%") % (s_tax * 100),
                        "parent_id": sale_temp_tax_paid_id,
                    }
                    new_paid_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_paid_tax_code_temp, context=context)
                    sales_tax_temp = obj_tax_temp.create(
                        cr,
                        uid,
                        {
                            "name": _("TAX %s%%") % (s_tax * 100),
                            "amount": s_tax,
                            "base_code_id": new_tax_code_temp,
                            "tax_code_id": new_paid_tax_code_temp,
                            "ref_base_code_id": new_tax_code_temp,
                            "ref_tax_code_id": new_paid_tax_code_temp,
                            "type_tax_use": "sale",
                            "type": "percent",
                            "sequence": 0,
                            "account_collected_id": sales_tax_account_id,
                            "account_paid_id": sales_tax_account_id,
                            "chart_template_id": chart_temp_id,
                        },
                        context=context,
                    )
                if p_tax * 100 > 0.0:
                    tax_account_ids = obj_acc_temp.search(cr, uid, [("name", "=", "Tax Paid")], context=context)
                    purchase_tax_account_id = tax_account_ids and tax_account_ids[0] or False
                    vals_tax_code_temp = {
                        "name": _("TAX %s%%") % (p_tax * 100),
                        "code": _("TAX %s%%") % (p_tax * 100),
                        "parent_id": pur_temp_tax_id,
                    }
                    new_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_tax_code_temp, context=context)
                    vals_paid_tax_code_temp = {
                        "name": _("TAX Paid %s%%") % (p_tax * 100),
                        "code": _("TAX Paid %s%%") % (p_tax * 100),
                        "parent_id": pur_temp_tax_paid_id,
                    }
                    new_paid_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_paid_tax_code_temp, context=context)
                    purchase_tax_temp = obj_tax_temp.create(
                        cr,
                        uid,
                        {
                            "name": _("TAX %s%%") % (p_tax * 100),
                            "description": _("TAX %s%%") % (p_tax * 100),
                            "amount": p_tax,
                            "base_code_id": new_tax_code_temp,
                            "tax_code_id": new_paid_tax_code_temp,
                            "ref_base_code_id": new_tax_code_temp,
                            "ref_tax_code_id": new_paid_tax_code_temp,
                            "type_tax_use": "purchase",
                            "type": "percent",
                            "sequence": 0,
                            "account_collected_id": purchase_tax_account_id,
                            "account_paid_id": purchase_tax_account_id,
                            "chart_template_id": chart_temp_id,
                        },
                        context=context,
                    )

            if "date_start" in res and "date_stop" in res:
                f_ids = fy_obj.search(
                    cr,
                    uid,
                    [
                        ("date_start", "<=", res["date_start"]),
                        ("date_stop", ">=", res["date_stop"]),
                        ("company_id", "=", res["company_id"][0]),
                    ],
                    context=context,
                )
                if not f_ids:
                    name = code = res["date_start"][:4]
                    if int(name) != int(res["date_stop"][:4]):
                        name = res["date_start"][:4] + "-" + res["date_stop"][:4]
                        code = res["date_start"][2:4] + "-" + res["date_stop"][2:4]
                    vals = {
                        "name": name,
                        "code": code,
                        "date_start": res["date_start"],
                        "date_stop": res["date_stop"],
                        "company_id": res["company_id"][0],
                    }
                    fiscal_id = fy_obj.create(cr, uid, vals, context=context)
                    if res["period"] == "month":
                        fy_obj.create_period(cr, uid, [fiscal_id])
                    elif res["period"] == "3months":
                        fy_obj.create_period3(cr, uid, [fiscal_id])
        super(account_installer, self).execute(cr, uid, ids, context=context)
Example #34
0
def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs):
    # **kwargs is passed directly to convert_xml_import
    if not status:
        status = {}

    status = status.copy()
    package_todo = []
    statusi = 0
    pool = pooler.get_pool(cr.dbname)

    migrations = MigrationManager(cr, graph)

    has_updates = False
    modobj = None

    for package in graph:
        logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading objects' % package.name)
        migrations.migrate_module(package, 'pre')
        register_class(package.name)
        modules = pool.instanciate(package.name, cr)
        if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
            init_module_objects(cr, package.name, modules)
        cr.commit()
        
    for package in graph:
        status['progress'] = (float(statusi)+0.1) / len(graph)
        m = package.name
        mid = package.id

        if modobj is None:
            modobj = pool.get('ir.module.module')

        if modobj and perform_checks:
            modobj.check(cr, 1, [mid])

        idref = {}
        status['progress'] = (float(statusi)+0.4) / len(graph)

        mode = 'update'
        if hasattr(package, 'init') or package.state == 'to install':
            mode = 'init'

        if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
            has_updates = True
            for kind in ('init', 'update'):
                if package.state=='to upgrade':
                    # upgrading the module information
                    modobj.write(cr, 1, [mid], {
                    'description': package.data.get('description', ''),
                    'shortdesc': package.data.get('name', ''),
                    'author': package.data.get('author', 'Unknown'),
                    'website': package.data.get('website', ''),
                    'license': package.data.get('license', 'GPL-2'),
                    'certificate': package.data.get('certificate') or None,
                    })
                for filename in package.data.get('%s_xml' % kind, []):
                    logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, filename))
                    name, ext = os.path.splitext(filename)
                    fp = tools.file_open(opj(m, filename))
                    if ext == '.csv':
                        tools.convert_csv_import(cr, m, os.path.basename(filename), fp.read(), idref, mode=mode)
                    elif ext == '.sql':
                        queries = fp.read().split(';')
                        for query in queries:
                            new_query = ' '.join(query.split())
                            if new_query:
                                cr.execute(new_query)
                    else:
                        tools.convert_xml_import(cr, m, fp, idref, mode=mode, **kwargs)
                    fp.close()
            if hasattr(package, 'demo') or (package.dbdemo and package.state != 'installed'):
                status['progress'] = (float(statusi)+0.75) / len(graph)
                for xml in package.data.get('demo_xml', []):
                    name, ext = os.path.splitext(xml)
                    logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, xml))
                    fp = tools.file_open(opj(m, xml))
                    if ext == '.csv':
                        tools.convert_csv_import(cr, m, os.path.basename(xml), fp.read(), idref, mode=mode, noupdate=True)
                    else:
                        tools.convert_xml_import(cr, m, fp, idref, mode=mode, noupdate=True, **kwargs)
                    fp.close()
                cr.execute('update ir_module_module set demo=%s where id=%s', (True, mid))
            package_todo.append(package.name)

            migrations.migrate_module(package, 'post')

            if modobj:
                ver = release.major_version + '.' + package.data.get('version', '1.0')
                # Set new modules and dependencies
                modobj.write(cr, 1, [mid], {'state': 'installed', 'latest_version': ver})
                cr.commit()
                # Update translations for all installed languages
                modobj.update_translations(cr, 1, [mid], None)
                cr.commit()

            package.state = 'installed'
            for kind in ('init', 'demo', 'update'):
                if hasattr(package, kind):
                    delattr(package, kind)

        statusi += 1

    cr.execute('select model from ir_model where state=%s', ('manual',))
    for model in cr.dictfetchall():
        pool.get('ir.model').instanciate(cr, 1, model['model'], {})

    pool.get('ir.model.data')._process_end(cr, 1, package_todo)
    cr.commit()

    return has_updates