[13.0][MIG] excel_import_export, excel_import_export_demo
parent
cf30d5a77f
commit
7162b84404
|
@ -1,202 +0,0 @@
|
||||||
==========================
|
|
||||||
Excel Import/Export/Report
|
|
||||||
==========================
|
|
||||||
|
|
||||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
!! This file is generated by oca-gen-addon-readme !!
|
|
||||||
!! changes will be overwritten. !!
|
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
|
||||||
:target: https://odoo-community.org/page/development-status
|
|
||||||
:alt: Beta
|
|
||||||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
|
||||||
:alt: License: AGPL-3
|
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
|
|
||||||
:target: https://github.com/OCA/server-tools/tree/12.0/excel_import_export
|
|
||||||
:alt: OCA/server-tools
|
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
|
||||||
:target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-excel_import_export
|
|
||||||
:alt: Translate me on Weblate
|
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
|
||||||
:target: https://runbot.odoo-community.org/runbot/149/12.0
|
|
||||||
:alt: Try me on Runbot
|
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|
||||||
|
|
||||||
The module provide pre-built functions and wizards for developer to build excel import / export / report with ease.
|
|
||||||
|
|
||||||
Without having to code to create excel file, developer do,
|
|
||||||
|
|
||||||
- Create menu, action, wizard, model, view a normal Odoo development.
|
|
||||||
- Design excel template using standard Excel application, e.g., colors, fonts, formulas, etc.
|
|
||||||
- Instruct how the data will be located in Excel with simple dictionary instruction or from Odoo UI.
|
|
||||||
- Odoo will combine instruction with excel template, and result in final excel file.
|
|
||||||
|
|
||||||
**Table of contents**
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
To install this module, you need to install following python library, **xlrd, xlwt, openpyxl**.
|
|
||||||
|
|
||||||
Then, simply install **excel_import_export**.
|
|
||||||
|
|
||||||
For demo, install **excel_import_export_demo**.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
=====
|
|
||||||
|
|
||||||
This module contain pre-defined function and wizards to make exporting, importing and reporting easy.
|
|
||||||
|
|
||||||
At the heart of this module, there are 2 `main methods`
|
|
||||||
|
|
||||||
- ``self.env['xlsx.export'].export_xlsx(...)``
|
|
||||||
- ``self.env['xlsx.import'].import_xlsx(...)``
|
|
||||||
|
|
||||||
For reporting, also call `export_xlsx(...)` but through following method
|
|
||||||
|
|
||||||
- ``self.env['xslx.report'].report_xlsx(...)``
|
|
||||||
|
|
||||||
After install this module, go to Settings > Excel Import/Export > XLSX Templates, this is where the key component located.
|
|
||||||
|
|
||||||
As this module provide tools, it is best to explain as use cases. For example use cases, please install **excel_import_export_demo**
|
|
||||||
|
|
||||||
**Use Case 1:** Export/Import Excel on existing document
|
|
||||||
|
|
||||||
This add export/import action menus in existing document (example - excel_import_export_demo/import_export_sale_order)
|
|
||||||
|
|
||||||
1. Create export action menu on document, <act_window> with res_model="export.xlsx.wizard" and src_model="<document_model>", and context['template_domain'] to locate the right template -- actions.xml
|
|
||||||
2. Create import action menu on document, <act_window> with res_model="import.xlsx.wizard" and src_model="<document_model>", and context['template_domain'] to locate the right template -- action.xml
|
|
||||||
3. Create/Design Excel Template File (.xlsx), in the template, name the underlining tab used for export/import -- <file>.xlsx
|
|
||||||
4. Create instruction dictionary for export/import in xlsx.template model -- templates.xml
|
|
||||||
|
|
||||||
**Use Case 2:** Import Excel Files
|
|
||||||
|
|
||||||
With menu wizard to create new documents (example - excel_import_export_demo/import_sale_orders)
|
|
||||||
|
|
||||||
1. Create report menu with search wizard, res_model="import.xlsx.wizard" and context['template_domain'] to locate the right template -- menu_action.xml
|
|
||||||
2. Create Excel Template File (.xlsx), in the template, name the underlining tab used for import -- <import file>.xlsx
|
|
||||||
3. Create instruction dictionary for import in xlsx.template model -- templates.xml
|
|
||||||
|
|
||||||
**Use Case 3:** Create Excel Report
|
|
||||||
|
|
||||||
This create report menu with criteria wizard. (example - excel_import_export_demo/report_sale_order)
|
|
||||||
|
|
||||||
1. Create report's menu, action, and add context['template_domain'] to locate the right template for this report -- <report>.xml
|
|
||||||
2. Create report's wizard for search criteria. The view inherits ``excel_import_export.xlsx_report_view`` and mode="primary". In this view, you only need to add criteria fields, the rest will reuse from interited view -- <report.xml>
|
|
||||||
3. Create report model as models.Transient, then define search criteria fields, and get reporing data into ``results`` field -- <report>.py
|
|
||||||
4. Create/Design Excel Template File (.xlsx), in the template, name the underlining tab used for report results -- <report_file>.xlsx
|
|
||||||
5. Create instruction dictionary for report in xlsx.template model -- templates.xml
|
|
||||||
|
|
||||||
**Note:**
|
|
||||||
|
|
||||||
Another option for reporting is to use report action (report_type='excel'), I.e.,
|
|
||||||
|
|
||||||
.. code-block:: xml
|
|
||||||
|
|
||||||
<report id='action_report_saleorder_excel'
|
|
||||||
string='Quotation / Order (.xlsx)'
|
|
||||||
model='sale.order'
|
|
||||||
name='sale_order.xlsx'
|
|
||||||
file='sale_order'
|
|
||||||
report_type='excel'
|
|
||||||
/>
|
|
||||||
|
|
||||||
By using report action, Odoo will find template using combination of model and name, then do the export for the underlining record.
|
|
||||||
Please see example in excel_import_export_demo/report_action, which shows,
|
|
||||||
|
|
||||||
1. Print excel from an active sale.order
|
|
||||||
2. Run partner list report based on search criteria.
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
- Module extension e.g., excel_import_export_async, that add ability to execute as async process.
|
|
||||||
- Ability to add contextual action in XLSX Tempalte, e.g., Add import action, Add export action. In similar manner as in Server Action.
|
|
||||||
|
|
||||||
Changelog
|
|
||||||
=========
|
|
||||||
|
|
||||||
12.0.1.0.5 (2019-12-19)
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
* Speed up export when dealing with many rows
|
|
||||||
|
|
||||||
12.0.1.0.4 (2019-08-28)
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
* Fix style sum in footer
|
|
||||||
|
|
||||||
12.0.1.0.3 (2019-08-09)
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
* Add report action for report_type = 'excel'
|
|
||||||
|
|
||||||
12.0.1.0.2 (2019-08-07)
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
* Small fix, to ensure that system parameter 'path_temp_file' (ir.config_parameter) is readable
|
|
||||||
|
|
||||||
12.0.1.0.1 (2019-06-24)
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
* Fix wizard on v12 can't download sample template file - https://github.com/OCA/server-tools/issues/1574
|
|
||||||
|
|
||||||
12.0.1.0.0 (2019-02-24)
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
* Start of the history
|
|
||||||
|
|
||||||
Bug Tracker
|
|
||||||
===========
|
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
|
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
|
||||||
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20excel_import_export%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
|
||||||
|
|
||||||
Credits
|
|
||||||
=======
|
|
||||||
|
|
||||||
Authors
|
|
||||||
~~~~~~~
|
|
||||||
|
|
||||||
* Ecosoft
|
|
||||||
|
|
||||||
Contributors
|
|
||||||
~~~~~~~~~~~~
|
|
||||||
|
|
||||||
* Kitti Upariphutthiphong. <kittiu@gmail.com> (http://ecosoft.co.th)
|
|
||||||
* Saran Lim. <saranl@ecosoft.co.th> (http://ecosoft.co.th)
|
|
||||||
|
|
||||||
Maintainers
|
|
||||||
~~~~~~~~~~~
|
|
||||||
|
|
||||||
This module is maintained by the OCA.
|
|
||||||
|
|
||||||
.. image:: https://odoo-community.org/logo.png
|
|
||||||
:alt: Odoo Community Association
|
|
||||||
:target: https://odoo-community.org
|
|
||||||
|
|
||||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|
||||||
mission is to support the collaborative development of Odoo features and
|
|
||||||
promote its widespread use.
|
|
||||||
|
|
||||||
.. |maintainer-kittiu| image:: https://github.com/kittiu.png?size=40px
|
|
||||||
:target: https://github.com/kittiu
|
|
||||||
:alt: kittiu
|
|
||||||
|
|
||||||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
|
||||||
|
|
||||||
|maintainer-kittiu|
|
|
||||||
|
|
||||||
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/12.0/excel_import_export>`_ project on GitHub.
|
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
|
|
@ -4,22 +4,23 @@
|
||||||
{
|
{
|
||||||
"name": "Excel Import/Export/Report",
|
"name": "Excel Import/Export/Report",
|
||||||
"summary": "Base module for developing Excel import/export/report",
|
"summary": "Base module for developing Excel import/export/report",
|
||||||
"version": "12.0.1.0.4",
|
"version": "13.0.1.0.0",
|
||||||
"author": "Ecosoft,Odoo Community Association (OCA)",
|
"author": "Ecosoft,Odoo Community Association (OCA)",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"website": "https://github.com/OCA/server-tools/",
|
"website": "https://github.com/OCA/server-tools/",
|
||||||
"category": "Tools",
|
"category": "Tools",
|
||||||
"depends": ["mail"],
|
"depends": ["mail"],
|
||||||
"external_dependencies": {"python": ["xlrd", "xlwt", "openpyxl",],},
|
"external_dependencies": {"python": ["xlrd", "xlwt", "openpyxl"]},
|
||||||
"data": [
|
"data": [
|
||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
"wizard/export_xlsx_wizard.xml",
|
"wizard/export_xlsx_wizard.xml",
|
||||||
"wizard/import_xlsx_wizard.xml",
|
"wizard/import_xlsx_wizard.xml",
|
||||||
|
"wizard/report_xlsx_wizard.xml",
|
||||||
"views/xlsx_template_view.xml",
|
"views/xlsx_template_view.xml",
|
||||||
"views/xlsx_report.xml",
|
"views/xlsx_report.xml",
|
||||||
"views/webclient_templates.xml",
|
"views/webclient_templates.xml",
|
||||||
],
|
],
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"development_status": "beta",
|
"development_status": "Beta",
|
||||||
"maintainers": ["kittiu"],
|
"maintainers": ["kittiu"],
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,18 +193,6 @@ msgstr ""
|
||||||
msgid "Allow Choose Template"
|
msgid "Allow Choose Template"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: excel_import_export
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_export_xlsx_wizard__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_export__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_import__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_report__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_styles__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_template__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_template_export__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_template_import__attachment_ids
|
|
||||||
msgid "Attachments"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model:ir.model,name:excel_import_export.model_xlsx_styles
|
#: model:ir.model,name:excel_import_export.model_xlsx_styles
|
||||||
msgid "Available styles for excel"
|
msgid "Available styles for excel"
|
||||||
|
@ -383,13 +371,7 @@ msgid "Error filling data into Excel sheets\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:212
|
#: code:addons/excel_import_export/models/xlsx_import.py:219
|
||||||
#, python-format
|
|
||||||
msgid "Error importing data"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:224
|
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Error importing data\n"
|
msgid "Error importing data\n"
|
||||||
"%s"
|
"%s"
|
||||||
|
@ -670,7 +652,7 @@ msgid "Invalid declaration, %s has no valid field type"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:222
|
#: code:addons/excel_import_export/models/xlsx_import.py:217
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Invalid file style, only .xls or .xlsx file allowed"
|
msgid "Invalid file style, only .xls or .xlsx file allowed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -737,7 +719,7 @@ msgid "No Delete"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:254
|
#: code:addons/excel_import_export/models/xlsx_import.py:249
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "No data_dict['__IMPORT__'] in template %s"
|
msgid "No data_dict['__IMPORT__'] in template %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -818,7 +800,7 @@ msgid "Post Import Hook"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:237
|
#: code:addons/excel_import_export/models/xlsx_import.py:232
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Post import operation error\n"
|
msgid "Post import operation error\n"
|
||||||
"%s"
|
"%s"
|
||||||
|
@ -961,8 +943,8 @@ msgid "Template with CSV Quoting = False, data must not contain the same char as
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_export.py:228
|
#: code:addons/excel_import_export/models/xlsx_export.py:230
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:249
|
#: code:addons/excel_import_export/models/xlsx_import.py:244
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Template's model mismatch"
|
msgid "Template's model mismatch"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Translation of Odoo Server.
|
# Translation of Odoo Server.
|
||||||
# This file contains the translation of the following modules:
|
# This file contains the translation of the following modules:
|
||||||
# * excel_import_export
|
# * excel_import_export
|
||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -32,8 +32,7 @@ msgstr "'%s' 找不到工作表"
|
||||||
#: model:ir.model.fields,help:excel_import_export.field_export_xlsx_wizard__state
|
#: model:ir.model.fields,help:excel_import_export.field_export_xlsx_wizard__state
|
||||||
#: model:ir.model.fields,help:excel_import_export.field_import_xlsx_wizard__state
|
#: model:ir.model.fields,help:excel_import_export.field_import_xlsx_wizard__state
|
||||||
#: model:ir.model.fields,help:excel_import_export.field_xlsx_report__state
|
#: model:ir.model.fields,help:excel_import_export.field_xlsx_report__state
|
||||||
msgid ""
|
msgid "* Choose: wizard show in user selection mode\n"
|
||||||
"* Choose: wizard show in user selection mode\n"
|
|
||||||
"* Get: wizard show results from user action"
|
"* Get: wizard show results from user action"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"* 选择:用户选择模式下的向导显示\n"
|
"* 选择:用户选择模式下的向导显示\n"
|
||||||
|
@ -46,35 +45,24 @@ msgstr "<b>单元格</b>:Excel工作表中的数据位置(例如:A1,B1,...
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<b>Continue</b>: If not selected, start rolling with specified first row cells. If selected, continue from previous one2many field"
|
||||||
"<b>Continue</b>: If not selected, start rolling with specified first row "
|
msgstr "<b>继续</b>: 如果未选中,则使用指定的第一行单元格开始滚动。 如果选中,则从之前的one2many字段继续"
|
||||||
"cells. If selected, continue from previous one2many field"
|
|
||||||
msgstr ""
|
|
||||||
"<b>继续</b>: 如果未选中,则使用指定的第一行单元格开始滚动。 如果选中,则从之"
|
|
||||||
"前的one2many字段继续"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<b>Field Cond.</b>: Python code in <code>${...}</code> to manipulate field value, e.g., if field = product_id, <code>value</code> will represent product object, e.g., <code>${value and value.uom_id.name or \"\"}</code>"
|
||||||
"<b>Field Cond.</b>: Python code in <code>${...}</code> to manipulate field "
|
|
||||||
"value, e.g., if field = product_id, <code>value</code> will represent "
|
|
||||||
"product object, e.g., <code>${value and value.uom_id.name or \"\"}</code>"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"<b>字段条件</b>: Python代码<code>${...}</code> 操纵字段值, 例如, if field = "
|
"<b>字段条件</b>: Python代码<code>${...}</code> 操纵字段值, 例如, if field = product_id, "
|
||||||
"product_id, <code>value</code> 将代表产品对象, 例如, <code>${value and value."
|
"<code>value</code> 将代表产品对象, 例如, <code>${value and value.uom_id.name or \"\""
|
||||||
"uom_id.name or \"\"}</code>"
|
"}</code>"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<b>Field Cond.</b>: Python code in <code>${...}</code> value will represent data from excel cell, e.g., if A1 = 'ABC', <code>value</code> will represent 'ABC', e.g., <code>${value == \"ABC\" and \"X\" or \"Y\"}</code> thus can change from cell value to other value for import."
|
||||||
"<b>Field Cond.</b>: Python code in <code>${...}</code> value will represent "
|
|
||||||
"data from excel cell, e.g., if A1 = 'ABC', <code>value</code> will represent "
|
|
||||||
"'ABC', e.g., <code>${value == \"ABC\" and \"X\" or \"Y\"}</code> thus can "
|
|
||||||
"change from cell value to other value for import."
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"<b>字段条件</b>: Python代码 <code>${...}</code> 值将代表来自excel 单元格的数"
|
"<b>字段条件</b>: Python代码 <code>${...}</code> 值将代表来自excel 单元格的数据, 例如, if A1 = "
|
||||||
"据, 例如, if A1 = 'ABC', <code>value</code> 代表'ABC',例如, <code>${value == "
|
"'ABC', <code>value</code> 代表'ABC',例如, <code>${value == \"ABC\" and \"X\" or "
|
||||||
"\"ABC\" and \"X\" or \"Y\"}</code> 因此可以从单元格值更改为其他值以进行导入."
|
"\"Y\"}</code> 因此可以从单元格值更改为其他值以进行导入."
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
|
@ -83,18 +71,13 @@ msgstr "<b>字段</b>: 要导入的记录的字段,例如product_id"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<b>Field</b>: Field of the record, e.g., product_id.uom_id.name. They are orm compliant."
|
||||||
"<b>Field</b>: Field of the record, e.g., product_id.uom_id.name. They are "
|
|
||||||
"orm compliant."
|
|
||||||
msgstr "<b>字段</b>: 记录的字段,例如product_id.uom_id.name。他们是合规的。"
|
msgstr "<b>字段</b>: 记录的字段,例如product_id.uom_id.name。他们是合规的。"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<b>No Delete</b>: By default, all one2many lines will be deleted before import. Select this, to avoid deletion"
|
||||||
"<b>No Delete</b>: By default, all one2many lines will be deleted before "
|
msgstr "<b>不删除</b>: 默认情况下,导入前将删除所有one2many行。选择此项,以避免删除"
|
||||||
"import. Select this, to avoid deletion"
|
|
||||||
msgstr ""
|
|
||||||
"<b>不删除</b>: 默认情况下,导入前将删除所有one2many行。选择此项,以避免删除"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
|
@ -103,12 +86,8 @@ msgstr "<b>备注:</b>"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<b>Row Field</b>: Use _HEAD_ for the record itself, and one2many field (e.g., line_ids) for row data"
|
||||||
"<b>Row Field</b>: Use _HEAD_ for the record itself, and one2many field (e."
|
msgstr "<b>行字段</b>: 使用_HEAD_表示记录本身,使用one2many字段(例如line_ids)表示行数据"
|
||||||
"g., line_ids) for row data"
|
|
||||||
msgstr ""
|
|
||||||
"<b>行字段</b>: 使用_HEAD_表示记录本身,使用one2many字段(例如line_ids)表示行"
|
|
||||||
"数据"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
|
@ -117,34 +96,22 @@ msgstr "<b>工作表</b>: excel工作表的名称(例如,工作表1)或索
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<b>Sheet</b>: Name (e.g., Sheet 1) or index (e.g., 1) of excel sheet to export data to"
|
||||||
"<b>Sheet</b>: Name (e.g., Sheet 1) or index (e.g., 1) of excel sheet to "
|
msgstr "<b>工作表</b>: 要将数据导出到的Excel工作表的名称(例如,工作表1)或索引(例如,1)"
|
||||||
"export data to"
|
|
||||||
msgstr ""
|
|
||||||
"<b>工作表</b>: 要将数据导出到的Excel工作表的名称(例如,工作表1)或索引(例"
|
|
||||||
"如,1)"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<b>Style w/Cond.</b>: Conditional style by python code in <code>#?...?</code>, e.g., apply style for specific product, <code>#?value.name == \"ABC\" and #{font=bold;fill=red} or None?</code>"
|
||||||
"<b>Style w/Cond.</b>: Conditional style by python code in <code>#?...?</"
|
|
||||||
"code>, e.g., apply style for specific product, <code>#?value.name == \"ABC\" "
|
|
||||||
"and #{font=bold;fill=red} or None?</code>"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"<b>样式条件</b>: python代码中的条件样式 <code>#?...?</code>, 例如,为特定产品"
|
"<b>样式条件</b>: python代码中的条件样式 <code>#?...?</code>, 例如,为特定产品应用样式, <code>#"
|
||||||
"应用样式, <code>#?value.name == \"ABC\" and #{font=bold;fill=red} or None?</"
|
"?value.name == \"ABC\" and #{font=bold;fill=red} or None?</code>"
|
||||||
"code>"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<b>Style</b>: Default style in <code>#{...}</code> that apply to each cell, e.g., <code>#{align=left;style=text}</code>. See module's <b>style.py</b> for available styles."
|
||||||
"<b>Style</b>: Default style in <code>#{...}</code> that apply to each cell, "
|
|
||||||
"e.g., <code>#{align=left;style=text}</code>. See module's <b>style.py</b> "
|
|
||||||
"for available styles."
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"<b>样式</b>: 默认样式<code>#{...}</code> 适用于每个单元格, 例如, "
|
"<b>样式</b>: 默认样式<code>#{...}</code> 适用于每个单元格, 例如, "
|
||||||
"<code>#{align=left;style=text}</code>. 请参阅模块的<b>style.py</b> 可用的样"
|
"<code>#{align=left;style=text}</code>. 请参阅模块的<b>style.py</b> 可用的样式。"
|
||||||
"式。"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
|
@ -153,20 +120,16 @@ msgstr "<b>总和</b>: 在最后一行添加总和值, <code>@{sum}</code>"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<code class=\"oe_grey\">\n"
|
||||||
"<code class=\"oe_grey\">\n"
|
|
||||||
"{\n"
|
"{\n"
|
||||||
" '__EXPORT__': {\n"
|
" '__EXPORT__': {\n"
|
||||||
" 'sale_order': { # sheet can be name (string) or index (integer)\n"
|
" 'sale_order': { # sheet can be name (string) or index (integer)\n"
|
||||||
" '_HEAD_': {\n"
|
" '_HEAD_': {\n"
|
||||||
" 'B2': 'partner_id.display_name${value or \"\"}#{align=left;"
|
" 'B2': 'partner_id.display_name${value or \"\"}#{align=left;style=text}',\n"
|
||||||
"style=text}',\n"
|
|
||||||
" 'B3': 'name${value or \"\"}#{align=left;style=text}',\n"
|
" 'B3': 'name${value or \"\"}#{align=left;style=text}',\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" 'line_ids': { # prefix with _CONT_ to continue rows from "
|
" 'line_ids': { # prefix with _CONT_ to continue rows from previous row field\n"
|
||||||
"previous row field\n"
|
" 'A6': 'product_id.display_name${value or \"\"}#{style=text}',\n"
|
||||||
" 'A6': 'product_id.display_name${value or \"\"}"
|
|
||||||
"#{style=text}',\n"
|
|
||||||
" 'C6': 'product_uom_qty${value or 0}#{style=number}',\n"
|
" 'C6': 'product_uom_qty${value or 0}#{style=number}',\n"
|
||||||
" 'E6': 'price_unit${value or 0}#{style=number}',\n"
|
" 'E6': 'price_unit${value or 0}#{style=number}',\n"
|
||||||
" 'G6': 'price_subtotal${value or 0}#{style=number}',\n"
|
" 'G6': 'price_subtotal${value or 0}#{style=number}',\n"
|
||||||
|
@ -175,8 +138,7 @@ msgid ""
|
||||||
" },\n"
|
" },\n"
|
||||||
" '__IMPORT__': {\n"
|
" '__IMPORT__': {\n"
|
||||||
" 'sale_order': { # sheet can be name (string) or index (integer)\n"
|
" 'sale_order': { # sheet can be name (string) or index (integer)\n"
|
||||||
" 'order_line': { # prefix with _NODEL_ to not delete rows before "
|
" 'order_line': { # prefix with _NODEL_ to not delete rows before import\n"
|
||||||
"import\n"
|
|
||||||
" 'A6': 'product_id',\n"
|
" 'A6': 'product_id',\n"
|
||||||
" 'C6': 'product_uom_qty',\n"
|
" 'C6': 'product_uom_qty',\n"
|
||||||
" 'E6': 'price_unit${value > 0 and value or 0}',\n"
|
" 'E6': 'price_unit${value > 0 and value or 0}',\n"
|
||||||
|
@ -193,14 +155,14 @@ msgstr ""
|
||||||
" '__EXPORT__': {\n"
|
" '__EXPORT__': {\n"
|
||||||
" 'sale_order': { # 工作表名称可以是(字符串)或索引(整数)\n"
|
" 'sale_order': { # 工作表名称可以是(字符串)或索引(整数)\n"
|
||||||
" '_HEAD_': {\n"
|
" '_HEAD_': {\n"
|
||||||
" 'B2': 'partner_id.display_name${value or \"\"}#{align=left;"
|
" 'B2': 'partner_id.display_name${value or \"\""
|
||||||
"style=text}',\n"
|
"}#{align=left;style=text}',\n"
|
||||||
" 'B3': 'name${value or \"\"}#{align=left;style=text}',\n"
|
" 'B3': 'name${value or \"\"}#{align=left;style=text}',\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" 'line_ids': { # prefix with _CONT_ to continue rows from "
|
" 'line_ids': { # prefix with _CONT_ to continue rows from "
|
||||||
"previous row field\n"
|
"previous row field\n"
|
||||||
" 'A6': 'product_id.display_name${value or \"\"}"
|
" 'A6': 'product_id.display_name${value or \"\"}#{style=text}',"
|
||||||
"#{style=text}',\n"
|
"\n"
|
||||||
" 'C6': 'product_uom_qty${value or 0}#{style=number}',\n"
|
" 'C6': 'product_uom_qty${value or 0}#{style=number}',\n"
|
||||||
" 'E6': 'price_unit${value or 0}#{style=number}',\n"
|
" 'E6': 'price_unit${value or 0}#{style=number}',\n"
|
||||||
" 'G6': 'price_subtotal${value or 0}#{style=number}',\n"
|
" 'G6': 'price_subtotal${value or 0}#{style=number}',\n"
|
||||||
|
@ -234,8 +196,7 @@ msgstr "<code>model</code>: 活动模型,例如., self.env['my.model']"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "<code>object</code>: record object or line object depends on <b>Row Field</b>"
|
||||||
"<code>object</code>: record object or line object depends on <b>Row Field</b>"
|
|
||||||
msgstr "<code>object</code>: 记录对象或行对象依赖于 <b>行字段</b>"
|
msgstr "<code>object</code>: 记录对象或行对象依赖于 <b>行字段</b>"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
|
@ -252,11 +213,8 @@ msgstr "<code>value</code>: 值来自 <b>字段</b>"
|
||||||
#. openerp-web
|
#. openerp-web
|
||||||
#: code:addons/excel_import_export/static/src/js/report/action_manager_report.js:49
|
#: code:addons/excel_import_export/static/src/js/report/action_manager_report.js:49
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
msgid "A popup window with your report was blocked. You may need to change your browser settings to allow popup windows for this page."
|
||||||
"A popup window with your report was blocked. You may need to change your "
|
msgstr "您的报告的弹出窗口被阻止。您可能需要更改浏览器设置以允许此页面的弹出窗口。"
|
||||||
"browser settings to allow popup windows for this page."
|
|
||||||
msgstr ""
|
|
||||||
"您的报告的弹出窗口被阻止。您可能需要更改浏览器设置以允许此页面的弹出窗口。"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
|
@ -283,18 +241,6 @@ msgstr "添加工作表部分"
|
||||||
msgid "Allow Choose Template"
|
msgid "Allow Choose Template"
|
||||||
msgstr "添加表单部分"
|
msgstr "添加表单部分"
|
||||||
|
|
||||||
#. module: excel_import_export
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_export_xlsx_wizard__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_export__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_import__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_report__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_styles__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_template__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_template_export__attachment_ids
|
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_template_import__attachment_ids
|
|
||||||
msgid "Attachments"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model:ir.model,name:excel_import_export.model_xlsx_styles
|
#: model:ir.model,name:excel_import_export.model_xlsx_styles
|
||||||
msgid "Available styles for excel"
|
msgid "Available styles for excel"
|
||||||
|
@ -302,8 +248,7 @@ msgstr "excel的可用样式"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model:ir.model.fields,help:excel_import_export.field_xlsx_template_import__no_delete
|
#: model:ir.model.fields,help:excel_import_export.field_xlsx_template_import__no_delete
|
||||||
msgid ""
|
msgid "By default, all rows will be deleted before import.\n"
|
||||||
"By default, all rows will be deleted before import.\n"
|
|
||||||
"Select No Delete, otherwise"
|
"Select No Delete, otherwise"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"默认情况下,导入前将删除所有行。\n"
|
"默认情况下,导入前将删除所有行。\n"
|
||||||
|
@ -326,8 +271,7 @@ msgstr "CSV引用"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model:ir.model.fields,help:excel_import_export.field_xlsx_template__post_import_hook
|
#: model:ir.model.fields,help:excel_import_export.field_xlsx_template__post_import_hook
|
||||||
msgid ""
|
msgid "Call a function after successful import, i.e.,\n"
|
||||||
"Call a function after successful import, i.e.,\n"
|
|
||||||
"${object.post_import_do_something()}"
|
"${object.post_import_do_something()}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"成功导入后调用函数,即,\n"
|
"成功导入后调用函数,即,\n"
|
||||||
|
@ -347,7 +291,8 @@ msgid "Cell"
|
||||||
msgstr "单元格"
|
msgstr "单元格"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: selection:export.xlsx.wizard,state:0 selection:import.xlsx.wizard,state:0
|
#: selection:export.xlsx.wizard,state:0
|
||||||
|
#: selection:import.xlsx.wizard,state:0
|
||||||
#: selection:xlsx.report,state:0
|
#: selection:xlsx.report,state:0
|
||||||
msgid "Choose"
|
msgid "Choose"
|
||||||
msgstr "选择"
|
msgstr "选择"
|
||||||
|
@ -466,8 +411,7 @@ msgstr "文件必须处于草稿状态"
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:89
|
#: code:addons/excel_import_export/models/xlsx_import.py:89
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
msgid "Error deleting data\n"
|
||||||
"Error deleting data\n"
|
|
||||||
"%s"
|
"%s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"删除数据时出错\n"
|
"删除数据时出错\n"
|
||||||
|
@ -476,29 +420,16 @@ msgstr ""
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_export.py:141
|
#: code:addons/excel_import_export/models/xlsx_export.py:141
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
msgid "Error filling data into Excel sheets\n"
|
||||||
"Error filling data into Excel sheets\n"
|
|
||||||
"%s"
|
"%s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"将数据填充到Excel工作表时出错\n"
|
"将数据填充到Excel工作表时出错\n"
|
||||||
"%s"
|
"%s"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:212
|
#: code:addons/excel_import_export/models/xlsx_import.py:219
|
||||||
#, fuzzy, python-format
|
|
||||||
#| msgid ""
|
|
||||||
#| "Error importing data\n"
|
|
||||||
#| "%s"
|
|
||||||
msgid "Error importing data"
|
|
||||||
msgstr ""
|
|
||||||
"导入数据时出错\n"
|
|
||||||
"%s"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:224
|
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
msgid "Error importing data\n"
|
||||||
"Error importing data\n"
|
|
||||||
"%s"
|
"%s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"导入数据时出错\n"
|
"导入数据时出错\n"
|
||||||
|
@ -553,25 +484,17 @@ msgstr "导出"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "Export Instruction is how to write data from an active data record to specified cells in excel sheet.\n"
|
||||||
"Export Instruction is how to write data from an active data record to "
|
" For example, an active record can be a sale order that user want to export.\n"
|
||||||
"specified cells in excel sheet.\n"
|
" The record itself will be mapped to the header part of excel sheet. The record can contain multiple one2many fields, which will be written as data lines.\n"
|
||||||
" For example, an active record can be a "
|
" You can look at following instruction as Excel Sheet(s), each with 1 header section (_HEAD_) and multiple row sections (one2many fields)."
|
||||||
"sale order that user want to export.\n"
|
|
||||||
" The record itself will be mapped to the "
|
|
||||||
"header part of excel sheet. The record can contain multiple one2many fields, "
|
|
||||||
"which will be written as data lines.\n"
|
|
||||||
" You can look at following instruction as "
|
|
||||||
"Excel Sheet(s), each with 1 header section (_HEAD_) and multiple row "
|
|
||||||
"sections (one2many fields)."
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"导出指令是如何将数据从活动数据记录写入Excel工作表中的指定单元格。\n"
|
"导出指令是如何将数据从活动数据记录写入Excel工作表中的指定单元格。\n"
|
||||||
" 例如,活动记录可以是用户想要导出的销售订"
|
" 例如,活动记录可以是用户想要导出的销售订单。\n"
|
||||||
"单。\n"
|
" "
|
||||||
" 记录本身将映射到Excel工作表的标题部分。该记"
|
"记录本身将映射到Excel工作表的标题部分。该记录可以包含多个one2many字段,这些字段将写为数据行。\n"
|
||||||
"录可以包含多个one2many字段,这些字段将写为数据行。\n"
|
" "
|
||||||
" 您可以将以下指令看作Excel工作表,每个工作表"
|
"您可以将以下指令看作Excel工作表,每个工作表有1个标题部分(_HEAD_)和多个行部分(one2many字段)。"
|
||||||
"有1个标题部分(_HEAD_)和多个行部分(one2many字段)。"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_template_export__field_name
|
#: model:ir.model.fields,field_description:excel_import_export.field_xlsx_template_export__field_name
|
||||||
|
@ -616,20 +539,15 @@ msgstr "以下是每列的详细说明:"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "Following show very simple example of the dictionary construct.\n"
|
||||||
"Following show very simple example of the dictionary construct.\n"
|
" Normally, this will be within templates.xml file within addons."
|
||||||
" Normally, this will be within templates."
|
|
||||||
"xml file within addons."
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"下面显示了字典构造的非常简单的示例。\n"
|
"下面显示了字典构造的非常简单的示例。\n"
|
||||||
" 通常,这将位于插件中的templates.xml文件"
|
" 通常,这将位于插件中的templates.xml文件中。"
|
||||||
"中。"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "For code block <code>${...}</code> and <code>#?...?</code>, following object are available,"
|
||||||
"For code block <code>${...}</code> and <code>#?...?</code>, following object "
|
|
||||||
"are available,"
|
|
||||||
msgstr "对于代码块 <code>${...}</code> 和 <code>#?...?</code>, 以下对象可用,"
|
msgstr "对于代码块 <code>${...}</code> 和 <code>#?...?</code>, 以下对象可用,"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
|
@ -638,7 +556,8 @@ msgid "For code block <code>${...}</code>, following object are available,"
|
||||||
msgstr "对于代码块<code>${...}</code>, 以下对象可用,"
|
msgstr "对于代码块<code>${...}</code>, 以下对象可用,"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: selection:export.xlsx.wizard,state:0 selection:import.xlsx.wizard,state:0
|
#: selection:export.xlsx.wizard,state:0
|
||||||
|
#: selection:import.xlsx.wizard,state:0
|
||||||
#: selection:xlsx.report,state:0
|
#: selection:xlsx.report,state:0
|
||||||
msgid "Get"
|
msgid "Get"
|
||||||
msgstr "获取"
|
msgstr "获取"
|
||||||
|
@ -706,8 +625,7 @@ msgstr "如果部分类型是行,则此字段是必需的"
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_export.py:137
|
#: code:addons/excel_import_export/models/xlsx_export.py:137
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
msgid "IllegalCharacterError\n"
|
||||||
"IllegalCharacterError\n"
|
|
||||||
"Some exporting data contain special character\n"
|
"Some exporting data contain special character\n"
|
||||||
"%s"
|
"%s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -745,24 +663,16 @@ msgstr "导入文件(*.xlsx)"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "Import Instruction is how to get data from excel sheet and write them to an active record.\n"
|
||||||
"Import Instruction is how to get data from excel sheet and write them to an "
|
" For example, user create a sales order document, and want to import order lines from excel.\n"
|
||||||
"active record.\n"
|
" In reverse direction to exporting, data from excel's cells will be mapped to record fields during import.\n"
|
||||||
" For example, user create a sales order "
|
" Cells can be mapped to record in header section (_HEAD_) and data table can be mapped to row section (one2many field, begins from specifed cells."
|
||||||
"document, and want to import order lines from excel.\n"
|
|
||||||
" In reverse direction to exporting, data "
|
|
||||||
"from excel's cells will be mapped to record fields during import.\n"
|
|
||||||
" Cells can be mapped to record in header "
|
|
||||||
"section (_HEAD_) and data table can be mapped to row section (one2many "
|
|
||||||
"field, begins from specifed cells."
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"导入指令是如何从Excel工作表中获取数据并将其写入活动记录。\n"
|
"导入指令是如何从Excel工作表中获取数据并将其写入活动记录。\n"
|
||||||
" 例如,用户创建销售订单文档,并希望从excel导"
|
" 例如,用户创建销售订单文档,并希望从excel导入订单行。\n"
|
||||||
"入订单行。\n"
|
" 与导出相反,excel单元格中的数据将在导入期间映射到记录字段。\n"
|
||||||
" 与导出相反,excel单元格中的数据将在导入期间"
|
" "
|
||||||
"映射到记录字段。\n"
|
"单元格可以映射到标题部分(_HEAD_)中的记录,数据表可以映射到行部分(one2many字段,从指定的单元格开始)。"
|
||||||
" 单元格可以映射到标题部分(_HEAD_)中的记"
|
|
||||||
"录,数据表可以映射到行部分(one2many字段,从指定的单元格开始)。"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.import_xlsx_wizard
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.import_xlsx_wizard
|
||||||
|
@ -771,41 +681,27 @@ msgstr "导入成功!"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "In header section part, map data fields (e.g., number, partner_id.name) into cells (e.g., B1, B2)."
|
||||||
"In header section part, map data fields (e.g., number, partner_id.name) into "
|
msgstr "在头部分,将数据字段(例如,number, partner id.name)映射到单元格(例如,B1, B2)。"
|
||||||
"cells (e.g., B1, B2)."
|
|
||||||
msgstr ""
|
|
||||||
"在头部分,将数据字段(例如,number, partner id.name)映射到单元格(例如,B1, "
|
|
||||||
"B2)。"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "In header section, map cells (e.g., B1, B2) into data fields (e.g., number, partner_id)."
|
||||||
"In header section, map cells (e.g., B1, B2) into data fields (e.g., number, "
|
|
||||||
"partner_id)."
|
|
||||||
msgstr "在头部分,将单元格(如B1、B2)映射到数据字段(如number、合作伙伴id)。"
|
msgstr "在头部分,将单元格(如B1、B2)映射到数据字段(如number、合作伙伴id)。"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "In row section, data list will be rolled out from one2many row field (e.g., order_line), and map data field (i.e., product_id.name, uom_id.name, qty) into the first row cells to start rolling (e.g., A6, B6, C6)."
|
||||||
"In row section, data list will be rolled out from one2many row field (e.g., "
|
|
||||||
"order_line), and map data field (i.e., product_id.name, uom_id.name, qty) "
|
|
||||||
"into the first row cells to start rolling (e.g., A6, B6, C6)."
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"在行部分中,数据列表将从one2many行字段(例如,order_line)推出,并将数据字段"
|
"在行部分中,数据列表将从one2many行字段(例如,order_line)推出,并将数据字段(即product_id.name,uom_id.name,"
|
||||||
"(即product_id.name,uom_id.name,qty)映射到第一行单元格以开始滚动(例如,"
|
"qty)映射到第一行单元格以开始滚动(例如,A6,B6,C6)。"
|
||||||
"A6,B6,C6)。"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
msgid ""
|
msgid "In row section, data table from excel can be imported to one2many row field (e.g., order_line) by mapping cells on first row onwards (e.g., A6, B6, C6) to fields (e.g., product_id, uom_id, qty)"
|
||||||
"In row section, data table from excel can be imported to one2many row field "
|
|
||||||
"(e.g., order_line) by mapping cells on first row onwards (e.g., A6, B6, C6) "
|
|
||||||
"to fields (e.g., product_id, uom_id, qty)"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"在行部分中,可以通过将第一行上的单元格(例如,A6,B6,C6)映射到字段(例如,"
|
"在行部分中,可以通过将第一行上的单元格(例如,A6,B6,C6)映射到字段(例如,product_id,uom_id,qty),将来自excel的数据表导"
|
||||||
"product_id,uom_id,qty),将来自excel的数据表导入到one2many行字段(例如,"
|
"入到one2many行字段(例如,order_line)"
|
||||||
"order_line)"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
#: model_terms:ir.ui.view,arch_db:excel_import_export.view_xlsx_template_form
|
||||||
|
@ -834,7 +730,7 @@ msgid "Invalid declaration, %s has no valid field type"
|
||||||
msgstr "声明无效,%s没有有效的字段类型"
|
msgstr "声明无效,%s没有有效的字段类型"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:222
|
#: code:addons/excel_import_export/models/xlsx_import.py:217
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Invalid file style, only .xls or .xlsx file allowed"
|
msgid "Invalid file style, only .xls or .xlsx file allowed"
|
||||||
msgstr "文件样式无效,仅允许.xls或.xlsx文件"
|
msgstr "文件样式无效,仅允许.xls或.xlsx文件"
|
||||||
|
@ -854,8 +750,7 @@ msgstr "样式类型%s的值%s无效"
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_export.py:134
|
#: code:addons/excel_import_export/models/xlsx_export.py:134
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
msgid "Key Error\n"
|
||||||
"Key Error\n"
|
|
||||||
"%s"
|
"%s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"关键字错误\n"
|
"关键字错误\n"
|
||||||
|
@ -894,8 +789,7 @@ msgstr "最后更新时间"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model:ir.model.fields,help:excel_import_export.field_xlsx_template__gname
|
#: model:ir.model.fields,help:excel_import_export.field_xlsx_template__gname
|
||||||
msgid ""
|
msgid "Multiple template of same model, can belong to same group,\n"
|
||||||
"Multiple template of same model, can belong to same group,\n"
|
|
||||||
"result in multiple template selection"
|
"result in multiple template selection"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"同一模型的多个模板,可以属于同一组,\n"
|
"同一模型的多个模板,可以属于同一组,\n"
|
||||||
|
@ -907,7 +801,7 @@ msgid "No Delete"
|
||||||
msgstr "不删除"
|
msgstr "不删除"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:254
|
#: code:addons/excel_import_export/models/xlsx_import.py:249
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "No data_dict['__IMPORT__'] in template %s"
|
msgid "No data_dict['__IMPORT__'] in template %s"
|
||||||
msgstr "模版%s中没有 data_dict['__IMPORT__']"
|
msgstr "模版%s中没有 data_dict['__IMPORT__']"
|
||||||
|
@ -988,10 +882,9 @@ msgid "Post Import Hook"
|
||||||
msgstr "导入后挂钩"
|
msgstr "导入后挂钩"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:237
|
#: code:addons/excel_import_export/models/xlsx_import.py:232
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
msgid "Post import operation error\n"
|
||||||
"Post import operation error\n"
|
|
||||||
"%s"
|
"%s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"发布导入操作错误\n"
|
"发布导入操作错误\n"
|
||||||
|
@ -1130,14 +1023,12 @@ msgstr "模板名称"
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/common.py:242
|
#: code:addons/excel_import_export/models/common.py:242
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid ""
|
msgid "Template with CSV Quoting = False, data must not contain the same char as delimiter -> \"%s\""
|
||||||
"Template with CSV Quoting = False, data must not contain the same char as "
|
|
||||||
"delimiter -> \"%s\""
|
|
||||||
msgstr "CSV Quoting =False的模板,数据不能包含与分隔符相同的字符->\"%s\""
|
msgstr "CSV Quoting =False的模板,数据不能包含与分隔符相同的字符->\"%s\""
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/models/xlsx_export.py:228
|
#: code:addons/excel_import_export/models/xlsx_export.py:230
|
||||||
#: code:addons/excel_import_export/models/xlsx_import.py:249
|
#: code:addons/excel_import_export/models/xlsx_import.py:244
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Template's model mismatch"
|
msgid "Template's model mismatch"
|
||||||
msgstr "模板的模型不匹配"
|
msgstr "模板的模型不匹配"
|
||||||
|
@ -1160,14 +1051,8 @@ msgstr "选定的重定向操作不适用于模型%s"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model:ir.model.fields,help:excel_import_export.field_ir_actions_report__report_type
|
#: model:ir.model.fields,help:excel_import_export.field_ir_actions_report__report_type
|
||||||
msgid ""
|
msgid "The type of the report that will be rendered, each one having its own rendering method. HTML means the report will be opened directly in your browser PDF means the report will be rendered using Wkhtmltopdf and downloaded by the user."
|
||||||
"The type of the report that will be rendered, each one having its own "
|
msgstr "将呈现的报告类型,每个报告都有自己的呈现方法。HTML表示报告将直接在浏览器中打开PDF表示报告将使用Wkhtmltopdf呈现并由用户下载。"
|
||||||
"rendering method. HTML means the report will be opened directly in your "
|
|
||||||
"browser PDF means the report will be rendered using Wkhtmltopdf and "
|
|
||||||
"downloaded by the user."
|
|
||||||
msgstr ""
|
|
||||||
"将呈现的报告类型,每个报告都有自己的呈现方法。HTML表示报告将直接在浏览器中打"
|
|
||||||
"开PDF表示报告将使用Wkhtmltopdf呈现并由用户下载。"
|
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: code:addons/excel_import_export/wizard/import_xlsx_wizard.py:89
|
#: code:addons/excel_import_export/wizard/import_xlsx_wizard.py:89
|
||||||
|
@ -1177,8 +1062,7 @@ msgstr "此导入操作在此文档上下文中不可用"
|
||||||
|
|
||||||
#. module: excel_import_export
|
#. module: excel_import_export
|
||||||
#: model:ir.model.fields,help:excel_import_export.field_xlsx_template__show_instruction
|
#: model:ir.model.fields,help:excel_import_export.field_xlsx_template__show_instruction
|
||||||
msgid ""
|
msgid "This is the computed instruction based on tab Import/Export,\n"
|
||||||
"This is the computed instruction based on tab Import/Export,\n"
|
|
||||||
"to be used by xlsx import/export engine"
|
"to be used by xlsx import/export engine"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"这是基于选项卡导入/导出的计算指令,\n"
|
"这是基于选项卡导入/导出的计算指令,\n"
|
||||||
|
|
|
@ -7,3 +7,17 @@ from . import xlsx_import
|
||||||
from . import xlsx_template
|
from . import xlsx_template
|
||||||
from . import xlsx_report
|
from . import xlsx_report
|
||||||
from . import ir_report
|
from . import ir_report
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# INSERT INTO "purchase_order_line" (
|
||||||
|
# "id", "create_uid", "create_date",
|
||||||
|
# "write_uid", "write_date", "date_planned",
|
||||||
|
# "display_type", "name", "order_id",
|
||||||
|
# "price_unit", "product_qty", "product_uom",
|
||||||
|
# "sequence") VALUES (
|
||||||
|
# nextval('purchase_order_line_id_seq'), 2, (now() at time zone 'UTC'),
|
||||||
|
# 2, (now() at time zone 'UTC'), '2020-10-05 09:39:28',
|
||||||
|
# NULL, '[FURN_0269] Office Chair Black', 8,
|
||||||
|
# '11111.00', '5.000', 1,
|
||||||
|
# 10)
|
||||||
|
|
|
@ -102,7 +102,7 @@ def get_field_style_cond(field):
|
||||||
|
|
||||||
|
|
||||||
def fill_cell_style(field, field_style, styles):
|
def fill_cell_style(field, field_style, styles):
|
||||||
field_styles = field_style.split(";")
|
field_styles = field_style.split(";") if field_style else []
|
||||||
for f in field_styles:
|
for f in field_styles:
|
||||||
(key, value) = f.split("=")
|
(key, value) = f.split("=")
|
||||||
if key not in styles.keys():
|
if key not in styles.keys():
|
||||||
|
|
|
@ -8,7 +8,7 @@ from odoo import api, models
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from openpyxl.styles import colors, PatternFill, Alignment, Font
|
from openpyxl.styles import PatternFill, Alignment, Font
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_logger.debug('Cannot import "openpyxl". Please make sure it is installed.')
|
_logger.debug('Cannot import "openpyxl". Please make sure it is installed.')
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class XLSXStyles(models.AbstractModel):
|
||||||
return {
|
return {
|
||||||
"font": {
|
"font": {
|
||||||
"bold": Font(name="Arial", size=10, bold=True),
|
"bold": Font(name="Arial", size=10, bold=True),
|
||||||
"bold_red": Font(name="Arial", size=10, color=colors.RED, bold=True),
|
"bold_red": Font(name="Arial", size=10, color="FF0000", bold=True),
|
||||||
},
|
},
|
||||||
"fill": {
|
"fill": {
|
||||||
"red": PatternFill("solid", fgColor="FF0000"),
|
"red": PatternFill("solid", fgColor="FF0000"),
|
||||||
|
|
|
@ -51,6 +51,7 @@ class XLSXExport(models.AbstractModel):
|
||||||
"""
|
"""
|
||||||
line_field, max_row = co.get_line_max(line_field)
|
line_field, max_row = co.get_line_max(line_field)
|
||||||
line_field = line_field.replace("_CONT_", "") # Remove _CONT_ if any
|
line_field = line_field.replace("_CONT_", "") # Remove _CONT_ if any
|
||||||
|
line_field = line_field.replace("_EXTEND_", "") # Remove _EXTEND_ if any
|
||||||
lines = record[line_field]
|
lines = record[line_field]
|
||||||
if max_row > 0 and len(lines) > max_row:
|
if max_row > 0 and len(lines) > max_row:
|
||||||
raise Exception(_("Records in %s exceed max records allowed") % line_field)
|
raise Exception(_("Records in %s exceed max records allowed") % line_field)
|
||||||
|
@ -89,10 +90,7 @@ class XLSXExport(models.AbstractModel):
|
||||||
elif style is False:
|
elif style is False:
|
||||||
style = field_style_dict[field[0]] # Use default style
|
style = field_style_dict[field[0]] # Use default style
|
||||||
vals[field[0]].append((value, style))
|
vals[field[0]].append((value, style))
|
||||||
return (
|
return (vals, aggre_func_dict)
|
||||||
vals,
|
|
||||||
aggre_func_dict,
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _eval_style_cond(self, model, record, value, style_cond):
|
def _eval_style_cond(self, model, record, value, style_cond):
|
||||||
|
@ -185,6 +183,7 @@ class XLSXExport(models.AbstractModel):
|
||||||
fields = ws.get(line_field, {}).values()
|
fields = ws.get(line_field, {}).values()
|
||||||
vals, func = self._get_line_vals(record, line_field, fields)
|
vals, func = self._get_line_vals(record, line_field, fields)
|
||||||
is_cont = "_CONT_" in line_field and True or False # continue row
|
is_cont = "_CONT_" in line_field and True or False # continue row
|
||||||
|
is_extend = "_EXTEND_" in line_field and True or False # extend row
|
||||||
cont_set = 0
|
cont_set = 0
|
||||||
rows_inserted = False # flag to insert row
|
rows_inserted = False # flag to insert row
|
||||||
for rc, field in ws.get(line_field, {}).items():
|
for rc, field in ws.get(line_field, {}).items():
|
||||||
|
@ -200,9 +199,9 @@ class XLSXExport(models.AbstractModel):
|
||||||
new_rc = False
|
new_rc = False
|
||||||
row_count = len(vals[field])
|
row_count = len(vals[field])
|
||||||
# Insert rows to preserve total line
|
# Insert rows to preserve total line
|
||||||
if not rows_inserted:
|
if is_extend and not rows_inserted:
|
||||||
rows_inserted = True
|
rows_inserted = True
|
||||||
st.insert_rows(row + 1, amount=row_count - 1)
|
st.insert_rows(row + 1, row_count - 1)
|
||||||
# --
|
# --
|
||||||
for (row_val, style) in vals[field]:
|
for (row_val, style) in vals[field]:
|
||||||
new_row = row + i
|
new_row = row + i
|
||||||
|
@ -220,6 +219,7 @@ class XLSXExport(models.AbstractModel):
|
||||||
new_row += 1
|
new_row += 1
|
||||||
f_rc = "{}{}".format(col, new_row)
|
f_rc = "{}{}".format(col, new_row)
|
||||||
st[f_rc] = "={}({}:{})".format(f, rc, new_rc)
|
st[f_rc] = "={}({}:{})".format(f, rc, new_rc)
|
||||||
|
styles = self.env["xlsx.styles"].get_openpyxl_styles()
|
||||||
co.fill_cell_style(st[f_rc], style, styles)
|
co.fill_cell_style(st[f_rc], style, styles)
|
||||||
cont_row = cont_row < new_row and new_row or cont_row
|
cont_row = cont_row < new_row and new_row or cont_row
|
||||||
return
|
return
|
||||||
|
@ -255,7 +255,7 @@ class XLSXExport(models.AbstractModel):
|
||||||
content = BytesIO()
|
content = BytesIO()
|
||||||
wb.save(content)
|
wb.save(content)
|
||||||
content.seek(0) # Set index to 0, and start reading
|
content.seek(0) # Set index to 0, and start reading
|
||||||
out_file = base64.encodestring(content.read())
|
out_file = base64.encodebytes(content.read())
|
||||||
if record and "name" in record and record.name:
|
if record and "name" in record and record.name:
|
||||||
out_name = record.name.replace(" ", "").replace("/", "")
|
out_name = record.name.replace(" ", "").replace("/", "")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -89,18 +89,40 @@ class XLSXImport(models.AbstractModel):
|
||||||
if line_field in record and record[line_field]:
|
if line_field in record and record[line_field]:
|
||||||
record[line_field].unlink()
|
record[line_field].unlink()
|
||||||
# Remove _NODEL_ from dict
|
# Remove _NODEL_ from dict
|
||||||
for s, sv in data_dict.items():
|
for s, _sv in data_dict.copy().items():
|
||||||
for f, fv in data_dict[s].items():
|
for f, _fv in data_dict[s].copy().items():
|
||||||
if "_NODEL_" in f:
|
if "_NODEL_" in f:
|
||||||
new_fv = data_dict[s].pop(f)
|
new_fv = data_dict[s].pop(f)
|
||||||
data_dict[s][f.replace("_NODEL_", "")] = new_fv
|
data_dict[s][f.replace("_NODEL_", "")] = new_fv
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValidationError(_("Error deleting data\n%s") % e)
|
raise ValidationError(_("Error deleting data\n%s") % e)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_end_row(self, st, worksheet, line_field):
|
||||||
|
""" Get max row or next empty row as the ending row """
|
||||||
|
_x, max_row = co.get_line_max(line_field)
|
||||||
|
test_rows = {}
|
||||||
|
max_end_row = 0
|
||||||
|
for rc, _col in worksheet.get(line_field, {}).items():
|
||||||
|
rc, key_eval_cond = co.get_field_condition(rc)
|
||||||
|
row, col = co.pos2idx(rc)
|
||||||
|
# Use max_row, i.e., order_line[5], use it. Otherwise, use st.nrows
|
||||||
|
max_end_row = st.nrows if max_row is False else (row + max_row)
|
||||||
|
for idx in range(row, max_row and max_end_row or st.nrows):
|
||||||
|
cell_type = st.cell_type(idx, col) # empty type = 0
|
||||||
|
r_types = test_rows.get(idx, [])
|
||||||
|
r_types.append(cell_type)
|
||||||
|
test_rows[idx] = r_types
|
||||||
|
empty_list = filter(lambda y: all(i == 0 for i in y[1]), test_rows.items())
|
||||||
|
empty_rows = list(map(lambda z: z[0], empty_list))
|
||||||
|
next_empty_row = empty_rows and min(empty_rows) or max_end_row
|
||||||
|
return next_empty_row
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_line_vals(self, st, worksheet, model, line_field):
|
def _get_line_vals(self, st, worksheet, model, line_field):
|
||||||
""" Get values of this field from excel sheet """
|
""" Get values of this field from excel sheet """
|
||||||
vals = {}
|
vals = {}
|
||||||
|
end_row = self._get_end_row(st, worksheet, line_field)
|
||||||
for rc, columns in worksheet.get(line_field, {}).items():
|
for rc, columns in worksheet.get(line_field, {}).items():
|
||||||
if not isinstance(columns, list):
|
if not isinstance(columns, list):
|
||||||
columns = [columns]
|
columns = [columns]
|
||||||
|
@ -108,10 +130,11 @@ class XLSXImport(models.AbstractModel):
|
||||||
rc, key_eval_cond = co.get_field_condition(rc)
|
rc, key_eval_cond = co.get_field_condition(rc)
|
||||||
x_field, val_eval_cond = co.get_field_condition(field)
|
x_field, val_eval_cond = co.get_field_condition(field)
|
||||||
row, col = co.pos2idx(rc)
|
row, col = co.pos2idx(rc)
|
||||||
out_field = "{}/{}".format(line_field, x_field)
|
new_line_field, _x = co.get_line_max(line_field)
|
||||||
|
out_field = "{}/{}".format(new_line_field, x_field)
|
||||||
field_type = self._get_field_type(model, out_field)
|
field_type = self._get_field_type(model, out_field)
|
||||||
vals.update({out_field: []})
|
vals.update({out_field: []})
|
||||||
for idx in range(row, st.nrows):
|
for idx in range(row, end_row):
|
||||||
value = co._get_cell_value(st.cell(idx, col), field_type=field_type)
|
value = co._get_cell_value(st.cell(idx, col), field_type=field_type)
|
||||||
eval_context = self.get_eval_context(model=model, value=value)
|
eval_context = self.get_eval_context(model=model, value=value)
|
||||||
if key_eval_cond:
|
if key_eval_cond:
|
||||||
|
@ -123,6 +146,53 @@ class XLSXImport(models.AbstractModel):
|
||||||
vals.pop(out_field)
|
vals.pop(out_field)
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _process_worksheet(self, wb, out_wb, out_st, model, data_dict, header_fields):
|
||||||
|
col_idx = 1
|
||||||
|
for sheet_name in data_dict: # For each Sheet
|
||||||
|
worksheet = data_dict[sheet_name]
|
||||||
|
st = False
|
||||||
|
if isinstance(sheet_name, str):
|
||||||
|
st = co.xlrd_get_sheet_by_name(wb, sheet_name)
|
||||||
|
elif isinstance(sheet_name, int):
|
||||||
|
st = wb.sheet_by_index(sheet_name - 1)
|
||||||
|
if not st:
|
||||||
|
raise ValidationError(_("Sheet %s not found") % sheet_name)
|
||||||
|
# HEAD updates
|
||||||
|
for rc, field in worksheet.get("_HEAD_", {}).items():
|
||||||
|
rc, key_eval_cond = co.get_field_condition(rc)
|
||||||
|
field, val_eval_cond = co.get_field_condition(field)
|
||||||
|
field_type = self._get_field_type(model, field)
|
||||||
|
value = False
|
||||||
|
try:
|
||||||
|
row, col = co.pos2idx(rc)
|
||||||
|
value = co._get_cell_value(st.cell(row, col), field_type=field_type)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
eval_context = self.get_eval_context(model=model, value=value)
|
||||||
|
if key_eval_cond:
|
||||||
|
value = str(safe_eval(key_eval_cond, eval_context))
|
||||||
|
if val_eval_cond:
|
||||||
|
value = str(safe_eval(val_eval_cond, eval_context))
|
||||||
|
out_st.write(0, col_idx, field) # Next Column
|
||||||
|
out_st.write(1, col_idx, value) # Next Value
|
||||||
|
header_fields.append(field)
|
||||||
|
col_idx += 1
|
||||||
|
# Line Items
|
||||||
|
line_fields = filter(lambda x: x != "_HEAD_", worksheet)
|
||||||
|
for line_field in line_fields:
|
||||||
|
vals = self._get_line_vals(st, worksheet, model, line_field)
|
||||||
|
for field in vals:
|
||||||
|
# Columns, i.e., line_ids/field_id
|
||||||
|
out_st.write(0, col_idx, field)
|
||||||
|
header_fields.append(field)
|
||||||
|
# Data
|
||||||
|
i = 1
|
||||||
|
for value in vals[field]:
|
||||||
|
out_st.write(i, col_idx, value)
|
||||||
|
i += 1
|
||||||
|
col_idx += 1
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _import_record_data(self, import_file, record, data_dict):
|
def _import_record_data(self, import_file, record, data_dict):
|
||||||
""" From complex excel, create temp simple excel and do import """
|
""" From complex excel, create temp simple excel and do import """
|
||||||
|
@ -130,9 +200,9 @@ class XLSXImport(models.AbstractModel):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
header_fields = []
|
header_fields = []
|
||||||
decoded_data = base64.decodestring(import_file)
|
model = record._name
|
||||||
|
decoded_data = base64.decodebytes(import_file)
|
||||||
wb = xlrd.open_workbook(file_contents=decoded_data)
|
wb = xlrd.open_workbook(file_contents=decoded_data)
|
||||||
col_idx = 0
|
|
||||||
out_wb = xlwt.Workbook()
|
out_wb = xlwt.Workbook()
|
||||||
out_st = out_wb.add_sheet("Sheet 1")
|
out_st = out_wb.add_sheet("Sheet 1")
|
||||||
xml_id = (
|
xml_id = (
|
||||||
|
@ -143,53 +213,9 @@ class XLSXImport(models.AbstractModel):
|
||||||
out_st.write(0, 0, "id") # id and xml_id on first column
|
out_st.write(0, 0, "id") # id and xml_id on first column
|
||||||
out_st.write(1, 0, xml_id)
|
out_st.write(1, 0, xml_id)
|
||||||
header_fields.append("id")
|
header_fields.append("id")
|
||||||
col_idx += 1
|
# Process on all worksheets
|
||||||
model = record._name
|
self._process_worksheet(wb, out_wb, out_st, model, data_dict, header_fields)
|
||||||
for sheet_name in data_dict: # For each Sheet
|
# --
|
||||||
worksheet = data_dict[sheet_name]
|
|
||||||
st = False
|
|
||||||
if isinstance(sheet_name, str):
|
|
||||||
st = co.xlrd_get_sheet_by_name(wb, sheet_name)
|
|
||||||
elif isinstance(sheet_name, int):
|
|
||||||
st = wb.sheet_by_index(sheet_name - 1)
|
|
||||||
if not st:
|
|
||||||
raise ValidationError(_("Sheet %s not found") % sheet_name)
|
|
||||||
# HEAD updates
|
|
||||||
for rc, field in worksheet.get("_HEAD_", {}).items():
|
|
||||||
rc, key_eval_cond = co.get_field_condition(rc)
|
|
||||||
field, val_eval_cond = co.get_field_condition(field)
|
|
||||||
field_type = self._get_field_type(model, field)
|
|
||||||
value = False
|
|
||||||
try:
|
|
||||||
row, col = co.pos2idx(rc)
|
|
||||||
value = co._get_cell_value(
|
|
||||||
st.cell(row, col), field_type=field_type
|
|
||||||
)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
eval_context = self.get_eval_context(model=model, value=value)
|
|
||||||
if key_eval_cond:
|
|
||||||
value = str(safe_eval(key_eval_cond, eval_context))
|
|
||||||
if val_eval_cond:
|
|
||||||
value = str(safe_eval(val_eval_cond, eval_context))
|
|
||||||
out_st.write(0, col_idx, field) # Next Column
|
|
||||||
out_st.write(1, col_idx, value) # Next Value
|
|
||||||
header_fields.append(field)
|
|
||||||
col_idx += 1
|
|
||||||
# Line Items
|
|
||||||
line_fields = filter(lambda x: x != "_HEAD_", worksheet)
|
|
||||||
for line_field in line_fields:
|
|
||||||
vals = self._get_line_vals(st, worksheet, model, line_field)
|
|
||||||
for field in vals:
|
|
||||||
# Columns, i.e., line_ids/field_id
|
|
||||||
out_st.write(0, col_idx, field)
|
|
||||||
header_fields.append(field)
|
|
||||||
# Data
|
|
||||||
i = 1
|
|
||||||
for value in vals[field]:
|
|
||||||
out_st.write(i, col_idx, value)
|
|
||||||
i += 1
|
|
||||||
col_idx += 1
|
|
||||||
content = BytesIO()
|
content = BytesIO()
|
||||||
out_wb.save(content)
|
out_wb.save(content)
|
||||||
content.seek(0) # Set index to 0, and start reading
|
content.seek(0) # Set index to 0, and start reading
|
||||||
|
@ -235,7 +261,7 @@ class XLSXImport(models.AbstractModel):
|
||||||
_("Invalid file style, only .xls or .xlsx file allowed")
|
_("Invalid file style, only .xls or .xlsx file allowed")
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValidationError(_("Error importing data\n%s") % e)
|
raise e
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _post_import_operation(self, record, operation):
|
def _post_import_operation(self, record, operation):
|
||||||
|
|
|
@ -11,8 +11,8 @@ class XLSXReport(models.AbstractModel):
|
||||||
_name = "xlsx.report"
|
_name = "xlsx.report"
|
||||||
_description = "Excel Report AbstractModel"
|
_description = "Excel Report AbstractModel"
|
||||||
|
|
||||||
name = fields.Char(string="File Name", readonly=True, size=500,)
|
name = fields.Char(string="File Name", readonly=True, size=500)
|
||||||
data = fields.Binary(string="File", readonly=True,)
|
data = fields.Binary(string="File", readonly=True)
|
||||||
template_id = fields.Many2one(
|
template_id = fields.Many2one(
|
||||||
"xlsx.template",
|
"xlsx.template",
|
||||||
string="Template",
|
string="Template",
|
||||||
|
@ -20,7 +20,7 @@ class XLSXReport(models.AbstractModel):
|
||||||
ondelete="cascade",
|
ondelete="cascade",
|
||||||
domain=lambda self: self._context.get("template_domain", []),
|
domain=lambda self: self._context.get("template_domain", []),
|
||||||
)
|
)
|
||||||
choose_template = fields.Boolean(string="Allow Choose Template", default=False,)
|
choose_template = fields.Boolean(string="Allow Choose Template", default=False)
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
[("choose", "Choose"), ("get", "Get")],
|
[("choose", "Choose"), ("get", "Get")],
|
||||||
default="choose",
|
default="choose",
|
||||||
|
@ -41,7 +41,6 @@ class XLSXReport(models.AbstractModel):
|
||||||
defaults["template_id"] = len(templates) == 1 and templates.id or False
|
defaults["template_id"] = len(templates) == 1 and templates.id or False
|
||||||
return defaults
|
return defaults
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def report_xlsx(self):
|
def report_xlsx(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
Export = self.env["xlsx.export"]
|
Export = self.env["xlsx.export"]
|
||||||
|
@ -51,7 +50,6 @@ class XLSXReport(models.AbstractModel):
|
||||||
"type": "ir.actions.act_window",
|
"type": "ir.actions.act_window",
|
||||||
"res_model": self._name,
|
"res_model": self._name,
|
||||||
"view_mode": "form",
|
"view_mode": "form",
|
||||||
"view_type": "form",
|
|
||||||
"res_id": self.id,
|
"res_id": self.id,
|
||||||
"views": [(False, "form")],
|
"views": [(False, "form")],
|
||||||
"target": "new",
|
"target": "new",
|
||||||
|
|
|
@ -7,7 +7,7 @@ from ast import literal_eval
|
||||||
from os.path import join as opj
|
from os.path import join as opj
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from odoo.modules.module import get_module_path
|
from odoo.modules.module import get_module_path
|
||||||
|
|
||||||
from . import common as co
|
from . import common as co
|
||||||
|
@ -24,18 +24,18 @@ class XLSXTemplate(models.Model):
|
||||||
_description = "Excel template file and instruction"
|
_description = "Excel template file and instruction"
|
||||||
_order = "name"
|
_order = "name"
|
||||||
|
|
||||||
name = fields.Char(string="Template Name", required=True,)
|
name = fields.Char(string="Template Name", required=True)
|
||||||
res_model = fields.Char(
|
res_model = fields.Char(
|
||||||
string="Resource Model",
|
string="Resource Model",
|
||||||
help="The database object this attachment will be attached to.",
|
help="The database object this attachment will be attached to.",
|
||||||
)
|
)
|
||||||
fname = fields.Char(string="File Name",)
|
fname = fields.Char(string="File Name")
|
||||||
gname = fields.Char(
|
gname = fields.Char(
|
||||||
string="Group Name",
|
string="Group Name",
|
||||||
help="Multiple template of same model, can belong to same group,\n"
|
help="Multiple template of same model, can belong to same group,\n"
|
||||||
"result in multiple template selection",
|
"result in multiple template selection",
|
||||||
)
|
)
|
||||||
description = fields.Char(string="Description",)
|
description = fields.Char(string="Description")
|
||||||
input_instruction = fields.Text(
|
input_instruction = fields.Text(
|
||||||
string="Instruction (Input)",
|
string="Instruction (Input)",
|
||||||
help="This is used to construct instruction in tab Import/Export",
|
help="This is used to construct instruction in tab Import/Export",
|
||||||
|
@ -45,8 +45,12 @@ class XLSXTemplate(models.Model):
|
||||||
compute="_compute_output_instruction",
|
compute="_compute_output_instruction",
|
||||||
help="Instruction on how to import/export, prepared by system.",
|
help="Instruction on how to import/export, prepared by system.",
|
||||||
)
|
)
|
||||||
datas = fields.Binary(string="File Content",)
|
datas = fields.Binary(string="File Content")
|
||||||
to_csv = fields.Boolean(string="Convert to CSV?", default=False,)
|
to_csv = fields.Boolean(
|
||||||
|
string="Convert to CSV?",
|
||||||
|
default=False,
|
||||||
|
help="Convert file into CSV format on export",
|
||||||
|
)
|
||||||
csv_delimiter = fields.Char(
|
csv_delimiter = fields.Char(
|
||||||
string="CSV Delimiter",
|
string="CSV Delimiter",
|
||||||
size=1,
|
size=1,
|
||||||
|
@ -67,10 +71,10 @@ class XLSXTemplate(models.Model):
|
||||||
help="Optional for CSV, default is full quoting.",
|
help="Optional for CSV, default is full quoting.",
|
||||||
)
|
)
|
||||||
export_ids = fields.One2many(
|
export_ids = fields.One2many(
|
||||||
comodel_name="xlsx.template.export", inverse_name="template_id",
|
comodel_name="xlsx.template.export", inverse_name="template_id"
|
||||||
)
|
)
|
||||||
import_ids = fields.One2many(
|
import_ids = fields.One2many(
|
||||||
comodel_name="xlsx.template.import", inverse_name="template_id",
|
comodel_name="xlsx.template.import", inverse_name="template_id"
|
||||||
)
|
)
|
||||||
post_import_hook = fields.Char(
|
post_import_hook = fields.Char(
|
||||||
string="Post Import Function Hook",
|
string="Post Import Function Hook",
|
||||||
|
@ -89,8 +93,36 @@ class XLSXTemplate(models.Model):
|
||||||
domain=[("type", "=", "ir.actions.act_window")],
|
domain=[("type", "=", "ir.actions.act_window")],
|
||||||
help="Optional action, redirection after finish import operation",
|
help="Optional action, redirection after finish import operation",
|
||||||
)
|
)
|
||||||
|
# Utilities
|
||||||
|
export_action_id = fields.Many2one(
|
||||||
|
comodel_name="ir.actions.act_window", ondelete="set null",
|
||||||
|
)
|
||||||
|
import_action_id = fields.Many2one(
|
||||||
|
comodel_name="ir.actions.act_window", ondelete="set null",
|
||||||
|
)
|
||||||
|
use_report_wizard = fields.Boolean(
|
||||||
|
string="Easy Reporting",
|
||||||
|
help="Use common report wizard model, instead of create specific model",
|
||||||
|
)
|
||||||
|
result_model_id = fields.Many2one(
|
||||||
|
comodel_name="ir.model",
|
||||||
|
string="Report Model",
|
||||||
|
help="When use commone wizard, choose the result model",
|
||||||
|
)
|
||||||
|
result_field = fields.Char(compute="_compute_result_field",)
|
||||||
|
report_menu_id = fields.Many2one(
|
||||||
|
comodel_name="ir.ui.menu", string="Report Menu", readonly=True,
|
||||||
|
)
|
||||||
|
report_action_id = fields.Many2one(
|
||||||
|
comodel_name="ir.actions.report", string="Report Action",
|
||||||
|
)
|
||||||
|
|
||||||
|
def _compute_result_field(self):
|
||||||
|
for rec in self:
|
||||||
|
rec.result_field = (
|
||||||
|
("x_%s_results" % rec.id) if rec.result_model_id else False
|
||||||
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("redirect_action", "res_model")
|
@api.constrains("redirect_action", "res_model")
|
||||||
def _check_action_model(self):
|
def _check_action_model(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
@ -105,13 +137,13 @@ class XLSXTemplate(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def load_xlsx_template(self, tempalte_ids, addon=False):
|
def load_xlsx_template(self, template_ids, addon=False):
|
||||||
for template in self.browse(tempalte_ids):
|
for template in self.browse(template_ids):
|
||||||
if not addon:
|
if not addon:
|
||||||
addon = list(template.get_external_id().values())[0].split(".")[0]
|
addon = list(template.get_external_id().values())[0].split(".")[0]
|
||||||
addon_path = get_module_path(addon)
|
addon_path = get_module_path(addon)
|
||||||
file_path = False
|
file_path = False
|
||||||
for root, dirs, files in os.walk(addon_path):
|
for root, _dirs, files in os.walk(addon_path):
|
||||||
for name in files:
|
for name in files:
|
||||||
if name == template.fname:
|
if name == template.fname:
|
||||||
file_path = os.path.abspath(opj(root, name))
|
file_path = os.path.abspath(opj(root, name))
|
||||||
|
@ -126,9 +158,11 @@ class XLSXTemplate(models.Model):
|
||||||
rec._compute_input_export_instruction()
|
rec._compute_input_export_instruction()
|
||||||
rec._compute_input_import_instruction()
|
rec._compute_input_import_instruction()
|
||||||
rec._compute_input_post_import_hook()
|
rec._compute_input_post_import_hook()
|
||||||
|
if vals.get("result_model_id"):
|
||||||
|
rec._update_result_field_common_wizard()
|
||||||
|
rec._update_result_export_ids()
|
||||||
return rec
|
return rec
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
res = super().write(vals)
|
res = super().write(vals)
|
||||||
if vals.get("input_instruction"):
|
if vals.get("input_instruction"):
|
||||||
|
@ -136,9 +170,89 @@ class XLSXTemplate(models.Model):
|
||||||
rec._compute_input_export_instruction()
|
rec._compute_input_export_instruction()
|
||||||
rec._compute_input_import_instruction()
|
rec._compute_input_import_instruction()
|
||||||
rec._compute_input_post_import_hook()
|
rec._compute_input_post_import_hook()
|
||||||
|
if vals.get("result_model_id"):
|
||||||
|
for rec in self:
|
||||||
|
rec._update_result_field_common_wizard()
|
||||||
|
rec._update_result_export_ids()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
def unlink(self):
|
||||||
|
self.env["ir.model.fields"].search(
|
||||||
|
[
|
||||||
|
("model", "=", "report.xlsx.wizard"),
|
||||||
|
("name", "=", self.mapped("result_field")),
|
||||||
|
]
|
||||||
|
).unlink()
|
||||||
|
return super().unlink()
|
||||||
|
|
||||||
|
def _update_result_field_common_wizard(self):
|
||||||
|
self.ensure_one()
|
||||||
|
_model = self.env["ir.model"].search([("model", "=", "report.xlsx.wizard")])
|
||||||
|
_model.ensure_one()
|
||||||
|
_field = self.env["ir.model.fields"].search(
|
||||||
|
[("model", "=", "report.xlsx.wizard"), ("name", "=", self.result_field)]
|
||||||
|
)
|
||||||
|
if not _field:
|
||||||
|
_field = self.env["ir.model.fields"].create(
|
||||||
|
{
|
||||||
|
"model_id": _model.id,
|
||||||
|
"name": self.result_field,
|
||||||
|
"field_description": "Results",
|
||||||
|
"ttype": "many2many",
|
||||||
|
"relation": self.result_model_id.model,
|
||||||
|
"store": False,
|
||||||
|
"depends": "res_model",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
_field.ensure_one()
|
||||||
|
_field.write({"relation": self.result_model_id.model})
|
||||||
|
_field.compute = """
|
||||||
|
self['%s'] = self.env['%s'].search(self.safe_domain(self.domain))
|
||||||
|
""" % (
|
||||||
|
self.result_field,
|
||||||
|
self.result_model_id.model,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _update_result_export_ids(self):
|
||||||
|
self.ensure_one()
|
||||||
|
results = self.env["xlsx.template.export"].search(
|
||||||
|
[("template_id", "=", self.id), ("row_field", "=", self.result_field)]
|
||||||
|
)
|
||||||
|
if not results:
|
||||||
|
self.export_ids.unlink()
|
||||||
|
self.write(
|
||||||
|
{
|
||||||
|
"export_ids": [
|
||||||
|
(0, 0, {"sequence": 10, "section_type": "sheet", "sheet": 1}),
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
"sequence": 20,
|
||||||
|
"section_type": "row",
|
||||||
|
"row_field": self.result_field,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
"sequence": 30,
|
||||||
|
"section_type": "data",
|
||||||
|
"excel_cell": "A1",
|
||||||
|
"field_name": "id",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.onchange("use_report_wizard")
|
||||||
|
def _onchange_use_report_wizard(self):
|
||||||
|
self.res_model = "report.xlsx.wizard" if self.use_report_wizard else False
|
||||||
|
self.redirect_action = False
|
||||||
|
|
||||||
def _compute_input_export_instruction(self):
|
def _compute_input_export_instruction(self):
|
||||||
self = self.with_context(compute_from_input=True)
|
self = self.with_context(compute_from_input=True)
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
@ -166,11 +280,16 @@ class XLSXTemplate(models.Model):
|
||||||
if "_CONT_" in row_field:
|
if "_CONT_" in row_field:
|
||||||
is_cont = True
|
is_cont = True
|
||||||
row_field = row_field.replace("_CONT_", "")
|
row_field = row_field.replace("_CONT_", "")
|
||||||
|
is_extend = False
|
||||||
|
if "_EXTEND_" in row_field:
|
||||||
|
is_extend = True
|
||||||
|
row_field = row_field.replace("_EXTEND_", "")
|
||||||
vals = {
|
vals = {
|
||||||
"sequence": sequence,
|
"sequence": sequence,
|
||||||
"section_type": (row_field == "_HEAD_" and "head" or "row"),
|
"section_type": (row_field == "_HEAD_" and "head" or "row"),
|
||||||
"row_field": row_field,
|
"row_field": row_field,
|
||||||
"is_cont": is_cont,
|
"is_cont": is_cont,
|
||||||
|
"is_extend": is_extend,
|
||||||
}
|
}
|
||||||
export_lines.append((0, 0, vals))
|
export_lines.append((0, 0, vals))
|
||||||
for excel_cell, field_name in lines.items():
|
for excel_cell, field_name in lines.items():
|
||||||
|
@ -184,7 +303,6 @@ class XLSXTemplate(models.Model):
|
||||||
export_lines.append((0, 0, vals))
|
export_lines.append((0, 0, vals))
|
||||||
rec.write({"export_ids": export_lines})
|
rec.write({"export_ids": export_lines})
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_input_import_instruction(self):
|
def _compute_input_import_instruction(self):
|
||||||
self = self.with_context(compute_from_input=True)
|
self = self.with_context(compute_from_input=True)
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
@ -230,7 +348,6 @@ class XLSXTemplate(models.Model):
|
||||||
import_lines.append((0, 0, vals))
|
import_lines.append((0, 0, vals))
|
||||||
rec.write({"import_ids": import_lines})
|
rec.write({"import_ids": import_lines})
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_input_post_import_hook(self):
|
def _compute_input_post_import_hook(self):
|
||||||
self = self.with_context(compute_from_input=True)
|
self = self.with_context(compute_from_input=True)
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
@ -238,7 +355,6 @@ class XLSXTemplate(models.Model):
|
||||||
input_dict = literal_eval(rec.input_instruction.strip())
|
input_dict = literal_eval(rec.input_instruction.strip())
|
||||||
rec.post_import_hook = input_dict.get("__POST_IMPORT__")
|
rec.post_import_hook = input_dict.get("__POST_IMPORT__")
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_output_instruction(self):
|
def _compute_output_instruction(self):
|
||||||
""" From database, compute back to dictionary """
|
""" From database, compute back to dictionary """
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
@ -259,6 +375,8 @@ class XLSXTemplate(models.Model):
|
||||||
row_field = line.row_field
|
row_field = line.row_field
|
||||||
if line.section_type == "row" and line.is_cont:
|
if line.section_type == "row" and line.is_cont:
|
||||||
row_field = "_CONT_%s" % row_field
|
row_field = "_CONT_%s" % row_field
|
||||||
|
if line.section_type == "row" and line.is_extend:
|
||||||
|
row_field = "_EXTEND_%s" % row_field
|
||||||
row_dict = {row_field: {}}
|
row_dict = {row_field: {}}
|
||||||
inst_dict[itype][prev_sheet].update(row_dict)
|
inst_dict[itype][prev_sheet].update(row_dict)
|
||||||
prev_row = row_field
|
prev_row = row_field
|
||||||
|
@ -305,6 +423,101 @@ class XLSXTemplate(models.Model):
|
||||||
inst_dict[itype] = rec.post_import_hook
|
inst_dict[itype] = rec.post_import_hook
|
||||||
rec.instruction = inst_dict
|
rec.instruction = inst_dict
|
||||||
|
|
||||||
|
def add_export_action(self):
|
||||||
|
self.ensure_one()
|
||||||
|
vals = {
|
||||||
|
"name": "Export Excel",
|
||||||
|
"res_model": "export.xlsx.wizard",
|
||||||
|
"binding_model_id": self.env["ir.model"]
|
||||||
|
.search([("model", "=", self.res_model)])
|
||||||
|
.id,
|
||||||
|
"binding_type": "action",
|
||||||
|
"target": "new",
|
||||||
|
"view_mode": "form",
|
||||||
|
"context": """
|
||||||
|
{'template_domain': [('res_model', '=', '%s'),
|
||||||
|
('fname', '=', '%s'),
|
||||||
|
('gname', '=', False)]}
|
||||||
|
"""
|
||||||
|
% (self.res_model, self.fname),
|
||||||
|
}
|
||||||
|
action = self.env["ir.actions.act_window"].create(vals)
|
||||||
|
self.export_action_id = action
|
||||||
|
|
||||||
|
def remove_export_action(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.export_action_id:
|
||||||
|
self.export_action_id.unlink()
|
||||||
|
|
||||||
|
def add_import_action(self):
|
||||||
|
self.ensure_one()
|
||||||
|
vals = {
|
||||||
|
"name": "Import Excel",
|
||||||
|
"res_model": "import.xlsx.wizard",
|
||||||
|
"binding_model_id": self.env["ir.model"]
|
||||||
|
.search([("model", "=", self.res_model)])
|
||||||
|
.id,
|
||||||
|
"binding_type": "action",
|
||||||
|
"target": "new",
|
||||||
|
"view_mode": "form",
|
||||||
|
"context": """
|
||||||
|
{'template_domain': [('res_model', '=', '%s'),
|
||||||
|
('fname', '=', '%s'),
|
||||||
|
('gname', '=', False)]}
|
||||||
|
"""
|
||||||
|
% (self.res_model, self.fname),
|
||||||
|
}
|
||||||
|
action = self.env["ir.actions.act_window"].create(vals)
|
||||||
|
self.import_action_id = action
|
||||||
|
|
||||||
|
def remove_import_action(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.import_action_id:
|
||||||
|
self.import_action_id.unlink()
|
||||||
|
|
||||||
|
def add_report_menu(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if not self.fname:
|
||||||
|
raise UserError(_("No file content!"))
|
||||||
|
# Create report action
|
||||||
|
vals = {
|
||||||
|
"name": self.name,
|
||||||
|
"report_type": "excel",
|
||||||
|
"model": "report.xlsx.wizard",
|
||||||
|
"report_name": self.fname,
|
||||||
|
"report_file": self.fname,
|
||||||
|
}
|
||||||
|
report_action = self.env["ir.actions.report"].create(vals)
|
||||||
|
self.report_action_id = report_action
|
||||||
|
# Create window action
|
||||||
|
vals = {
|
||||||
|
"name": self.name,
|
||||||
|
"res_model": "report.xlsx.wizard",
|
||||||
|
"binding_type": "action",
|
||||||
|
"target": "new",
|
||||||
|
"view_mode": "form",
|
||||||
|
"context": {
|
||||||
|
"report_action_id": report_action.id,
|
||||||
|
"default_res_model": self.result_model_id.model,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
action = self.env["ir.actions.act_window"].create(vals)
|
||||||
|
# Create menu
|
||||||
|
vals = {
|
||||||
|
"name": self.name,
|
||||||
|
"action": "{},{}".format(action._name, action.id),
|
||||||
|
}
|
||||||
|
menu = self.env["ir.ui.menu"].create(vals)
|
||||||
|
self.report_menu_id = menu
|
||||||
|
|
||||||
|
def remove_report_menu(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.report_action_id:
|
||||||
|
self.report_action_id.unlink()
|
||||||
|
if self.report_menu_id:
|
||||||
|
self.report_menu_id.action.unlink()
|
||||||
|
self.report_menu_id.unlink()
|
||||||
|
|
||||||
|
|
||||||
class XLSXTemplateImport(models.Model):
|
class XLSXTemplateImport(models.Model):
|
||||||
_name = "xlsx.template.import"
|
_name = "xlsx.template.import"
|
||||||
|
@ -318,15 +531,15 @@ class XLSXTemplateImport(models.Model):
|
||||||
ondelete="cascade",
|
ondelete="cascade",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
sequence = fields.Integer(string="Sequence", default=10,)
|
sequence = fields.Integer(string="Sequence", default=10)
|
||||||
sheet = fields.Char(string="Sheet",)
|
sheet = fields.Char(string="Sheet")
|
||||||
section_type = fields.Selection(
|
section_type = fields.Selection(
|
||||||
[("sheet", "Sheet"), ("head", "Head"), ("row", "Row"), ("data", "Data")],
|
[("sheet", "Sheet"), ("head", "Head"), ("row", "Row"), ("data", "Data")],
|
||||||
string="Section Type",
|
string="Section Type",
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
row_field = fields.Char(
|
row_field = fields.Char(
|
||||||
string="Row Field", help="If section type is row, this field is required",
|
string="Row Field", help="If section type is row, this field is required"
|
||||||
)
|
)
|
||||||
no_delete = fields.Boolean(
|
no_delete = fields.Boolean(
|
||||||
string="No Delete",
|
string="No Delete",
|
||||||
|
@ -334,9 +547,9 @@ class XLSXTemplateImport(models.Model):
|
||||||
help="By default, all rows will be deleted before import.\n"
|
help="By default, all rows will be deleted before import.\n"
|
||||||
"Select No Delete, otherwise",
|
"Select No Delete, otherwise",
|
||||||
)
|
)
|
||||||
excel_cell = fields.Char(string="Cell",)
|
excel_cell = fields.Char(string="Cell")
|
||||||
field_name = fields.Char(string="Field",)
|
field_name = fields.Char(string="Field")
|
||||||
field_cond = fields.Char(string="Field Cond.",)
|
field_cond = fields.Char(string="Field Cond.")
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
|
@ -348,9 +561,7 @@ class XLSXTemplateImport(models.Model):
|
||||||
if self._context.get("compute_from_input") and vals.get("field_name"):
|
if self._context.get("compute_from_input") and vals.get("field_name"):
|
||||||
field_name, field_cond = co.get_field_condition(vals["field_name"])
|
field_name, field_cond = co.get_field_condition(vals["field_name"])
|
||||||
field_cond = field_cond and "${%s}" % (field_cond or "") or False
|
field_cond = field_cond and "${%s}" % (field_cond or "") or False
|
||||||
vals.update(
|
vals.update({"field_name": field_name, "field_cond": field_cond})
|
||||||
{"field_name": field_name, "field_cond": field_cond,}
|
|
||||||
)
|
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,25 +577,30 @@ class XLSXTemplateExport(models.Model):
|
||||||
ondelete="cascade",
|
ondelete="cascade",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
sequence = fields.Integer(string="Sequence", default=10,)
|
sequence = fields.Integer(string="Sequence", default=10)
|
||||||
sheet = fields.Char(string="Sheet",)
|
sheet = fields.Char(string="Sheet")
|
||||||
section_type = fields.Selection(
|
section_type = fields.Selection(
|
||||||
[("sheet", "Sheet"), ("head", "Head"), ("row", "Row"), ("data", "Data")],
|
[("sheet", "Sheet"), ("head", "Head"), ("row", "Row"), ("data", "Data")],
|
||||||
string="Section Type",
|
string="Section Type",
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
row_field = fields.Char(
|
row_field = fields.Char(
|
||||||
string="Row Field", help="If section type is row, this field is required",
|
string="Row Field", help="If section type is row, this field is required"
|
||||||
)
|
)
|
||||||
is_cont = fields.Boolean(
|
is_cont = fields.Boolean(
|
||||||
string="Continue", default=False, help="Continue data rows after last data row",
|
string="Continue", default=False, help="Continue data rows after last data row"
|
||||||
)
|
)
|
||||||
excel_cell = fields.Char(string="Cell",)
|
is_extend = fields.Boolean(
|
||||||
field_name = fields.Char(string="Field",)
|
string="Extend",
|
||||||
field_cond = fields.Char(string="Field Cond.",)
|
default=False,
|
||||||
is_sum = fields.Boolean(string="Sum", default=False,)
|
help="Extend a blank row after filling each record, to extend the footer",
|
||||||
style = fields.Char(string="Default Style",)
|
)
|
||||||
style_cond = fields.Char(string="Style w/Cond.",)
|
excel_cell = fields.Char(string="Cell")
|
||||||
|
field_name = fields.Char(string="Field")
|
||||||
|
field_cond = fields.Char(string="Field Cond.")
|
||||||
|
is_sum = fields.Boolean(string="Sum", default=False)
|
||||||
|
style = fields.Char(string="Default Style")
|
||||||
|
style_cond = fields.Char(string="Style w/Cond.")
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
13.0.1.0.0 (2020-08-23)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
* Migration to Odoo 13
|
||||||
|
* Enhancement on usability, to be more configurable instead of coding
|
||||||
|
* Import/Export now have "Add/Remove Export Action", "Add/Remove Import Action"
|
||||||
|
* "Easy Report" option which allow user to create export directly by config only.
|
||||||
|
|
||||||
12.0.1.0.5 (2019-12-19)
|
12.0.1.0.5 (2019-12-19)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,4 @@ To install this module, you need to install following python library, **xlrd, xl
|
||||||
|
|
||||||
Then, simply install **excel_import_export**.
|
Then, simply install **excel_import_export**.
|
||||||
|
|
||||||
For demo, install **excel_import_export_demo**.
|
For demo, install **excel_import_export_demo**
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
- Module extension e.g., excel_import_export_async, that add ability to execute as async process.
|
- Module extension e.g., excel_import_export_async, that add ability to execute as async process.
|
||||||
- Ability to add contextual action in XLSX Tempalte, e.g., Add import action, Add export action. In similar manner as in Server Action.
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
Concepts
|
||||||
|
--------
|
||||||
|
|
||||||
This module contain pre-defined function and wizards to make exporting, importing and reporting easy.
|
This module contain pre-defined function and wizards to make exporting, importing and reporting easy.
|
||||||
|
|
||||||
At the heart of this module, there are 2 `main methods`
|
At the heart of this module, there are 2 `main methods`
|
||||||
|
@ -13,6 +16,9 @@ After install this module, go to Settings > Excel Import/Export > XLSX Templates
|
||||||
|
|
||||||
As this module provide tools, it is best to explain as use cases. For example use cases, please install **excel_import_export_demo**
|
As this module provide tools, it is best to explain as use cases. For example use cases, please install **excel_import_export_demo**
|
||||||
|
|
||||||
|
Use Cases
|
||||||
|
---------
|
||||||
|
|
||||||
**Use Case 1:** Export/Import Excel on existing document
|
**Use Case 1:** Export/Import Excel on existing document
|
||||||
|
|
||||||
This add export/import action menus in existing document (example - excel_import_export_demo/import_export_sale_order)
|
This add export/import action menus in existing document (example - excel_import_export_demo/import_export_sale_order)
|
||||||
|
@ -59,3 +65,24 @@ Please see example in excel_import_export_demo/report_action, which shows,
|
||||||
|
|
||||||
1. Print excel from an active sale.order
|
1. Print excel from an active sale.order
|
||||||
2. Run partner list report based on search criteria.
|
2. Run partner list report based on search criteria.
|
||||||
|
|
||||||
|
Easy Reporting Option
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Technically, this option is the same as "Create Excel Report" use case. But instead of having to write XML / Python code like normally do,
|
||||||
|
this option allow user to create a report based on a model or view, all by configuration only.
|
||||||
|
|
||||||
|
1. Goto > Technical> Excel Import/Export > XLSX Templates, and create a new template for a report.
|
||||||
|
2. On the new template, select "Easy Reporting" option, then select followings
|
||||||
|
- Report Model, this can be data model or data view we want to get the results from.
|
||||||
|
- Click upload your file and add the excel template (.xlsx)
|
||||||
|
- Click Save, system will create sample export line, user can add more fields according to results model.
|
||||||
|
3. Click Add Report Menu, the report menu will be created, user can change its location. Now the report is ready to use.
|
||||||
|
|
||||||
|
.. figure:: ../static/description/xlsx_template.png
|
||||||
|
:width: 800 px
|
||||||
|
|
||||||
|
Note: Using easy reporting mode, system will used a common criteria wizard.
|
||||||
|
|
||||||
|
.. figure:: ../static/description/common_wizard.png
|
||||||
|
:width: 800 px
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -379,35 +379,34 @@ ul.auto-toc {
|
||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
<div class="contents local topic" id="contents">
|
<div class="contents local topic" id="contents">
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><a class="reference internal" href="#installation" id="id7">Installation</a></li>
|
<li><a class="reference internal" href="#installation" id="id6">Installation</a></li>
|
||||||
<li><a class="reference internal" href="#usage" id="id8">Usage</a></li>
|
<li><a class="reference internal" href="#usage" id="id7">Usage</a></li>
|
||||||
<li><a class="reference internal" href="#known-issues-roadmap" id="id9">Known issues / Roadmap</a></li>
|
<li><a class="reference internal" href="#known-issues-roadmap" id="id8">Known issues / Roadmap</a></li>
|
||||||
<li><a class="reference internal" href="#changelog" id="id10">Changelog</a><ul>
|
<li><a class="reference internal" href="#changelog" id="id9">Changelog</a><ul>
|
||||||
<li><a class="reference internal" href="#id1" id="id11">12.0.1.0.5 (2019-12-19)</a></li>
|
<li><a class="reference internal" href="#id1" id="id10">12.0.1.0.4 (2019-08-28)</a></li>
|
||||||
<li><a class="reference internal" href="#id2" id="id12">12.0.1.0.4 (2019-08-28)</a></li>
|
<li><a class="reference internal" href="#id2" id="id11">12.0.1.0.3 (2019-08-09)</a></li>
|
||||||
<li><a class="reference internal" href="#id3" id="id13">12.0.1.0.3 (2019-08-09)</a></li>
|
<li><a class="reference internal" href="#id3" id="id12">12.0.1.0.2 (2019-08-07)</a></li>
|
||||||
<li><a class="reference internal" href="#id4" id="id14">12.0.1.0.2 (2019-08-07)</a></li>
|
<li><a class="reference internal" href="#id4" id="id13">12.0.1.0.1 (2019-06-24)</a></li>
|
||||||
<li><a class="reference internal" href="#id5" id="id15">12.0.1.0.1 (2019-06-24)</a></li>
|
<li><a class="reference internal" href="#id5" id="id14">12.0.1.0.0 (2019-02-24)</a></li>
|
||||||
<li><a class="reference internal" href="#id6" id="id16">12.0.1.0.0 (2019-02-24)</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference internal" href="#bug-tracker" id="id17">Bug Tracker</a></li>
|
<li><a class="reference internal" href="#bug-tracker" id="id15">Bug Tracker</a></li>
|
||||||
<li><a class="reference internal" href="#credits" id="id18">Credits</a><ul>
|
<li><a class="reference internal" href="#credits" id="id16">Credits</a><ul>
|
||||||
<li><a class="reference internal" href="#authors" id="id19">Authors</a></li>
|
<li><a class="reference internal" href="#authors" id="id17">Authors</a></li>
|
||||||
<li><a class="reference internal" href="#contributors" id="id20">Contributors</a></li>
|
<li><a class="reference internal" href="#contributors" id="id18">Contributors</a></li>
|
||||||
<li><a class="reference internal" href="#maintainers" id="id21">Maintainers</a></li>
|
<li><a class="reference internal" href="#maintainers" id="id19">Maintainers</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="installation">
|
<div class="section" id="installation">
|
||||||
<h1><a class="toc-backref" href="#id7">Installation</a></h1>
|
<h1><a class="toc-backref" href="#id6">Installation</a></h1>
|
||||||
<p>To install this module, you need to install following python library, <strong>xlrd, xlwt, openpyxl</strong>.</p>
|
<p>To install this module, you need to install following python library, <strong>xlrd, xlwt, openpyxl</strong>.</p>
|
||||||
<p>Then, simply install <strong>excel_import_export</strong>.</p>
|
<p>Then, simply install <strong>excel_import_export</strong>.</p>
|
||||||
<p>For demo, install <strong>excel_import_export_demo</strong>.</p>
|
<p>For demo, install <strong>excel_import_export_demo</strong>.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="usage">
|
<div class="section" id="usage">
|
||||||
<h1><a class="toc-backref" href="#id8">Usage</a></h1>
|
<h1><a class="toc-backref" href="#id7">Usage</a></h1>
|
||||||
<p>This module contain pre-defined function and wizards to make exporting, importing and reporting easy.</p>
|
<p>This module contain pre-defined function and wizards to make exporting, importing and reporting easy.</p>
|
||||||
<p>At the heart of this module, there are 2 <cite>main methods</cite></p>
|
<p>At the heart of this module, there are 2 <cite>main methods</cite></p>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
|
@ -463,53 +462,47 @@ Please see example in excel_import_export_demo/report_action, which shows,</p>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="known-issues-roadmap">
|
<div class="section" id="known-issues-roadmap">
|
||||||
<h1><a class="toc-backref" href="#id9">Known issues / Roadmap</a></h1>
|
<h1><a class="toc-backref" href="#id8">Known issues / Roadmap</a></h1>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Module extension e.g., excel_import_export_async, that add ability to execute as async process.</li>
|
<li>Module extension e.g., excel_import_export_async, that add ability to execute as async process.</li>
|
||||||
<li>Ability to add contextual action in XLSX Tempalte, e.g., Add import action, Add export action. In similar manner as in Server Action.</li>
|
<li>Ability to add contextual action in XLSX Tempalte, e.g., Add import action, Add export action. In similar manner as in Server Action.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="changelog">
|
<div class="section" id="changelog">
|
||||||
<h1><a class="toc-backref" href="#id10">Changelog</a></h1>
|
<h1><a class="toc-backref" href="#id9">Changelog</a></h1>
|
||||||
<div class="section" id="id1">
|
<div class="section" id="id1">
|
||||||
<h2><a class="toc-backref" href="#id11">12.0.1.0.5 (2019-12-19)</a></h2>
|
<h2><a class="toc-backref" href="#id10">12.0.1.0.4 (2019-08-28)</a></h2>
|
||||||
<ul class="simple">
|
|
||||||
<li>Speed up export when dealing with many rows</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="id2">
|
|
||||||
<h2><a class="toc-backref" href="#id12">12.0.1.0.4 (2019-08-28)</a></h2>
|
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Fix style sum in footer</li>
|
<li>Fix style sum in footer</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="id3">
|
<div class="section" id="id2">
|
||||||
<h2><a class="toc-backref" href="#id13">12.0.1.0.3 (2019-08-09)</a></h2>
|
<h2><a class="toc-backref" href="#id11">12.0.1.0.3 (2019-08-09)</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Add report action for report_type = ‘excel’</li>
|
<li>Add report action for report_type = ‘excel’</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="id4">
|
<div class="section" id="id3">
|
||||||
<h2><a class="toc-backref" href="#id14">12.0.1.0.2 (2019-08-07)</a></h2>
|
<h2><a class="toc-backref" href="#id12">12.0.1.0.2 (2019-08-07)</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Small fix, to ensure that system parameter ‘path_temp_file’ (ir.config_parameter) is readable</li>
|
<li>Small fix, to ensure that system parameter ‘path_temp_file’ (ir.config_parameter) is readable</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="id5">
|
<div class="section" id="id4">
|
||||||
<h2><a class="toc-backref" href="#id15">12.0.1.0.1 (2019-06-24)</a></h2>
|
<h2><a class="toc-backref" href="#id13">12.0.1.0.1 (2019-06-24)</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Fix wizard on v12 can’t download sample template file - <a class="reference external" href="https://github.com/OCA/server-tools/issues/1574">https://github.com/OCA/server-tools/issues/1574</a></li>
|
<li>Fix wizard on v12 can’t download sample template file - <a class="reference external" href="https://github.com/OCA/server-tools/issues/1574">https://github.com/OCA/server-tools/issues/1574</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="id6">
|
<div class="section" id="id5">
|
||||||
<h2><a class="toc-backref" href="#id16">12.0.1.0.0 (2019-02-24)</a></h2>
|
<h2><a class="toc-backref" href="#id14">12.0.1.0.0 (2019-02-24)</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Start of the history</li>
|
<li>Start of the history</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#id17">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#id15">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
|
@ -517,22 +510,22 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
<h1><a class="toc-backref" href="#id18">Credits</a></h1>
|
<h1><a class="toc-backref" href="#id16">Credits</a></h1>
|
||||||
<div class="section" id="authors">
|
<div class="section" id="authors">
|
||||||
<h2><a class="toc-backref" href="#id19">Authors</a></h2>
|
<h2><a class="toc-backref" href="#id17">Authors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Ecosoft</li>
|
<li>Ecosoft</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="contributors">
|
<div class="section" id="contributors">
|
||||||
<h2><a class="toc-backref" href="#id20">Contributors</a></h2>
|
<h2><a class="toc-backref" href="#id18">Contributors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Kitti Upariphutthiphong. <<a class="reference external" href="mailto:kittiu@gmail.com">kittiu@gmail.com</a>> (<a class="reference external" href="http://ecosoft.co.th">http://ecosoft.co.th</a>)</li>
|
<li>Kitti Upariphutthiphong. <<a class="reference external" href="mailto:kittiu@gmail.com">kittiu@gmail.com</a>> (<a class="reference external" href="http://ecosoft.co.th">http://ecosoft.co.th</a>)</li>
|
||||||
<li>Saran Lim. <<a class="reference external" href="mailto:saranl@ecosoft.co.th">saranl@ecosoft.co.th</a>> (<a class="reference external" href="http://ecosoft.co.th">http://ecosoft.co.th</a>)</li>
|
<li>Saran Lim. <<a class="reference external" href="mailto:saranl@ecosoft.co.th">saranl@ecosoft.co.th</a>> (<a class="reference external" href="http://ecosoft.co.th">http://ecosoft.co.th</a>)</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#id21">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#id19">Maintainers</a></h2>
|
||||||
<p>This module is maintained by the OCA.</p>
|
<p>This module is maintained by the OCA.</p>
|
||||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 80 KiB |
|
@ -1,21 +1,21 @@
|
||||||
// Copyright 2019 Ecosoft Co., Ltd.
|
// © 2017 Creu Blanca
|
||||||
// License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).
|
// License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).
|
||||||
odoo.define("excel_import_export.report", function(require) {
|
odoo.define("excel_import_export.report", function(require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var core = require("web.core");
|
var core = require("web.core");
|
||||||
var ActionManager = require("web.ActionManager");
|
var ActionManager = require("web.ActionManager");
|
||||||
var crash_manager = require("web.crash_manager");
|
|
||||||
var framework = require("web.framework");
|
var framework = require("web.framework");
|
||||||
var session = require("web.session");
|
var session = require("web.session");
|
||||||
var _t = core._t;
|
var _t = core._t;
|
||||||
|
|
||||||
ActionManager.include({
|
ActionManager.include({
|
||||||
_downloadReportExcel: function(url, actions) {
|
_downloadReportExcel: function(url, actions) {
|
||||||
|
var self = this;
|
||||||
framework.blockUI();
|
framework.blockUI();
|
||||||
var def = $.Deferred();
|
|
||||||
var type = "excel";
|
var type = "excel";
|
||||||
var cloned_action = _.clone(actions);
|
var cloned_action = _.clone(actions);
|
||||||
|
var new_url = url;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
_.isUndefined(cloned_action.data) ||
|
_.isUndefined(cloned_action.data) ||
|
||||||
|
@ -23,41 +23,42 @@ odoo.define("excel_import_export.report", function(require) {
|
||||||
(_.isObject(cloned_action.data) && _.isEmpty(cloned_action.data))
|
(_.isObject(cloned_action.data) && _.isEmpty(cloned_action.data))
|
||||||
) {
|
) {
|
||||||
if (cloned_action.context.active_ids) {
|
if (cloned_action.context.active_ids) {
|
||||||
url += "/" + cloned_action.context.active_ids.join(",");
|
new_url += "/" + cloned_action.context.active_ids.join(",");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
url +=
|
new_url +=
|
||||||
"?options=" +
|
"?options=" +
|
||||||
encodeURIComponent(JSON.stringify(cloned_action.data));
|
encodeURIComponent(JSON.stringify(cloned_action.data));
|
||||||
url +=
|
new_url +=
|
||||||
"&context=" +
|
"&context=" +
|
||||||
encodeURIComponent(JSON.stringify(cloned_action.context));
|
encodeURIComponent(JSON.stringify(cloned_action.context));
|
||||||
}
|
}
|
||||||
|
|
||||||
var blocked = !session.get_file({
|
return new Promise(function(resolve, reject) {
|
||||||
url: url,
|
var blocked = !session.get_file({
|
||||||
data: {
|
url: new_url,
|
||||||
data: JSON.stringify([url, type]),
|
data: {
|
||||||
},
|
data: JSON.stringify([new_url, type]),
|
||||||
success: def.resolve.bind(def),
|
},
|
||||||
error: function() {
|
success: resolve,
|
||||||
crash_manager.rpc_error.apply(crash_manager, arguments);
|
error: error => {
|
||||||
def.reject();
|
self.call("crash_manager", "rpc_error", error);
|
||||||
},
|
reject();
|
||||||
complete: framework.unblockUI,
|
},
|
||||||
|
complete: framework.unblockUI,
|
||||||
|
});
|
||||||
|
if (blocked) {
|
||||||
|
// AAB: this check should be done in get_file service directly,
|
||||||
|
// should not be the concern of the caller (and that way, get_file
|
||||||
|
// could return a deferred)
|
||||||
|
var message = _t(
|
||||||
|
"A popup window with your report was blocked. You " +
|
||||||
|
"may need to change your browser settings to allow " +
|
||||||
|
"popup windows for this page."
|
||||||
|
);
|
||||||
|
this.do_warn(_t("Warning"), message, true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (blocked) {
|
|
||||||
// AAB: this check should be done in get_file service directly,
|
|
||||||
// should not be the concern of the caller (and that way, get_file
|
|
||||||
// could return a deferred)
|
|
||||||
var message = _t(
|
|
||||||
"A popup window with your report was blocked. You " +
|
|
||||||
"may need to change your browser settings to allow " +
|
|
||||||
"popup windows for this page."
|
|
||||||
);
|
|
||||||
this.do_warn(_t("Warning"), message, true);
|
|
||||||
}
|
|
||||||
return def;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_triggerDownload: function(action, options, type) {
|
_triggerDownload: function(action, options, type) {
|
||||||
|
|
|
@ -16,6 +16,25 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="XLSX Template">
|
<form string="XLSX Template">
|
||||||
<sheet>
|
<sheet>
|
||||||
|
<div class="oe_button_box" name="button_box">
|
||||||
|
<button
|
||||||
|
name="add_report_menu"
|
||||||
|
string="Add Report Menu"
|
||||||
|
type="object"
|
||||||
|
attrs="{'invisible': ['|', ('use_report_wizard', '=', False), ('report_menu_id', '!=', False)]}"
|
||||||
|
icon="fa-plus-square"
|
||||||
|
help="Add new report menu at root level"
|
||||||
|
class="oe_stat_button"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
name="remove_report_menu"
|
||||||
|
string="Remove Report Menu"
|
||||||
|
type="object"
|
||||||
|
attrs="{'invisible': [('report_menu_id', '=', False)]}"
|
||||||
|
icon="fa-minus-square"
|
||||||
|
class="oe_stat_button"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<h1>
|
<h1>
|
||||||
<field name="name" colspan="3" />
|
<field name="name" colspan="3" />
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -35,6 +54,20 @@
|
||||||
name="csv_quote"
|
name="csv_quote"
|
||||||
attrs="{'invisible': [('to_csv', '=', False)]}"
|
attrs="{'invisible': [('to_csv', '=', False)]}"
|
||||||
/>
|
/>
|
||||||
|
<field name="use_report_wizard" />
|
||||||
|
<field
|
||||||
|
name="report_menu_id"
|
||||||
|
attrs="{'invisible': [('report_menu_id', '=', False)]}"
|
||||||
|
/>
|
||||||
|
<field
|
||||||
|
name="result_model_id"
|
||||||
|
attrs="{'invisible': [('use_report_wizard', '=', False)],
|
||||||
|
'required': [('use_report_wizard', '=', True)]}"
|
||||||
|
/>
|
||||||
|
<field
|
||||||
|
name="result_field"
|
||||||
|
attrs="{'invisible': [('use_report_wizard', '=', False)]}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="fname" invisible="1" />
|
<field name="fname" invisible="1" />
|
||||||
|
@ -46,6 +79,26 @@
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="Export">
|
<page string="Export">
|
||||||
|
<div
|
||||||
|
name="export_actions"
|
||||||
|
attrs="{'invisible': [('use_report_wizard', '=', True)]}"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
name="add_export_action"
|
||||||
|
class="oe_highlight"
|
||||||
|
type="object"
|
||||||
|
string="Add Export Action"
|
||||||
|
attrs="{'invisible': [('export_action_id', '!=', False)]}"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
name="remove_export_action"
|
||||||
|
type="object"
|
||||||
|
string="Remove Export Action"
|
||||||
|
attrs="{'invisible': [('export_action_id', '=', False)]}"
|
||||||
|
/>
|
||||||
|
<field name="export_action_id" invisible="1" />
|
||||||
|
</div>
|
||||||
|
<separator />
|
||||||
<field name="export_ids">
|
<field name="export_ids">
|
||||||
<tree name="export_instruction" editable="bottom">
|
<tree name="export_instruction" editable="bottom">
|
||||||
<control>
|
<control>
|
||||||
|
@ -83,6 +136,11 @@
|
||||||
attrs="{'required': [('section_type', 'in', ('head', 'row'))],
|
attrs="{'required': [('section_type', 'in', ('head', 'row'))],
|
||||||
'invisible': [('section_type', 'not in', ('head', 'row'))]}"
|
'invisible': [('section_type', 'not in', ('head', 'row'))]}"
|
||||||
/>
|
/>
|
||||||
|
<field
|
||||||
|
name="is_extend"
|
||||||
|
attrs="{'required': [('section_type', 'in', ('head', 'row'))],
|
||||||
|
'invisible': [('section_type', 'not in', ('head', 'row'))]}"
|
||||||
|
/>
|
||||||
<field
|
<field
|
||||||
name="excel_cell"
|
name="excel_cell"
|
||||||
attrs="{'required': [('section_type', '=', 'data')],
|
attrs="{'required': [('section_type', '=', 'data')],
|
||||||
|
@ -132,6 +190,8 @@
|
||||||
>Row Field</b>: Use _HEAD_ for the record itself, and one2many field (e.g., line_ids) for row data</li>
|
>Row Field</b>: Use _HEAD_ for the record itself, and one2many field (e.g., line_ids) for row data</li>
|
||||||
<li><b
|
<li><b
|
||||||
>Continue</b>: If not selected, start rolling with specified first row cells. If selected, continue from previous one2many field</li>
|
>Continue</b>: If not selected, start rolling with specified first row cells. If selected, continue from previous one2many field</li>
|
||||||
|
<li><b
|
||||||
|
>Extend</b>: If selected, extend one row after one data row in order to preserve the sum line</li>
|
||||||
<li><b
|
<li><b
|
||||||
>Cell</b>: Location of data in excel sheet (e.g., A1, B1, ...)</li>
|
>Cell</b>: Location of data in excel sheet (e.g., A1, B1, ...)</li>
|
||||||
<li><b
|
<li><b
|
||||||
|
@ -168,7 +228,27 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</page>
|
</page>
|
||||||
<page string="Import">
|
<page
|
||||||
|
string="Import"
|
||||||
|
attrs="{'invisible': [('use_report_wizard', '=', True)]}"
|
||||||
|
>
|
||||||
|
<div name="import_actions">
|
||||||
|
<button
|
||||||
|
name="add_import_action"
|
||||||
|
class="oe_highlight"
|
||||||
|
type="object"
|
||||||
|
string="Add Import Action"
|
||||||
|
attrs="{'invisible': [('import_action_id', '!=', False)]}"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
name="remove_import_action"
|
||||||
|
type="object"
|
||||||
|
string="Remove Import Action"
|
||||||
|
attrs="{'invisible': [('import_action_id', '=', False)]}"
|
||||||
|
/>
|
||||||
|
<field name="import_action_id" invisible="1" />
|
||||||
|
</div>
|
||||||
|
<separator />
|
||||||
<field name="import_ids">
|
<field name="import_ids">
|
||||||
<tree name="import_instruction" editable="bottom">
|
<tree name="import_instruction" editable="bottom">
|
||||||
<control>
|
<control>
|
||||||
|
@ -246,7 +326,9 @@
|
||||||
<li><b
|
<li><b
|
||||||
>Sheet</b>: Name (e.g., Sheet 1) or index (e.g., 1) of excel sheet</li>
|
>Sheet</b>: Name (e.g., Sheet 1) or index (e.g., 1) of excel sheet</li>
|
||||||
<li><b
|
<li><b
|
||||||
>Row Field</b>: Use _HEAD_ for the record itself, and one2many field (e.g., line_ids) for row data</li>
|
>Row Field</b>: Use _HEAD_ for the record itself, and one2many field for row data, e.g., order_line, line_ids<code
|
||||||
|
>[max_row]</code> where <code
|
||||||
|
>[max_row]</code> is optional number of rows to import</li>
|
||||||
<li><b
|
<li><b
|
||||||
>No Delete</b>: By default, all one2many lines will be deleted before import. Select this, to avoid deletion</li>
|
>No Delete</b>: By default, all one2many lines will be deleted before import. Select this, to avoid deletion</li>
|
||||||
<li><b
|
<li><b
|
||||||
|
@ -329,7 +411,6 @@
|
||||||
<field name="name">XLSX Templates</field>
|
<field name="name">XLSX Templates</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">xlsx.template</field>
|
<field name="res_model">xlsx.template</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="oe_view_nocontent_create">
|
<p class="oe_view_nocontent_create">
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
from . import export_xlsx_wizard
|
from . import export_xlsx_wizard
|
||||||
from . import import_xlsx_wizard
|
from . import import_xlsx_wizard
|
||||||
|
from . import report_xlsx_wizard
|
||||||
|
|
|
@ -12,8 +12,8 @@ class ExportXLSXWizard(models.TransientModel):
|
||||||
_name = "export.xlsx.wizard"
|
_name = "export.xlsx.wizard"
|
||||||
_description = "Wizard for exporting excel"
|
_description = "Wizard for exporting excel"
|
||||||
|
|
||||||
name = fields.Char(string="File Name", readonly=True, size=500,)
|
name = fields.Char(string="File Name", readonly=True, size=500)
|
||||||
data = fields.Binary(string="File", readonly=True,)
|
data = fields.Binary(string="File", readonly=True)
|
||||||
template_id = fields.Many2one(
|
template_id = fields.Many2one(
|
||||||
"xlsx.template",
|
"xlsx.template",
|
||||||
string="Template",
|
string="Template",
|
||||||
|
@ -21,9 +21,9 @@ class ExportXLSXWizard(models.TransientModel):
|
||||||
ondelete="cascade",
|
ondelete="cascade",
|
||||||
domain=lambda self: self._context.get("template_domain", []),
|
domain=lambda self: self._context.get("template_domain", []),
|
||||||
)
|
)
|
||||||
res_id = fields.Integer(string="Resource ID", readonly=True, required=True,)
|
res_id = fields.Integer(string="Resource ID", readonly=True, required=True)
|
||||||
res_model = fields.Char(
|
res_model = fields.Char(
|
||||||
string="Resource Model", readonly=True, required=True, size=500,
|
string="Resource Model", readonly=True, required=True, size=500
|
||||||
)
|
)
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
[("choose", "Choose"), ("get", "Get")],
|
[("choose", "Choose"), ("get", "Get")],
|
||||||
|
@ -49,7 +49,6 @@ class ExportXLSXWizard(models.TransientModel):
|
||||||
defaults["res_model"] = res_model
|
defaults["res_model"] = res_model
|
||||||
return defaults
|
return defaults
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_export(self):
|
def action_export(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
Export = self.env["xlsx.export"]
|
Export = self.env["xlsx.export"]
|
||||||
|
@ -61,7 +60,6 @@ class ExportXLSXWizard(models.TransientModel):
|
||||||
"type": "ir.actions.act_window",
|
"type": "ir.actions.act_window",
|
||||||
"res_model": "export.xlsx.wizard",
|
"res_model": "export.xlsx.wizard",
|
||||||
"view_mode": "form",
|
"view_mode": "form",
|
||||||
"view_type": "form",
|
|
||||||
"res_id": self.id,
|
"res_id": self.id,
|
||||||
"views": [(False, "form")],
|
"views": [(False, "form")],
|
||||||
"target": "new",
|
"target": "new",
|
||||||
|
|
|
@ -12,19 +12,19 @@ class ImportXLSXWizard(models.TransientModel):
|
||||||
_name = "import.xlsx.wizard"
|
_name = "import.xlsx.wizard"
|
||||||
_description = "Wizard for importing excel"
|
_description = "Wizard for importing excel"
|
||||||
|
|
||||||
import_file = fields.Binary(string="Import File (*.xlsx)",)
|
import_file = fields.Binary(string="Import File (*.xlsx)")
|
||||||
template_id = fields.Many2one(
|
template_id = fields.Many2one(
|
||||||
"xlsx.template",
|
"xlsx.template",
|
||||||
string="Template",
|
string="Template",
|
||||||
required=True,
|
required=True,
|
||||||
ondelete="set null",
|
ondelete="cascade",
|
||||||
domain=lambda self: self._context.get("template_domain", []),
|
domain=lambda self: self._context.get("template_domain", []),
|
||||||
)
|
)
|
||||||
res_id = fields.Integer(string="Resource ID", readonly=True,)
|
res_id = fields.Integer(string="Resource ID", readonly=True)
|
||||||
res_model = fields.Char(string="Resource Model", readonly=True, size=500,)
|
res_model = fields.Char(string="Resource Model", readonly=True, size=500)
|
||||||
datas = fields.Binary(string="Sample", related="template_id.datas", readonly=True,)
|
datas = fields.Binary(string="Sample", related="template_id.datas", readonly=True)
|
||||||
fname = fields.Char(
|
fname = fields.Char(
|
||||||
string="Template Name", related="template_id.fname", readonly=True,
|
string="Template Name", related="template_id.fname", readonly=True
|
||||||
)
|
)
|
||||||
attachment_ids = fields.Many2many(
|
attachment_ids = fields.Many2many(
|
||||||
"ir.attachment",
|
"ir.attachment",
|
||||||
|
@ -108,7 +108,6 @@ class ImportXLSXWizard(models.TransientModel):
|
||||||
defaults["res_model"] = res_model
|
defaults["res_model"] = res_model
|
||||||
return defaults
|
return defaults
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def get_import_sample(self):
|
def get_import_sample(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
|
@ -116,14 +115,12 @@ class ImportXLSXWizard(models.TransientModel):
|
||||||
"type": "ir.actions.act_window",
|
"type": "ir.actions.act_window",
|
||||||
"res_model": "import.xlsx.wizard",
|
"res_model": "import.xlsx.wizard",
|
||||||
"view_mode": "form",
|
"view_mode": "form",
|
||||||
"view_type": "form",
|
|
||||||
"res_id": self.id,
|
"res_id": self.id,
|
||||||
"views": [(False, "form")],
|
"views": [(False, "form")],
|
||||||
"target": "new",
|
"target": "new",
|
||||||
"context": self._context.copy(),
|
"context": self._context.copy(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_import(self):
|
def action_import(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
Import = self.env["xlsx.import"]
|
Import = self.env["xlsx.import"]
|
||||||
|
@ -149,7 +146,6 @@ class ImportXLSXWizard(models.TransientModel):
|
||||||
"type": "ir.actions.act_window",
|
"type": "ir.actions.act_window",
|
||||||
"res_model": self._name,
|
"res_model": self._name,
|
||||||
"view_mode": "form",
|
"view_mode": "form",
|
||||||
"view_type": "form",
|
|
||||||
"res_id": self.id,
|
"res_id": self.id,
|
||||||
"views": [(False, "form")],
|
"views": [(False, "form")],
|
||||||
"target": "new",
|
"target": "new",
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||||
|
import ast
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ReportXLSXWizard(models.TransientModel):
|
||||||
|
_name = "report.xlsx.wizard"
|
||||||
|
_description = "Generic Report Wizard, used with template reporting option"
|
||||||
|
|
||||||
|
res_model = fields.Char()
|
||||||
|
domain = fields.Char(string="Search Criterias")
|
||||||
|
|
||||||
|
def action_report(self):
|
||||||
|
action_id = self._context.get("report_action_id")
|
||||||
|
action = self.env["ir.actions.report"].browse(action_id)
|
||||||
|
res = action.read()[0]
|
||||||
|
return res
|
||||||
|
|
||||||
|
def safe_domain(self, str_domain):
|
||||||
|
return ast.literal_eval(str_domain or "[]")
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!--
|
||||||
|
Copyright 2019 Ecosoft Co., Ltd.
|
||||||
|
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).-->
|
||||||
|
<odoo>
|
||||||
|
<record id="report_xlsx_wizard" model="ir.ui.view">
|
||||||
|
<field name="name">report.xlsx.wizard</field>
|
||||||
|
<field name="model">report.xlsx.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<group>
|
||||||
|
<field name="res_model" invisible="1" />
|
||||||
|
<field
|
||||||
|
name="domain"
|
||||||
|
widget="domain"
|
||||||
|
options="{'model': 'res_model', 'in_dialog': True}"
|
||||||
|
/>
|
||||||
|
</group>
|
||||||
|
<footer>
|
||||||
|
<button
|
||||||
|
name="action_report"
|
||||||
|
type="object"
|
||||||
|
string="Execute"
|
||||||
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
|
<button special='cancel' string='Cancel' />
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue