@ -0,0 +1,49 @@ |
|||
.. 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 |
|||
|
|||
Lunch Orders - PDF |
|||
================== |
|||
This module allow to print PDF report for lunch orders. |
|||
|
|||
Configuration |
|||
============= |
|||
The user should be added to the security group: Administrator(Human Resources/ Lunch) inorder to get access to the new menus. |
|||
|
|||
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: (V16) Ammu Raj, |
|||
(V17) Gayathri V |
|||
(V18) Nandakishore M |
|||
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,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nandakishore M (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from . import report |
|||
from . import wizard |
@ -0,0 +1,44 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nandakishore M (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
{ |
|||
'name': 'Lunch Orders - PDF', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Human Resources', |
|||
'summary': "Custom report for Lunch module", |
|||
'description': "Create custom PDF Report for Lunch with required filters", |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['lunch'], |
|||
'data': [ |
|||
'security/ir.model.access.csv', |
|||
'report/lunch_order_report_templates.xml', |
|||
'report/lunch_order_reports.xml', |
|||
'wizard/lunch_report_views.xml' |
|||
], |
|||
'images': ['static/description/banner.jpg'], |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
} |
@ -0,0 +1,7 @@ |
|||
## Module <lunch_order_pdf> |
|||
|
|||
#### 24.09.2024 |
|||
#### Version 17.0.1.0.0 |
|||
#### ADD |
|||
|
|||
- Initial commit for Lunch Orders - PDF |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nandakishore M (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from . import lunch_order_report |
@ -0,0 +1,89 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nandakishore M (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from odoo import api, fields, models |
|||
|
|||
|
|||
class LunchOrderReport(models.TransientModel): |
|||
"""Model for creating custom reports. Passing the values to the template""" |
|||
_name = 'report.lunch_order_pdf.report_lunch_order' |
|||
_description = 'Report for lunch orders' |
|||
|
|||
@api.model |
|||
def _get_report_values(self, docids, data=None): |
|||
""" |
|||
Override the method to create custom report with custom values |
|||
:param docids: the recordset/ record from which the report action is |
|||
invoked |
|||
:param data: report data |
|||
:return: data dictionary to pass values to the report template |
|||
""" |
|||
period = None |
|||
grouped_orders = [] |
|||
docs = self.env['lunch.report'].browse( |
|||
self.env.context.get('active_id')) |
|||
lang = self.env['res.lang'].search( |
|||
[('code', '=', self.env.context.get('lang'))]) |
|||
order_ids = data.get('order_ids') |
|||
orders = self.env['lunch.order'].sudo().browse(order_ids) |
|||
end_date = docs.end_date |
|||
if not end_date: |
|||
end_date = fields.Date.context_today(self) |
|||
if docs.start_date: |
|||
period = "From " + docs.start_date.strftime( |
|||
lang.date_format) + " To " + end_date.strftime(lang.date_format) |
|||
if docs.group_order: |
|||
if docs.group_order == 'user_id': |
|||
users = orders.mapped('user_id').sorted(key='name') |
|||
for user in users: |
|||
grouped_orders.append([user.name, orders.filtered( |
|||
lambda order: order.user_id == user)]) |
|||
elif docs.group_order == 'supplier_id': |
|||
vendors = orders.mapped('supplier_id').sorted(key='name') |
|||
for vendor in vendors: |
|||
grouped_orders.append([vendor.name, orders.filtered( |
|||
lambda order: order.supplier_id == vendor)]) |
|||
elif docs.group_order == 'product_id': |
|||
products = orders.mapped('product_id').sorted(key='name') |
|||
for product in products: |
|||
grouped_orders.append([product.name, orders.filtered( |
|||
lambda order: order.product_id == product)]) |
|||
elif docs.group_order == 'state': |
|||
order_states = ['new', 'ordered', 'confirmed', 'cancelled'] |
|||
states = orders.mapped('state') |
|||
for state in order_states: |
|||
if state in states: |
|||
grouped_orders.append([state, orders.filtered( |
|||
lambda order: order.state == state)]) |
|||
else: |
|||
companies = orders.mapped('company_id').sorted(key='name') |
|||
for company in companies: |
|||
grouped_orders.append([company.name, orders.filtered( |
|||
lambda order: order.company_id == company)]) |
|||
else: |
|||
grouped_orders.append([False, orders]) |
|||
return { |
|||
'doc_ids': self.ids, |
|||
'docs': docs, |
|||
'group_order': docs.group_order, |
|||
'grouped_orders': grouped_orders, |
|||
'period': period |
|||
} |
@ -0,0 +1,116 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Report template --> |
|||
<template id="report_lunch_order"> |
|||
<t t-call="web.html_container"> |
|||
<t t-call="web.basic_layout"> |
|||
<t t-foreach="docs" t-as="o"> |
|||
<div class="page"> |
|||
<div style="padding-bottom:20px !important;" |
|||
class="oe_structure"/> |
|||
<h1 align="center">Lunch Report</h1> |
|||
<br/> |
|||
<p t-if="period" style="text-align: center;"> |
|||
<strong style="text-align: right;">Period:</strong> |
|||
<span style="text-align: left;"> |
|||
<span t-esc="period"/> |
|||
</span> |
|||
</p> |
|||
<t t-if="grouped_orders"> |
|||
<table name="orders" class="table table-condensed"> |
|||
<thead> |
|||
<tr> |
|||
<t t-if="group_order"> |
|||
<th t-if="group_order == 'user_id'"> |
|||
User |
|||
</th> |
|||
<th t-if="group_order == 'supplier_id'"> |
|||
Vendor |
|||
</th> |
|||
<th t-if="group_order == 'product_id'"> |
|||
Product |
|||
</th> |
|||
<th t-if="group_order == 'state'"> |
|||
Status |
|||
</th> |
|||
<th t-if="group_order == 'company_id'"> |
|||
Company |
|||
</th> |
|||
</t> |
|||
<th>Order Date</th> |
|||
<th t-if="not group_order or group_order != 'supplier_id'"> |
|||
Vendor |
|||
</th> |
|||
<th t-if="not group_order or group_order != 'product_id'"> |
|||
Product |
|||
</th> |
|||
<th>Extras</th> |
|||
<th t-if="not group_order or group_order != 'user_id'"> |
|||
User |
|||
</th> |
|||
<th>Lunch Location</th> |
|||
<th t-if="not group_order or group_order != 'company_id'"> |
|||
Company |
|||
</th> |
|||
<th>Price</th> |
|||
<th t-if="not group_order or group_order != 'state'"> |
|||
Status |
|||
</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<t t-foreach="grouped_orders" |
|||
t-as="order_list"> |
|||
<t t-if="group_order"> |
|||
<td> |
|||
<t t-if="group_order == 'state'"> |
|||
<span t-esc="dict(order_list[1][0].fields_get(allfields=['state'])['state']['selection'])[order_list[0]]"/> |
|||
</t> |
|||
<t t-else=""> |
|||
<span t-esc="order_list[0]"/> |
|||
</t> |
|||
</td> |
|||
</t> |
|||
<tr t-foreach="order_list[1]" |
|||
t-as="order"> |
|||
<td t-if="group_order"/> |
|||
<td> |
|||
<span t-esc="order.date" |
|||
t-options="{'widget': 'date'}"/> |
|||
</td> |
|||
<td t-if="not group_order or group_order != 'supplier_id'"> |
|||
<span t-esc="order.supplier_id.name"/> |
|||
</td> |
|||
<td t-if="not group_order or group_order != 'product_id'"> |
|||
<span t-esc="order.product_id.name"/> |
|||
</td> |
|||
<td> |
|||
<span t-esc="order.display_toppings"/> |
|||
</td> |
|||
<td t-if="not group_order or group_order != 'user_id'"> |
|||
<span t-esc="order.user_id.name"/> |
|||
</td> |
|||
<td> |
|||
<span t-esc="order.lunch_location_id.name"/> |
|||
</td> |
|||
<td t-if="not group_order or group_order != 'company_id'"> |
|||
<span t-esc="order.company_id.name"/> |
|||
</td> |
|||
<td> |
|||
<span t-esc="order.price" |
|||
t-options="{'widget': 'monetary', 'display_currency': order.currency_id}"/> |
|||
</td> |
|||
<td t-if="not group_order or group_order != 'state'"> |
|||
<span t-esc="dict(order.fields_get(allfields=['state'])['state']['selection'])[order.state]"/> |
|||
</td> |
|||
</tr> |
|||
</t> |
|||
</tbody> |
|||
</table> |
|||
</t> |
|||
</div> |
|||
</t> |
|||
</t> |
|||
</t> |
|||
</template> |
|||
</odoo> |
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Report action --> |
|||
<record id="report_lunch_report_action" model="ir.actions.report"> |
|||
<field name="name">Lunch Report</field> |
|||
<field name="model">lunch.report</field> |
|||
<field name="report_type">qweb-pdf</field> |
|||
<field name="report_name">lunch_order_pdf.report_lunch_order</field> |
|||
<field name="report_file">lunch_order_pdf.report_lunch_order</field> |
|||
</record> |
|||
</odoo> |
|
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: 245 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: 269 KiB |
After Width: | Height: | Size: 822 KiB |
After Width: | Height: | Size: 519 KiB |
After Width: | Height: | Size: 311 KiB |
After Width: | Height: | Size: 526 KiB |
After Width: | Height: | Size: 312 KiB |
After Width: | Height: | Size: 245 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 7.8 KiB |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nandakishore M (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from . import lunch_report |
@ -0,0 +1,98 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nandakishore M (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from odoo import api, fields, models, _ |
|||
from odoo.exceptions import UserError |
|||
|
|||
|
|||
class LunchReport(models.TransientModel): |
|||
"""Creating the report for Lunch""" |
|||
_name = 'lunch.report' |
|||
_description = 'Wizard for lunch report' |
|||
|
|||
start_date = fields.Date( |
|||
string='Start Date', required=True, default=fields.Date.context_today, |
|||
help='Start date to filter the records') |
|||
end_date = fields.Date( |
|||
string='End Date', default=fields.Date.context_today, |
|||
help='End date to filter the records') |
|||
user_ids = fields.Many2many('res.users', string='Users', |
|||
domain='[("share", "=", False)]', |
|||
help="Add user for filter based on user") |
|||
lunch_supplier_ids = fields.Many2many('lunch.supplier', string='Vendors', |
|||
help='Vendors/ Lunch Suppliers.') |
|||
lunch_location_ids = fields.Many2many( |
|||
'lunch.location', string='Lunch Locations', |
|||
help="The Locations allocated for lunch") |
|||
product_filter = fields.Selection( |
|||
[('product', 'Product'), ('category', 'Product Category')], |
|||
string='Product Filter', |
|||
help='Filter orders by Products or Product Categories.') |
|||
product_ids = fields.Many2many( |
|||
'lunch.product', string='Products', |
|||
domain='[("active", "=", True)]', help='Products belongs to lunch') |
|||
category_ids = fields.Many2many( |
|||
'lunch.product.category', string='Categories', |
|||
help='Lunch Product Categories.') |
|||
company_ids = fields.Many2many('res.company', string='Companies', |
|||
help='For selecting the Companies') |
|||
group_order = fields.Selection( |
|||
[('user_id', 'User'), ('supplier_id', 'Vendor'), |
|||
('product_id', 'Product'), ('state', 'Status'), |
|||
('company_id', 'Company')], string='Group Orders', |
|||
help='Group orders in the report') |
|||
|
|||
@api.onchange('start_date', 'end_date') |
|||
def _onchange_date(self): |
|||
""" |
|||
Set valid start_date and end_date on changing it |
|||
""" |
|||
if self.start_date and self.end_date: |
|||
if self.start_date > self.end_date: |
|||
raise UserError(_("'Start Date' Should be lesser than 'End Date'!")) |
|||
|
|||
def action_print_report(self): |
|||
""" |
|||
Print PDF report for lunch based on selected data |
|||
:return: report action |
|||
""" |
|||
domain = [('date', '>=', self.start_date)] |
|||
if self.end_date: |
|||
domain += [('date', '<=', self.end_date)] |
|||
if self.user_ids: |
|||
domain += [('user_id', 'in', self.user_ids.ids)] |
|||
if self.company_ids: |
|||
domain += [('company_id', 'in', self.company_ids.ids)] |
|||
if self.lunch_supplier_ids: |
|||
domain += [('supplier_id', 'in', self.lunch_supplier_ids.ids)] |
|||
if self.lunch_location_ids: |
|||
domain += [('lunch_location_id', 'in', self.lunch_location_ids.ids)] |
|||
if self.product_filter == 'product' and self.product_ids: |
|||
domain += [('product_id', 'in', self.product_ids.ids)] |
|||
if self.product_filter == 'category' and self.category_ids: |
|||
domain += [('product_id.category_id', 'in', self.category_ids.ids)] |
|||
orders = self.env['lunch.order'].sudo().search(domain) |
|||
if not orders: |
|||
raise UserError(_('There are no lunch orders in this period!')) |
|||
data = {'order_ids': orders.ids} |
|||
return self.env.ref( |
|||
'lunch_order_pdf.report_lunch_report_action').report_action( |
|||
self, data=data) |
@ -0,0 +1,61 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<odoo> |
|||
<!-- Wizard form view --> |
|||
<record id="lunch_report_view_form" model="ir.ui.view"> |
|||
<field name="name">lunch.report.view.form</field> |
|||
<field name="model">lunch.report</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Lunch Report"> |
|||
<group> |
|||
<group> |
|||
<field name="start_date" widget="date"/> |
|||
<field name="end_date" widget="date"/> |
|||
<field name="user_ids" widget="many2many_tags" |
|||
options="{'create': false, 'create_edit': false}"/> |
|||
<field name="lunch_supplier_ids" widget="many2many_tags" |
|||
options="{'create': false, 'create_edit': false}"/> |
|||
</group> |
|||
<group> |
|||
<field name="lunch_location_ids" widget="many2many_tags" |
|||
options="{'create': false, 'create_edit': false}"/> |
|||
<field name="company_ids" widget="many2many_tags" |
|||
options="{'create': false, 'create_edit': false}" |
|||
groups="base.group_multi_company"/> |
|||
<field name="product_filter"/> |
|||
<field name="product_ids" widget="many2many_tags" |
|||
invisible="product_filter != 'product'" required="product_filter == 'product'" |
|||
options="{'create': false, 'create_edit': false}"/> |
|||
<field name="category_ids" widget="many2many_tags" |
|||
invisible="product_filter !='category'" required="product_filter == 'category'" |
|||
options="{'create': false, 'create_edit': false}"/> |
|||
</group> |
|||
</group> |
|||
<group string="Group Orders in the Report"> |
|||
<field name="group_order"/> |
|||
</group> |
|||
<footer> |
|||
<button string="Print" name="action_print_report" |
|||
type="object" class="btn-primary"/> |
|||
<button string="Discard" class="btn-default" |
|||
special="cancel"/> |
|||
</footer> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
<!-- Wizard action window --> |
|||
<record id="lunch_report_action" model="ir.actions.act_window"> |
|||
<field name="name">Lunch Report</field> |
|||
<field name="res_model">lunch.report</field> |
|||
<field name="type">ir.actions.act_window</field> |
|||
<field name="view_mode">form</field> |
|||
<field name="view_id" ref="lunch_report_view_form"/> |
|||
<field name="target">new</field> |
|||
</record> |
|||
<!-- Report menu --> |
|||
<menuitem name="Report" id="lunch_report_menu_root" sequence="52" |
|||
parent="lunch.menu_lunch" groups="lunch.group_lunch_manager"/> |
|||
<menuitem name="Lunch Report" id="lunch_report_menu_action" |
|||
action="lunch_report_action" sequence="5" |
|||
parent="lunch_order_pdf.lunch_report_menu_root" |
|||
groups="lunch.group_lunch_manager"/> |
|||
</odoo> |