-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
130 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# © 2024 Deltatech | ||
# Dorin Hongu <dhongu(@)gmail(.)com | ||
# See README.rst file on addons rcoot folder for license details | ||
|
||
from . import test_stock_valuation |
119 changes: 119 additions & 0 deletions
119
deltatech_stock_valuation/tests/test_stock_valuation.py
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 |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# © 2024 Deltatech | ||
# Dorin Hongu <dhongu(@)gmail(.)com | ||
# See README.rst file on addons rcoot folder for license details | ||
|
||
from dateutil.relativedelta import relativedelta | ||
|
||
from odoo import Command, fields | ||
from odoo.tests import tagged | ||
|
||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestStockValuation(AccountTestInvoicingCommon): | ||
@classmethod | ||
def setUpClass(cls, chart_template_ref=None): | ||
if not chart_template_ref: | ||
chart_template_ref = "l10n_ro.ro_chart_template" | ||
super().setUpClass(chart_template_ref=chart_template_ref) | ||
|
||
cls.company = cls.env.company | ||
|
||
cls.account = cls.env["account.account"].create( | ||
{ | ||
"name": "Account A", | ||
"code": "1234", | ||
"user_type_id": cls.env.ref("account.data_account_type_current_assets").id, | ||
"stock_valuation": True, | ||
} | ||
) | ||
|
||
cls.sale_journal = cls.env["account.journal"].create( | ||
{ | ||
"name": "Test Journal", | ||
"type": "sale", | ||
"code": "TEST", | ||
} | ||
) | ||
|
||
cls.env.company.set_stock_valuation_at_company_level() | ||
|
||
def test_account_move(self): | ||
today = fields.Date.today() | ||
today = fields.Date.from_string(today) | ||
date = today + relativedelta(day=1, months=-1, days=15) | ||
|
||
invoices = self.env["account.move"].create( | ||
[ | ||
{ | ||
"move_type": "out_invoice", | ||
"invoice_date": date, | ||
"date": date, | ||
"partner_id": self.partner_a.id, | ||
"invoice_line_ids": [ | ||
Command.create( | ||
{ | ||
"product_id": self.product_a.id, | ||
"account_id": self.account.id, | ||
"quantity": 5.0, | ||
"price_unit": 1000.0, | ||
"tax_ids": [Command.set(self.company_data["default_tax_sale"].ids)], | ||
} | ||
) | ||
], | ||
}, | ||
{ | ||
"move_type": "out_invoice", | ||
"invoice_date": date, | ||
"date": date, | ||
"partner_id": self.company_data["company"].partner_id.id, | ||
"invoice_line_ids": [ | ||
Command.create( | ||
{ | ||
"product_id": self.product_a.id, | ||
"account_id": self.account.id, | ||
"quantity": 2.0, | ||
"price_unit": 1500.0, | ||
"tax_ids": [Command.set(self.company_data["default_tax_sale"].ids)], | ||
} | ||
) | ||
], | ||
}, | ||
{ | ||
"move_type": "out_refund", | ||
"invoice_date": date, | ||
"date": date, | ||
"partner_id": self.partner_a.id, | ||
"invoice_line_ids": [ | ||
Command.create( | ||
{ | ||
"product_id": self.product_a.id, | ||
"account_id": self.account.id, | ||
"quantity": 3.0, | ||
"price_unit": 1000.0, | ||
"tax_ids": [Command.set(self.company_data["default_tax_sale"].ids)], | ||
} | ||
) | ||
], | ||
}, | ||
{ | ||
"move_type": "in_invoice", | ||
"invoice_date": date, | ||
"date": date, | ||
"partner_id": self.partner_b.id, | ||
"invoice_line_ids": [ | ||
Command.create( | ||
{ | ||
"product_id": self.product_b.id, | ||
"account_id": self.account.id, | ||
"quantity": 10.0, | ||
"price_unit": 800.0, | ||
"tax_ids": [Command.set(self.company_data["default_tax_purchase"].ids)], | ||
} | ||
) | ||
], | ||
}, | ||
] | ||
) | ||
invoices.action_post() |