You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
5.3 KiB

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <openerp>
  3. <data>
  4. <record id="view_import_odoo_database_tree" model="ir.ui.view">
  5. <field name="model">import.odoo.database</field>
  6. <field name="arch" type="xml">
  7. <tree>
  8. <field name="url" />
  9. <field name="database" />
  10. </tree>
  11. </field>
  12. </record>
  13. <record id="view_import_odoo_database_form" model="ir.ui.view">
  14. <field name="model">import.odoo.database</field>
  15. <field name="arch" type="xml">
  16. <form>
  17. <header>
  18. <button type="object" name="action_import" string="Run import" class="oe_highlight" attrs="{'invisible': [('cronjob_running', '=', True)]}" />
  19. <button type="object" name="exists" string="Refresh" class="oe_highlight" attrs="{'invisible': [('cronjob_running', '=', False)]}" />
  20. <field name="cronjob_running" invisible="1" />
  21. </header>
  22. <sheet>
  23. <field name="status_html" attrs="{'invisible': [('status_html', '=', False)]}" />
  24. <group col="4" name="credentials">
  25. <field name="url" widget="url" attrs="{'readonly': [('cronjob_running', '=', True)]}" />
  26. <field name="database" attrs="{'readonly': [('cronjob_running', '=', True)]}" />
  27. <field name="user" attrs="{'readonly': [('cronjob_running', '=', True)]}" />
  28. <field name="password" password="True" attrs="{'readonly': [('cronjob_running', '=', True)], 'required': [('cronjob_running', '=', False)]}" />
  29. <field name="duplicates" />
  30. <field name="cronjob_id" attrs="{'invisible': [('cronjob_id', '=', False)]}" />
  31. </group>
  32. <field name="import_line_ids" attrs="{'readonly': [('cronjob_running', '=', True)]}">
  33. <tree editable="top">
  34. <field name="sequence" widget="handle" />
  35. <field name="model_id" />
  36. <field name="domain" />
  37. </tree>
  38. </field>
  39. <field name="import_field_mappings" attrs="{'readonly': [('cronjob_running', '=', True)]}"/>
  40. </sheet>
  41. </form>
  42. </field>
  43. </record>
  44. <template id="view_import_odoo_database_qweb">
  45. <script type="text/javascript">
  46. function base_import_database_open(model, model_name, database_id)
  47. {
  48. return new openerp.web.Model('ir.model.data')
  49. .query(['res_id'])
  50. .filter([
  51. ['module', '=', 'base_import_odoo'],
  52. ['model', '=', model],
  53. ['import_database_id', '=', database_id],
  54. ])
  55. .all()
  56. .then(function(data)
  57. {
  58. return openerp.webclient.action_manager.do_action({
  59. 'name': model_name,
  60. 'type': 'ir.actions.act_window',
  61. 'views': [[false, 'list'], [false, 'form']],
  62. 'res_model': model,
  63. 'domain': [['id', 'in', _.map(data, function(x) {return x.res_id})]]
  64. });
  65. });
  66. }
  67. </script>
  68. <h2 t-if="object.cronjob_running">Import progress</h2>
  69. <h2 t-if="not object.cronjob_running">Import results</h2>
  70. <div style="display: flex; flex-flow: row wrap">
  71. <div style="margin-right: .5em" t-foreach="object.import_line_ids" t-as="import_line">
  72. <t t-set="model_name" t-value="import_line.model_id.model" />
  73. <t t-set="model_display_name" t-value="import_line.model_id.name" />
  74. <h3 t-esc="model_display_name" />
  75. <a href="#" t-att-onclick="'base_import_database_open(&quot;%s&quot;, &quot;%s&quot;, %s)' % (model_name, model_display_name, object.id)">
  76. <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
  77. </a>
  78. </div>
  79. </div>
  80. <t t-if="object.status_data.get('error')"><pre t-esc="object.status_data['error']" /></t>
  81. <div t-if="object.status_data.get('dummies')">
  82. The following remote ids don't have a mapping but have to be imported anyways due to not null constraints.
  83. <dl>
  84. <t t-foreach="object.status_data['dummies']" t-as="model_name">
  85. <dt t-esc="model_name" />
  86. <dd t-esc="object.status_data['dummies'][model_name]" />
  87. </t>
  88. </dl>
  89. To fix this, create mappings for the remote ids listed, or if this is not feasible, map the whole model. You might also have a too specific domain on your import model definition.
  90. </div>
  91. </template>
  92. </data>
  93. </openerp>