forked from OCA/stock-logistics-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] stock_picking_invoice_link: Migration to 15.0
- Loading branch information
1 parent
cbb682c
commit c332869
Showing
10 changed files
with
83 additions
and
32 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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Copyright 2017 Jacques-Etienne Baudoux <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import fields, models | ||
from odoo import api, fields, models | ||
|
||
|
||
class StockPicking(models.Model): | ||
|
@@ -13,6 +13,9 @@ class StockPicking(models.Model): | |
invoice_ids = fields.Many2many( | ||
comodel_name="account.move", copy=False, string="Invoices", readonly=True | ||
) | ||
invoice_count = fields.Integer( | ||
string="Invoices Orders", compute="_compute_invoice_count" | ||
) | ||
|
||
def action_view_invoice(self): | ||
"""This function returns an action that display existing invoices | ||
|
@@ -22,12 +25,18 @@ def action_view_invoice(self): | |
""" | ||
self.ensure_one() | ||
form_view_name = "account.view_move_form" | ||
action = self.env.ref("account.action_move_out_invoice_type").sudo() | ||
result = action.read()[0] | ||
result = self.env["ir.actions.act_window"]._for_xml_id( | ||
"account.action_move_out_invoice_type" | ||
) | ||
if len(self.invoice_ids) > 1: | ||
result["domain"] = "[('id', 'in', %s)]" % self.invoice_ids.ids | ||
else: | ||
form_view = self.env.ref(form_view_name) | ||
result["views"] = [(form_view.id, "form")] | ||
result["res_id"] = self.invoice_ids.id | ||
return result | ||
|
||
@api.depends("invoice_ids") | ||
def _compute_invoice_count(self): | ||
for order in self: | ||
order.invoice_count = len(order.invoice_ids) |
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 |
---|---|---|
|
@@ -26,3 +26,4 @@ | |
* Jacques-Etienne Baudoux <[email protected]> | ||
* Aitor Bouzas Naveira <[email protected]> | ||
* Carlos Lopez Mite <[email protected]> | ||
* Joel Matías Zilli <[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
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,13 +3,13 @@ | |
# Copyright 2017 Jacques-Etienne Baudoux <[email protected]> | ||
# Copyright 2021 Tecnativa - João Marques | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo.exceptions import UserError | ||
from odoo.tests import Form | ||
from odoo.tests import Form, tagged | ||
|
||
from odoo.addons.sale.tests.common import TestSaleCommon | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestStockPickingInvoiceLink(TestSaleCommon): | ||
@classmethod | ||
def _update_product_qty(cls, product): | ||
|
@@ -255,7 +255,13 @@ def test_invoice_refund(self): | |
wiz_invoice_refund = ( | ||
self.env["account.move.reversal"] | ||
.with_context(active_model="account.move", active_ids=inv.ids) | ||
.create({"refund_method": "modify", "reason": "test"}) | ||
.create( | ||
{ | ||
"refund_method": "modify", | ||
"reason": "test", | ||
"journal_id": inv.journal_id.id, | ||
} | ||
) | ||
) | ||
wiz_invoice_refund.reverse_moves() | ||
new_invoice = self.so.invoice_ids.filtered( | ||
|
@@ -288,7 +294,13 @@ def test_invoice_refund_invoice(self): | |
wiz_invoice_refund = ( | ||
self.env["account.move.reversal"] | ||
.with_context(active_model="account.move", active_ids=inv.ids) | ||
.create({"refund_method": "cancel", "reason": "test"}) | ||
.create( | ||
{ | ||
"refund_method": "cancel", | ||
"reason": "test", | ||
"journal_id": inv.journal_id.id, | ||
} | ||
) | ||
) | ||
wiz_invoice_refund.reverse_moves() | ||
# Create invoice again | ||
|
@@ -306,7 +318,7 @@ def test_partial_invoice_full_link(self): | |
and x.state in ("confirmed", "assigned", "partially_available") | ||
) | ||
pick_1.move_line_ids.write({"qty_done": 2}) | ||
pick_1.action_done() | ||
pick_1._action_done() | ||
# Create invoice | ||
inv = self.so._create_invoices() | ||
with Form(inv) as move_form: | ||
|
@@ -324,7 +336,7 @@ def test_return_and_invoice_refund(self): | |
and x.state in ("confirmed", "assigned", "partially_available") | ||
) | ||
pick_1.move_line_ids.write({"qty_done": 2}) | ||
pick_1.action_done() | ||
pick_1._action_done() | ||
# Create invoice | ||
inv = self.so._create_invoices() | ||
inv_line_prod_del = inv.invoice_line_ids.filtered( | ||
|
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
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