diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..ba7466050 --- /dev/null +++ b/.gitignore @@ -0,0 +1,57 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ diff --git a/account_pdc/__init__.py b/account_pdc/__init__.py index 55e11f5a1..fedc9b4b9 100644 --- a/account_pdc/__init__.py +++ b/account_pdc/__init__.py @@ -21,3 +21,8 @@ # ############################################################################## import models +<<<<<<< HEAD +======= +import wizard +import report +>>>>>>> e773d5cc4ac49a15b964551d003ba499cf2bf5ad diff --git a/account_pdc/__manifest__.py b/account_pdc/__manifest__.py index da56b10d3..8d9b7cbc2 100644 --- a/account_pdc/__manifest__.py +++ b/account_pdc/__manifest__.py @@ -22,7 +22,11 @@ ############################################################################## { 'name': 'PDC Management', +<<<<<<< HEAD 'version': '10.0.1.0', +======= + 'version': '10.0.2.0', +>>>>>>> e773d5cc4ac49a15b964551d003ba499cf2bf5ad 'author': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions', 'website': 'http://www.cybrosys.com', @@ -33,6 +37,11 @@ 'data': [ 'data/account_pdc_data.xml', 'views/account_payment_view.xml', +<<<<<<< HEAD +======= + 'views/report_payment.xml', + 'wizard/account_report_payment_view.xml', +>>>>>>> e773d5cc4ac49a15b964551d003ba499cf2bf5ad ], 'images': ['static/description/banner.jpg'], 'license': 'LGPL-3', diff --git a/account_pdc/__manifest__.py~ b/account_pdc/__manifest__.py~ new file mode 100644 index 000000000..83193e896 --- /dev/null +++ b/account_pdc/__manifest__.py~ @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Cybrosys Technologies() +# 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 . +# +############################################################################## +{ + 'name': 'PDC Management', + 'version': '10.0.1.0', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'http://www.cybrosys.com', + 'category': 'Accounting', + 'summary': 'Extension on Cheques to handle Post Dated Cheques', + 'description': """ Extension on Cheques to handle Post Dated Cheques """, + 'depends': ['account_check_printing'], + 'data': [ + 'data/account_pdc_data.xml', + 'views/account_payment_view.xml', + 'views/report_payment.xml', + 'wizard/account_report_payment_view.xml', + ], + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, +} diff --git a/account_pdc/models/account_payment.py b/account_pdc/models/account_payment.py index 3d0e4d61e..43cac299d 100644 --- a/account_pdc/models/account_payment.py +++ b/account_pdc/models/account_payment.py @@ -28,9 +28,15 @@ from odoo.exceptions import UserError class AccountRegisterPayments(models.TransientModel): _inherit = "account.register.payments" +<<<<<<< HEAD bank_reference = fields.Char(copy=False) cheque_reference = fields.Char(copy=False) effective_date = fields.Date('Effective Date', help='Effective date of PDC', copy=False, default=False) +======= + effective_date = fields.Date('Effective Date', help='Effective date of PDC', copy=False, default=False) + bank_reference = fields.Char(copy=False) + cheque_reference = fields.Char(copy=False) +>>>>>>> e773d5cc4ac49a15b964551d003ba499cf2bf5ad def get_payment_vals(self): res = super(AccountRegisterPayments, self).get_payment_vals() diff --git a/account_pdc/models/account_payment.py~ b/account_pdc/models/account_payment.py~ new file mode 100644 index 000000000..16a0eddce --- /dev/null +++ b/account_pdc/models/account_payment.py~ @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Cybrosys Technologies() +# 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 . +# +############################################################################## + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError + + +class AccountRegisterPayments(models.TransientModel): + _inherit = "account.register.payments" + + effective_date = fields.Date('Effective Date', help='Effective date of PDC', copy=False, default=False) + bank_reference = fields.Char(copy=False) + cheque_reference = fields.Char(copy=False) + + def get_payment_vals(self): + res = super(AccountRegisterPayments, self).get_payment_vals() + if self.payment_method_id == self.env.ref('account_check_printing.account_payment_method_check'): + res.update({ + 'check_amount_in_words': self.check_amount_in_words, + 'check_manual_sequencing': self.check_manual_sequencing, + 'effective_date': self.effective_date, + }) + return res + + +class AccountPayment(models.Model): + _inherit = "account.payment" + + bank_reference = fields.Char(copy=False) + cheque_reference = fields.Char(copy=False) + effective_date = fields.Date('Effective Date', help='Effective date of PDC', copy=False, default=False) + + @api.multi + def print_checks(self): + """ Check that the recordset is valid, set the payments state to sent and call print_checks() """ + # Since this method can be called via a client_action_multi, we need to make sure the received records are what we expect + self = self.filtered(lambda r: r.payment_method_id.code in ['check_printing', 'pdc'] and r.state != 'reconciled') + + if len(self) == 0: + raise UserError(_("Payments to print as a checks must have 'Check' or 'PDC' selected as payment method and " + "not have already been reconciled")) + if any(payment.journal_id != self[0].journal_id for payment in self): + raise UserError(_("In order to print multiple checks at once, they must belong to the same bank journal.")) + + if not self[0].journal_id.check_manual_sequencing: + # The wizard asks for the number printed on the first pre-printed check + # so payments are attributed the number of the check the'll be printed on. + last_printed_check = self.search([ + ('journal_id', '=', self[0].journal_id.id), + ('check_number', '!=', 0)], order="check_number desc", limit=1) + next_check_number = last_printed_check and last_printed_check.check_number + 1 or 1 + return { + 'name': _('Print Pre-numbered Checks'), + 'type': 'ir.actions.act_window', + 'res_model': 'print.prenumbered.checks', + 'view_type': 'form', + 'view_mode': 'form', + 'target': 'new', + 'context': { + 'payment_ids': self.ids, + 'default_next_check_number': next_check_number, + } + } + else: + self.filtered(lambda r: r.state == 'draft').post() + self.write({'state': 'sent'}) + return self.do_print_checks() + + + def _get_move_vals(self, journal=None): + """ Return dict to create the payment move + """ + journal = journal or self.journal_id + if not journal.sequence_id: + raise UserError(_('Configuration Error !'), + _('The journal %s does not have a sequence, please specify one.') % journal.name) + if not journal.sequence_id.active: + raise UserError(_('Configuration Error !'), _('The sequence of journal %s is deactivated.') % journal.name) + name = self.move_name or journal.with_context(ir_sequence_date=self.payment_date).sequence_id.next_by_id() + if self.payment_method_code =='pdc': + date = self.effective_date + else: + date = self.payment_date + return { + 'name': name, + 'date': date, + 'ref': self.communication or '', + 'company_id': self.company_id.id, + 'journal_id': journal.id, + } diff --git a/account_pdc/report/__init__.py b/account_pdc/report/__init__.py new file mode 100644 index 000000000..935b971f3 --- /dev/null +++ b/account_pdc/report/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +import report_payment + diff --git a/account_pdc/report/report_payment.py b/account_pdc/report/report_payment.py new file mode 100644 index 000000000..5cbcd286a --- /dev/null +++ b/account_pdc/report/report_payment.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +import time +from odoo import api, models +import logging + +_logger = logging.getLogger(__name__) + + +class ReportPayment(models.AbstractModel): + _name = 'report.account_pdc.report_payment_template' + + def lines(self, payment_type, journal_ids, pdc_only, data): + domain = [] + if isinstance(journal_ids, int): + journal_ids = [journal_ids] + domain.append(('journal_id', 'in', journal_ids)) + if payment_type == 'inbound': + domain.append(('payment_type', '=', 'inbound')) + elif payment_type == 'outbound': + domain.append(('payment_type', '=', 'outbound')) + if data['form']['date_from']: + domain.append(('payment_date', '>=', data['form']['date_from'])) + if data['form']['date_to']: + domain.append(('payment_date', '<=', data['form']['date_to'])) + if data['form']['company_id']: + domain.append(('company_id', '=', data['form']['company_id'][0])) + if pdc_only: + domain.append(('payment_method_id.code', '=', 'pdc')) + if data['form']['effective_date_from']: + domain.append(('effective_date_from', '>=', data['form']['effective_date_from'])) + if data['form']['effective_date_to']: + domain.append(('effective_date_to', '<=', data['form']['effective_date_to'])) + + + return self.env['account.payment'].search(domain) + + + @api.model + def render_html(self, docids, data=None): + _logger.info("................................1..............................") + # target_move = data['form'].get('target_move', 'all') + # sort_selection = data['form'].get('sort_selection', 'date') + payment_type = data['form']['payment_type'] + pdc_only = data['form']['pdc_only'] + # effective_date_from = data['form']['effective_date_from'] + # effective_date_to = data['form']['effective_date_to'] + + res = {} + for journal in data['form']['journal_ids']: + res[journal] = self.with_context(data['form'].get('used_context', {})).lines(payment_type, journal, pdc_only, data) + docargs = { + 'doc_ids': data['form']['journal_ids'], + 'doc_model': self.env['account.journal'], + 'data': data, + 'docs': self.env['account.journal'].browse(data['form']['journal_ids']), + 'time': time, + 'lines': res, + } + return self.env['report'].render('account_pdc.report_payment_template', docargs) diff --git a/account_pdc/static/description/index.html b/account_pdc/static/description/index.html index 48d9b1115..2acff9de4 100644 --- a/account_pdc/static/description/index.html +++ b/account_pdc/static/description/index.html @@ -1,7 +1,11 @@
+<<<<<<< HEAD

