Skip to content
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
wants to merge 32 commits into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Oct 30, 2014
93f08f0
[IMP] Improve header
adrienpeiffer Dec 2, 2014
73bfe06
[IMP] Replace description in __openerp__ file with README.rst
adrienpeiffer Dec 2, 2014
ff07688
[IMP] Not necessary to use checks list on 8.0
adrienpeiffer Dec 2, 2014
9ff2a3a
[IMP] addons separation of functionality
adrienpeiffer Dec 4, 2014
f8d7c7d
[ADD] Add account_cash_discount_payment_term addons
adrienpeiffer Dec 4, 2014
5fe073c
[ADD] Add fr and fr_BE translation for account_cash_discount_base
adrienpeiffer Dec 29, 2014
2f8ae08
[ADD] Add fr and fr_BE translation for account_cash_discount_payment
adrienpeiffer Dec 29, 2014
0260397
[ADD] Add fr and fr_BE translation for account_cash_discount_payment_…
adrienpeiffer Dec 29, 2014
d75fac0
[IMP] Use current object instead of parameters
adrienpeiffer Dec 29, 2014
63c3f5f
[IMP] Use current object instead of parameters
adrienpeiffer Dec 29, 2014
5bcd91e
[FIX] Bad xpath
adrienpeiffer Dec 29, 2014
151c611
[IMP] Refactoring
adrienpeiffer Jan 15, 2015
5d77ba1
[FIX] Bad string
adrienpeiffer Jan 20, 2015
0ff0baa
[FIX] Bad condition
adrienpeiffer Jan 20, 2015
41fef9d
[IMP] Overwrite extend_payment_order_domain method instead of search_…
adrienpeiffer Jan 20, 2015
9fa0c36
[ADD] Hide cash discount information on refund
adrienpeiffer Jan 22, 2015
2934093
[ADD] Use amount residual to compute cash discount amount on payment …
adrienpeiffer Jan 22, 2015
87e8754
[IMP] Use context to get cash discount date information
adrienpeiffer Feb 11, 2015
b5fafb0
[IMP] DB end admin_user_id are not used
adrienpeiffer Feb 11, 2015
b26e045
[IMP] Use fields.Date.today()
adrienpeiffer Feb 11, 2015
2d9b5b8
[IMP] Use fields.Date.today()
adrienpeiffer Feb 11, 2015
d0c4606
[IMP] Use local copy of context
adrienpeiffer Feb 11, 2015
ead4480
[IMP] Improve readme files
adrienpeiffer Feb 11, 2015
e712bb9
[IMP] Use api.one to avoid loops
adrienpeiffer Feb 11, 2015
b036bf2
[FLAKE8] Remove unused import
adrienpeiffer Feb 11, 2015
af603f9
[FIX] Bad condition
adrienpeiffer Mar 27, 2015
5b3d06f
[FIX] Use due date in context
adrienpeiffer Mar 27, 2015
2bbc8c8
[FIX] Avoid to set value at partner change in case of refund
adrienpeiffer Apr 21, 2015
204fb92
[FIX] Set key to False because context isn't reinitialized
adrienpeiffer May 11, 2015
8d7d4c9
[CHG] Version number and setup file.
adrienpeiffer Nov 22, 2017
afc3d5f
[FIX] Change in upsteam.
adrienpeiffer Nov 26, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions account_cash_discount_base/README.rst
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.
23 changes: 23 additions & 0 deletions account_cash_discount_base/__init__.py
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
44 changes: 44 additions & 0 deletions account_cash_discount_base/__openerp__.py
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,
}
53 changes: 53 additions & 0 deletions account_cash_discount_base/i18n/fr.po
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"

53 changes: 53 additions & 0 deletions account_cash_discount_base/i18n/fr_BE.po
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"

23 changes: 23 additions & 0 deletions account_cash_discount_base/models/__init__.py
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
93 changes: 93 additions & 0 deletions account_cash_discount_base/models/account_invoice.py
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
Copy link
Member

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)

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.

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
15 changes: 15 additions & 0 deletions account_cash_discount_base/reports/report_invoice.xml
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>
Loading