Excel Import/Export/Report (#1522)
* [ADD] v12 excel_import_export * Change from eval() to safe_evel() * Change variable to format to style, as fomat is a common python function :100644 100644 00ee3d9f... e9e48d87... M excel_import_export/models/common.py :100644 100644 a215d29b... 5b4d1fb1... M excel_import_export/models/styles.py :100644 100644 ace11a32... 01e5b9f5... M excel_import_export/models/xlsx_export.py :100644 100644 881b814f... cadfb0f2... M excel_import_export/models/xlsx_import.py :100644 100644 58689ee5... 80490ce8... M excel_import_export/models/xlsx_template.py :100644 100644 5c9c09a6... a363ad19... M excel_import_export/views/xlsx_template_view.xml :100644 100644 475b5187... 392fe6e5... M excel_import_export_demo/import_export_sale_order/templates.xml :100644 100644 4af9c519... 45ee33c6... M excel_import_export_demo/report_sale_order/templates.xml :100644 100644 96157ea3... 17d3964d... M excel_import_export/__manifest__.py :100644 100644 00ee3d9f... 51c2572a... M excel_import_export/models/common.py :100644 100644 a215d29b... 5b4d1fb1... M excel_import_export/models/styles.py :100644 100644 ace11a32... 185a3330... M excel_import_export/models/xlsx_export.py :100644 100644 881b814f... cadfb0f2... M excel_import_export/models/xlsx_import.py :100644 100644 58689ee5... 80490ce8... M excel_import_export/models/xlsx_template.py :100644 100644 5c9c09a6... a363ad19... M excel_import_export/views/xlsx_template_view.xml :100644 100644 475b5187... 392fe6e5... M excel_import_export_demo/import_export_sale_order/templates.xml :100644 100644 4af9c519... 45ee33c6... M excel_import_export_demo/report_sale_order/templates.xml :100644 100644 96157ea3... 933ce0dc... M excel_import_export/__manifest__.py :100644 100644 00ee3d9f... 51c2572a... M excel_import_export/models/common.py :100644 100644 a215d29b... 5b4d1fb1... M excel_import_export/models/styles.py :100644 100644 ace11a32... 185a3330... M excel_import_export/models/xlsx_export.py :100644 100644 881b814f... cadfb0f2... M excel_import_export/models/xlsx_import.py :100644 100644 58689ee5... 80490ce8... M excel_import_export/models/xlsx_template.py :100644 100644 5c9c09a6... a363ad19... M excel_import_export/views/xlsx_template_view.xml :100644 100644 475b5187... 392fe6e5... M excel_import_export_demo/import_export_sale_order/templates.xml :100644 100644 4af9c519... 45ee33c6... M excel_import_export_demo/report_sale_order/templates.xml :100644 100644pull/2505/head96157ea3
3b1217e8 M excel_import_export/__manifest__.py :100644 10064400ee3d9f
51c2572a
M excel_import_export/models/common.py :100644 100644a215d29b
5b4d1fb1 M excel_import_export/models/styles.py :100644 100644ace11a32
185a3330 M excel_import_export/models/xlsx_export.py :100644 100644881b814f
cadfb0f2 M excel_import_export/models/xlsx_import.py :100644 10064458689ee5
80490ce8 M excel_import_export/models/xlsx_template.py :100644 1006445c9c09a6
a363ad19
M excel_import_export/views/xlsx_template_view.xml :100644 100644475b5187
392fe6e5 M excel_import_export_demo/import_export_sale_order/templates.xml :100644 1006444af9c519
45ee33c6
M excel_import_export_demo/report_sale_order/templates.xml :100644 10064496157ea3
fee958bc
M excel_import_export/__manifest__.py :100644 10064400ee3d9f
51c2572a
M excel_import_export/models/common.py :100644 100644a215d29b
5b4d1fb1 M excel_import_export/models/styles.py :100644 100644ace11a32
185a3330 M excel_import_export/models/xlsx_export.py :100644 100644881b814f
cadfb0f2 M excel_import_export/models/xlsx_import.py :100644 10064458689ee5
80490ce8 M excel_import_export/models/xlsx_template.py :100644 1006445c9c09a6
a363ad19
M excel_import_export/views/xlsx_template_view.xml :100644 100644475b5187
392fe6e5 M excel_import_export_demo/import_export_sale_order/templates.xml :100644 1006444af9c519
45ee33c6
M excel_import_export_demo/report_sale_order/templates.xml :100644 10064496157ea3
fee958bc
M excel_import_export/__manifest__.py :100644 10064400ee3d9f
51c2572a
M excel_import_export/models/common.py :100644 100644a215d29b
9738a3c8
M excel_import_export/models/styles.py :100644 100644ace11a32
a7d6adc5 M excel_import_export/models/xlsx_export.py :100644 100644881b814f
12f9ca99 M excel_import_export/models/xlsx_import.py :100644 10064470c37799
f123d2a6
M excel_import_export/models/xlsx_report.py :100644 10064458689ee5
578a1fd8 M excel_import_export/models/xlsx_template.py :100644 1006445c9c09a6
a363ad19
M excel_import_export/views/xlsx_template_view.xml :100644 100644800ea573
1807ea7e
M excel_import_export/wizard/export_xlsx_wizard.py :100644 100644febed8d0
750dc17e
M excel_import_export/wizard/import_xlsx_wizard.py :100644 100644475b5187
392fe6e5 M excel_import_export_demo/import_export_sale_order/templates.xml :100644 1006448e40a2d0
21574896
M excel_import_export_demo/report_sale_order/report_sale_order.py :100644 1006444af9c519
45ee33c6
M excel_import_export_demo/report_sale_order/templates.xml :100644 10064496157ea3
fee958bc
M excel_import_export/__manifest__.py :100644 10064400ee3d9f
51c2572a
M excel_import_export/models/common.py :100644 100644a215d29b
9738a3c8
M excel_import_export/models/styles.py :100644 100644ace11a32
c7db3f92
M excel_import_export/models/xlsx_export.py :100644 100644881b814f
12f9ca99 M excel_import_export/models/xlsx_import.py :100644 10064470c37799
f123d2a6
M excel_import_export/models/xlsx_report.py :100644 10064458689ee5
578a1fd8 M excel_import_export/models/xlsx_template.py :100644 1006445c9c09a6
a363ad19
M excel_import_export/views/xlsx_template_view.xml :100644 100644800ea573
1807ea7e
M excel_import_export/wizard/export_xlsx_wizard.py :100644 100644febed8d0
750dc17e
M excel_import_export/wizard/import_xlsx_wizard.py :100644 100644475b5187
392fe6e5 M excel_import_export_demo/import_export_sale_order/templates.xml :100644 1006448e40a2d0
21574896
M excel_import_export_demo/report_sale_order/report_sale_order.py :100644 1006444af9c519
45ee33c6
M excel_import_export_demo/report_sale_order/templates.xml :100644 10064496157ea3
fee958bc
M excel_import_export/__manifest__.py :100644 10064400ee3d9f
51c2572a
M excel_import_export/models/common.py :100644 100644a215d29b
9738a3c8
M excel_import_export/models/styles.py :100644 100644ace11a32
c7db3f92
M excel_import_export/models/xlsx_export.py :100644 100644881b814f
12f9ca99 M excel_import_export/models/xlsx_import.py :100644 10064470c37799
f123d2a6
M excel_import_export/models/xlsx_report.py :100644 10064458689ee5
e3826e08 M excel_import_export/models/xlsx_template.py :000000 100644 00000000 34aa53bf A excel_import_export/tests/__init__.py :000000 100644 0000000018618688
A excel_import_export/tests/sale_order.xlsx :000000 100644 00000000 c8481487 A excel_import_export/tests/test_xlsx_template.py :100644 1006445c9c09a6
a363ad19
M excel_import_export/views/xlsx_template_view.xml :100644 100644800ea573
1807ea7e
M excel_import_export/wizard/export_xlsx_wizard.py :100644 100644febed8d0
750dc17e
M excel_import_export/wizard/import_xlsx_wizard.py :100644 100644475b5187
392fe6e5 M excel_import_export_demo/import_export_sale_order/templates.xml :100644 1006448e40a2d0
21574896
M excel_import_export_demo/report_sale_order/report_sale_order.py :100644 1006444af9c519
45ee33c6
M excel_import_export_demo/report_sale_order/templates.xml :100644 10064496157ea3
fee958bc
M excel_import_export/__manifest__.py :100644 10064400ee3d9f
51c2572a
M excel_import_export/models/common.py :100644 100644a215d29b
9738a3c8
M excel_import_export/models/styles.py :100644 100644ace11a32
c7db3f92
M excel_import_export/models/xlsx_export.py :100644 100644881b814f
12f9ca99 M excel_import_export/models/xlsx_import.py :100644 10064470c37799
f123d2a6
M excel_import_export/models/xlsx_report.py :100644 10064458689ee5
ed8c9fc7 M excel_import_export/models/xlsx_template.py :000000 100644 00000000 34aa53bf A excel_import_export/tests/__init__.py :000000 100644 0000000018618688
A excel_import_export/tests/sale_order.xlsx :000000 100644 00000000 69aa6ea0 A excel_import_export/tests/test_xlsx_template.py :100644 1006445c9c09a6
a363ad19
M excel_import_export/views/xlsx_template_view.xml :100644 100644800ea573
1807ea7e
M excel_import_export/wizard/export_xlsx_wizard.py :100644 100644febed8d0
750dc17e
M excel_import_export/wizard/import_xlsx_wizard.py :100644 100644475b5187
392fe6e5 M excel_import_export_demo/import_export_sale_order/templates.xml :100644 1006448e40a2d0
21574896
M excel_import_export_demo/report_sale_order/report_sale_order.py :100644 1006444af9c519
45ee33c6
M excel_import_export_demo/report_sale_order/templates.xml :100644 10064496157ea3
fee958bc
M excel_import_export/__manifest__.py :100644 10064400ee3d9f
51c2572a
M excel_import_export/models/common.py :100644 100644a215d29b
9738a3c8
M excel_import_export/models/styles.py :100644 100644ace11a32
c7db3f92
M excel_import_export/models/xlsx_export.py :100644 100644881b814f
933d8614
M excel_import_export/models/xlsx_import.py :100644 10064470c37799
f123d2a6
M excel_import_export/models/xlsx_report.py :100644 10064458689ee5
1460473a
M excel_import_export/models/xlsx_template.py :100644 1006445c9c09a6
a363ad19
M excel_import_export/views/xlsx_template_view.xml :100644 100644800ea573
1807ea7e
M excel_import_export/wizard/export_xlsx_wizard.py :100644 100644febed8d0
750dc17e
M excel_import_export/wizard/import_xlsx_wizard.py :100644 100644a2d035ef
9463f279
M excel_import_export_demo/__manifest__.py :100644 100644475b5187
e7f1255b
M excel_import_export_demo/import_export_sale_order/templates.xml :100644 1006448e40a2d0
21574896
M excel_import_export_demo/report_sale_order/report_sale_order.py :100644 1006444af9c519
45ee33c6
M excel_import_export_demo/report_sale_order/templates.xml :000000 100644 00000000 79db62f7 A excel_import_export_demo/tests/__init__.py :000000 100644 0000000018618688
A excel_import_export_demo/tests/sale_order.xlsx :000000 100644 00000000 c9733b95 A excel_import_export_demo/tests/test_common.py :000000 100644 00000000 9c943768 A excel_import_export_demo/tests/test_xlsx_import_export.py :000000 100644 00000000730605c1
A excel_import_export_demo/tests/test_xlsx_template.py :100644 10064496157ea3
fee958bc
M excel_import_export/__manifest__.py :100644 10064400ee3d9f
51c2572a
M excel_import_export/models/common.py :100644 100644a215d29b
9738a3c8
M excel_import_export/models/styles.py :100644 100644ace11a32
c7db3f92
M excel_import_export/models/xlsx_export.py :100644 100644881b814f
933d8614
M excel_import_export/models/xlsx_import.py :100644 10064470c37799
f123d2a6
M excel_import_export/models/xlsx_report.py :100644 10064458689ee5
1460473a
M excel_import_export/models/xlsx_template.py :100644 1006445c9c09a6
a363ad19
M excel_import_export/views/xlsx_template_view.xml :100644 100644800ea573
1807ea7e
M excel_import_export/wizard/export_xlsx_wizard.py :100644 100644febed8d0
750dc17e
M excel_import_export/wizard/import_xlsx_wizard.py :100644 100644a2d035ef
9463f279
M excel_import_export_demo/__manifest__.py :100644 100644475b5187
e7f1255b
M excel_import_export_demo/import_export_sale_order/templates.xml :100644 1006448e40a2d0
21574896
M excel_import_export_demo/report_sale_order/report_sale_order.py :100644 1006444af9c519
45ee33c6
M excel_import_export_demo/report_sale_order/templates.xml :000000 100644 00000000 79db62f7 A excel_import_export_demo/tests/__init__.py :000000 100644 0000000018618688
A excel_import_export_demo/tests/sale_order.xlsx :000000 100644 00000000 bb3ea32e A excel_import_export_demo/tests/test_common.py :000000 100644 00000000 9c943768 A excel_import_export_demo/tests/test_xlsx_import_export.py :000000 100644 00000000730605c1
A excel_import_export_demo/tests/test_xlsx_template.py
parent
0065be27e6
commit
9e2ae60028
|
@ -0,0 +1,112 @@
|
|||
========================
|
||||
Excel Import/Export Demo
|
||||
========================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| 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
|
||||
.. |badge2| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/server-tools/tree/12-add-excel_import_export/excel_import_export_demo
|
||||
:alt: OCA/server-tools
|
||||
.. |badge3| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/server-tools-12-add-excel_import_export/server-tools-12-add-excel_import_export-excel_import_export_demo
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/149/12-add-excel_import_export
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4|
|
||||
|
||||
This module provide some example use case for excel_import_export
|
||||
|
||||
1. Import/Export Sales Order (import_export_sale_order)
|
||||
2. Import New Sales Orders (import_sale_orders)
|
||||
3. Sales Orders Report (report_sale_order)
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
To install this module, you need to install **excel_import_export**
|
||||
|
||||
Then, simply install **excel_import_export_demo**.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
**Use Case 1:** Export/Import Excel on existing document
|
||||
|
||||
To test this use case, go to any Sales Order and use Export Excel or Import Excel in action menu.
|
||||
|
||||
**Use Case 2:** Import Excel Files
|
||||
|
||||
To test this use case, go to Settings > Excel Import/Export > Sample Import Sales Order
|
||||
|
||||
**Use Case 3:** Create Excel Report
|
||||
|
||||
To test this use case, go to Settings > Excel Import/Export > Sample Sales Report
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
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_demo%0Aversion:%2012-add-excel_import_export%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)
|
||||
|
||||
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-add-excel_import_export/excel_import_export_demo>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from . import import_export_sale_order
|
||||
from . import report_sale_order
|
|
@ -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)
|
||||
|
||||
{'name': 'Excel Import/Export Demo',
|
||||
'version': '12.0.1.0.0',
|
||||
'author': 'Ecosoft,Odoo Community Association (OCA)',
|
||||
'license': 'AGPL-3',
|
||||
'website': 'https://github.com/OCA/server-tools/',
|
||||
'category': 'Tools',
|
||||
'depends': ['excel_import_export',
|
||||
'sale_management'],
|
||||
'data': ['import_export_sale_order/actions.xml',
|
||||
'import_export_sale_order/templates.xml',
|
||||
'report_sale_order/report_sale_order.xml',
|
||||
'report_sale_order/templates.xml',
|
||||
'import_sale_orders/menu_action.xml',
|
||||
'import_sale_orders/templates.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'development_status': 'alpha',
|
||||
'maintainers': ['kittiu'],
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?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>
|
||||
|
||||
<act_window id="action_sale_oder_export_xlsx"
|
||||
name="Export Excel"
|
||||
res_model="export.xlsx.wizard"
|
||||
src_model="sale.order"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
context="{
|
||||
'template_domain': [('res_model', '=', 'sale.order'),
|
||||
('fname', '=', 'sale_order.xlsx'),
|
||||
('gname', '=', False)],
|
||||
}"/>
|
||||
<act_window id="action_sale_oder_import_xlsx"
|
||||
name="Import Excel"
|
||||
res_model="import.xlsx.wizard"
|
||||
src_model="sale.order"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
context="{
|
||||
'template_domain': [('res_model', '=', 'sale.order'),
|
||||
('fname', '=', 'sale_order.xlsx'),
|
||||
('gname', '=', False)],
|
||||
'template_context': {},
|
||||
'template_import_states': [],
|
||||
}"/>
|
||||
|
||||
</odoo>
|
Binary file not shown.
|
@ -0,0 +1,52 @@
|
|||
<?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="sale_order_xlsx_template" model="xlsx.template">
|
||||
<field name="res_model">sale.order</field>
|
||||
<field name="fname">sale_order.xlsx</field>
|
||||
<field name="name">Sale Order Template</field>
|
||||
<field name="description">Sample Sales Order Tempalte for testing</field>
|
||||
<field name="input_instruction">
|
||||
{
|
||||
'__EXPORT__': {
|
||||
'sale_order': {
|
||||
'_HEAD_': {
|
||||
'B2': 'partner_id.display_name${value or ""}#{align=left;style=text}',
|
||||
'B3': 'name${value or ""}#{align=left;style=text}',
|
||||
},
|
||||
'order_line': {
|
||||
'A6': 'product_id.display_name${value or ""}#{style=text}',
|
||||
'B6': 'name${value or ""}#{style=text}',
|
||||
'C6': 'product_uom_qty${value or 0}#{style=number}',
|
||||
'D6': 'product_uom.name${value or ""}#{style=text}',
|
||||
'E6': 'price_unit${value or 0}#{style=number}',
|
||||
'F6': 'tax_id${value and ",".join([x.display_name for x in value]) or ""}',
|
||||
'G6': 'price_subtotal${value or 0}#{style=number}',
|
||||
}
|
||||
}
|
||||
},
|
||||
'__IMPORT__': {
|
||||
'sale_order': {
|
||||
'_NODEL_order_line': {
|
||||
'A6': 'product_id',
|
||||
'B6': 'name',
|
||||
'C6': 'product_uom_qty',
|
||||
'D6': 'product_uom',
|
||||
'E6': 'price_unit',
|
||||
'F6': 'tax_id',
|
||||
}
|
||||
}
|
||||
},
|
||||
# '__POST_IMPORT__': '${object.post_import_do_something()}',
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<function model="xlsx.template" name="load_xlsx_template">
|
||||
<value eval="[ref('sale_order_xlsx_template')]"/>
|
||||
</function>
|
||||
|
||||
</odoo>
|
Binary file not shown.
|
@ -0,0 +1,25 @@
|
|||
<?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="action_import_sale_order" model="ir.actions.act_window">
|
||||
<field name="name">Sample Import Sale Order</field>
|
||||
<field name="res_model">import.xlsx.wizard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{
|
||||
'template_domain': [('res_model', '=', 'sale.order'),
|
||||
('fname', '=', 'import_sale_order.xlsx'),
|
||||
('gname', '=', False)], }
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_import_sale_order"
|
||||
parent="excel_import_export.menu_excel_import_export"
|
||||
action="action_import_sale_order"
|
||||
sequence="30"/>
|
||||
|
||||
</odoo>
|
|
@ -0,0 +1,38 @@
|
|||
<?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="import_sale_order_xlsx_template" model="xlsx.template">
|
||||
<field name="res_model">sale.order</field>
|
||||
<field name="fname">import_sale_order.xlsx</field>
|
||||
<field name="name">Import Sale Order Template</field>
|
||||
<field name="description">Sample Import Sales Order Tempalte for testing</field>
|
||||
<field name="redirect_action" ref="sale.action_orders"/>
|
||||
<field name="input_instruction">
|
||||
{
|
||||
'__IMPORT__': {
|
||||
'sale_order': {
|
||||
'_HEAD_': {
|
||||
'B2': 'partner_id',
|
||||
},
|
||||
'order_line': {
|
||||
'A6': 'product_id',
|
||||
'B6': 'name',
|
||||
'C6': 'product_uom_qty',
|
||||
'D6': 'product_uom',
|
||||
'E6': 'price_unit',
|
||||
'F6': 'tax_id',
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<function model="xlsx.template" name="load_xlsx_template">
|
||||
<value eval="[ref('import_sale_order_xlsx_template')]"/>
|
||||
</function>
|
||||
|
||||
</odoo>
|
|
@ -0,0 +1 @@
|
|||
* Kitti Upariphutthiphong. <kittiu@gmail.com> (http://ecosoft.co.th)
|
|
@ -0,0 +1,5 @@
|
|||
This module provide some example use case for excel_import_export
|
||||
|
||||
1. Import/Export Sales Order (import_export_sale_order)
|
||||
2. Import New Sales Orders (import_sale_orders)
|
||||
3. Sales Orders Report (report_sale_order)
|
|
@ -0,0 +1,4 @@
|
|||
12.0.1.0.0 (2019-02-24)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Start of the history
|
|
@ -0,0 +1,3 @@
|
|||
To install this module, you need to install **excel_import_export**
|
||||
|
||||
Then, simply install **excel_import_export_demo**.
|
|
@ -0,0 +1,11 @@
|
|||
**Use Case 1:** Export/Import Excel on existing document
|
||||
|
||||
To test this use case, go to any Sales Order and use Export Excel or Import Excel in action menu.
|
||||
|
||||
**Use Case 2:** Import Excel Files
|
||||
|
||||
To test this use case, go to Settings > Excel Import/Export > Sample Import Sales Order
|
||||
|
||||
**Use Case 3:** Create Excel Report
|
||||
|
||||
To test this use case, go to Settings > Excel Import/Export > Sample Sales Report
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from . import report_sale_order
|
|
@ -0,0 +1,35 @@
|
|||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class ReportSaleOrder(models.TransientModel):
|
||||
_name = 'report.sale.order'
|
||||
_description = 'Wizard for report.sale.order'
|
||||
_inherit = 'xlsx.report'
|
||||
|
||||
# Search Criteria
|
||||
partner_id = fields.Many2one(
|
||||
'res.partner',
|
||||
string='Partner',
|
||||
)
|
||||
# Report Result, sale.order
|
||||
results = fields.Many2many(
|
||||
'sale.order',
|
||||
string='Results',
|
||||
compute='_compute_results',
|
||||
help='Use compute fields, so there is nothing stored in database',
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _compute_results(self):
|
||||
""" On the wizard, result will be computed and added to results line
|
||||
before export to excel, by using xlsx.export
|
||||
"""
|
||||
self.ensure_one()
|
||||
Result = self.env['sale.order']
|
||||
domain = []
|
||||
if self.partner_id:
|
||||
domain += [('partner_id', '=', self.partner_id.id)]
|
||||
self.results = Result.search(domain)
|
Binary file not shown.
|
@ -0,0 +1,41 @@
|
|||
<?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_sale_order" model="ir.ui.view">
|
||||
<field name="name">report.sale.order</field>
|
||||
<field name="model">report.sale.order</field>
|
||||
<field name="inherit_id" ref="excel_import_export.xlsx_report_view"/>
|
||||
<field name="mode">primary</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='criteria']" position="inside">
|
||||
<group>
|
||||
<field name="partner_id"/>
|
||||
</group>
|
||||
<group>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_report_sale_order" model="ir.actions.act_window">
|
||||
<field name="name">Sample Sales Report</field>
|
||||
<field name="res_model">report.sale.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="context">
|
||||
{'template_domain': [('res_model', '=', 'report.sale.order'),
|
||||
('fname', '=', 'report_sale_order.xlsx'),
|
||||
('gname', '=', False)]}
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_report_sale_order"
|
||||
parent="excel_import_export.menu_excel_import_export"
|
||||
action="action_report_sale_order"
|
||||
sequence="20"/>
|
||||
|
||||
</odoo>
|
|
@ -0,0 +1,36 @@
|
|||
<?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_sale_order_template" model="xlsx.template">
|
||||
<field name="res_model">report.sale.order</field>
|
||||
<field name="fname">report_sale_order.xlsx</field>
|
||||
<field name="name">Report Sale Order Template</field>
|
||||
<field name="description">Sample Report Sales Order Tempalte for testing</field>
|
||||
<field name="input_instruction">
|
||||
{
|
||||
'__EXPORT__': {
|
||||
1: {
|
||||
'_HEAD_': {
|
||||
'B2': 'partner_id.display_name${value or ""}#{align=left;style=text}',
|
||||
},
|
||||
'results': {
|
||||
'A5': 'name${value or ""}#{style=text}',
|
||||
'B5': 'confirmation_date${value or ""}#{style=date}',
|
||||
'C5': 'amount_untaxed${value or 0}#{style=number}@{sum}',
|
||||
'D5': 'amount_tax${value or 0}#{style=number}@{sum}',
|
||||
'E5': 'amount_total${value or 0}#{style=number}@{sum}',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<function model="xlsx.template" name="load_xlsx_template">
|
||||
<value eval="[ref('report_sale_order_template')]"/>
|
||||
</function>
|
||||
|
||||
</odoo>
|
|
@ -0,0 +1,455 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
|
||||
<title>Excel Import/Export Demo</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
|
||||
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
.subscript {
|
||||
vertical-align: sub;
|
||||
font-size: smaller }
|
||||
|
||||
.superscript {
|
||||
vertical-align: super;
|
||||
font-size: smaller }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title, .code .error {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||
clear: left ;
|
||||
float: left ;
|
||||
margin-right: 1em }
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||
clear: right ;
|
||||
float: right ;
|
||||
margin-left: 1em }
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left }
|
||||
|
||||
.align-center {
|
||||
clear: both ;
|
||||
text-align: center }
|
||||
|
||||
.align-right {
|
||||
text-align: right }
|
||||
|
||||
/* reset inner alignment in figures */
|
||||
div.align-right {
|
||||
text-align: inherit }
|
||||
|
||||
/* div.align-center * { */
|
||||
/* text-align: left } */
|
||||
|
||||
.align-top {
|
||||
vertical-align: top }
|
||||
|
||||
.align-middle {
|
||||
vertical-align: middle }
|
||||
|
||||
.align-bottom {
|
||||
vertical-align: bottom }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font: inherit }
|
||||
|
||||
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: grey; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
/* "booktabs" style (no vertical lines) */
|
||||
table.docutils.booktabs {
|
||||
border: 0px;
|
||||
border-top: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.docutils.booktabs * {
|
||||
border: 0px;
|
||||
}
|
||||
table.docutils.booktabs th {
|
||||
border-bottom: thin solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="excel-import-export-demo">
|
||||
<h1 class="title">Excel Import/Export Demo</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/12-add-excel_import_export/excel_import_export_demo"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-12-add-excel_import_export/server-tools-12-add-excel_import_export-excel_import_export_demo"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/12-add-excel_import_export"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module provide some example use case for excel_import_export</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Import/Export Sales Order (import_export_sale_order)</li>
|
||||
<li>Import New Sales Orders (import_sale_orders)</li>
|
||||
<li>Sales Orders Report (report_sale_order)</li>
|
||||
</ol>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#installation" id="id2">Installation</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="id3">Usage</a></li>
|
||||
<li><a class="reference internal" href="#changelog" id="id4">Changelog</a><ul>
|
||||
<li><a class="reference internal" href="#id1" id="id5">12.0.1.0.0 (2019-02-24)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id6">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id7">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id8">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id9">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id10">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="installation">
|
||||
<h1><a class="toc-backref" href="#id2">Installation</a></h1>
|
||||
<p>To install this module, you need to install <strong>excel_import_export</strong></p>
|
||||
<p>Then, simply install <strong>excel_import_export_demo</strong>.</p>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#id3">Usage</a></h1>
|
||||
<p><strong>Use Case 1:</strong> Export/Import Excel on existing document</p>
|
||||
<p>To test this use case, go to any Sales Order and use Export Excel or Import Excel in action menu.</p>
|
||||
<p><strong>Use Case 2:</strong> Import Excel Files</p>
|
||||
<p>To test this use case, go to Settings > Excel Import/Export > Sample Import Sales Order</p>
|
||||
<p><strong>Use Case 3:</strong> Create Excel Report</p>
|
||||
<p>To test this use case, go to Settings > Excel Import/Export > Sample Sales Report</p>
|
||||
</div>
|
||||
<div class="section" id="changelog">
|
||||
<h1><a class="toc-backref" href="#id4">Changelog</a></h1>
|
||||
<div class="section" id="id1">
|
||||
<h2><a class="toc-backref" href="#id5">12.0.1.0.0 (2019-02-24)</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Start of the history</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#id6">Bug Tracker</a></h1>
|
||||
<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.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20excel_import_export_demo%0Aversion:%2012-add-excel_import_export%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#id7">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id8">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Ecosoft</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id9">Contributors</a></h2>
|
||||
<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>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#id10">Maintainers</a></h2>
|
||||
<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>
|
||||
<p>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.</p>
|
||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||
<p><a class="reference external" href="https://github.com/kittiu"><img alt="kittiu" src="https://github.com/kittiu.png?size=40px" /></a></p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/12-add-excel_import_export/excel_import_export_demo">OCA/server-tools</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
from . import test_xlsx_template
|
||||
from . import test_xlsx_import_export
|
||||
from . import test_xlsx_report
|
Binary file not shown.
|
@ -0,0 +1,130 @@
|
|||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
from odoo.tests.common import SingleTransactionCase
|
||||
|
||||
|
||||
class TestExcelImportExport(SingleTransactionCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestExcelImportExport, cls).setUpClass()
|
||||
|
||||
@classmethod
|
||||
def setUpXLSXTemplate(cls):
|
||||
cls.template_obj = cls.env['xlsx.template']
|
||||
# Create xlsx.template using input_instruction
|
||||
input_instruction = {
|
||||
'__EXPORT__': {
|
||||
'sale_order': {
|
||||
'_HEAD_': {
|
||||
'B2': 'partner_id.display_name${value or ""}'
|
||||
'#{align=left;style=text}',
|
||||
'B3': 'name${value or ""}#{align=left;style=text}',
|
||||
},
|
||||
'order_line': {
|
||||
'A6': 'product_id.display_name${value or ""}'
|
||||
'#{style=text}',
|
||||
'B6': 'name${value or ""}#{style=text}',
|
||||
'C6': 'product_uom_qty${value or 0}#{style=number}',
|
||||
'D6': 'product_uom.name${value or ""}#{style=text}',
|
||||
'E6': 'price_unit${value or 0}#{style=number}',
|
||||
'F6': 'tax_id${value and ","'
|
||||
'.join([x.display_name for x in value]) or ""}',
|
||||
'G6': 'price_subtotal${value or 0}#{style=number}',
|
||||
}
|
||||
}
|
||||
},
|
||||
'__IMPORT__': {
|
||||
'sale_order': {
|
||||
'order_line': {
|
||||
'A6': 'product_id',
|
||||
'B6': 'name',
|
||||
'C6': 'product_uom_qty',
|
||||
'D6': 'product_uom',
|
||||
'E6': 'price_unit',
|
||||
'F6': 'tax_id',
|
||||
}
|
||||
}
|
||||
},
|
||||
# '__POST_IMPORT__': '${object.post_import_do_something()}',
|
||||
}
|
||||
vals = {
|
||||
'res_model': 'sale.order',
|
||||
'fname': 'sale_order.xlsx',
|
||||
'name': 'Sale Order Template',
|
||||
'description': 'Sample Sales Order Tempalte for testing',
|
||||
'input_instruction': str(input_instruction),
|
||||
}
|
||||
cls.sample_template = cls.template_obj.create(vals)
|
||||
|
||||
@classmethod
|
||||
def setUpSaleOrder(cls):
|
||||
cls.setUpPrepSaleOrder()
|
||||
# Create a Sales Order
|
||||
product_line = {
|
||||
'name': cls.product_order.name,
|
||||
'product_id': cls.product_order.id,
|
||||
'product_uom_qty': 2,
|
||||
'product_uom': cls.product_order.uom_id.id,
|
||||
'price_unit': cls.product_order.list_price,
|
||||
'tax_id': False,
|
||||
}
|
||||
cls.sale_order = cls.env['sale.order'].create({
|
||||
'partner_id': cls.partner.id,
|
||||
'order_line': [(0, 0, product_line), (0, 0, product_line)],
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def setUpManySaleOrder(cls):
|
||||
cls.setUpPrepSaleOrder()
|
||||
# Create a Sales Order
|
||||
product_line = {
|
||||
'name': cls.product_order.name,
|
||||
'product_id': cls.product_order.id,
|
||||
'product_uom_qty': 2,
|
||||
'product_uom': cls.product_order.uom_id.id,
|
||||
'price_unit': cls.product_order.list_price,
|
||||
'tax_id': False,
|
||||
}
|
||||
for i in range(10):
|
||||
cls.env['sale.order'].create({
|
||||
'partner_id': cls.partner.id,
|
||||
'order_line': [(0, 0, product_line), (0, 0, product_line)],
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def setUpPrepSaleOrder(cls):
|
||||
categ_ids = cls.env['res.partner.category'].search([]).ids
|
||||
cls.partner = cls.env['res.partner'].create({
|
||||
'name': 'Test Partner',
|
||||
'category_id': [(6, 0, categ_ids)],
|
||||
})
|
||||
# Create a Product
|
||||
user_type_income = \
|
||||
cls.env.ref('account.data_account_type_direct_costs')
|
||||
cls.account_income_product = cls.env['account.account'].create({
|
||||
'code': 'INCOME_PROD111',
|
||||
'name': 'Icome - Test Account',
|
||||
'user_type_id': user_type_income.id,
|
||||
})
|
||||
# Create category
|
||||
cls.product_category = cls.env['product.category'].create({
|
||||
'name': 'Product Category with Income account',
|
||||
'property_account_income_categ_id': cls.account_income_product.id
|
||||
})
|
||||
# Products
|
||||
uom_unit = cls.env.ref('uom.product_uom_unit')
|
||||
cls.product_order = cls.env['product.product'].create({
|
||||
'name': "Test Product",
|
||||
'standard_price': 235.0,
|
||||
'list_price': 280.0,
|
||||
'type': 'consu',
|
||||
'uom_id': uom_unit.id,
|
||||
'uom_po_id': uom_unit.id,
|
||||
'invoice_policy': 'order',
|
||||
'expense_policy': 'no',
|
||||
'default_code': 'PROD_ORDER',
|
||||
'service_type': 'manual',
|
||||
'taxes_id': False,
|
||||
'categ_id': cls.product_category.id,
|
||||
})
|
|
@ -0,0 +1,48 @@
|
|||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
from .test_common import TestExcelImportExport
|
||||
from odoo.tests.common import Form
|
||||
|
||||
|
||||
class TestXLSXImportExport(TestExcelImportExport):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestExcelImportExport, cls).setUpClass()
|
||||
|
||||
def test_xlsx_export_import(self):
|
||||
""" Test Export Excel from Sales Order """
|
||||
# Create Sales Order
|
||||
self.setUpSaleOrder()
|
||||
# ----------- EXPORT ---------------
|
||||
ctx = {'active_model': 'sale.order',
|
||||
'active_id': self.sale_order.id,
|
||||
'template_domain': [('res_model', '=', 'sale.order'),
|
||||
('fname', '=', 'sale_order.xlsx'),
|
||||
('gname', '=', False)], }
|
||||
f = Form(self.env['export.xlsx.wizard'].with_context(ctx))
|
||||
export_wizard = f.save()
|
||||
# Test whether it loads correct template
|
||||
self.assertEqual(export_wizard.template_id,
|
||||
self.env.ref('excel_import_export_demo.'
|
||||
'sale_order_xlsx_template'))
|
||||
# Export excel
|
||||
export_wizard.action_export()
|
||||
self.assertTrue(export_wizard.data)
|
||||
self.export_file = export_wizard.data
|
||||
|
||||
# ----------- IMPORT ---------------
|
||||
ctx = {'active_model': 'sale.order',
|
||||
'active_id': self.sale_order.id,
|
||||
'template_domain': [('res_model', '=', 'sale.order'),
|
||||
('fname', '=', 'sale_order.xlsx'),
|
||||
('gname', '=', False)], }
|
||||
with Form(self.env['import.xlsx.wizard'].with_context(ctx)) as f:
|
||||
f.import_file = self.export_file
|
||||
import_wizard = f.save()
|
||||
# Test whether it loads correct template
|
||||
self.assertEqual(import_wizard.template_id,
|
||||
self.env.ref('excel_import_export_demo.'
|
||||
'sale_order_xlsx_template'))
|
||||
# Import Excel
|
||||
import_wizard.action_import()
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
from .test_common import TestExcelImportExport
|
||||
from odoo.tests.common import Form
|
||||
|
||||
|
||||
class TestXLSXReport(TestExcelImportExport):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestXLSXReport, cls).setUpClass()
|
||||
|
||||
def test_xlsx_report(self):
|
||||
""" Test Report from Sales Order """
|
||||
# Create Many Sales Orders
|
||||
self.setUpManySaleOrder()
|
||||
ctx = {'template_domain': [('res_model', '=', 'report.sale.order'),
|
||||
('fname', '=', 'report_sale_order.xlsx'),
|
||||
('gname', '=', False)], }
|
||||
with Form(self.env['report.sale.order'].with_context(ctx)) as f:
|
||||
f.partner_id = self.partner
|
||||
report_wizard = f.save()
|
||||
# Test whether it loads correct template
|
||||
self.assertEqual(report_wizard.template_id,
|
||||
self.env.ref('excel_import_export_demo.'
|
||||
'report_sale_order_template'))
|
||||
# Report excel
|
||||
report_wizard.report_xlsx()
|
||||
self.assertTrue(report_wizard.data)
|
|
@ -0,0 +1,62 @@
|
|||
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
from ast import literal_eval
|
||||
from .test_common import TestExcelImportExport
|
||||
|
||||
|
||||
class TestXLSXTemplate(TestExcelImportExport):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestExcelImportExport, cls).setUpClass()
|
||||
|
||||
def test_xlsx_tempalte(self):
|
||||
""" Test XLSX Tempalte input and output instruction """
|
||||
self.setUpXLSXTemplate()
|
||||
instruction_dict = literal_eval(self.sample_template.instruction)
|
||||
self.assertDictEqual(
|
||||
instruction_dict,
|
||||
{
|
||||
'__EXPORT__': {
|
||||
'sale_order': {
|
||||
'_HEAD_': {
|
||||
'B2': 'partner_id.display_name${value or ""}'
|
||||
'#{align=left;style=text}#??',
|
||||
'B3': 'name${value or ""}'
|
||||
'#{align=left;style=text}#??'},
|
||||
'order_line': {
|
||||
'A6': 'product_id.display_name${value or ""}'
|
||||
'#{style=text}#??',
|
||||
'B6': 'name${value or ""}#{style=text}#??',
|
||||
'C6': 'product_uom_qty${value or 0}'
|
||||
'#{style=number}#??',
|
||||
'D6': 'product_uom.name${value or ""}'
|
||||
'#{style=text}#??',
|
||||
'E6': 'price_unit${value or 0}#{style=number}#??',
|
||||
'F6': 'tax_id${value and ",".join([x.display_name '
|
||||
'for x in value]) or ""}#{}#??',
|
||||
'G6': 'price_subtotal${value or 0}'
|
||||
'#{style=number}#??'
|
||||
}
|
||||
}
|
||||
},
|
||||
'__IMPORT__': {
|
||||
'sale_order': {
|
||||
'order_line': {
|
||||
'A6': 'product_id',
|
||||
'B6': 'name',
|
||||
'C6': 'product_uom_qty',
|
||||
'D6': 'product_uom',
|
||||
'E6': 'price_unit',
|
||||
'F6': 'tax_id',
|
||||
}
|
||||
}
|
||||
},
|
||||
'__POST_IMPORT__': False
|
||||
}
|
||||
)
|
||||
# Finally load excel file into this new template
|
||||
self.assertFalse(self.sample_template.datas) # Not yet loaded
|
||||
self.template_obj.load_xlsx_template([self.sample_template.id],
|
||||
addon='excel_import_export_demo')
|
||||
self.assertTrue(self.sample_template.datas) # Loaded successfully
|
Loading…
Reference in New Issue