19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:30:07 +01:00
parent ba20ce7443
commit 768b70e05e
2357 changed files with 1057103 additions and 712486 deletions

View file

@ -3,8 +3,7 @@
from lxml import etree
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.tests.common import Form
from odoo.tests import tagged
from odoo.tests import Form, tagged
from odoo import fields, Command
from collections import defaultdict
@ -14,13 +13,14 @@ from collections import defaultdict
class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
def setUpClass(cls):
super().setUpClass()
cls.other_currency = cls.setup_other_currency('EUR')
cls.invoice = cls.init_invoice('in_refund', products=cls.product_a+cls.product_b)
cls.product_line_vals_1 = {
'name': cls.product_a.name,
'product_id': cls.product_a.id,
'account_id': cls.product_a.property_account_expense_id.id,
'partner_id': cls.partner_a.id,
@ -39,7 +39,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'date_maturity': False,
}
cls.product_line_vals_2 = {
'name': cls.product_b.name,
'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,
@ -96,7 +96,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'date_maturity': False,
}
cls.term_line_vals_1 = {
'name': '',
'name': False,
'product_id': False,
'account_id': cls.company_data['default_account_payable'].id,
'partner_id': cls.partner_a.id,
@ -120,13 +120,16 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'journal_id': cls.company_data['default_journal_purchase'].id,
'invoice_date': fields.Date.from_string('2019-01-01'),
'fiscal_position_id': False,
'payment_reference': '',
'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.tax_armageddon + cls.tax_armageddon.children_tax_ids).write({'type_tax_use': 'purchase'})
@classmethod
def setup_armageddon_tax(cls, tax_name, company_data, **kwargs):
return super().setup_armageddon_tax(tax_name, company_data, type_tax_use='purchase', **kwargs)
def setUp(self):
super(TestAccountMoveInRefundOnchanges, self).setUp()
@ -147,7 +150,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
self.assertInvoiceValues(self.invoice, [
{
**self.product_line_vals_1,
'name': self.product_b.name,
'name': 'product_b',
'product_id': self.product_b.id,
'product_uom_id': self.product_b.uom_id.id,
'account_id': self.product_b.property_account_expense_id.id,
@ -266,7 +269,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
},
{
**self.term_line_vals_1,
'name': 'turlututu',
'name': 'turlututu installment #1',
'partner_id': self.partner_b.id,
'account_id': self.partner_b.property_account_payable_id.id,
'amount_currency': 338.4,
@ -274,7 +277,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
},
{
**self.term_line_vals_1,
'name': 'turlututu',
'name': 'turlututu installment #2',
'partner_id': self.partner_b.id,
'account_id': self.partner_b.property_account_payable_id.id,
'amount_currency': 789.6,
@ -323,7 +326,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
},
{
**self.term_line_vals_1,
'name': 'turlututu',
'name': 'turlututu installment #1',
'account_id': self.partner_b.property_account_payable_id.id,
'partner_id': self.partner_b.id,
'amount_currency': 331.2,
@ -331,7 +334,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
},
{
**self.term_line_vals_1,
'name': 'turlututu',
'name': 'turlututu installment #2',
'account_id': self.partner_b.property_account_payable_id.id,
'partner_id': self.partner_b.id,
'amount_currency': 772.8,
@ -444,7 +447,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
def test_in_refund_line_onchange_cash_rounding_1(self):
# Required for `invoice_cash_rounding_id` to be visible in the view
self.env.user.groups_id += self.env.ref('account.group_cash_rounding')
self.env.user.group_ids += self.env.ref('account.group_cash_rounding')
# Test 'add_invoice_line' rounding
move_form = Form(self.invoice)
# Add a cash rounding having 'add_invoice_line'.
@ -602,44 +605,46 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
})
def test_in_refund_line_onchange_currency_1(self):
self.other_currency.rounding = 0.001
move_form = Form(self.invoice)
move_form.currency_id = self.currency_data['currency']
move_form.currency_id = self.other_currency
move_form.save()
self.assertInvoiceValues(self.invoice, [
{
**self.product_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -800.0,
'credit': 400.0,
},
{
**self.product_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -160.0,
'credit': 80.0,
},
{
**self.tax_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -144.0,
'credit': 72.0,
},
{
**self.tax_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -24.0,
'credit': 12.0,
},
{
**self.term_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': 1128.0,
'debit': 564.0,
},
], {
**self.move_vals,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
})
# Change the date to get another rate: 1/3 instead of 1/2.
@ -650,38 +655,38 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
self.assertInvoiceValues(self.invoice, [
{
**self.product_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -800.0,
'credit': 266.67,
},
{
**self.product_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -160.0,
'credit': 53.33,
},
{
**self.tax_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -144.0,
'credit': 48.0,
},
{
**self.tax_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -24.0,
'credit': 8.0,
},
{
**self.term_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': 1128.0,
'debit': 376.0,
'date_maturity': fields.Date.from_string('2016-01-01'),
},
], {
**self.move_vals,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'date': fields.Date.from_string('2016-01-01'),
'invoice_date': fields.Date.from_string('2016-01-01'),
})
@ -698,41 +703,41 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
{
**self.product_line_vals_1,
'quantity': 0.1,
'price_unit': 0.05,
'price_unit': 0.045,
'price_subtotal': 0.005,
'price_total': 0.006,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -0.005,
'credit': 0.0,
},
{
**self.product_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -160.0,
'credit': 53.33,
},
{
**self.tax_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -24.001,
'credit': 8.0,
},
{
**self.tax_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -24.0,
'credit': 8.0,
},
{
**self.term_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': 208.006,
'debit': 69.33,
'date_maturity': fields.Date.from_string('2016-01-01'),
},
], {
**self.move_vals,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'date': fields.Date.from_string('2016-01-01'),
'invoice_date': fields.Date.from_string('2016-01-01'),
'amount_untaxed': 160.005,
@ -749,11 +754,11 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
{
**self.product_line_vals_1,
'quantity': 0.1,
'price_unit': 0.05,
'price_subtotal': 0.01,
'price_total': 0.01,
'amount_currency': -0.01,
'credit': 0.01,
'price_unit': 0.045,
'price_subtotal': 0.0,
'price_total': 0.0,
'amount_currency': -0.0,
'credit': 0.0,
},
self.product_line_vals_2,
{
@ -764,8 +769,8 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
self.tax_line_vals_2,
{
**self.term_line_vals_1,
'amount_currency': 208.01,
'debit': 208.01,
'amount_currency': 208.0,
'debit': 208.0,
'date_maturity': fields.Date.from_string('2016-01-01'),
},
], {
@ -773,9 +778,9 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'currency_id': self.company_data['currency'].id,
'date': fields.Date.from_string('2016-01-01'),
'invoice_date': fields.Date.from_string('2016-01-01'),
'amount_untaxed': 160.01,
'amount_untaxed': 160.0,
'amount_tax': 48.0,
'amount_total': 208.01,
'amount_total': 208.0,
})
def test_in_refund_onchange_past_invoice_1(self):
@ -784,15 +789,15 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
# `purchase` adds a view which makes `invoice_vendor_bill_id` invisible
# for purchase users
# https://github.com/odoo/odoo/blob/385884afd31f25d61e99d139ecd4c574d99a1863/addons/purchase/views/account_move_views.xml#L26
self.env.user.groups_id -= self.env.ref('purchase.group_purchase_manager')
self.env.user.groups_id -= self.env.ref('purchase.group_purchase_user')
# 'invisible': ['|', ('state', '!=', 'draft'), ('move_type', '!=', 'in_invoice')]
self.env.user.group_ids -= self.env.ref('purchase.group_purchase_manager')
self.env.user.group_ids -= self.env.ref('purchase.group_purchase_user')
# invisible="state != 'draft' or move_type != 'in_invoice'"
# This is an in_refund invoice, `invoice_vendor_bill_id` is not supposed to be visible
# and therefore not supposed to be changed.
view = self.env.ref('account.view_move_form')
tree = etree.fromstring(view.arch)
for node in tree.xpath('//field[@name="invoice_vendor_bill_id"]'):
del node.attrib['attrs']
del node.attrib['invisible']
view.arch = etree.tostring(tree)
move_form = Form(self.invoice)
@ -815,7 +820,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'move_type': 'in_refund',
'partner_id': self.partner_a.id,
'invoice_date': fields.Date.from_string('2019-01-01'),
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'invoice_payment_term_id': self.pay_terms_a.id,
'invoice_line_ids': [
Command.create({
@ -836,37 +841,37 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
self.assertInvoiceValues(move, [
{
**self.product_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -800.0,
'credit': 400.0,
},
{
**self.product_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -160.0,
'credit': 80.0,
},
{
**self.tax_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -144.0,
'credit': 72.0,
},
{
**self.tax_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -24.0,
'credit': 12.0,
},
{
**self.term_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': 1128.0,
'debit': 564.0,
},
], {
**self.move_vals,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
})
def test_in_refund_write_1(self):
@ -875,7 +880,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'move_type': 'in_refund',
'partner_id': self.partner_a.id,
'invoice_date': fields.Date.from_string('2019-01-01'),
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'invoice_payment_term_id': self.pay_terms_a.id,
'invoice_line_ids': [
Command.create({
@ -900,37 +905,37 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
self.assertInvoiceValues(move, [
{
**self.product_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -800.0,
'credit': 400.0,
},
{
**self.product_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -160.0,
'credit': 80.0,
},
{
**self.tax_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -144.0,
'credit': 72.0,
},
{
**self.tax_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -24.0,
'credit': 12.0,
},
{
**self.term_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': 1128.0,
'debit': 564.0,
},
], {
**self.move_vals,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
})
def test_in_refund_create_storno(self):
@ -942,7 +947,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'move_type': 'in_refund',
'partner_id': self.partner_a.id,
'invoice_date': fields.Date.from_string('2019-01-01'),
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'invoice_payment_term_id': self.pay_terms_a.id,
'invoice_line_ids': [
Command.create({
@ -963,7 +968,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
self.assertInvoiceValues(move, [
{
**self.product_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -800.0,
'balance': -400.0,
'debit': -400.0,
@ -971,7 +976,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
},
{
**self.product_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -160.0,
'balance': -80.0,
'debit': -80.0,
@ -979,7 +984,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
},
{
**self.tax_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -144.0,
'balance': -72.0,
'debit': -72.0,
@ -987,7 +992,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
},
{
**self.tax_line_vals_2,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': -24.0,
'balance': -12.0,
'debit': -12.0,
@ -995,7 +1000,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
},
{
**self.term_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
'amount_currency': 1128.0,
'balance': 564.0,
'debit': 0.0,
@ -1003,7 +1008,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
},
], {
**self.move_vals,
'currency_id': self.currency_data['currency'].id,
'currency_id': self.other_currency.id,
})
def test_in_refund_reverse_caba(self):
@ -1012,19 +1017,16 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'code': 'TWAIT',
'account_type': 'liability_current',
'reconcile': True,
'company_id': self.company_data['company'].id,
})
tax_final_account = self.env['account.account'].create({
'name': 'TAX_TO_DEDUCT',
'code': 'TDEDUCT',
'account_type': 'asset_current',
'company_id': self.company_data['company'].id,
})
tax_base_amount_account = self.env['account.account'].create({
'name': 'TAX_BASE',
'code': 'TBASE',
'account_type': 'asset_current',
'company_id': self.company_data['company'].id,
})
self.env.company.account_cash_basis_base_account_id = tax_base_amount_account
self.env.company.tax_exigibility = True
@ -1138,20 +1140,17 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'code': 'TWAIT',
'account_type': 'liability_current',
'reconcile': True,
'company_id': self.company_data['company'].id,
})
tax_final_account = self.env['account.account'].create({
'name': 'TAX_TO_DEDUCT',
'code': 'TDEDUCT',
'account_type': 'asset_current',
'company_id': self.company_data['company'].id,
})
default_expense_account = self.company_data['default_account_expense']
not_default_expense_account = self.env['account.account'].create({
'name': 'NOT_DEFAULT_EXPENSE',
'code': 'NDE',
'account_type': 'expense',
'company_id': self.company_data['company'].id,
})
self.env.company.tax_exigibility = True
tax_tags = defaultdict(dict)
@ -1218,7 +1217,6 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
# check caba move
partial_rec = invoice.mapped('line_ids.matched_credit_ids')
caba_move = self.env['account.move'].search([('tax_cash_basis_rec_id', '=', partial_rec.id)])
# all amls with tax_tag should all have tax_tag_invert at True since the caba move comes from a vendor refund
expected_values = [
{
'tax_line_id': False,
@ -1228,7 +1226,6 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'account_id': not_default_expense_account.id,
'debit': 800.0,
'credit': 0.0,
'tax_tag_invert': False,
},
{
'tax_line_id': False,
@ -1238,7 +1235,6 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'account_id': not_default_expense_account.id,
'debit': 0.0,
'credit': 800.0,
'tax_tag_invert': True,
},
{
'tax_line_id': False,
@ -1248,7 +1244,6 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'account_id': default_expense_account.id,
'debit': 0.0,
'credit': 300.0,
'tax_tag_invert': False,
},
{
'tax_line_id': False,
@ -1258,7 +1253,6 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'account_id': default_expense_account.id,
'debit': 300.0,
'credit': 0.0,
'tax_tag_invert': True,
},
{
'tax_line_id': False,
@ -1268,7 +1262,6 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'account_id': tax_waiting_account.id,
'debit': 50.0,
'credit': 0.0,
'tax_tag_invert': False,
},
{
'tax_line_id': tax.id,
@ -1278,7 +1271,6 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
'account_id': tax_final_account.id,
'debit': 0.0,
'credit': 50.0,
'tax_tag_invert': True,
},
]
self.assertRecordValues(caba_move.line_ids, expected_values)