Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
from . import test_account_move_reverse
from . import test_product_tax_multicompany

View File

@@ -0,0 +1,169 @@
from odoo import fields
from odoo.tests import tagged
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.addons.auditlog.tests.common import AuditLogRuleCommon
@tagged("post_install", "-at_install")
class TestAccountMoveReverse(AccountTestInvoicingCommon, AuditLogRuleCommon):
@classmethod
def setUpClass(cls):
# Class setup taken from account/tests/test_account_move_in_invoice.py
super().setUpClass()
cls.other_currency = cls.setup_other_currency("EUR")
cls.invoice = cls.init_invoice(
"in_invoice", products=cls.product_a + cls.product_b
)
cls.product_line_vals_1 = {
"name": "product_a",
"product_id": cls.product_a.id,
"account_id": cls.product_a.property_account_expense_id.id,
"partner_id": cls.partner_a.id,
"product_uom_id": cls.product_a.uom_id.id,
"quantity": 1.0,
"discount": 0.0,
"price_unit": 800.0,
"price_subtotal": 800.0,
"price_total": 920.0,
"tax_ids": cls.product_a.supplier_taxes_id.ids,
"tax_line_id": False,
"currency_id": cls.company_data["currency"].id,
"amount_currency": 800.0,
"debit": 800.0,
"credit": 0.0,
"date_maturity": False,
}
cls.product_line_vals_2 = {
"name": "product_b",
"product_id": cls.product_b.id,
"account_id": cls.product_b.property_account_expense_id.id,
"partner_id": cls.partner_a.id,
"product_uom_id": cls.product_b.uom_id.id,
"quantity": 1.0,
"discount": 0.0,
"price_unit": 160.0,
"price_subtotal": 160.0,
"price_total": 208.0,
"tax_ids": cls.product_b.supplier_taxes_id.ids,
"tax_line_id": False,
"currency_id": cls.company_data["currency"].id,
"amount_currency": 160.0,
"debit": 160.0,
"credit": 0.0,
"date_maturity": False,
}
cls.tax_line_vals_1 = {
"name": cls.tax_purchase_a.name,
"product_id": False,
"account_id": cls.company_data["default_account_tax_purchase"].id,
"partner_id": cls.partner_a.id,
"product_uom_id": False,
"quantity": False,
"discount": 0.0,
"price_unit": 0.0,
"price_subtotal": 0.0,
"price_total": 0.0,
"tax_ids": [],
"tax_line_id": cls.tax_purchase_a.id,
"currency_id": cls.company_data["currency"].id,
"amount_currency": 144.0,
"debit": 144.0,
"credit": 0.0,
"date_maturity": False,
}
cls.tax_line_vals_2 = {
"name": cls.tax_purchase_b.name,
"product_id": False,
"account_id": cls.company_data["default_account_tax_purchase"].id,
"partner_id": cls.partner_a.id,
"product_uom_id": False,
"quantity": False,
"discount": 0.0,
"price_unit": 0.0,
"price_subtotal": 0.0,
"price_total": 0.0,
"tax_ids": [],
"tax_line_id": cls.tax_purchase_b.id,
"currency_id": cls.company_data["currency"].id,
"amount_currency": 24.0,
"debit": 24.0,
"credit": 0.0,
"date_maturity": False,
}
cls.term_line_vals_1 = {
"name": False,
"product_id": False,
"account_id": cls.company_data["default_account_payable"].id,
"partner_id": cls.partner_a.id,
"product_uom_id": False,
"quantity": False,
"discount": 0.0,
"price_unit": 0.0,
"price_subtotal": 0.0,
"price_total": 0.0,
"tax_ids": [],
"tax_line_id": False,
"currency_id": cls.company_data["currency"].id,
"amount_currency": -1128.0,
"debit": 0.0,
"credit": 1128.0,
"date_maturity": fields.Date.from_string("2019-01-01"),
}
cls.move_vals = {
"partner_id": cls.partner_a.id,
"currency_id": cls.company_data["currency"].id,
"journal_id": cls.company_data["default_journal_purchase"].id,
"date": fields.Date.from_string("2019-01-01"),
"fiscal_position_id": False,
"payment_reference": False,
"invoice_payment_term_id": cls.pay_terms_a.id,
"amount_untaxed": 960.0,
"amount_tax": 168.0,
"amount_total": 1128.0,
}
cls.env.user.groups_id += cls.env.ref("uom.group_uom")
def setUp(self):
super().setUp()
rules = self.env["auditlog.rule"].search([])
rules.unsubscribe()
rules.unlink()
self.rule = self.env["auditlog.rule"].create(
{
"name": __name__,
"model_id": self.env.ref("account.model_account_move_line").id,
"log_read": True,
"log_create": True,
"log_write": True,
"log_unlink": True,
"log_type": "full",
}
)
self.rule.subscribe()
def test_in_invoice_create_refund(self):
"""Test creating a refund from a vendor bill.
If auditlog does not carefully separate the main transaction cache from
the cache that it uses to fetch the logged values, this test would fail
on the loss of values related to the dynamic syncing of invoice and
journal entry lines.
"""
self.invoice.action_post()
move_reversal = (
self.env["account.move.reversal"]
.with_context(active_model="account.move", active_ids=self.invoice.ids)
.create(
{
"date": fields.Date.from_string("2019-02-01"),
"reason": "no reason",
"journal_id": self.invoice.journal_id.id,
}
)
)
move_reversal.refund_moves()

