Skip to content

Commit a3e4c94

Browse files
committed
[IMP] account_netting: remove Form() in tests
1 parent fe7e930 commit a3e4c94

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

account_netting/tests/test_account_netting.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import odoo.tests.common as common
99
from odoo import Command
1010
from odoo.exceptions import UserError
11-
from odoo.tests import Form, tagged
11+
from odoo.tests import tagged
1212

1313

1414
@tagged("post_install", "-at_install")
@@ -104,19 +104,23 @@ def _create_partner(self, name):
104104
)
105105

106106
def _create_move(self, move_type, partner, price):
107-
move_form = Form(
108-
self.env["account.move"]
109-
.with_company(self.company.id)
110-
.with_context(
111-
default_move_type=move_type,
112-
)
113-
)
114-
move_form.partner_id = partner
115-
move_form.invoice_date = datetime.now()
116-
with move_form.invoice_line_ids.new() as line_form:
117-
line_form.product_id = self.product
118-
line_form.price_unit = price
119-
return move_form.save()
107+
vals = {
108+
"company_id": self.company.id,
109+
"move_type": move_type,
110+
"partner_id": partner.id,
111+
"invoice_line_ids": [
112+
Command.create(
113+
{
114+
"product_id": self.product.id,
115+
"price_unit": price,
116+
}
117+
)
118+
],
119+
}
120+
if move_type in ("in_invoice", "in_refund"):
121+
vals["invoice_date"] = datetime.now()
122+
move = self.env["account.move"].create(vals)
123+
return move
120124

121125
def test_compensation(self):
122126
# Test raise if 1 account.move.line selected

0 commit comments

Comments
 (0)