|
8 | 8 | import odoo.tests.common as common
|
9 | 9 | from odoo import Command
|
10 | 10 | from odoo.exceptions import UserError
|
11 |
| -from odoo.tests import Form, tagged |
| 11 | +from odoo.tests import tagged |
12 | 12 |
|
13 | 13 |
|
14 | 14 | @tagged("post_install", "-at_install")
|
@@ -104,19 +104,23 @@ def _create_partner(self, name):
|
104 | 104 | )
|
105 | 105 |
|
106 | 106 | 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 |
120 | 124 |
|
121 | 125 | def test_compensation(self):
|
122 | 126 | # Test raise if 1 account.move.line selected
|
|
0 commit comments