View File

@@ -0,0 +1,72 @@
from odoo import fields
from odoo.tests import tagged
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.addons.auditlog.tests.common import AuditLogRuleCommon
@tagged("post_install", "-at_install")
class TestProductTaxMulticompany(AccountTestInvoicingCommon, AuditLogRuleCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.company1 = cls.company_data["company"]
cls.tax1 = cls.company_data["default_tax_sale"]
cls.company_data_2 = cls.setup_other_company()
cls.company2 = cls.company_data_2["company"]
cls.tax2 = cls.company_data_2["default_tax_sale"]
cls.product_a.sudo().taxes_id = cls.tax1 + cls.tax2
cls.env.user.company_ids = cls.company1
def setUp(self):
super().setUp()
rules = self.env["auditlog.rule"].search([])
rules.unsubscribe()
rules.unlink()
self.rule = self.env["auditlog.rule"].create(
{
"name": __name__,
"model_id": self.env.ref("product.model_product_template").id,
"log_read": True,
"log_create": True,
"log_write": True,
"log_unlink": True,
"log_type": "full",
}
)
self.rule.subscribe()
def test_cache_accesserror(self):
"""No AccessError occurs reading the product after writing taxes.
The current user only has access to one of the taxes assigned to the
product. If auditlog does sanitize the cache after fetching old and
new values for the log lines, the other company's tax may remain in the
product's cache which will raise an AccessError when it is read.
"""
product = self.product_a.product_tmpl_id
product.write(
{"taxes_id": [fields.Command.unlink(self.tax1.id)]},
)
self.tax1.invalidate_model()
product.read(["taxes_id"])
def test_product_tax_multicompany_result(self):
"""The value from the other company is preserved"""
product = self.product_a.product_tmpl_id
product.write(
{"taxes_id": [fields.Command.unlink(self.tax1.id)]},
)
self.assertFalse(product.taxes_id)
product.invalidate_recordset()
self.assertEqual(product.sudo().taxes_id, self.tax2)
def test_product_tax_multicompany_log(self):
"""The log covers the taxes across all companies."""
product = self.product_a.product_tmpl_id
product.write(
{"taxes_id": [fields.Command.unlink(self.tax1.id)]},
)
log = self.env["auditlog.log"].search([], order="id desc", limit=1)
self.assertEqual(log.line_ids.old_value, f"[{self.tax1.id}, {self.tax2.id}]")
self.assertEqual(log.line_ids.new_value, f"[{self.tax2.id}]")