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

14.0 mig account invoice fixed discount #835

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4784e06
[9.0][ADD] account_invoice_fixed_discount
LoisRForgeFlow Sep 1, 2017
8b08de6
[10.0][MIG] account_invoice_fixed_discount
LoisRForgeFlow Jan 12, 2018
82775d5
[UPD] Update account_invoice_fixed_discount.pot
oca-travis Jun 19, 2018
c8494c3
[MIG] account_invoice_fixed_discount: Migration to 11.0
MiquelRForgeFlow Aug 28, 2018
6c49787
[UPD] README.rst
OCA-git-bot Oct 8, 2018
da04e86
[UPD] Update account_invoice_fixed_discount.pot
oca-travis Oct 8, 2018
8dca4ec
[MIG] account_invoice_fixed_discount: Migration to 12.0
HviorForgeFlow Apr 18, 2019
2a7adf0
[UPD] README.rst
OCA-git-bot Jun 7, 2019
480a7fa
[UPD] Update account_invoice_fixed_discount.pot
oca-travis Jun 7, 2019
78943e7
[FIX] account_invoice_fixed_discount: templated correctly
MiquelRForgeFlow Jun 7, 2019
a3e2e22
[UPD] Update account_invoice_fixed_discount.pot
oca-travis Jun 7, 2019
641957d
Added translation using Weblate (German)
marylla Jul 16, 2019
5520cd8
Translated using Weblate (German)
marylla Jul 17, 2019
4406b5f
[UPD] README.rst
OCA-git-bot Jul 29, 2019
7a10a1f
fix invoice report
JordiBForgeFlow Sep 13, 2019
1c3e809
account_invoice_fixed_discount 12.0.1.0.1
OCA-git-bot Oct 1, 2019
d610184
[IMP] account_invoice_fixed_discount: black, isort
kongrattapong Dec 17, 2019
386957c
[MIG] account_invoice_fixed_discount: Migration to 13.0
kongrattapong Dec 19, 2019
02cb503
[FIX] compute tax
kongrattapong Jan 13, 2020
fe93570
[UPD] Update account_invoice_fixed_discount.pot
oca-travis Jan 15, 2020
752a71a
[UPD] README.rst
OCA-git-bot Jan 15, 2020
3cc9ce4
[13.0][FIX] account_invoice_fixed_discount, missing param when update…
kittiu Jan 30, 2020
1899067
Update translation files
oca-transbot Jan 31, 2020
9898bf1
[UPD] README.rst
OCA-git-bot Feb 3, 2020
383a874
account_invoice_fixed_discount 13.0.1.0.1
OCA-git-bot Feb 3, 2020
5b06d65
pre-commit update
OCA-git-bot Mar 14, 2020
ced3afa
[UPD] Eficent -> ForgeFlow
MiquelRForgeFlow Sep 30, 2020
a13ea07
[UPD] README.rst
OCA-git-bot Oct 5, 2020
199d273
[FIX] account_invoice_fixed_discount: Adapt to upstream change
pedrobaeza Oct 14, 2020
69121e2
[MIG] account_invoice_fixed_discount: Migration to 14.0
mohamedhagag Dec 16, 2020
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
101 changes: 101 additions & 0 deletions account_invoice_fixed_discount/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
======================
Account Fixed Discount
======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
:target: https:/OCA/account-invoicing/tree/13.0/account_invoice_fixed_discount
:alt: OCA/account-invoicing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-invoicing-13-0/account-invoicing-13-0-account_invoice_fixed_discount
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/95/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of Invoicing to allow you to apply fixed
amount discounts at invoice line level.

The module also extends the invoice report to show fixed discount.

**Table of contents**

.. contents::
:local:

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

**Warning**: This module is incompatible with
``account_invoice_triple_discount`` which also belongs to `OCA/account-invoicing
<https:/OCA/account-invoicing>`__.

Usage
=====

To use this module, you need to:

#. Go to *Settings* and *Activate the developer mode*
#. Go to *Invoicing*.
#. Create a Invoice and specify a fixed discount in a line.

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

* At the moment, the simultaneous use of percent and fixed discounts (at
line level) is not supported.

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

