forked from OCA/bank-payment
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD] Add account_cash_discount_base addons #1
Open
sbidoul
wants to merge
32
commits into
8.0
Choose a base branch
from
8.0-add-account-cash-discount-base-ape
base: 8.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
e292b15
[ADD] Add account_cash_discount_base addons
adrienpeiffer 93f08f0
[IMP] Improve header
adrienpeiffer 73bfe06
[IMP] Replace description in __openerp__ file with README.rst
adrienpeiffer ff07688
[IMP] Not necessary to use checks list on 8.0
adrienpeiffer 9ff2a3a
[IMP] addons separation of functionality
adrienpeiffer f8d7c7d
[ADD] Add account_cash_discount_payment_term addons
adrienpeiffer 5fe073c
[ADD] Add fr and fr_BE translation for account_cash_discount_base
adrienpeiffer 2f8ae08
[ADD] Add fr and fr_BE translation for account_cash_discount_payment
adrienpeiffer 0260397
[ADD] Add fr and fr_BE translation for account_cash_discount_payment_…
adrienpeiffer d75fac0
[IMP] Use current object instead of parameters
adrienpeiffer 63c3f5f
[IMP] Use current object instead of parameters
adrienpeiffer 5bcd91e
[FIX] Bad xpath
adrienpeiffer 151c611
[IMP] Refactoring
adrienpeiffer 5d77ba1
[FIX] Bad string
adrienpeiffer 0ff0baa
[FIX] Bad condition
adrienpeiffer 41fef9d
[IMP] Overwrite extend_payment_order_domain method instead of search_…
adrienpeiffer 9fa0c36
[ADD] Hide cash discount information on refund
adrienpeiffer 2934093
[ADD] Use amount residual to compute cash discount amount on payment …
adrienpeiffer 87e8754
[IMP] Use context to get cash discount date information
adrienpeiffer b5fafb0
[IMP] DB end admin_user_id are not used
adrienpeiffer b26e045
[IMP] Use fields.Date.today()
adrienpeiffer 2d9b5b8
[IMP] Use fields.Date.today()
adrienpeiffer d0c4606
[IMP] Use local copy of context
adrienpeiffer ead4480
[IMP] Improve readme files
adrienpeiffer e712bb9
[IMP] Use api.one to avoid loops
adrienpeiffer b036bf2
[FLAKE8] Remove unused import
adrienpeiffer af603f9
[FIX] Bad condition
adrienpeiffer 5b3d06f
[FIX] Use due date in context
adrienpeiffer 2bbc8c8
[FIX] Avoid to set value at partner change in case of refund
adrienpeiffer 204fb92
[FIX] Set key to False because context isn't reinitialized
adrienpeiffer 8d7d4c9
[CHG] Version number and setup file.
adrienpeiffer afc3d5f
[FIX] Change in upsteam.
adrienpeiffer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Account Cash Discount Base | ||
========================== | ||
|
||
This module was written to allow you to define cash discount on your customer | ||
or supplier invoice. On customer invoice, you can add a discount delay and | ||
a discount percent. At invoice's validation, the discount due date is genereted | ||
from the delay. The amount with discount deducted is computed at the same time | ||
as taxes. This module also adds cash discount informations on customer invoice | ||
report. | ||
|
||
On supplier invoices, you can set the discount percent or directly defined the | ||
total amount with discount deducted. For the discount due date, you can fill it | ||
directly or set a delay. In this case, discount due date is still computed at | ||
invoice's validation. | ||
|
||
In all cases, the discount is a percentage of the untaxed amount. | ||
|
||
|
||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
* Click on install button | ||
|
||
Usage | ||
===== | ||
|
||
To use this module you can defined all of informations written in the | ||
description on customer and supplier invoices. | ||
|
||
|
||
For further information, please visit: | ||
|
||
* https://www.odoo.com/forum/help-1 | ||
|
||
|
||
Credits | ||
======= | ||
|
||
Contributors: | ||
------------- | ||
|
||
* Christelle De Coninck (ACSONE) <[email protected]> | ||
* Stéphane Bidoul (ACSONE) <[email protected]> | ||
* Adrien Peiffer (ACSONE) <[email protected]> | ||
|
||
Maintainer: | ||
----------- | ||
|
||
.. image:: http://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
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,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
############################################################################## | ||
# | ||
# Authors: Adrien Peiffer | ||
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
# | ||
# 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 . import models |
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,44 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
############################################################################## | ||
# | ||
# Authors: Adrien Peiffer | ||
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
# | ||
# 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/>. | ||
# | ||
############################################################################## | ||
|
||
{ | ||
"name": "Account Cash Discount Base", | ||
"version": "8.0.1.0.0", | ||
"author": "ACSONE SA/NV", | ||
"maintainer": "ACSONE SA/NV", | ||
"website": "http://www.acsone.eu", | ||
"images": [], | ||
"category": "Accounting", | ||
"depends": [ | ||
"account", | ||
], | ||
"data": [ | ||
'views/account_invoice_view.xml', | ||
'reports/report_invoice.xml', | ||
], | ||
"demo": [], | ||
"test": [], | ||
"licence": "AGPL-3", | ||
"installable": True, | ||
"auto_install": False, | ||
"application": True, | ||
} |
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,53 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_cash_discount_base | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2014-12-29 08:58+0000\n" | ||
"PO-Revision-Date: 2014-12-29 08:58+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: account_cash_discount_base | ||
#: view:website:account.report_invoice_document | ||
msgid "% discount for payment before" | ||
msgstr "% d'escompte pour un paiement avant le" | ||
|
||
#. module: account_cash_discount_base | ||
#: field:account.invoice,discount_amount:0 | ||
msgid "Amount Discount deducted" | ||
msgstr "Montant total escompte déduit" | ||
|
||
#. module: account_cash_discount_base | ||
#: field:payment.order.create,cash_discount_date:0 | ||
msgid "Cash Discount Due Date" | ||
msgstr "Date d'échéance de l'escompte" | ||
|
||
#. module: account_cash_discount_base | ||
#: view:account.invoice:account_cash_discount_base.invoice_form_inherit | ||
#: view:account.invoice:account_cash_discount_base.invoice_supplier_form_inherit | ||
msgid "Cash discount" | ||
msgstr "Escompte" | ||
|
||
#. module: account_cash_discount_base | ||
#: field:payment.line,discount_amount:0 | ||
msgid "Discount Amount" | ||
msgstr "Escompte" | ||
|
||
#. module: account_cash_discount_base | ||
#: field:account.invoice,discount_due_date:0 | ||
msgid "Discount Due Date" | ||
msgstr "Date d'échéance de l'escompte" | ||
|
||
#. module: account_cash_discount_base | ||
#: view:website:account.report_invoice_document | ||
msgid "Total With a" | ||
msgstr "Total avec" | ||
|
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,53 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_cash_discount_base | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2014-12-29 08:58+0000\n" | ||
"PO-Revision-Date: 2014-12-29 08:58+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: account_cash_discount_base | ||
#: view:website:account.report_invoice_document | ||
msgid "% discount for payment before" | ||
msgstr "% d'escompte pour un paiement avant le" | ||
|
||
#. module: account_cash_discount_base | ||
#: field:account.invoice,discount_amount:0 | ||
msgid "Amount Discount deducted" | ||
msgstr "Montant total escompte déduit" | ||
|
||
#. module: account_cash_discount_base | ||
#: field:payment.order.create,cash_discount_date:0 | ||
msgid "Cash Discount Due Date" | ||
msgstr "Date d'échéance de l'escompte" | ||
|
||
#. module: account_cash_discount_base | ||
#: view:account.invoice:account_cash_discount_base.invoice_form_inherit | ||
#: view:account.invoice:account_cash_discount_base.invoice_supplier_form_inherit | ||
msgid "Cash discount" | ||
msgstr "Escompte" | ||
|
||
#. module: account_cash_discount_base | ||
#: field:payment.line,discount_amount:0 | ||
msgid "Discount Amount" | ||
msgstr "Escompte" | ||
|
||
#. module: account_cash_discount_base | ||
#: field:account.invoice,discount_due_date:0 | ||
msgid "Discount Due Date" | ||
msgstr "Date d'échéance de l'escompte" | ||
|
||
#. module: account_cash_discount_base | ||
#: view:website:account.report_invoice_document | ||
msgid "Total With a" | ||
msgstr "Total avec" | ||
|
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,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
############################################################################## | ||
# | ||
# Authors: Adrien Peiffer | ||
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
# | ||
# 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 . import account_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,93 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
############################################################################## | ||
# | ||
# Authors: Adrien Peiffer | ||
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
# | ||
# 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, api, exceptions, _ | ||
from datetime import datetime, timedelta | ||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT | ||
|
||
|
||
class account_invoice(models.Model): | ||
_inherit = 'account.invoice' | ||
|
||
discount_percent = fields.Float(string='Discount Percent', | ||
readonly=True, | ||
states={'draft': [('readonly', False)]}) | ||
discount_amount = fields.Float(string='Amount Discount deducted', | ||
readonly=True, | ||
states={'draft': [('readonly', False)]}) | ||
discount_delay = fields.Integer(string='Discount Delay (days)', | ||
readonly=True, | ||
states={'draft': [('readonly', False)]}) | ||
discount_due_date = fields.Date(string='Discount Due Date', | ||
readonly=True, | ||
states={'draft': [('readonly', False)]}) | ||
|
||
@api.v8 | ||
def _compute_discount_amount(self): | ||
discount = self.amount_untaxed * (0.0 + self.discount_percent/100) | ||
return (self.amount_total - discount) | ||
|
||
@api.v8 | ||
def _compute_discount_due_date(self): | ||
if self.date_invoice: | ||
date_invoice = datetime.strptime(self.date_invoice, | ||
DEFAULT_SERVER_DATE_FORMAT) | ||
else: | ||
date_invoice = datetime.now() | ||
due_date = date_invoice + timedelta(days=self.discount_delay) | ||
discount_due_date = due_date.date() | ||
return discount_due_date | ||
|
||
@api.one | ||
def compute_discount_amount(self): | ||
if (self.type in ['in_invoice', 'out_invoice'] and | ||
self.discount_percent != 0.0): | ||
self.discount_amount = self._compute_discount_amount() | ||
|
||
@api.one | ||
def compute_discount_due_date(self): | ||
if self.discount_delay != 0 and (self.type != 'in_invoice' or | ||
self.discount_delay != 0): | ||
self.discount_due_date = self._compute_discount_due_date() | ||
|
||
@api.multi | ||
def button_reset_taxes(self): | ||
res = super(account_invoice, self).button_reset_taxes() | ||
self.compute_discount_amount() | ||
return res | ||
|
||
@api.multi | ||
def action_move_create(self): | ||
super(account_invoice, self).action_move_create() | ||
for inv in self: | ||
inv.compute_discount_amount() | ||
if not inv.discount_due_date and \ | ||
inv.discount_amount and inv.discount_amount != 0.0: | ||
raise exceptions.Warning(_('Warning !\n You have to define ' | ||
'a discount due date')) | ||
return True | ||
|
||
@api.multi | ||
def action_date_assign(self): | ||
super(account_invoice, self).action_date_assign() | ||
self.compute_discount_due_date() | ||
return True |
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" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<template id="report_invoice_document_inherit" inherit_id="account.report_invoice_document"> | ||
<xpath expr="//span[@t-field='o.amount_total']" position="after"> | ||
<tr name="discount_information" t-if="o.discount_percent and o.discount_due_date and o.discount_amount"> | ||
<td>Total With a <span t-field="o.discount_percent"/> % discount for payment before <span t-field="o.discount_due_date"/></td> | ||
<td class="text-right"> | ||
<span t-field="o.discount_amount" t-field-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/> | ||
</td> | ||
</tr> | ||
</xpath> | ||
</template> | ||
</data> | ||
</openerp> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need api.v8 ? (just out of curiosity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is not really necessary but it shows that this method is designed for use on new API consistent with the description of the decorator. does not hesitate to correct me if I'm wrong.