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.

95 lines
5.3 KiB

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