[MIG] account_sale_stock_report_non_billed: Migration to 15.0

pull/1183/head
Stefan 2023-01-26 13:30:57 +01:00 committed by Christopher Ormaza
parent f9d3900e41
commit 0471d795fb
6 changed files with 36 additions and 18 deletions

View File

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Account Sale Stock Report Non Billed",
"version": "13.0.1.1.0",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-reporting",
@ -10,6 +10,7 @@
"data": [
"views/res_config_settings_views.xml",
"views/stock_move_non_billed_views.xml",
"security/ir.model.access.csv",
"wizard/account_sale_stock_report_non_billed_wiz_views.xml",
],
"installable": True,

View File

@ -69,8 +69,8 @@ class StockMove(models.Model):
sum(
invoice_lines.mapped(
lambda l: l.quantity
if (l.move_id.type == "out_invoice" and not self.to_refund)
or (l.move_id.type == "out_refund" and self.to_refund)
if (l.move_id.move_type == "out_invoice" and not self.to_refund)
or (l.move_id.move_type == "out_refund" and self.to_refund)
else -l.quantity
)
)

View File

@ -2,3 +2,4 @@
* Carlos Roca
* Pedro M. Baeza
* Stefan Ungureanu

View File

@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
account_sale_stock_report_non_billed.access_account_sale_stock_report_non_billed_wiz,access_account_sale_stock_report_non_billed_wiz,account_sale_stock_report_non_billed.model_account_sale_stock_report_non_billed_wiz,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 account_sale_stock_report_non_billed.access_account_sale_stock_report_non_billed_wiz access_account_sale_stock_report_non_billed_wiz account_sale_stock_report_non_billed.model_account_sale_stock_report_non_billed_wiz base.group_user 1 1 1 1

View File

@ -3,13 +3,14 @@
from dateutil.relativedelta import relativedelta
from odoo import fields
from odoo.tests import Form
from odoo.tests import Form, tagged
from odoo.addons.stock_picking_invoice_link.tests.test_stock_picking_invoice_link import (
TestStockPickingInvoiceLink,
)
@tagged("post_install")
class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
def setUp(self):
super().setUp()
@ -21,7 +22,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
and x.state in ("confirmed", "assigned", "partially_available")
)
picking.move_line_ids.write({"qty_done": 2})
picking.action_done()
picking.button_validate()
return picking
def test_01_report_move_not_invoiced(self):
@ -55,7 +56,14 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
move_done = picking.move_lines[0]
moves_not_done = picking.move_lines[1:]
move_done.move_line_ids.write({"qty_done": 2})
picking.action_done()
backorder_wiz = picking.button_validate()
backorder_wiz = Form(
self.env[backorder_wiz["res_model"]].with_context(
**backorder_wiz["context"]
)
).save()
backorder_wiz.process()
self.assertEqual(picking.state, "done")
inv = self.so._create_invoices()
inv.action_post()
# Done other moves to appear at report
@ -77,7 +85,13 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
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()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
@ -99,7 +113,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
return_id = wiz_return.create_returns()["res_id"]
picking_return = self.env["stock.picking"].browse(return_id)
picking_return.move_line_ids.write({"qty_done": 2})
picking_return.action_done()
picking_return.button_validate()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()}
)
@ -123,7 +137,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
return_id = wiz_return.create_returns()["res_id"]
picking_return = self.env["stock.picking"].browse(return_id)
picking_return.move_line_ids.write({"qty_done": 2})
picking_return.action_done()
picking_return.button_validate()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()}
)
@ -134,7 +148,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
for move in picking_return.move_lines:
self.assertIn(move.id, domain_ids)
inv = self.so._create_invoices(final=True)
inv.post()
inv.action_post()
action = wiz.open_at_date()
domain_ids = action["domain"][0][2]
for move in picking_return.move_lines:
@ -151,7 +165,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
return_id = wiz_return.create_returns()["res_id"]
picking_return = self.env["stock.picking"].browse(return_id)
picking_return.move_line_ids.write({"qty_done": 2})
picking_return.action_done()
picking_return.button_validate()
wiz_return_return_form = Form(
self.env["stock.return.picking"].with_context(
active_model="stock.picking", active_id=picking_return.id
@ -161,7 +175,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
return_return_id = wiz_return_return.create_returns()["res_id"]
picking_return_return = self.env["stock.picking"].browse(return_return_id)
picking_return_return.move_line_ids.write({"qty_done": 2})
picking_return_return.action_done()
picking_return_return.button_validate()
self.so._create_invoices(final=True)
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()}
@ -186,7 +200,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
return_id = wiz_return.create_returns()["res_id"]
picking_return = self.env["stock.picking"].browse(return_id)
picking_return.move_line_ids.write({"qty_done": 2})
picking_return.action_done()
picking_return.button_validate()
wiz_return_return_form = Form(
self.env["stock.return.picking"].with_context(
active_model="stock.picking", active_id=picking_return.id
@ -196,7 +210,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
return_return_id = wiz_return_return.create_returns()["res_id"]
picking_return_return = self.env["stock.picking"].browse(return_return_id)
picking_return_return.move_line_ids.write({"qty_done": 2})
picking_return_return.action_done()
picking_return_return.button_validate()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()}
)
@ -223,7 +237,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
return_id = wiz_return.create_returns()["res_id"]
picking_return = self.env["stock.picking"].browse(return_id)
picking_return.move_line_ids.write({"qty_done": 2})
picking_return.action_done()
picking_return.button_validate()
wiz_return_return_form = Form(
self.env["stock.return.picking"].with_context(
active_model="stock.picking",
@ -235,7 +249,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
return_return_id = wiz_return_return.create_returns()["res_id"]
picking_return_return = self.env["stock.picking"].browse(return_return_id)
picking_return_return.move_line_ids.write({"qty_done": 2})
picking_return_return.action_done()
picking_return_return.button_validate()
wiz = self.env["account.sale.stock.report.non.billed.wiz"].create(
{"date_check": fields.Date.today()}
)
@ -254,7 +268,7 @@ class TestAccountSaleStrockReportNonBilled(TestStockPickingInvoiceLink):
and x.state in ("confirmed", "assigned", "partially_available")
)
picking.move_line_ids.write({"qty_done": 2})
picking.action_done()
picking.button_validate()
# Emulate prepaying invoice
inv = self.so._create_invoices()
inv.date = fields.Date.today() - relativedelta(days=5)

View File

@ -31,7 +31,7 @@
</xpath>
<xpath expr="//field[@name='reference']" position="after">
<field name="picking_id" string="Picking" />
<field name="picking_partner_id" />
<field name="partner_id" />
<field name="origin" nolabel="1" />
<button
name="open_origin_document"