-
-
Notifications
You must be signed in to change notification settings - Fork 166
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_margin: Migration to 16.0
- Loading branch information
1 parent
cd73bf4
commit b241bed
Showing
6 changed files
with
81 additions
and
117 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
File renamed without changes
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 |
---|---|---|
@@ -1,96 +1,34 @@ | ||
# © 2016 Sergio Teruel <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields | ||
from odoo.tests.common import Form, TransactionCase, tagged | ||
from odoo.tests.common import Form, tagged | ||
|
||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestAccountInvoiceMargin(TransactionCase): | ||
class TestAccountInvoiceMargin(AccountTestInvoicingCommon): | ||
@classmethod | ||
def setUpClass(cls): | ||
super(TestAccountInvoiceMargin, cls).setUpClass() | ||
cls.Product = cls.env["product.template"] | ||
|
||
cls.journal = cls.env["account.journal"].create( | ||
{"name": "Test journal", "type": "sale", "code": "TEST_J"} | ||
) | ||
cls.account_type = cls.env["account.account.type"].create( | ||
{"name": "Test account type", "type": "other", "internal_group": "income"} | ||
) | ||
cls.account = cls.env["account.account"].create( | ||
{ | ||
"name": "Test account", | ||
"code": "TEST_A", | ||
"user_type_id": cls.account_type.id, | ||
"reconcile": True, | ||
} | ||
) | ||
cls.partner = cls.env["res.partner"].create( | ||
{"name": "Test partner", "customer_rank": 1, "is_company": True} | ||
) | ||
cls.partner.property_account_receivable_id = cls.account | ||
cls.product_categ = cls.env["product.category"].create( | ||
{"name": "Test category"} | ||
) | ||
|
||
cls.product = cls.env["product.product"].create( | ||
{ | ||
"name": "test product", | ||
"categ_id": cls.product_categ.id, | ||
"uom_id": cls.env.ref("uom.product_uom_unit").id, | ||
"uom_po_id": cls.env.ref("uom.product_uom_unit").id, | ||
"default_code": "test-margin", | ||
"list_price": 200.00, | ||
"standard_price": 100.00, | ||
} | ||
) | ||
cls.product.property_account_income_id = cls.account | ||
cls.invoice = cls.env["account.move"].create( | ||
{ | ||
"partner_id": cls.partner.id, | ||
"invoice_date": fields.Date.from_string("2017-06-19"), | ||
"move_type": "out_invoice", | ||
"currency_id": cls.env.user.company_id.currency_id.id, | ||
"invoice_line_ids": [ | ||
( | ||
0, | ||
None, | ||
{ | ||
"product_id": cls.product.id, | ||
"product_uom_id": cls.product.uom_id.id, | ||
"account_id": cls.product.property_account_income_id.id, | ||
"name": "Test Margin", | ||
"price_unit": cls.product.list_price, | ||
"quantity": 10, | ||
"purchase_price": cls.product.standard_price, | ||
}, | ||
) | ||
], | ||
} | ||
cls.product_a.lst_price = 200 | ||
cls.product_a.standard_price = 100 | ||
cls.invoice = cls.init_invoice( | ||
"out_invoice", | ||
partner=cls.partner_a, | ||
invoice_date=fields.Date.from_string("2017-06-19"), | ||
post=False, | ||
products=cls.product_a, | ||
) | ||
cls.vendor_bill = cls.env["account.move"].create( | ||
{ | ||
"partner_id": cls.partner.id, | ||
"invoice_date": fields.Date.from_string("2017-06-19"), | ||
"move_type": "in_invoice", | ||
"currency_id": cls.env.user.company_id.currency_id.id, | ||
"invoice_line_ids": [ | ||
( | ||
0, | ||
None, | ||
{ | ||
"product_id": cls.product.id, | ||
"product_uom_id": cls.product.uom_id.id, | ||
"account_id": cls.product.property_account_income_id.id, | ||
"name": "Test Margin", | ||
"price_unit": cls.product.list_price, | ||
"quantity": 10, | ||
}, | ||
) | ||
], | ||
} | ||
cls.invoice.invoice_line_ids.quantity = 10 | ||
cls.vendor_bill = cls.init_invoice( | ||
"in_invoice", | ||
partner=cls.partner_a, | ||
invoice_date=fields.Date.from_string("2017-06-19"), | ||
post=False, | ||
products=cls.product_a, | ||
) | ||
cls.vendor_bill.invoice_line_ids.quantity = 10 | ||
|
||
def test_invoice_margin(self): | ||
self.assertEqual(self.invoice.invoice_line_ids.purchase_price, 100.00) | ||
|
@@ -108,7 +46,6 @@ def test_vendor_bill_margin(self): | |
def test_invoice_margin_uom(self): | ||
inv_line = self.invoice.invoice_line_ids | ||
inv_line.update({"product_uom_id": self.env.ref("uom.product_uom_dozen").id}) | ||
inv_line.with_context(check_move_validity=False)._onchange_uom_id() | ||
self.assertEqual(inv_line.margin, 12000.00) | ||
|
||
def test_invoice_refund(self): | ||
|
@@ -148,10 +85,10 @@ def test_invoice_different_currency(self): | |
move_form = Form( | ||
self.env["account.move"].with_context(default_move_type="out_invoice") | ||
) | ||
move_form.partner_id = self.partner | ||
move_form.partner_id = self.partner_a | ||
move_form.currency_id = currency | ||
move_form.invoice_date = "2022-01-01" | ||
with move_form.invoice_line_ids.new() as line_form: | ||
line_form.product_id = self.product | ||
line_form.product_id = self.product_a | ||
invoice = move_form.save() | ||
self.assertEqual(invoice.invoice_line_ids.purchase_price, 200) |
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