Browse Source

[ADD] better progress

pull/988/head
Holger Brunn 7 years ago
parent
commit
c6744dea42
No known key found for this signature in database GPG Key ID: 1C9760FECA3AE18
  1. 2
      base_import_odoo/tests/test_base_import_odoo.py
  2. 24
      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
run += 1
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()
self.assertTrue(demodb.cronjob_id)
demodb.cronjob_id.write({'active': False})

24
base_import_odoo/views/import_odoo_database.xml

@ -20,13 +20,13 @@
<field name="cronjob_running" invisible="1" />
</header>
<sheet>
<field name="status_html" attrs="{'invisible': [('status_html', '=', False)]}" />
<group col="4" name="credentials">
<field name="url" widget="url" attrs="{'readonly': [('cronjob_running', '=', True)]}" />
<field name="database" 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="cronjob_id" attrs="{'invisible': [('cronjob_id', '=', False)]}" />
<field name="status_html" attrs="{'invisible': [('status_html', '=', False)]}" string="Progress" />
</group>
<field name="import_line_ids" attrs="{'readonly': [('cronjob_running', '=', True)]}">
<tree editable="top">
@ -64,17 +64,17 @@
});
}
</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>
<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
</a>
</dd>
</t>
</dl>
<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)">
<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>
</div>
</div>
<t t-if="object.status_data.get('error')"><pre t-esc="object.status_data['error']" /></t>
</template>
</data>

Loading…
Cancel
Save