Skip to content

Commit 46a6ce0

Browse files
committed
[ADD] account_invoice_fixed_triple_discount: Glue module
1 parent b292d8b commit 46a6ce0

File tree

15 files changed

+682
-0
lines changed

15 files changed

+682
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
5+
=============================
6+
Account Fixed Triple Discount
7+
=============================
8+
9+
..
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11+
!! This file is generated by oca-gen-addon-readme !!
12+
!! changes will be overwritten. !!
13+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14+
!! source digest: sha256:146d6ec09dd55edb8f963aab0c8cca98d2dd89e7340350c6633070022a3e026a
15+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16+
17+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
18+
:target: https://odoo-community.org/page/development-status
19+
:alt: Beta
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
21+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
22+
:alt: License: AGPL-3
23+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
24+
:target: https://github.com/OCA/account-invoicing/tree/16.0/account_invoice_fixed_triple_discount
25+
:alt: OCA/account-invoicing
26+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27+
:target: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-account_invoice_fixed_triple_discount
28+
:alt: Translate me on Weblate
29+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=16.0
31+
:alt: Try me on Runboat
32+
33+
|badge1| |badge2| |badge3| |badge4| |badge5|
34+
35+
Glue module between `account_invoice_fixed_discount` and `account_invoice_triple_discount`.
36+
When both are used on the same line a warning will appear to alert the user that the fixed discount will take priority and it's recommended to only use one.
37+
38+
**Table of contents**
39+
40+
.. contents::
41+
:local:
42+
43+
Bug Tracker
44+
===========
45+
46+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/issues>`_.
47+
In case of trouble, please check there if your issue has already been reported.
48+
If you spotted it first, help us to smash it by providing a detailed and welcomed
49+
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_fixed_triple_discount%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
50+
51+
Do not contact contributors directly about support or help with technical issues.
52+
53+
Credits
54+
=======
55+
56+
Contributors
57+
~~~~~~~~~~~~
58+
59+
* Ethan Hildick <hildickethan@gmail.com>
60+
61+
Maintainers
62+
~~~~~~~~~~~
63+
64+
This module is maintained by the OCA.
65+
66+
.. image:: https://odoo-community.org/logo.png
67+
:alt: Odoo Community Association
68+
:target: https://odoo-community.org
69+
70+
OCA, or the Odoo Community Association, is a nonprofit organization whose
71+
mission is to support the collaborative development of Odoo features and
72+
promote its widespread use.
73+
74+
This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/16.0/account_invoice_fixed_triple_discount>`_ project on GitHub.
75+
76+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 Ethan Hildick
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Account Fixed Triple Discount",
6+
"summary": "Compatibility between fixed and triple discount modules",
7+
"version": "16.0.1.0.0",
8+
"category": "Accounting & Finance",
9+
"website": "https://github.com/OCA/account-invoicing",
10+
"author": "Odoo Community Association (OCA)",
11+
"license": "AGPL-3",
12+
"application": False,
13+
"installable": True,
14+
"depends": ["account_invoice_fixed_discount", "account_invoice_triple_discount"],
15+
"auto_install": True,
16+
"data": ["views/account_move_view.xml"],
17+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import account_move
2+
from . import triple_discount_mixin
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2025 Ethan Hildick
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class AccountMove(models.Model):
8+
_inherit = "account.move"
9+
10+
show_discount_warning_label = fields.Boolean(
11+
compute="_compute_show_discount_warning_label"
12+
)
13+
14+
@api.depends(
15+
"invoice_line_ids.discount_fixed",
16+
"invoice_line_ids.discount1",
17+
"invoice_line_ids.discount2",
18+
"invoice_line_ids.discount3",
19+
)
20+
def _compute_show_discount_warning_label(self):
21+
for move in self:
22+
move.show_discount_warning_label = any(
23+
line.discount_fixed
24+
and (line.discount1 or line.discount2 or line.discount3)
25+
for line in move.invoice_line_ids
26+
)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2025 Ethan Hildick
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
from odoo.tools.float_utils import float_is_zero
6+
7+
8+
class TripleDiscountMixin(models.AbstractModel):
9+
_inherit = "triple.discount.mixin"
10+
11+
def _get_lines_to_compute_discount(self):
12+
return self.filtered(
13+
lambda line: float_is_zero(
14+
line.discount_fixed, precision_rounding=line.currency_id.rounding
15+
)
16+
)
17+
18+
def _should_copy_discount_to_discount1(self, vals):
19+
res = super()._should_copy_discount_to_discount1(vals)
20+
currency = (
21+
self.env["res.currency"].browse(vals.get("currency_id"))
22+
or self.env.company.currency_id
23+
)
24+
return res and not (
25+
"discount_fixed" in vals
26+
and not float_is_zero(
27+
vals.get("discount_fixed"),
28+
precision_rounding=currency.rounding,
29+
)
30+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Ethan Hildick <hildickethan@gmail.com>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Glue module between `account_invoice_fixed_discount` and `account_invoice_triple_discount`.
2+
When both are used on the same line a warning will appear to alert the user that the fixed discount will take priority and it's recommended to only use one.
9.23 KB
Loading

0 commit comments

Comments
 (0)