Browse Source

[ADD] better progress

10.0
Holger Brunn 7 years ago
committed by OCA-git-bot
parent
commit
c0d97da261
  1. 2
      base_import_odoo/tests/test_base_import_odoo.py
  2. 20
      base_import_odoo/views/import_odoo_database.xml

2
base_import_odoo/tests/test_base_import_odoo.py

@ -73,6 +73,8 @@ class TestBaseImportOdoo(TransactionCase):
# TODO: test much more # TODO: test much more
run += 1 run += 1
demodb = self.env.ref('base_import_odoo.demodb') demodb = self.env.ref('base_import_odoo.demodb')
for line in demodb.import_line_ids:
self.assertIn(line.model_id.model, demodb.status_html)
demodb.action_import() demodb.action_import()
self.assertTrue(demodb.cronjob_id) self.assertTrue(demodb.cronjob_id)
demodb.cronjob_id.write({'active': False}) demodb.cronjob_id.write({'active': False})

20
base_import_odoo/views/import_odoo_database.xml

@ -20,13 +20,13 @@
<field name="cronjob_running" invisible="1" /> <field name="cronjob_running" invisible="1" />
</header> </header>
<sheet> <sheet>
<field name="status_html" attrs="{'invisible': [('status_html', '=', False)]}" />
<group col="4" name="credentials"> <group col="4" name="credentials">
<field name="url" widget="url" attrs="{'readonly': [('cronjob_running', '=', True)]}" /> <field name="url" widget="url" attrs="{'readonly': [('cronjob_running', '=', True)]}" />
<field name="database" attrs="{'readonly': [('cronjob_running', '=', True)]}" /> <field name="database" attrs="{'readonly': [('cronjob_running', '=', True)]}" />
<field name="user" attrs="{'readonly': [('cronjob_running', '=', True)]}" /> <field name="user" attrs="{'readonly': [('cronjob_running', '=', True)]}" />
<field name="password" password="True" attrs="{'readonly': [('cronjob_running', '=', True)], 'required': [('cronjob_running', '=', False)]}" /> <field name="password" password="True" attrs="{'readonly': [('cronjob_running', '=', True)], 'required': [('cronjob_running', '=', False)]}" />
<field name="cronjob_id" attrs="{'invisible': [('cronjob_id', '=', False)]}" /> <field name="cronjob_id" attrs="{'invisible': [('cronjob_id', '=', False)]}" />
<field name="status_html" attrs="{'invisible': [('status_html', '=', False)]}" string="Progress" />
</group> </group>
<field name="import_line_ids" attrs="{'readonly': [('cronjob_running', '=', True)]}"> <field name="import_line_ids" attrs="{'readonly': [('cronjob_running', '=', True)]}">
<tree editable="top"> <tree editable="top">
@ -64,17 +64,17 @@
}); });
} }
</script> </script>
<dl>
<t t-foreach="object.status_data.get('counts', [])" t-as="model_name">
<t t-set="model_display_name" t-value="request.env['ir.model'].search([('model', '=', model_name)]).name" />
<dt t-esc="model_display_name" />
<dd>
<h2>Import progress</h2>
<div style="display: flex;">
<div style="margin-right: .5em" t-foreach="object.import_line_ids" t-as="import_line">
<t t-set="model_name" t-value="import_line.model_id.model" />
<t t-set="model_display_name" t-value="import_line.model_id.name" />
<h3 t-esc="model_display_name" />
<a href="#" t-att-onclick="'base_import_database_open(&quot;%s&quot;, &quot;%s&quot;, %s)' % (model_name, model_display_name, object.id)"> <a href="#" t-att-onclick="'base_import_database_open(&quot;%s&quot;, &quot;%s&quot;, %s)' % (model_name, model_display_name, object.id)">
<span t-esc="object.status_data.get('done', {}).get(model_name, 0)" />/<span t-esc="object.status_data['counts'][model_name]" /> done
<span t-esc="object.status_data.get('done', {}).get(model_name, 0)" />/<span t-esc="object.status_data.get('counts', {}).get(model_name, 0)" /> done
</a> </a>
</dd>
</t>
</dl>
</div>
</div>
<t t-if="object.status_data.get('error')"><pre t-esc="object.status_data['error']" /></t> <t t-if="object.status_data.get('error')"><pre t-esc="object.status_data['error']" /></t>
</template> </template>
</data> </data>

Loading…
Cancel
Save