Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association
======================
Account Fixed Discount
======================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7da2b640ce4b9f11baa7e5b41442f1e830e87c391fc7381c6032a521ad00bfae
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/license-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://github.com/OCA/account-invoicing/tree/18.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-18-0/account-invoicing-18-0-account_invoice_fixed_discount
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=18.0
:alt: Try me on Runboat
|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://github.com/OCA/account-invoicing>`__.
Usage
=====
To use this module, you need to:
1. Go to *Settings* and *Activate the developer mode*
2. Go to *Invoicing*.
3. Create a Invoice and specify a fixed discount in a line.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_fixed_discount%0Aversion:%2018.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 <lois.rilo@forgeflow.com>
- Jordi Ballester <jordi.ballester@forgeflow.com>
- Rattapong Chokmasermkul <rattapongc@ecosoft.co.th>
- Kitti U. <kittiu@ecosoft.co.th>
- Pieter Paulussen <pieterpaulussen@code-source.be>
- OERP Canada <https://www.oerp.ca/>:
- Foram Darji <fd@oerp.ca>
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://github.com/OCA/account-invoicing/tree/18.0/account_invoice_fixed_discount>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from . import models

View File

@@ -0,0 +1,21 @@
# 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": "18.0.1.0.0",
"category": "Accounting & Finance",
"website": "https://github.com/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["account"],
"excludes": ["account_invoice_triple_discount"],
"data": [
"security/res_groups.xml",
"views/account_move_view.xml",
"reports/report_account_invoice.xml",
],
}

View File

@@ -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 18.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 class=\"text-nowrap\"> %)</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> (or</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span>Discount Amount (%)</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model:ir.model.fields,help:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid ""
"Apply a fixed amount discount to this line. The amount is multiplied by the "
"quantity of the product."
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:res.groups,name:account_invoice_fixed_discount.group_fixed_discount
msgid "Fixed Discount"
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
#: model:ir.model,name:account_invoice_fixed_discount.model_account_tax
msgid "Tax"
msgstr ""

View File

@@ -0,0 +1,59 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_fixed_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-14 16:59+0000\n"
"PO-Revision-Date: 2024-02-14 16:59+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \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 class=\"text-nowrap\"> %)</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> (or</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span>Discount Amount (%)</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model:ir.model.fields,help:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid ""
"Apply a fixed amount discount to this line. The amount is multiplied by the "
"quantity of the product."
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:res.groups,name:account_invoice_fixed_discount.group_fixed_discount
msgid "Fixed Discount"
msgstr ""
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move_line
msgid "Journal Item"
msgstr "Apunt comptable"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_tax
msgid "Tax"
msgstr "Impost"

View File

@@ -0,0 +1,59 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_fixed_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-14 17:00+0000\n"
"PO-Revision-Date: 2024-02-14 17:00+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \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 class=\"text-nowrap\"> %)</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> (or</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span>Discount Amount (%)</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model:ir.model.fields,help:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid ""
"Apply a fixed amount discount to this line. The amount is multiplied by the "
"quantity of the product."
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 "Rabatt (abs.)"
#. module: account_invoice_fixed_discount
#: model:res.groups,name:account_invoice_fixed_discount.group_fixed_discount
msgid "Fixed Discount"
msgstr ""
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move_line
msgid "Journal Item"
msgstr "Buchungszeile"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_tax
msgid "Tax"
msgstr "Steuer"

View File

