mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-24 17:12:02 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
from . import test_brand_mixin
|
||||
from . import test_account_move
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
# Copyright 2019 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestAccountMove(TransactionCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.product = self.env.ref("product.product_product_4")
|
||||
self.account_receivable = self.env["account.account"].create(
|
||||
{
|
||||
"name": "Partner Receivable",
|
||||
"code": "RCV00",
|
||||
"account_type": "asset_receivable",
|
||||
"reconcile": True,
|
||||
}
|
||||
)
|
||||
self.account_receivable_brand_default = self.env["account.account"].create(
|
||||
{
|
||||
"name": "Receivable Brand Default",
|
||||
"code": "RCV01",
|
||||
"account_type": "asset_receivable",
|
||||
"reconcile": True,
|
||||
}
|
||||
)
|
||||
self.account_receivable_partner_brand_default = self.env[
|
||||
"account.account"
|
||||
].create(
|
||||
{
|
||||
"name": "Receivable Partner Brand Default",
|
||||
"code": "RCV02",
|
||||
"account_type": "asset_receivable",
|
||||
"reconcile": True,
|
||||
}
|
||||
)
|
||||
self.partner_id = self.env.ref("base.res_partner_12")
|
||||
self.partner_id.property_account_receivable_id = self.account_receivable
|
||||
self.account_revenue = self.env["account.account"].create(
|
||||
{"name": "Test sale", "code": "XX.700", "account_type": "income"}
|
||||
)
|
||||
self.move = self.env["account.move"].create(
|
||||
{
|
||||
"partner_id": self.partner_id.id,
|
||||
"move_type": "out_invoice",
|
||||
"invoice_line_ids": [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"quantity": 1,
|
||||
"price_unit": 42,
|
||||
"name": "something",
|
||||
"account_id": self.account_revenue.id,
|
||||
},
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
self.brand_id = self.env["res.brand"].create({"name": "Brand"})
|
||||
|
||||
def _get_receivable_account(self, move):
|
||||
return self.move.line_ids.filtered(
|
||||
lambda line: line.account_id.account_type == "asset_receivable"
|
||||
).account_id
|
||||
|
||||
def test_on_change_partner_id(self):
|
||||
account = self._get_receivable_account(self.move)
|
||||
self.assertEqual(account, self.account_receivable)
|
||||
partner_account_brand = self.env["res.partner.account.brand"].create(
|
||||
{
|
||||
"partner_id": False,
|
||||
"account_id": self.account_receivable_brand_default.id,
|
||||
"brand_id": self.brand_id.id,
|
||||
"account_type": "asset_receivable",
|
||||
}
|
||||
)
|
||||
self.move._onchange_partner_id()
|
||||
account = self._get_receivable_account(self.move)
|
||||
self.assertEqual(account, self.account_receivable)
|
||||
self.move.brand_id = self.brand_id
|
||||
self.move._onchange_partner_id()
|
||||
account = self._get_receivable_account(self.move)
|
||||
self.assertEqual(account, self.account_receivable_brand_default)
|
||||
partner_account_brand.update(
|
||||
{
|
||||
"partner_id": self.partner_id.id,
|
||||
"account_id": self.account_receivable_partner_brand_default.id,
|
||||
}
|
||||
)
|
||||
self.move._onchange_partner_id()
|
||||
account = self._get_receivable_account(self.move)
|
||||
self.assertEqual(
|
||||
account,
|
||||
self.account_receivable_partner_brand_default,
|
||||
)
|
||||
move = self.env["account.move"].create(
|
||||
{
|
||||
"partner_id": self.partner_id.id,
|
||||
"brand_id": self.brand_id.id,
|
||||
"move_type": "out_invoice",
|
||||
}
|
||||
)
|
||||
account = self._get_receivable_account(move)
|
||||
self.assertEqual(
|
||||
account,
|
||||
self.account_receivable_partner_brand_default,
|
||||
)
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
# Copyright 2019 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import Form
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
from odoo.addons.brand.models.res_company import BRAND_USE_LEVEL_REQUIRED_LEVEL
|
||||
|
||||
|
||||
class TestBrandMixin(TransactionCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.partner = self.env.user.partner_id
|
||||
self.company = self.env.user.company_id
|
||||
self.other_company = self.env["res.company"].create(
|
||||
{"name": "other company", "parent_id": self.company.id}
|
||||
)
|
||||
self.journal = self.env["account.journal"].create(
|
||||
{"type": "sale", "code": "SALE", "name": "Sale journal"}
|
||||
)
|
||||
self.invoice = self.env["account.move"].create(
|
||||
{
|
||||
"name": "Sample invoice",
|
||||
"company_id": self.company.id,
|
||||
"journal_id": self.journal.id,
|
||||
"partner_id": self.partner.id,
|
||||
}
|
||||
)
|
||||
self.brand = self.env["res.brand"].create({"name": "brand"})
|
||||
self.other_company_brand = self.env["res.brand"].create(
|
||||
{"name": "brand", "company_id": self.other_company.id}
|
||||
)
|
||||
|
||||
def test_is_brand_required(self):
|
||||
self.assertFalse(self.invoice._is_brand_required())
|
||||
self.company.brand_use_level = BRAND_USE_LEVEL_REQUIRED_LEVEL
|
||||
self.assertTrue(self.invoice._is_brand_required())
|
||||
|
||||
def test_check_brand_requirement(self):
|
||||
self.env["account.move"].create(
|
||||
{
|
||||
"name": "Sample invoice",
|
||||
"company_id": self.company.id,
|
||||
"journal_id": self.journal.id,
|
||||
"partner_id": self.partner.id,
|
||||
}
|
||||
)
|
||||
self.company.brand_use_level = BRAND_USE_LEVEL_REQUIRED_LEVEL
|
||||
with self.assertRaises(ValidationError):
|
||||
self.env["account.move"].create(
|
||||
{
|
||||
"name": "Sample invoice",
|
||||
"company_id": self.company.id,
|
||||
"journal_id": self.journal.id,
|
||||
"partner_id": self.partner.id,
|
||||
}
|
||||
)
|
||||
self.env["account.move"].create(
|
||||
{
|
||||
"name": "Sample invoice",
|
||||
"company_id": self.company.id,
|
||||
"journal_id": self.journal.id,
|
||||
"partner_id": self.partner.id,
|
||||
"brand_id": self.brand.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_brand_company_id(self):
|
||||
invoice = self.env["account.move"].create(
|
||||
{
|
||||
"name": "Sample invoice",
|
||||
"company_id": self.company.id,
|
||||
"journal_id": self.journal.id,
|
||||
"partner_id": self.partner.id,
|
||||
"brand_id": self.brand.id,
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
invoice.brand_id = self.other_company_brand
|
||||
|
||||
def test_onchange_brand_id(self):
|
||||
new_invoice = self.env["account.move"].new(
|
||||
{
|
||||
"name": "Sample invoice",
|
||||
"company_id": self.company.id,
|
||||
"journal_id": self.journal.id,
|
||||
"partner_id": self.partner.id,
|
||||
"brand_id": self.brand.id,
|
||||
}
|
||||
)
|
||||
self.assertEqual(new_invoice.company_id, self.company)
|
||||
new_invoice.brand_id = self.other_company_brand
|
||||
new_invoice._onchange_brand_id()
|
||||
self.assertEqual(new_invoice.company_id, self.other_company)
|
||||
|
||||
def test_get_view(self):
|
||||
view = self.env["account.move"].get_view(
|
||||
view_id=self.env.ref("account.view_move_form").id,
|
||||
view_type="form",
|
||||
)
|
||||
doc = etree.XML(view["arch"])
|
||||
self.assertTrue(doc.xpath("//field[@name='brand_id']"))
|
||||
|
||||
def test_reverse_move(self):
|
||||
move = self.env["account.move"].create(
|
||||
{
|
||||
"name": "Sample invoice",
|
||||
"move_type": "out_invoice",
|
||||
"company_id": self.company.id,
|
||||
"journal_id": self.journal.id,
|
||||
"partner_id": self.partner.id,
|
||||
"brand_id": self.brand.id,
|
||||
"invoice_line_ids": [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"product_id": self.env.ref("product.product_product_1").id,
|
||||
"quantity": 40.0,
|
||||
"name": "product test 1",
|
||||
"discount": 10.00,
|
||||
"price_unit": 2.27,
|
||||
},
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
move.action_post()
|
||||
reverse_wizard = Form(
|
||||
self.env["account.move.reversal"].with_context(
|
||||
active_ids=move.ids, active_model="account.move"
|
||||
)
|
||||
)
|
||||
reverse_wizard.reason = "modify"
|
||||
reverse = reverse_wizard.save()
|
||||
action = reverse.reverse_moves()
|
||||
credit_note = self.env["account.move"].browse(action.get("res_id"))
|
||||
self.assertEqual(credit_note.brand_id, self.brand)
|
||||
Loading…
Add table
Add a link
Reference in a new issue