-
-
Notifications
You must be signed in to change notification settings - Fork 692
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_refund_link: Migration to 16.0
- Loading branch information
1 parent
df9b8b1
commit 3610b9b
Showing
7 changed files
with
29 additions
and
25 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# Copyright 2014-2022 Pedro M. Baeza <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
from odoo import fields, models | ||
|
||
|
||
class AccountMove(models.Model): | ||
|
@@ -13,21 +13,17 @@ class AccountMove(models.Model): | |
"account.move", "reversed_entry_id", string="Refund Invoices", readonly=True | ||
) | ||
|
||
@api.model | ||
def _reverse_move_vals(self, default_values, cancel=True): | ||
move_vals = super()._reverse_move_vals(default_values, cancel) | ||
if self.env.context.get("link_origin_line", False) and move_vals[ | ||
"move_type" | ||
] in ( | ||
"out_refund", | ||
"in_refund", | ||
): | ||
refund_lines_vals = [ | ||
x[2] | ||
for x in move_vals.get("line_ids", []) | ||
if not x[2].get("exclude_from_invoice_tab", True) | ||
] | ||
for i, line in enumerate(self.invoice_line_ids): | ||
if i < len(refund_lines_vals): | ||
refund_lines_vals[i]["origin_line_id"] = line.id | ||
return move_vals | ||
def _reverse_moves(self, default_values_list=None, cancel=False): | ||
reverse_moves = super()._reverse_moves( | ||
default_values_list=default_values_list, cancel=cancel | ||
) | ||
if self.env.context.get("link_origin_line", False): | ||
for move in reverse_moves: | ||
if move.move_type in ("out_refund", "in_refund"): | ||
refund_lines = move.line_ids.filtered( | ||
lambda x: x.display_type == "product" | ||
) | ||
for i, line in enumerate(self.invoice_line_ids): | ||
if i < len(refund_lines): | ||
refund_lines[i].origin_line_id = line.id | ||
return reverse_moves |
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 |
---|---|---|
|
@@ -7,3 +7,7 @@ | |
* Luis M. Ontalba | ||
* Ernesto Tejeda | ||
* João Marques | ||
|
||
* `Factor Libre <https://factorlibre.com>`_: | ||
|
||
* Luis J. Salvatierra <[email protected]> |
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
1 change: 1 addition & 0 deletions
1
setup/account_invoice_refund_link/odoo/addons/account_invoice_refund_link
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 @@ | ||
../../../../account_invoice_refund_link |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |