You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
3.5 KiB
77 lines
3.5 KiB
# -*- coding: utf-8 -*-
|
|
##############################################################################
|
|
#
|
|
# Cybrosys Technologies Pvt. Ltd.
|
|
# Copyright (C) 2017-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
|
|
# Author: Cybrosys Technologies(<http://www.cybrosys.com>)
|
|
# you can modify it under the terms of the GNU LESSER
|
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
|
|
#
|
|
# It is forbidden to publish, distribute, sublicense, or sell copies
|
|
# of the Software or modified copies of the Software.
|
|
#
|
|
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
|
|
#
|
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
|
|
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
|
|
# If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
##############################################################################
|
|
|
|
from odoo import fields, models, api
|
|
|
|
|
|
class AccountReportPayment(models.TransientModel):
|
|
_name = "account.report.payment"
|
|
_description = "Account Payment Report"
|
|
|
|
company_id = fields.Many2one('res.company', string='Company', readonly=True, default=lambda self: self.env.user.company_id)
|
|
date_from = fields.Date(string='Start Date')
|
|
date_to = fields.Date(string='End Date')
|
|
journal_ids = fields.Many2many('account.journal', string='Journals', required=True,
|
|
default=lambda self: self.env['account.journal'].search(
|
|
[('type', 'in', ['cash', 'bank'])]))
|
|
payment_type = fields.Selection([('inbound', 'Customer'), ('outbound', 'Supplier')], 'Payment Type')
|
|
pdc_only = fields.Boolean('PDC only')
|
|
effective_date_from = fields.Date('Effective Date From')
|
|
effective_date_to = fields.Date('Effective Date Upto')
|
|
|
|
def _build_contexts(self, data):
|
|
result = {}
|
|
result['journal_ids'] = 'journal_ids' in data['form'] and data['form']['journal_ids'] or False
|
|
result['state'] = 'target_move' in data['form'] and data['form']['target_move'] or ''
|
|
result['date_from'] = data['form']['date_from'] or False
|
|
result['date_to'] = data['form']['date_to'] or False
|
|
result['payment_type'] = data['form']['payment_type'] or False
|
|
result['pdc_only'] = data['form']['pdc_only']
|
|
if result['pdc_only']:
|
|
result['effective_date_from'] = data['form']['effective_date_from'] or False
|
|
result['effective_date_to'] = data['form']['effective_date_to'] or False
|
|
result['strict_range'] = True if result['date_from'] else False
|
|
return result
|
|
|
|
@api.multi
|
|
def check_report(self):
|
|
self.ensure_one()
|
|
data = {}
|
|
data['ids'] = self.env.context.get('active_ids', [])
|
|
data['model'] = self.env.context.get('active_model', 'ir.ui.menu')
|
|
data['form'] = self.read(['date_from', 'date_to', 'journal_ids', 'payment_type', 'pdc_only', 'effective_date_from', 'effective_date_to', 'company_id'])[0]
|
|
used_context = self._build_contexts(data)
|
|
data['form']['used_context'] = dict(used_context, lang=self.env.context.get('lang', 'en_US'))
|
|
return self._print_report(data)
|
|
|
|
def _print_report(self, data):
|
|
return self.env['report'].with_context(landscape=True).get_action(self, 'account_pdc.report_payment_template', data=data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|