PDC Management

+======= +

PDC with Payments Report

+>>>>>>> e773d5cc4ac49a15b964551d003ba499cf2bf5ad

...A simple way to handle Post Dated Checks...

Cybrosys Techno Solutions, www.cybrosys.com

@@ -46,7 +50,11 @@

+<<<<<<< HEAD

When you select PDC, You have to put 'effective date' of PDC.

+======= +

When you select PDC, You can also put 'effective date' of PDC.

+>>>>>>> e773d5cc4ac49a15b964551d003ba499cf2bf5ad

@@ -57,6 +65,22 @@
+<<<<<<< HEAD +======= +
+
+
+

Yes,...You can generate a PDF report of all your payments.

+
+
+
+ +
+
+
+
+ +>>>>>>> e773d5cc4ac49a15b964551d003ba499cf2bf5ad

Need Any Help?

diff --git a/account_pdc/views/report_payment.xml b/account_pdc/views/report_payment.xml new file mode 100644 index 000000000..793845de8 --- /dev/null +++ b/account_pdc/views/report_payment.xml @@ -0,0 +1,76 @@ + + + + + + + + + diff --git a/account_pdc/wizard/__init__.py b/account_pdc/wizard/__init__.py new file mode 100644 index 000000000..0c0457886 --- /dev/null +++ b/account_pdc/wizard/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Cybrosys Technologies() +# 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 . +# +############################################################################## +import account_report_payment diff --git a/account_pdc/wizard/account_report_payment.py b/account_pdc/wizard/account_report_payment.py new file mode 100644 index 000000000..3ebb9e434 --- /dev/null +++ b/account_pdc/wizard/account_report_payment.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Cybrosys Technologies() +# 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 . +# +############################################################################## + +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) + + + + + + + + + diff --git a/account_pdc/wizard/account_report_payment_view.xml b/account_pdc/wizard/account_report_payment_view.xml new file mode 100644 index 000000000..8f9fc7065 --- /dev/null +++ b/account_pdc/wizard/account_report_payment_view.xml @@ -0,0 +1,61 @@ + + + + + Payments Report + account.report.payment + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + Payments Report + ir.actions.act_window + account.report.payment + form + form + + new + + + + +