[12.0][IMP] excel_import_export, excel_import_export_demo

Add report action feature and new examples
pull/2505/head
Kitti U 2019-08-09 12:27:10 +07:00 committed by Aungkokolin1997
parent 5c53c419e8
commit bffd5d9eb6
15 changed files with 202 additions and 4 deletions

View File

@ -3,3 +3,4 @@
from . import import_export_sale_order
from . import report_sale_order
from . import report_action

View File

@ -1,7 +1,7 @@
# 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',
{'name': 'Excel Import/Export/Report Demo',
'version': '12.0.1.0.0',
'author': 'Ecosoft,Odoo Community Association (OCA)',
'license': 'AGPL-3',
@ -15,6 +15,12 @@
'report_sale_order/templates.xml',
'import_sale_orders/menu_action.xml',
'import_sale_orders/templates.xml',
# Use report action
'report_action/sale_order/report.xml',
'report_action/sale_order/templates.xml',
'report_action/partner_list/report.xml',
'report_action/partner_list/templates.xml',
'report_action/partner_list/report_partner_list.xml',
],
'installable': True,
'development_status': 'alpha',

View File

@ -3,3 +3,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)
4. Print Quoation / Order (.xlsx) (report_action/sale_order)
5. Run Partner List Report (report_action/partner_list)

View File

@ -1,3 +1,8 @@
12.0.1.0.0 (2019-08-09)
~~~~~~~~~~~~~~~~~~~~~~~
* Add 2 new examples using report action, 1) sale_order 2) partner_list
12.0.1.0.0 (2019-02-24)
~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,11 +1,19 @@
**Use Case 1:** Export/Import Excel on existing document
**Example 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
**Example 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
**Example 3:** Create Excel Report
To test this use case, go to Settings > Excel Import/Export > Sample Sales Report
**Example 4:** Printout Excel on existing document, using report action
To test this use case, go to any Sales Order and click print "Quotation / Order (.xlsx)".
**Example 5:** Run Partner List Report, using report action
To test this use case, go to menu Sales > Reporting > Partner List Report

View File

@ -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 partner_list

View File

@ -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_partner_list

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<report id='action_report_partner_excel'
string='Partner List (.xlsx)'
model='report.partner.list'
name='partner_list.xlsx'
file='partner_list'
report_type='excel'
/>
</odoo>

View File

@ -0,0 +1,37 @@
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from odoo import models, fields, api
class ReportPartnerList(models.TransientModel):
_name = 'report.partner.list'
_description = 'Wizard for report.partner.list'
partner_ids = fields.Many2many(
comodel_name='res.partner',
)
supplier = fields.Boolean(
default=True,
)
customer = fields.Boolean(
default=True,
)
results = fields.Many2many(
'res.partner',
string='Results',
compute='_compute_results',
help='Use compute fields, so there is nothing store 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 report_excel action
"""
self.ensure_one()
domain = ['|', ('supplier', '=', self.supplier),
('customer', '=', self.customer)]
if self.partner_ids:
domain.append(('id', 'in', self.partner_ids.ids))
self.results = self.env['res.partner'].search(domain, order='id')

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="partner_list_wizard" model="ir.ui.view">
<field name="name">partner.list.wizard</field>
<field name="model">report.partner.list</field>
<field name="arch" type="xml">
<form>
<group>
<group>
<field name="partner_ids" widget="many2many_tags"/>
</group>
<group>
<field name="customer"/>
<field name="supplier"/>
</group>
</group>
<footer>
<button name='%(excel_import_export_demo.action_report_partner_excel)d'
type='action' string='Execute'
class='oe_highlight'/>
<button special='cancel'
string='Cancel'/>
</footer>
</form>
</field>
</record>
<record id='action_report_partner_list' model='ir.actions.act_window'>
<field name='name'>Partner List Report</field>
<field name='res_model'>report.partner.list</field>
<field name='view_type'>form</field>
<field name='view_mode'>form</field>
<field name='target'>new</field>
</record>
<menuitem id="menu_report_partner_list"
parent="sale.menu_sale_report"
action="action_report_partner_list"
name="Partner List Report"
/>
</odoo>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="partner_list_xlsx_template" model="xlsx.template">
<field name="res_model">report.partner.list</field>
<field name="fname">partner_list.xlsx</field>
<field name="name">Partner List Report Template</field>
<field name="description">Sample Partner List Report Template for testing</field>
<field name="input_instruction">
{
'__EXPORT__': {
1: {
'results': {
'A4': 'id',
'B4': 'name${value or ""}#{style=text}',
'C4': 'phone${value or ""}#{style=text}',
'D4': 'email${value or ""}#{style=text}',
}
}
},
}
</field>
</record>
<function model="xlsx.template" name="load_xlsx_template">
<value eval="[ref('partner_list_xlsx_template')]"/>
</function>
</odoo>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<report id='action_report_saleorder_excel'
string='Quotation / Order (.xlsx)'
model='sale.order'
name='sale_order_form.xlsx'
file='sale_order'
print_report_name="(object.state in ('draft', 'sent') and 'Quotation - %s' % (object.name)) or 'Order - %s' % (object.name)"
report_type='excel'
/>
</odoo>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="sale_order_excel_template" model="xlsx.template">
<field name="res_model">sale.order</field>
<field name="fname">sale_order_form.xlsx</field>
<field name="name">Sale Order Template</field>
<field name="description">Sample Sales Order Template 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}@{sum}',
}
}
},
}
</field>
</record>
<function model="xlsx.template" name="load_xlsx_template">
<value eval="[ref('sale_order_excel_template')]"/>
</function>
</odoo>