From 6d75255e07b05c185237844eb2a310f99de31568 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Mon, 25 Nov 2024 05:06:39 +0000 Subject: [PATCH] [IMP] excel_import_export_demo: add hooks --- excel_import_export_demo/__init__.py | 1 + excel_import_export_demo/__manifest__.py | 1 + excel_import_export_demo/hooks.py | 11 +++++++++++ .../import_export_purchase_order/actions.xml | 15 --------------- .../import_export_purchase_order/templates.xml | 4 ---- .../import_export_sale_order/actions.xml | 18 ------------------ .../import_export_sale_order/templates.xml | 3 +-- 7 files changed, 14 insertions(+), 39 deletions(-) create mode 100644 excel_import_export_demo/hooks.py diff --git a/excel_import_export_demo/__init__.py b/excel_import_export_demo/__init__.py index d82c0f79ca2..9a265191eb8 100644 --- a/excel_import_export_demo/__init__.py +++ b/excel_import_export_demo/__init__.py @@ -5,3 +5,4 @@ from . import report_sale_order from . import report_crm_lead from . import report_action +from .hooks import post_init_hook diff --git a/excel_import_export_demo/__manifest__.py b/excel_import_export_demo/__manifest__.py index e96b4c37cd1..e7a14f83d00 100644 --- a/excel_import_export_demo/__manifest__.py +++ b/excel_import_export_demo/__manifest__.py @@ -30,6 +30,7 @@ "report_action/partner_list/report_partner_list.xml", "report_action/partner_list/security/ir.model.access.csv", ], + "post_init_hook": "post_init_hook", "installable": True, "development_status": "Beta", "maintainers": ["kittiu"], diff --git a/excel_import_export_demo/hooks.py b/excel_import_export_demo/hooks.py new file mode 100644 index 00000000000..cdfa05698fd --- /dev/null +++ b/excel_import_export_demo/hooks.py @@ -0,0 +1,11 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import SUPERUSER_ID, api + + +def post_init_hook(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + templates = env["xlsx.template"].search([("export_ids", "!=", False)]) + for template in templates: + template.add_export_action() diff --git a/excel_import_export_demo/import_export_purchase_order/actions.xml b/excel_import_export_demo/import_export_purchase_order/actions.xml index 5d2ee0e3124..3db59d2790b 100644 --- a/excel_import_export_demo/import_export_purchase_order/actions.xml +++ b/excel_import_export_demo/import_export_purchase_order/actions.xml @@ -4,21 +4,6 @@ License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).--> - - Export Excel - export.xlsx.wizard - form - form - new - - { - 'template_domain': [('res_model', '=', 'purchase.order'), - ('fname', '=', 'purchase_order.xlsx'), - ('gname', '=', False)], - } - - - Import Excel import.xlsx.wizard diff --git a/excel_import_export_demo/import_export_purchase_order/templates.xml b/excel_import_export_demo/import_export_purchase_order/templates.xml index 0fc94136b36..38fcb992141 100644 --- a/excel_import_export_demo/import_export_purchase_order/templates.xml +++ b/excel_import_export_demo/import_export_purchase_order/templates.xml @@ -12,10 +12,6 @@ name="import_action_id" eval="ref('action_purchase_order_import_xlsx')" /> - { '__EXPORT__': { diff --git a/excel_import_export_demo/import_export_sale_order/actions.xml b/excel_import_export_demo/import_export_sale_order/actions.xml index 5077a088072..df372e75e24 100644 --- a/excel_import_export_demo/import_export_sale_order/actions.xml +++ b/excel_import_export_demo/import_export_sale_order/actions.xml @@ -3,23 +3,6 @@ Copyright 2019 Ecosoft Co., Ltd. License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).--> - - - Export Excel - export.xlsx.wizard - list,form - - form - new - - { - 'template_domain': [('res_model', '=', 'sale.order'), - ('fname', '=', 'sale_order.xlsx'), - ('gname', '=', False)], - } - - - Import Excel import.xlsx.wizard @@ -37,5 +20,4 @@ } - diff --git a/excel_import_export_demo/import_export_sale_order/templates.xml b/excel_import_export_demo/import_export_sale_order/templates.xml index 50f506c7f88..0363bf95826 100644 --- a/excel_import_export_demo/import_export_sale_order/templates.xml +++ b/excel_import_export_demo/import_export_sale_order/templates.xml @@ -8,8 +8,7 @@ sale_order.xlsx Sale Order Template (import/export) Sample Sales Order Template for testing - - + { '__EXPORT__': {