forked from OCA/l10n-switzerland
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new background configuration option
- Loading branch information
Showing
6 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Nicolas Bessi | ||
# Copyright 2015 Camptocamp SA | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License 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 <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
from openerp import models, fields | ||
|
||
|
||
class ResCompany(models.Model): | ||
|
||
_inherit = 'res.company' | ||
|
||
bvr_background_on_merge = fields.Boolean( | ||
'Insert BVR Background with invoice ?' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Nicolas Bessi | ||
# Copyright 2015 Camptocamp SA | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License 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 <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
from reportlab.lib.units import inch | ||
from openerp import models, api | ||
|
||
|
||
class PaymentSlip(models.Model): | ||
|
||
_inherit = 'l10n_ch.payment_slip' | ||
|
||
@api.model | ||
def _draw_background(self, canvas, print_settings): | ||
"""Draw payment slip background based on company setting | ||
:param canvas: payment slip reportlab component to be drawn | ||
:type canvas: :py:class:`reportlab.pdfgen.canvas.Canvas` | ||
:param print_settings: layouts print setting | ||
:type print_settings: :py:class:`PaymentSlipSettings` or subclass | ||
""" | ||
def _draw_on_canvas(): | ||
canvas.drawImage(self.image_absolute_path('bvr.png'), | ||
0, 0, 8.271 * inch, 4.174 * inch) | ||
report_name = print_settings.report_name | ||
if report_name == 'invoice_and_one_slip_per_page_from_invoice': | ||
if print_settings.bvr_background_on_merge: | ||
_draw_on_canvas() | ||
else: | ||
if print_settings.bvr_background: | ||
_draw_on_canvas() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<openerp> | ||
<data> | ||
<record model="ir.ui.view" id="company_form_view"> | ||
<field name="name">res.company.form.inherit.bvr</field> | ||
<field name="model">res.company</field> | ||
<field name="inherit_id" ref="l10n_ch_payment_slip.company_form_view"/> | ||
<field name="arch" type="xml"> | ||
<field name="bvr_background" position="after"> | ||
<field name="bvr_background_on_merge"/> | ||
</field> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |