Skip to content

Commit

Permalink
Merge 824c31c into d3770b3
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis M. Ontalba committed Feb 16, 2018
2 parents d3770b3 + 824c31c commit 84d646d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 2 deletions.
10 changes: 9 additions & 1 deletion account_check_printing_report_base/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Account Check Printing Report Base
This module provides the basic framework for check printing, and a sample
layout.


Installation
============

Expand All @@ -30,11 +29,19 @@ Usage

* Go to 'Invoicing / Purchases / Payments'. Select one of the payments with
type 'Check' and print the check.
* For automatic check printing when validating payment, mark the field in
the journal associated.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/96/10.0

Known issues / Roadmap
======================

* When print check automatically in the payment validation process, the wizard
remains opened.

Bug Tracker
===========

Expand All @@ -57,6 +64,7 @@ Contributors
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Lois Rilo Antelo <lois.rilo@eficent.com>
* Sandip Mangukiya <smangukiya@ursainfosystems.com>
* Luis M. Ontalba <luis.martinez@tecnativa.com>

Maintainer
----------
Expand Down
4 changes: 3 additions & 1 deletion account_check_printing_report_base/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
# Copyright 2017 Tecnativa.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Account Check Printing Report Base",
"version": "10.0.1.0.1",
"version": "10.0.1.1.0",
"license": "AGPL-3",
"author": "Eficent,"
"Serpent Consulting Services Pvt. Ltd.,"
Expand All @@ -20,6 +21,7 @@
"security/ir.model.access.csv",
"data/report_paperformat.xml",
"data/account_payment_check_report_data.xml",
"views/account_journal_view.xml",
"views/report_check_base.xml",
"views/res_company_view.xml",
"views/account_payment_check_report_view.xml",
Expand Down
1 change: 1 addition & 0 deletions account_check_printing_report_base/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import account_journal
from . import account_payment
from . import res_company
from . import account_payment_check_report
15 changes: 15 additions & 0 deletions account_check_printing_report_base/models/account_journal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class AccountJournal(models.Model):
_inherit = "account.journal"

check_print_auto = fields.Boolean(
string='Automatic check printing',
help='Default check for the company is printed automatically when '
'invoice payment is validated',
)
24 changes: 24 additions & 0 deletions account_check_printing_report_base/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@
from odoo import models, api


class AccountRegisterPayments(models.TransientModel):
_inherit = "account.register.payments"

@api.multi
def create_payment(self):
res = super(AccountRegisterPayments, self).create_payment()
if (self.journal_id.check_print_auto and
self.payment_method_id.code == 'check_printing'):
payment = self.env['account.payment'].search([
('journal_id', '=', self.journal_id.id),
('payment_method_id.name', 'like',
self.payment_method_id.name)], order="id desc", limit=1)
return payment.do_print_checks()
return res


class AccountPayment(models.Model):
_inherit = "account.payment"

Expand All @@ -17,3 +33,11 @@ def do_print_checks(self):
return self.env['report'].get_action(
rec, rec.company_id.check_layout_id.report)
return super(AccountPayment, self).do_print_checks()

@api.multi
def post(self):
res = super(AccountPayment, self).post()
if (self.journal_id.check_print_auto and
self.payment_method_id.code == 'check_printing'):
return self.do_print_checks()
return res
16 changes: 16 additions & 0 deletions account_check_printing_report_base/views/account_journal_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_account_journal_form_inherited" model="ir.ui.view">
<field name="name">account.journal.form.inherited</field>
<field name="model">account.journal</field>
<field name="inherit_id"
ref="account_check_printing.view_account_journal_form_inherited"/>
<field name="arch" type="xml">
<field name="check_next_number" position="after">
<field name="check_print_auto"/>
</field>
</field>
</record>

</odoo>

0 comments on commit 84d646d

Please sign in to comment.