-
-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] account_invoice_fixed_discount: Migration to 16.0
- Loading branch information
1 parent
2350456
commit 0f2a152
Showing
6 changed files
with
49 additions
and
146 deletions.
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
|
||
from . import account_move | ||
from . import account_move_line |
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
account_invoice_fixed_discount/models/account_move_line.py
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,37 @@ | ||
# Copyright 2017 ForgeFlow S.L. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
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_fixed") | ||
def _onchange_discount_fixed(self): | ||
"""When the discount fixed is changed, we set the ``discount`` on the line to the | ||
appropriate value and apply the default downstream implementation. | ||
When the display_type is not ``'product'`` we reset the discount_fixed to 0.0. | ||
""" | ||
if self.display_type != "product": | ||
self.discount_fixed = 0.0 | ||
return | ||
|
||
if self.discount_fixed: | ||
self.discount = self.discount_fixed / self.price_unit * 100.0 | ||
|
||
@api.onchange("discount") | ||
def _onchange_discount(self): | ||
"""Reset the ``discount_fixed`` when ``discount`` is changed.""" | ||
if self.env.context.get("ignore_discount_fixed", False): | ||
return | ||
self.discount_fixed = 0.0 |
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
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