@@ -0,0 +1,68 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_fixed_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-14 17:02+0000\n"
"PO-Revision-Date: 2024-04-24 10:41+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: \n"
"Language: es\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 4.17\n"
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> %)</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> (or</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span>Discount Amount (%)</span>"
msgstr "<span>Importe del descuento (%)</span>"
#. module: account_invoice_fixed_discount
#: model:ir.model.fields,help:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid ""
"Apply a fixed amount discount to this line. The amount is multiplied by the "
"quantity of the product."
msgstr ""
"Aplica un descuento de importe fijo a esta línea. El importe se multiplica "
"por la cantidad del producto."
#. 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 "Descuento (Fijo)"
#. module: account_invoice_fixed_discount
#: model:res.groups,name:account_invoice_fixed_discount.group_fixed_discount
msgid "Fixed Discount"
msgstr "Descuento fijo"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move_line
msgid "Journal Item"
msgstr "Apunte contable"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_tax
msgid "Tax"
msgstr "Impuesto"
#~ msgid "(or"
#~ msgstr "(o"
#~ msgid "<span>Disc. %</span>"
#~ msgstr "<span>Desc. %</span>"

View File

@@ -0,0 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_fixed_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-05-22 13:45+0000\n"
"Last-Translator: Vincent Hatakeyama <vincent+github@hatakeyama.fr>\n"
"Language-Team: none\n"
"Language: fr\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 5.10.4\n"
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> %)</span>"
msgstr "<span class=\"text-nowrap\">%)</span>"
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> (or</span>"
msgstr "<span class=\"text-nowrap\"> (ou</span>"
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span>Discount Amount (%)</span>"
msgstr "<span>Montant de la remise (%)</span>"
#. module: account_invoice_fixed_discount
#: model:ir.model.fields,help:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid ""
"Apply a fixed amount discount to this line. The amount is multiplied by the "
"quantity of the product."
msgstr ""
"Applique une remise dun montant fixe à cette ligne. Le montant est "
"multiplié par la quantité de produit."
#. 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 "Remise (fixe)"
#. module: account_invoice_fixed_discount
#: model:res.groups,name:account_invoice_fixed_discount.group_fixed_discount
msgid "Fixed Discount"
msgstr "Remise fixe"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move_line
msgid "Journal Item"
msgstr "Écriture comptable"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_tax
msgid "Tax"
msgstr "Taxe"

View File

@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_fixed_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-05-17 12:35+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\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 4.17\n"
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> %)</span>"
msgstr "<span class=\"text-nowrap\"> %)</span>"
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> (or</span>"
msgstr "<span class=\"text-nowrap\"> (o</span>"
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span>Discount Amount (%)</span>"
msgstr "<span>Valore sconto (%)</span>"
#. module: account_invoice_fixed_discount
#: model:ir.model.fields,help:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid ""
"Apply a fixed amount discount to this line. The amount is multiplied by the "
"quantity of the product."
msgstr ""
"Applica un valore sconto a questa riga. Il valore è moltiplicato per la "
"quantità del prodotto."
#. 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 "Sconto (fisso)"
#. module: account_invoice_fixed_discount
#: model:res.groups,name:account_invoice_fixed_discount.group_fixed_discount
msgid "Fixed Discount"
msgstr "Sconto fisso"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move_line
msgid "Journal Item"
msgstr "Movimento contabile"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_tax
msgid "Tax"
msgstr "Imposta"
#~ msgid "(or"
#~ msgstr "(o"
#~ msgid "<span>Disc. %</span>"
#~ msgstr "<span>Sconto %</span>"

View File

@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_fixed_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-14 17:04+0000\n"
"PO-Revision-Date: 2024-02-14 17:04+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \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 class=\"text-nowrap\"> %)</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span class=\"text-nowrap\"> (or</span>"
msgstr ""
#. module: account_invoice_fixed_discount
#: model_terms:ir.ui.view,arch_db:account_invoice_fixed_discount.report_invoice_document
msgid "<span>Discount Amount (%)</span>"
msgstr "<span>Total Desconto (%)</span>"
#. module: account_invoice_fixed_discount
#: model:ir.model.fields,help:account_invoice_fixed_discount.field_account_move_line__discount_fixed
msgid ""
"Apply a fixed amount discount to this line. The amount is multiplied by the "
"quantity of the product."
msgstr ""
"Aplique um desconto de valor fixo a esta linha. O valor é multiplicado pela "
"quantidade do produto."
#. 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 "Desconto (Fixo)"
#. module: account_invoice_fixed_discount
#: model:res.groups,name:account_invoice_fixed_discount.group_fixed_discount
msgid "Fixed Discount"
msgstr "Desconto Fixo"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_move_line
msgid "Journal Item"
msgstr "Item do diário"
#. module: account_invoice_fixed_discount
#: model:ir.model,name:account_invoice_fixed_discount.model_account_tax
msgid "Tax"
msgstr "Imposto"
#~ msgid "(or"
#~ msgstr "(ou"
#~ msgid "<span>Disc. %</span>"
#~ msgstr "<span>Desc. %</span>"

View File

@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from . import account_move_line
from . import account_tax

View File

@@ -0,0 +1,88 @@
# 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.tools.float_utils import float_is_zero
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
discount_fixed = fields.Monetary(
string="Discount (Fixed)",
default=0.0,
currency_field="currency_id",
help=(
"Apply a fixed amount discount to this line. The amount is multiplied by "
"the quantity of the product."
),
)
@api.depends("quantity", "discount", "price_unit", "tax_ids", "currency_id")
def _compute_totals(self):
"""Adjust the computation of the price_subtotal and price_total fields to
account for the fixed discount amount.
By using the unrounded calculated discount value, we avoid rounding errors
in the resulting calculated totals.
We only need to do this for lines with a fixed discount.
"""
done_lines = self.env["account.move.line"]
for line in self:
if float_is_zero(
line.discount_fixed, precision_rounding=line.currency_id.rounding
):
continue
# Pass the actual float value of the discount to the tax computation method.
discount = line._get_discount_from_fixed_discount()
line_discount_price_unit = line.price_unit * (1 - (discount / 100.0))
if line.tax_ids:
taxes_res = line.tax_ids.compute_all(
line_discount_price_unit,
quantity=line.quantity,
currency=line.currency_id,
product=line.product_id,
partner=line.partner_id,
is_refund=line.is_refund,
)
line.price_subtotal = taxes_res["total_excluded"]
line.price_total = taxes_res["total_included"]
else:
# No taxes applied on the line.
subtotal = line.quantity * line_discount_price_unit
line.price_total = line.price_subtotal = subtotal
done_lines |= line
# Compute the regular totals for regular lines.
return super(AccountMoveLine, self - done_lines)._compute_totals()
@api.onchange("discount_fixed", "price_unit")
def _onchange_discount_fixed(self):
"""Compute the fixed discount based on the discount percentage."""
if self.env.context.get("ignore_discount_onchange"):
return
self.env.context = self.with_context(ignore_discount_onchange=True).env.context
self.discount = self._get_discount_from_fixed_discount()
@api.onchange("discount")
def _onchange_discount(self):
"""Compute the discount percentage based on the fixed discount.
Ignore the onchange if the fixed discount is already set.
"""
if self.env.context.get("ignore_discount_onchange"):
return
self.env.context = self.with_context(ignore_discount_onchange=True).env.context
self.discount_fixed = 0.0
def _get_discount_from_fixed_discount(self):
"""Calculate the discount percentage from the fixed discount amount."""
self.ensure_one()
currency = self.currency_id or self.company_id.currency_id
if float_is_zero(
self.discount_fixed, precision_rounding=currency.rounding
) or float_is_zero(self.price_unit, precision_rounding=currency.rounding):
return 0.0
return (self.discount_fixed / self.price_unit) * 100

View File

@@ -0,0 +1,15 @@
# Copyright 2017 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import api, models
class AccountTax(models.Model):
_inherit = "account.tax"
@api.model
def _prepare_base_line_for_taxes_computation(self, record, **kwargs):
res = super()._prepare_base_line_for_taxes_computation(record, **kwargs)
if record and record._name == "account.move.line" and record.discount_fixed:
res["discount"] = record._get_discount_from_fixed_discount()
return res

View File

@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@@ -0,0 +1,7 @@
- Lois Rilo \<<lois.rilo@forgeflow.com>\>
- Jordi Ballester \<<jordi.ballester@forgeflow.com>\>
- Rattapong Chokmasermkul \<<rattapongc@ecosoft.co.th>\>
- Kitti U. \<<kittiu@ecosoft.co.th>\>
- Pieter Paulussen \<<pieterpaulussen@code-source.be>\>
* OERP Canada \<<https://www.oerp.ca/>\>:
- Foram Darji \<<fd@oerp.ca>\>

View File

@@ -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.

View File

@@ -0,0 +1,3 @@
**Warning**: This module is incompatible with
`account_invoice_triple_discount` which also belongs to
[OCA/account-invoicing](https://github.com/OCA/account-invoicing).

View File

@@ -0,0 +1,5 @@
To use this module, you need to:
1. Go to *Settings* and *Activate the developer mode*
2. Go to *Invoicing*.
3. Create a Invoice and specify a fixed discount in a line.

View File

@@ -0,0 +1,33 @@
<!-- Copyright 2017 ForgeFlow S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//t[@t-set='display_discount']" position="after">
<t
t-set="display_discount_fixed"
t-value="any([l.discount_fixed for l in o.invoice_line_ids])"
/>
</xpath>
<xpath expr="//th[@name='th_discount']/span" position="attributes">
<attribute name="t-if">not display_discount_fixed</attribute>
</xpath>
<xpath expr="//th[@t-if='display_discount']/span" position="before">
<t t-if="display_discount_fixed">
<span>Discount Amount (%)</span>
</t>
</xpath>
<span t-field="line.discount" position="before">
<t t-if="display_discount_fixed">
<span class="text-nowrap" t-field="line.discount_fixed" />
<span class="text-nowrap"> (or</span>
</t>
</span>
<span t-field="line.discount" position="after">
<t t-if="display_discount_fixed">
<span class="text-nowrap"> %)</span>
</t>
</span>
</template>
</odoo>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record id="group_fixed_discount" model="res.groups">
<field name="name">Fixed Discount</field>
</record>
</data>
<data noupdate="1">
<record id="account.group_account_invoice" model="res.groups">
<field
name="implied_ids"
eval="[(4, ref('account_invoice_fixed_discount.group_fixed_discount'))]"
/>
</record>
</data>
</odoo>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,456 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document">
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="account-fixed-discount">
<h1>Account Fixed Discount</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7da2b640ce4b9f11baa7e5b41442f1e830e87c391fc7381c6032a521ad00bfae
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-invoicing/tree/18.0/account_invoice_fixed_discount"><img alt="OCA/account-invoicing" src="https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoicing-18-0/account-invoicing-18-0-account_invoice_fixed_discount"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of Invoicing to allow you to apply
fixed amount discounts at invoice line level.</p>
<p>The module also extends the invoice report to show fixed discount.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#installation" id="toc-entry-1">Installation</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="installation">
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
<p><strong>Warning</strong>: This module is incompatible with
<tt class="docutils literal">account_invoice_triple_discount</tt> which also belongs to
<a class="reference external" href="https://github.com/OCA/account-invoicing">OCA/account-invoicing</a>.</p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<p>To use this module, you need to:</p>
<ol class="arabic simple">
<li>Go to <em>Settings</em> and <em>Activate the developer mode</em></li>
<li>Go to <em>Invoicing</em>.</li>
<li>Create a Invoice and specify a fixed discount in a line.</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-invoicing/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_fixed_discount%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
<ul class="simple">
<li>ForgeFlow</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
<ul class="simple">
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li>Jordi Ballester &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li>Rattapong Chokmasermkul &lt;<a class="reference external" href="mailto:rattapongc&#64;ecosoft.co.th">rattapongc&#64;ecosoft.co.th</a>&gt;</li>
<li>Kitti U. &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt;</li>
<li>Pieter Paulussen &lt;<a class="reference external" href="mailto:pieterpaulussen&#64;code-source.be">pieterpaulussen&#64;code-source.be</a>&gt;</li>
<li>OERP Canada &lt;<a class="reference external" href="https://www.oerp.ca/">https://www.oerp.ca/</a>&gt;:<ul>
<li>Foram Darji &lt;<a class="reference external" href="mailto:fd&#64;oerp.ca">fd&#64;oerp.ca</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-invoicing/tree/18.0/account_invoice_fixed_discount">OCA/account-invoicing</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from . import test_account_fixed_discount

View File

@@ -0,0 +1,162 @@
# Copyright 2017 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo.tests import Form
from odoo.addons.base.tests.common import BaseCommon
class TestInvoiceFixedDiscount(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env.user.groups_id |= cls.env.ref("account.group_account_invoice")
cls.partner = cls.env["res.partner"].create({"name": "Test"})
cls.product = cls.env.ref("product.product_product_3")
cls.account = cls.env["account.account"].search(
[("account_type", "=", "income")],
limit=1,
)
cls.output_vat_acct = cls.env["account.account"].create(
{"name": "10", "code": "10", "account_type": "liability_current"}
)
cls.tax_group_vat = cls.env["account.tax.group"].create({"name": "VAT"})
cls.vat = cls.env["account.tax"].create(
{
"name": "TEST 10%",
"type_tax_use": "sale",
"amount_type": "percent",
"amount": 10.00,
"tax_group_id": cls.tax_group_vat.id,
"tax_exigibility": "on_invoice",
"invoice_repartition_line_ids": [
(0, 0, {"factor_percent": 100.0, "repartition_type": "base"}),
(
0,
0,
{
"factor_percent": 100.0,
"repartition_type": "tax",
"account_id": cls.output_vat_acct.id,
},
),
],
}
)
cls.invoice = cls._create_invoice()
@classmethod
def _create_invoice(cls, discount=0.00, discount_fixed=0.00):
invoice_vals = [
(
0,
0,
{
"product_id": cls.product.id,
"quantity": 1.0,
"account_id": cls.account.id,
"name": "Line 1",
"price_unit": 200.00,
"discount_fixed": discount_fixed,
"discount": discount,
"tax_ids": [(6, 0, [cls.vat.id])],
},
)
]
invoice = (
cls.env["account.move"]
.with_context(check_move_validity=False)
.create(
{
"journal_id": cls.env["account.journal"]
.search([("type", "=", "sale")], limit=1)
.id,
"partner_id": cls.partner.id,
"move_type": "out_invoice",
"invoice_line_ids": invoice_vals,
}
)
)
return invoice
def test_01_discounts_fixed_single_unit(self):
"""Tests multiple discounts in line with taxes."""
# Fixed discount 1.0 unit at 57.00
with Form(self.invoice) as invoice_form:
with invoice_form.invoice_line_ids.edit(0) as line:
line.discount_fixed = 57.00
# compute discount (57 / 200) * 100
self.assertEqual(self.invoice.invoice_line_ids.discount, 28.5)
# compute amount total (200 - 57) * 10%
self.assertEqual(self.invoice.amount_total, 157.3)
self.assertEqual(self.invoice.invoice_line_ids.price_unit, 200.00)
self.assertEqual(self.invoice.invoice_line_ids.price_subtotal, 143.00)
# Reset to regular discount at 20.00%
with Form(self.invoice) as invoice_form:
with invoice_form.invoice_line_ids.edit(0) as line:
# Force the fixed discount as the onchange does not
# handle the context properly
line.discount_fixed = 0.0
line.discount = 20.0
self.assertEqual(self.invoice.invoice_line_ids.discount_fixed, 0.0)
self.assertEqual(self.invoice.invoice_line_ids.discount, 20.0)
self.assertEqual(self.invoice.amount_total, 176.0)
self.assertEqual(self.invoice.invoice_line_ids.price_unit, 200.00)
self.assertEqual(self.invoice.invoice_line_ids.price_subtotal, 160.00)
def test_02_discounts_fixed_multiple_units(self):
"""Tests multiple discounts in line with taxes."""
# Fixed discount 2.0 units at 50.00
with Form(self.invoice) as invoice_form:
with invoice_form.invoice_line_ids.edit(0) as line:
line.discount_fixed = 25.00
line.quantity = 2.0
# compute discount ((50 / 2) / 200) * 100
self.assertEqual(self.invoice.invoice_line_ids.discount, 12.5)
self.assertEqual(self.invoice.amount_total, 385.0)
self.assertEqual(self.invoice.invoice_line_ids.price_unit, 200.00)
self.assertEqual(self.invoice.invoice_line_ids.price_subtotal, 350)
def test_03_discount_fixed_no_tax(self):
"""Tests fixed discount with no taxes."""
# Fixed discount 1.0 unit at 57.00
with Form(self.invoice) as invoice_form:
with invoice_form.invoice_line_ids.edit(0) as line:
line.tax_ids.clear()
line.discount_fixed = 57.00
# compute discount (57 / 200) * 100
self.assertEqual(self.invoice.invoice_line_ids.discount, 28.5)
self.assertEqual(self.invoice.amount_total, 143)
self.assertEqual(self.invoice.invoice_line_ids.price_unit, 200.00)
self.assertEqual(self.invoice.invoice_line_ids.price_subtotal, 143)
def test_03_discount_fixed_no_unit_prise(self):
"""Tests fixed discount with no taxes."""
# Fixed discount 1.0 unit at 57.00
with Form(self.invoice) as invoice_form:
with invoice_form.invoice_line_ids.edit(0) as line:
line.price_unit = 0.00
line.discount_fixed = 57.00
# compute discount (57 / 200) * 100
self.assertEqual(self.invoice.invoice_line_ids.discount, 0.0)
self.assertEqual(self.invoice.amount_total, 0)
self.assertEqual(self.invoice.invoice_line_ids.price_unit, 0.00)
self.assertEqual(self.invoice.invoice_line_ids.price_subtotal, 0)
def test_04_base_line_set_to_none(self):
self.vat._prepare_base_line_for_taxes_computation(
None,
price_unit=10,
currency=1,
)

View File

@@ -0,0 +1,30 @@
<!-- Copyright 2017 ForgeFlow S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form - fixed_discount</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='invoice_line_ids']/list/field[@name='discount']"
position="before"
>
<field
name="discount_fixed"
groups="account_invoice_fixed_discount.group_fixed_discount"
optional="show"
/>
</xpath>
<xpath
expr="//field[@name='invoice_line_ids']/form/sheet/group/field[@name='discount']"
position="before"
>
<field
name="discount_fixed"
groups="account_invoice_fixed_discount.group_fixed_discount"
/>
</xpath>
</field>
</record>
</odoo>