Bugs are tracked on `GitHub Issues <https:/OCA/account-invoicing/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https:/OCA/account-invoicing/issues/new?body=module:%20account_invoice_fixed_discount%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Lois Rilo <[email protected]>
* Jordi Ballester <[email protected]>
* Rattapong Chokmasermkul <[email protected]>
* Kitti U. <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/account-invoicing <https:/OCA/account-invoicing/tree/13.0/account_invoice_fixed_discount>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions account_invoice_fixed_discount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from . import models
16 changes: 16 additions & 0 deletions account_invoice_fixed_discount/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2017 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

{
"name": "Account Fixed Discount",
"summary": "Allows to apply fixed amount discounts in invoices.",
"version": "14.0.1.0.0",
"category": "Accounting & Finance",
"website": "https:/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["account"],
"data": ["views/account_move_view.xml", "reports/report_account_invoice.xml"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_fixed_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \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_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span>Disc. Fixed Amount</span>"
msgstr ""

#. module: account_invoice_fixed_discount
#: model:ir.model.fields,field_description:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid "Discount (Fixed)"
msgstr ""

#. module: account_invoice_fixed_discount
#: model:ir.model.fields,help:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid "Fixed amount discount."
msgstr ""

#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move
msgid "Journal Entries"
msgstr ""

#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move_line
msgid "Journal Item"
msgstr ""

#. module: account_invoice_fixed_discount
#: code:addons/account_invoice_fixed_discount/models/account_move.py:0
#, python-format
msgid "You can only set one type of discount per line."
msgstr ""
56 changes: 56 additions & 0 deletions account_invoice_fixed_discount/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_fixed_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2019-07-17 12:43+0000\n"
"Last-Translator: Maria Sparenberg <[email protected]>\n"
"Language-Team: none\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.7.1\n"

#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span>Disc. Fixed Amount</span>"
msgstr "<span>Rabatt (abs.)</span>"

#. module: account_invoice_fixed_discount
#: model:ir.model.fields,field_description:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid "Discount (Fixed)"
msgstr "Rabatt (abs.)"

#. module: account_invoice_fixed_discount
#: model:ir.model.fields,help:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid "Fixed amount discount."
msgstr "Hier kann ein absoluter Rabatt hinzugefügt werden."

#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move
msgid "Journal Entries"
msgstr ""

#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move_line
msgid "Journal Item"
msgstr ""

#. module: account_invoice_fixed_discount
#: code:addons/account_invoice_fixed_discount/models/account_move.py:0
#, python-format
msgid "You can only set one type of discount per line."
msgstr ""
"Es kann nur eine Art von Rabatt (prozentual oder absolut) pro Zeile gesetzt "
"werden."

#~ msgid "Invoice"
#~ msgstr "Rechnung"

#~ msgid "Invoice Line"
#~ msgstr "Rechnungsposition"
3 changes: 3 additions & 0 deletions account_invoice_fixed_discount/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from . import account_move
121 changes: 121 additions & 0 deletions account_invoice_fixed_discount/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Copyright 2017 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class AccountMove(models.Model):
_inherit = "account.move"

def _recompute_tax_lines(self, recompute_tax_base_amount=False):
vals = {}
for line in self.invoice_line_ids.filtered("discount_fixed"):
vals[line] = {"price_unit": line.price_unit}
price_unit = line.price_unit - line.discount_fixed
line.update({"price_unit": price_unit})
res = super(AccountMove, self)._recompute_tax_lines(
recompute_tax_base_amount=recompute_tax_base_amount
)
for line in vals.keys():
line.update(vals[line])
return res


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

discount_fixed = fields.Float(
string="Discount (Fixed)",
digits="Product Price",
default=0.00,
help="Fixed amount discount.",
)

@api.onchange("discount")
def _onchange_discount(self):
if self.discount:
self.discount_fixed = 0.0

@api.onchange("discount_fixed")
def _onchange_discount_fixed(self):
if self.discount_fixed:
self.discount = 0.0

@api.constrains("discount", "discount_fixed")
def _check_only_one_discount(self):
for rec in self:
for line in rec:
if line.discount and line.discount_fixed:
raise ValidationError(
_("You can only set one type of discount per line.")
)

@api.onchange("quantity", "discount", "price_unit", "tax_ids", "discount_fixed")
def _onchange_price_subtotal(self):
return super(AccountMoveLine, self)._onchange_price_subtotal()

@api.model
def _get_price_total_and_subtotal_model(
self,
price_unit,
quantity,
discount,
currency,
product,
partner,
taxes,
move_type,
):
if self.discount_fixed != 0:
discount = ((self.discount_fixed) / price_unit) * 100 or 0.00
return super(AccountMoveLine, self)._get_price_total_and_subtotal_model(
price_unit, quantity, discount, currency, product, partner, taxes, move_type
)

@api.model
def _get_fields_onchange_balance_model(
self,
quantity,
discount,
balance,
move_type,
currency,
taxes,
price_subtotal,
force_computation=False,
):
if self.discount_fixed != 0:
discount = ((self.discount_fixed) / self.price_unit) * 100 or 0.00
return super(AccountMoveLine, self)._get_fields_onchange_balance_model(
quantity,
discount,
balance,
move_type,
currency,
taxes,
price_subtotal,
force_computation=force_computation,
)

@api.model_create_multi
def create(self, vals_list):
prev_discount = []
for vals in vals_list:
if vals.get("discount_fixed"):
prev_discount.append(
{"discount_fixed": vals.get("discount_fixed"), "discount": 0.00}
)
fixed_discount = (
vals.get("discount_fixed") / vals.get("price_unit")
) * 100
vals.update({"discount": fixed_discount, "discount_fixed": 0.00})
elif vals.get("discount"):
prev_discount.append({"discount": vals.get("discount")})
res = super(AccountMoveLine, self).create(vals_list)
i = 0
for rec in res:
if rec.discount and prev_discount:
rec.write(prev_discount[i])
i += 1
return res
4 changes: 4 additions & 0 deletions account_invoice_fixed_discount/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Lois Rilo <[email protected]>
* Jordi Ballester <[email protected]>
* Rattapong Chokmasermkul <[email protected]>
* Kitti U. <[email protected]>
4 changes: 4 additions & 0 deletions account_invoice_fixed_discount/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module extends the functionality of Invoicing to allow you to apply fixed
amount discounts at invoice line level.

The module also extends the invoice report to show fixed discount.
3 changes: 3 additions & 0 deletions account_invoice_fixed_discount/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Warning**: This module is incompatible with
``account_invoice_triple_discount`` which also belongs to `OCA/account-invoicing
<https:/OCA/account-invoicing>`__.
2 changes: 2 additions & 0 deletions account_invoice_fixed_discount/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* At the moment, the simultaneous use of percent and fixed discounts (at
line level) is not supported.
5 changes: 5 additions & 0 deletions account_invoice_fixed_discount/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To use this module, you need to:

#. Go to *Settings* and *Activate the developer mode*
#. Go to *Invoicing*.
#. Create a Invoice and specify a fixed discount in a line.
Loading