@ -0,0 +1,48 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
|||
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
Dynamic Report Operations |
|||
========================= |
|||
User can get the different types of operations of report in this module |
|||
|
|||
Configuration |
|||
============= |
|||
* No additional configurations needed |
|||
|
|||
Company |
|||
------- |
|||
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
License |
|||
======= |
|||
General Public License, version 3 (AGPL v3). |
|||
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
|||
|
|||
Credits |
|||
------- |
|||
* Developer : (V17) Bhagyadev KP, |
|||
(V18) Ammu Raj, |
|||
* Contact: odoo@cybrosys.com |
|||
|
|||
Contacts |
|||
-------- |
|||
* Mail Contact : odoo@cybrosys.com |
|||
* Website : https://cybrosys.com |
|||
|
|||
Bug Tracker |
|||
----------- |
|||
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
|||
|
|||
Maintainer |
|||
========== |
|||
.. image:: https://cybrosys.com/images/logo.png |
|||
:target: https://cybrosys.com |
|||
|
|||
This module is maintained by Cybrosys Technologies. |
|||
|
|||
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Ayana K P(<https://www.cybrosys.com>) |
|||
# |
|||
# This program is free software: you can modify |
|||
# it under the terms of the GNU Affero General Public License (AGPL) as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from . import wizard |
@ -0,0 +1,53 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Ayana K P(<https://www.cybrosys.com>) |
|||
# |
|||
# This program is free software: you can modify |
|||
# it under the terms of the GNU Affero General Public License (AGPL) as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
{ |
|||
'name': 'Dynamic Report Operations', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Productivity', |
|||
'summary': """ Perform multiple report operations in Sales/Purchase |
|||
/Inventory/ Accounting """, |
|||
'description': "Users can perform various actions such as printing, " |
|||
"downloading, and sharing reports of various records in " |
|||
"Sales, Purchase, Inventory, Accounting", |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['sale_management', 'purchase', 'stock', 'account',], |
|||
'data': [ |
|||
'security/ir.model.access.csv', |
|||
'wizard/dynamic_action_views.xml', |
|||
], |
|||
'assets': { |
|||
'web.assets_backend': [ |
|||
'pdf_report_action/static/src/css/report_action.css', |
|||
'pdf_report_action/static/src/js/report_action.js', |
|||
'pdf_report_action/static/src/js/report_action_systray.js', |
|||
'pdf_report_action/static/src/xml/report_action_systray.xml', |
|||
], |
|||
}, |
|||
'images': ['static/description/banner.png'], |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
} |
@ -0,0 +1,6 @@ |
|||
## Module <pdf_report_action> |
|||
|
|||
#### 19.10.2024 |
|||
#### Version 18.0.1.0.0 |
|||
##### ADD |
|||
- Initial Commit for Dynamic Report Operations |
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 912 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 590 KiB |
After Width: | Height: | Size: 328 KiB |
After Width: | Height: | Size: 344 KiB |
After Width: | Height: | Size: 149 KiB |
After Width: | Height: | Size: 150 KiB |
After Width: | Height: | Size: 149 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 322 KiB |
After Width: | Height: | Size: 246 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,6 @@ |
|||
.wizard_btn { |
|||
margin: 12px; |
|||
border-radius: 7px; |
|||
height: 40px; |
|||
width: 150px; |
|||
} |
@ -0,0 +1,8 @@ |
|||
/** @odoo-module*/ |
|||
import { registry } from "@web/core/registry"; |
|||
/** |
|||
*Action for open the print screen |
|||
*/ |
|||
registry.category("ir.actions.report handlers").add("xlsx", async (action) => { |
|||
var printWindow = window.open(action.data).print(); |
|||
}) |
@ -0,0 +1,27 @@ |
|||
/** @odoo-module **/ |
|||
import {Component} from '@odoo/owl'; |
|||
import {registry} from '@web/core/registry'; |
|||
import {useService} from "@web/core/utils/hooks"; |
|||
|
|||
// creating systray menu for report
|
|||
export class ReportMenu extends Component { |
|||
setup() { |
|||
this.action = useService("action"); |
|||
} |
|||
// Defining a function to open the wizard while clicking the systray menu
|
|||
openWizard() { |
|||
this.action.doAction({ |
|||
type: 'ir.actions.act_window', |
|||
name: 'Open Report Wizard', |
|||
res_model: 'dynamic.action', |
|||
views: [[false, 'form']], |
|||
target: 'new', |
|||
}); |
|||
} |
|||
} |
|||
|
|||
ReportMenu.template = 'pdf_report_action.IconSystrayDropdown'; |
|||
export const ReportMenuItem = { |
|||
Component: ReportMenu, |
|||
}; |
|||
registry.category("systray").add("ReportAction", ReportMenuItem); |
@ -0,0 +1,17 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!-- This is a template for a systray theme menu --> |
|||
<templates id="template"> |
|||
<!-- Template for weather notification--> |
|||
<t t-name="pdf_report_action.IconSystrayDropdown" owl="1"> |
|||
<div class="o_MessagingMenu dropdown "> |
|||
<div class="o-dropdown dropdown o_debug_manager o-dropdown--no-caret"> |
|||
<a class="o_MessagingMenu_toggler dropdown-toggle o-no-caret o-dropdown--narrow" |
|||
href="#" |
|||
title="Report Actions" role="button" aria-haspopup="true" |
|||
aria-expanded=""> |
|||
<i id='create_so' class="fa fa-file-text-o" t-on-click="openWizard"/> |
|||
</a> |
|||
</div> |
|||
</div> |
|||
</t> |
|||
</templates> |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Ayana K P(<https://www.cybrosys.com>) |
|||
# |
|||
# This program is free software: you can modify |
|||
# it under the terms of the GNU Affero General Public License (AGPL) as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from . import dynamic_action |
@ -0,0 +1,216 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Ayana K P(<https://www.cybrosys.com>) |
|||
# |
|||
# This program is free software: you can modify |
|||
# it under the terms of the GNU Affero General Public License (AGPL) as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
import base64 |
|||
from odoo import api, fields, models, _ |
|||
from odoo.exceptions import ValidationError |
|||
|
|||
|
|||
class DynamicAction(models.TransientModel): |
|||
""" |
|||
The class DynamicAction provides print, share, open and download reports |
|||
in various models . |
|||
Methods: |
|||
print_report(self): |
|||
In this method print the screen of the form.Return a dict. |
|||
download_report(self): |
|||
In this method download the report of the form.Return a dict. |
|||
open_report(self): |
|||
In this methode open the print screen of the form.Return a dict. |
|||
share_by_email(self): |
|||
In this method share email report of the corresponding form. |
|||
Return a dict.3.Some misspelled words are there in the doc |
|||
string of the function. check it and correct it |
|||
""" |
|||
_name = "dynamic.action" |
|||
_description = "Dynamic Action" |
|||
|
|||
res_model = fields.Char('Related Document Model', |
|||
help='Model of the related document') |
|||
res_id = fields.Integer('Related Document ID', |
|||
model_field='res_model', |
|||
help='ID of the related document') |
|||
resource_ref = fields.Reference(string='Record', |
|||
selection='_selection_target_model', |
|||
inverse='_set_resource_ref', |
|||
help='Reference to the record') |
|||
|
|||
@api.model |
|||
def _selection_target_model(self): |
|||
""" Reference field function""" |
|||
domain = [('model', 'in', ['account.move', 'sale.order', |
|||
'purchase.order', 'stock.picking'])] |
|||
models_with_printing = self.env['ir.model'].sudo().search(domain) |
|||
return [(model.model, model.name) for model in models_with_printing] |
|||
|
|||
def _set_resource_ref(self): |
|||
""" Reference field function""" |
|||
for participant in self: |
|||
if participant.resource_ref: |
|||
participant.res_id = participant.resource_ref.id |
|||
participant.res_model = participant.resource_ref._name |
|||
|
|||
def action_print_report(self): |
|||
""" print button function""" |
|||
form_id = self.res_id |
|||
model = self.res_model |
|||
server_address = self.env['ir.config_parameter'].sudo().get_param( |
|||
'web.base.url') |
|||
if model == 'sale.order': |
|||
data = f"{server_address}/report/pdf/sale.report_saleorder/{form_id}" |
|||
elif model == 'purchase.order': |
|||
data = f"{server_address}/report/pdf/purchase.report_purchaseorder/{form_id}" |
|||
elif model == 'stock.picking': |
|||
data = f"{server_address}/report/pdf/stock.report_picking/{form_id}" |
|||
elif model == 'account.move': |
|||
data = f"{server_address}/report/pdf/account.report_invoice/{form_id}" |
|||
else: |
|||
raise ValidationError(_("No record to print!!!")) |
|||
return { |
|||
'type': 'ir.actions.report', |
|||
'data': data, |
|||
'report_type': 'xlsx', |
|||
} |
|||
|
|||
def action_download_report(self): |
|||
""" |
|||
Summary: |
|||
In this method download the report of the form.Return a dict. |
|||
Returns: |
|||
type:dict , it contains the data for the download report. |
|||
""" |
|||
form_id = self.res_id |
|||
model = self.res_model |
|||
if model == 'sale.order': |
|||
record = self.env['ir.actions.report']._render_qweb_pdf( |
|||
'sale.report_saleorder', form_id) |
|||
elif model == 'purchase.order': |
|||
record = self.env['ir.actions.report']._render_qweb_pdf( |
|||
'purchase.report_purchaseorder', form_id) |
|||
elif model == 'stock.picking': |
|||
record = self.env['ir.actions.report']._render_qweb_pdf( |
|||
'stock.report_picking', form_id) |
|||
elif model == 'account.move': |
|||
record = self.env['ir.actions.report']._render_qweb_pdf( |
|||
'account.report_invoice', form_id) |
|||
else: |
|||
raise ValidationError(_("Select a record to download!!!")) |
|||
file_name = self.env[model].browse(form_id).name + '.pdf' |
|||
attachment = self.env['ir.attachment'].create({ |
|||
'name': file_name, |
|||
'type': 'binary', |
|||
'datas': base64.b64encode(record[0]), |
|||
'res_model': model, |
|||
'res_id': form_id, |
|||
'mimetype': 'application/x-pdf' |
|||
}) |
|||
return { |
|||
'type': 'ir.actions.act_url', |
|||
'target': 'new', |
|||
'url': f"/web/content/{attachment.id}?download=true" |
|||
} |
|||
|
|||
def action_open_report(self): |
|||
""" |
|||
Summary: |
|||
In this method open the print screen of the form.Return a dict. |
|||
Returns: |
|||
type:dict , it contains the data for the open print report. |
|||
""" |
|||
form_id = self.res_id |
|||
model = self.res_model |
|||
server_address = self.get_base_url() |
|||
if model == 'sale.order': |
|||
url = f"{server_address}/report/pdf/sale.report_saleorder/{form_id}" |
|||
elif model == 'purchase.order': |
|||
url = f"{server_address}/report/pdf/purchase.report_purchaseorder/{form_id}" |
|||
elif model == 'stock.picking': |
|||
url = f"{server_address}/report/pdf/stock.report_picking/{form_id}" |
|||
elif model == 'account.move': |
|||
url = f"{server_address}/report/pdf/account.report_invoice/{form_id}" |
|||
else: |
|||
raise ValidationError(_("select any record!!!")) |
|||
return { |
|||
'type': 'ir.actions.act_url', |
|||
'target': 'new', |
|||
'url': url |
|||
} |
|||
|
|||
def action_share_email(self): |
|||
""" |
|||
Summary: |
|||
In this method share email report of the corresponding form. |
|||
Return a dict. |
|||
Returns: |
|||
type:dict , it contains the data for the email template. |
|||
""" |
|||
form_id = self.res_id |
|||
model = self.res_model |
|||
model_name = self.resource_ref |
|||
self.ensure_one() |
|||
if model == 'sale.order': |
|||
if model_name.state not in ('sale', 'done'): |
|||
mail_template = self.env.ref('sale.email_template_edi_sale') |
|||
else: |
|||
mail_template = self.env.ref( |
|||
'sale.mail_template_sale_confirmation') |
|||
elif model == 'purchase.order': |
|||
if model_name.state not in ('purchase', 'done'): |
|||
mail_template = self.env.ref( |
|||
'purchase.email_template_edi_purchase') |
|||
else: |
|||
mail_template = self.env.ref( |
|||
'purchase.email_template_edi_purchase_done') |
|||
elif model == 'account.move': |
|||
if model_name.move_type == 'out_refund': |
|||
mail_template = self.env.ref( |
|||
'account.email_template_edi_credit_note') |
|||
else: |
|||
mail_template = self.env.ref( |
|||
'account.email_template_edi_invoice') |
|||
else: |
|||
raise ValidationError(_("select a record or selected record does " |
|||
"not have a share option!!!!!!")) |
|||
ctx = { |
|||
'default_model': model, |
|||
'default_res_ids': [form_id], |
|||
'default_use_template': bool(mail_template), |
|||
'default_template_id': mail_template.id if mail_template else None, |
|||
'default_composition_mode': 'comment', |
|||
'mark_so_as_sent': True, |
|||
'default_email_layout_xmlid': 'mail.mail_notification_layout_with_' |
|||
'responsible_signature', |
|||
'proforma': self.env.context.get('proforma', False), |
|||
'force_email': True, |
|||
} |
|||
if mail_template: |
|||
# If module has email template |
|||
return { |
|||
'type': 'ir.actions.act_window', |
|||
'view_mode': 'form', |
|||
'res_model': 'mail.compose.message', |
|||
'views': [(False, 'form')], |
|||
'view_id': False, |
|||
'target': 'new', |
|||
'context': ctx, |
|||
} |
|||
raise ValidationError(_("select a record or selected record does not" |
|||
" have a share option!!!!!!!!!!!!")) |
@ -0,0 +1,41 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<odoo> |
|||
<!-- Action for the form view of the wizard --> |
|||
<record id="dynamic_action_view_form" model="ir.ui.view"> |
|||
<field name="name">dynamic.action.view.form</field> |
|||
<field name="model">dynamic.action</field> |
|||
<field name="arch" type="xml"> |
|||
<form name="report"> |
|||
<center> |
|||
<span>Select model and Record :</span> |
|||
<field name="resource_ref"/><br/><br/><br/> |
|||
<field name="res_model" invisible="1"/> |
|||
<button name="action_print_report" type="object" |
|||
class="btn btn-primary wizard_btn"> |
|||
<i class="fa fa-print mr-2"/> |
|||
Print |
|||
</button> |
|||
<button name="action_download_report" |
|||
class="btn btn-primary wizard_btn" type="object"> |
|||
<i class="fa fa-download mr-2"/> |
|||
Download |
|||
</button> |
|||
<button name="action_open_report" type="object" |
|||
class="btn btn-primary wizard_btn"> |
|||
<i class="fa fa-file-text"/> |
|||
Open |
|||
</button> |
|||
<button name="action_share_email" |
|||
class="btn btn-primary wizard_btn" type="object" invisible="res_model == 'stock.picking'"> |
|||
<i class="fa fa-envelope fa-fw"/> |
|||
Share By Email |
|||
</button> |
|||
</center> |
|||
<footer> |
|||
<button class="btn-secondary" string="Cancel" |
|||
special="cancel"/> |
|||
</footer> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
</odoo> |