[IMP] account: soft post entries in the future

Add an easy way to not post the entries in the future when calling
post() on it, but rather set it to be auto-posted at accounting date.
This is useful when we are creating a lot of entries in batch and some
might be in the future, some in the past, and we don't want to separate
that in two batch every time. (asset, accrual, transfer,... )
This commit is contained in:
william
2020-08-05 11:57:10 +00:00
parent 276ba8e90c
commit 82dc0cb7b9
80 changed files with 319 additions and 284 deletions
@@ -391,7 +391,7 @@ class AccountBankStatement(models.Model):
statement._set_next_sequence()
self.write({'state': 'posted'})
self.line_ids.move_id.post()
self.line_ids.move_id._post(soft=False)
def button_validate(self):
if any(statement.state != 'posted' or not statement.all_lines_reconciled for statement in self):
+47 -20
View File
@@ -2,11 +2,10 @@
from odoo import api, fields, models, _
from odoo.exceptions import RedirectWarning, UserError, ValidationError, AccessError
from odoo.tools import float_is_zero, float_repr, float_compare, date_utils, email_split, email_escape_char, email_re
from odoo.tools import float_compare, date_utils, email_split, email_re
from odoo.tools.misc import formatLang, format_date, get_lang
from datetime import date, timedelta
from itertools import groupby
from itertools import zip_longest
from hashlib import sha256
from json import dumps
@@ -14,6 +13,7 @@ from json import dumps
import ast
import json
import re
import warnings
#forbidden fields
INTEGRITY_HASH_MOVE_FIELDS = ('date', 'journal_id', 'company_id')
@@ -228,7 +228,7 @@ class AccountMove(models.Model):
help="The journal entry from which this tax cash basis journal entry has been created.")
# ==== Auto-post feature fields ====
auto_post = fields.Boolean(string='Post Automatically', default=False,
auto_post = fields.Boolean(string='Post Automatically', default=False, copy=False,
help='If this checkbox is ticked, this entry will be automatically posted at its date.')
# ==== Reverse feature fields ====
@@ -2226,7 +2226,7 @@ class AccountMove(models.Model):
# Reconcile moves together to cancel the previous one.
if cancel:
reverse_moves.with_context(move_reverse_cancel=cancel).post()
reverse_moves.with_context(move_reverse_cancel=cancel)._post(soft=False)
for move, reverse_move in zip(self, reverse_moves):
accounts = move.mapped('line_ids.account_id') \
.filtered(lambda account: account.reconcile or account.internal_type == 'liquidity')
@@ -2288,10 +2288,40 @@ class AccountMove(models.Model):
return move
def post(self):
warnings.warn(
"RedirectWarning method 'post()' is a deprecated alias to 'action_post()' or _post()",
DeprecationWarning
)
return self.action_post()
def _post(self, soft=True):
"""Post/Validate the documents.
Posting the documents will give it a number, and check that the document is
complete (some fields might not be required if not posted but are required
otherwise).
If the journal is locked with a hash table, it will be impossible to change
some fields afterwards.
:param soft (bool): if True, future documents are not immediately posted,
but are set to be auto posted automatically at the set accounting date.
Nothing will be performed on those documents before the accounting date.
:return Model<account.move>: the documents that have been posted
"""
if soft:
future_moves = self.filtered(lambda move: move.date > fields.Date.today())
future_moves.auto_post = True
for move in future_moves:
msg = _('This move will be posted at the accounting date: %(date)s', date=format_date(self.env, move.date))
move.message_post(body=msg)
to_post = self - future_moves
else:
to_post = self
# `user_has_group` won't be bypassed by `sudo()` since it doesn't change the user anymore.
if not self.env.su and not self.env.user.has_group('account.group_account_invoice'):
raise AccessError(_("You don't have the access rights to post an invoice."))
for move in self:
for move in to_post:
if not move.line_ids.filtered(lambda line: not line.display_type):
raise UserError(_('You need to add a line before posting.'))
if move.auto_post and move.date > fields.Date.today():
@@ -2323,16 +2353,13 @@ class AccountMove(models.Model):
move.with_context(check_move_validity=False)._onchange_currency()
# Create the analytic lines in batch is faster as it leads to less cache invalidation.
self.mapped('line_ids').create_analytic_lines()
self.write({
to_post.mapped('line_ids').create_analytic_lines()
to_post.write({
'state': 'posted',
'posted_before': True,
})
for move in self:
if move.auto_post and move.date > fields.Date.today():
raise UserError(_("This move is configured to be auto-posted on %s", move.date.strftime(get_lang(self.env).date_format)))
for move in to_post:
move.message_subscribe([p.id for p in [move.partner_id] if p not in move.sudo().message_partner_ids])
# Compute 'ref' for 'out_invoice'.
@@ -2345,7 +2372,7 @@ class AccountMove(models.Model):
to_write['line_ids'].append((1, line.id, {'name': to_write['payment_reference']}))
move.write(to_write)
for move in self:
for move in to_post:
if move.is_sale_document() \
and move.journal_id.sale_activity_type_id \
and (move.journal_id.sale_activity_user_id or move.invoice_user_id).id not in (self.env.ref('base.user_root').id, False):
@@ -2356,21 +2383,21 @@ class AccountMove(models.Model):
user_id=move.journal_id.sale_activity_user_id.id or move.invoice_user_id.id,
)
for move in self:
for move in to_post:
if move.is_sale_document():
move.partner_id._increase_rank('customer_rank')
elif move.is_purchase_document():
move.partner_id._increase_rank('supplier_rank')
# Trigger action for paid invoices in amount is zero
self.filtered(
to_post.filtered(
lambda m: m.is_invoice(include_receipts=True) and m.currency_id.is_zero(m.amount_total)
).action_invoice_paid()
# Force balance check since nothing prevents another module to create an incorrect entry.
# This is performed at the very end to avoid flushing fields before the whole processing.
self._check_balanced()
return True
to_post._check_balanced()
return to_post
def _auto_compute_invoice_reference(self):
''' Hook to be overridden to set custom conditions for auto-computed invoice references.
@@ -2389,7 +2416,7 @@ class AccountMove(models.Model):
return action
def action_post(self):
return self.post()
return self._post(soft=False)
def js_assign_outstanding_line(self, line_id):
''' Called by the 'payment' widget to reconcile a suggested journal item to the present
@@ -2629,7 +2656,7 @@ class AccountMove(models.Model):
('date', '<=', fields.Date.today()),
('auto_post', '=', True),
])
records.post()
records._post()
# offer the possibility to duplicate thanks to a button instead of a hidden menu, which is more visible
def action_duplicate(self):
@@ -4374,7 +4401,7 @@ class AccountMoveLine(models.Model):
involved_partials += exchange_diff_partials
results['partials'] += exchange_diff_partials
exchange_move.post()
exchange_move._post(soft=False)
# ==== Create the full reconcile ====
@@ -4477,7 +4504,7 @@ class AccountMoveLine(models.Model):
#post all the writeoff moves at once
if writeoff_moves:
writeoff_moves.post()
writeoff_moves._post()
# Return the writeoff move.line which is to be reconciled
return line_to_reconcile
@@ -597,7 +597,7 @@ class AccountPartialReconcile(models.Model):
moves_to_create.append(move_vals)
moves = self.env['account.move'].create(moves_to_create)
moves.post()
moves._post(soft=False)
# Reconcile the tax lines being on a reconcile tax basis transfer account.
for line, move_index, sequence in to_reconcile_after:
+1 -1
View File
@@ -717,7 +717,7 @@ class AccountPayment(models.Model):
def action_post(self):
''' draft -> posted '''
self.move_id.post()
self.move_id._post(soft=False)
def action_cancel(self):
''' draft -> cancelled '''
+1 -1
View File
@@ -532,7 +532,7 @@ class TestAccountReconciliationCommon(AccountTestInvoicingCommon):
invoice = self.env['account.move'].with_context(default_move_type=type).create(invoice_vals)
if auto_validate:
invoice.post()
invoice.action_post()
return invoice
def create_invoice(self, type='out_invoice', invoice_amount=50, currency_id=None):
+2 -2
View File
@@ -52,7 +52,7 @@ class TestAccountAccount(AccountTestInvoicingCommon):
}),
],
})
move.post()
move.action_post()
self.assertRecordValues(move.line_ids, [
{'reconciled': False, 'amount_residual': 0.0, 'amount_residual_currency': 0.0},
@@ -115,7 +115,7 @@ class TestAccountAccount(AccountTestInvoicingCommon):
}),
],
})
move.post()
move.action_post()
# Set the account as reconcile and partially reconcile something.
account.reconcile = True
@@ -761,7 +761,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
# You can't set the journal entry in an unconsistent state.
with self.assertRaises(UserError), self.cr.savepoint():
st_line.move_id.post()
st_line.move_id.action_post()
def test_statement_line_move_onchange_1(self):
''' Test the consistency between the account.bank.statement.line and the generated account.move.lines
@@ -935,7 +935,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
],
},
])
test_invoices.post()
test_invoices.action_post()
statement.button_post()
counterpart_lines = test_invoices.mapped('line_ids').filtered(lambda line: line.account_internal_type in ('receivable', 'payable'))
@@ -1198,7 +1198,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
}),
]
})
test_move.post()
test_move.action_post()
test_line_1 = test_move.line_ids.filtered(lambda line: line.account_id == receivable_acc_1)
test_line_2 = test_move.line_ids.filtered(lambda line: line.account_id == receivable_acc_2)
@@ -1403,7 +1403,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
}),
]
})
test_move.post()
test_move.action_post()
test_line_1 = test_move.line_ids.filtered(lambda line: line.name == 'test line 1')
test_line_2 = test_move.line_ids.filtered(lambda line: line.name == 'test line 2')
@@ -49,7 +49,7 @@ class TestAccountJournalDashboard(AccountTestInvoicingCommon):
self.assertIn('0.00', dashboard_data['sum_waiting'])
# Check Both
invoice.post()
invoice.action_post()
dashboard_data = journal.get_journal_dashboard_datas()
self.assertEqual(dashboard_data['number_draft'], 1)
@@ -59,7 +59,7 @@ class TestAccountJournalDashboard(AccountTestInvoicingCommon):
self.assertIn('81.72', dashboard_data['sum_waiting'])
# Check waiting payment
refund.post()
refund.action_post()
dashboard_data = journal.get_journal_dashboard_datas()
self.assertEqual(dashboard_data['number_draft'], 0)
+21 -21
View File
@@ -69,7 +69,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
self.test_move.line_ids[0].account_id = custom_account
def test_misc_fiscalyear_lock_date_1(self):
self.test_move.post()
self.test_move.action_post()
# Set the lock date after the journal entry date.
self.test_move.company_id.fiscalyear_lock_date = fields.Date.from_string('2017-01-01')
@@ -143,7 +143,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
self.assertEqual(copy_move.date, copy_move.company_id.fiscalyear_lock_date + relativedelta(days=1))
def test_misc_fiscalyear_lock_date_2(self):
self.test_move.post()
self.test_move.action_post()
# Create a bank statement to get a balance in the suspense account.
statement = self.env['account.bank.statement'].create({
@@ -160,7 +160,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
self.test_move.company_id.fiscalyear_lock_date = fields.Date.from_string('2017-01-01')
def test_misc_tax_lock_date_1(self):
self.test_move.post()
self.test_move.action_post()
# Set the tax lock date after the journal entry date.
self.test_move.company_id.tax_lock_date = fields.Date.from_string('2017-01-01')
@@ -249,7 +249,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
copy_move = self.test_move.copy()
# /!\ The date is changed automatically to the next available one during the post.
copy_move.post()
copy_move.action_post()
# You can't change the date to one being in a locked period.
with self.assertRaises(UserError), self.cr.savepoint():
@@ -297,7 +297,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
# lines[1] = 'move 1 counterpart line'
# lines[2] = 'move 1 receivable line'
# lines[3] = 'move 2 counterpart line'
draft_moves.post()
draft_moves.action_post()
lines = draft_moves.mapped('line_ids').sorted('balance')
(lines[0] + lines[2]).reconcile()
@@ -352,23 +352,23 @@ class TestAccountMove(AccountTestInvoicingCommon):
# We don't recompute user's input when posting
self.test_move.name = 'MyMISC/2020/0000001'
self.test_move.post()
self.test_move.action_post()
self.assertEqual(self.test_move.name, 'MyMISC/2020/0000001')
# Has been posted, and it doesn't change anymore
self.test_move.button_draft()
self.test_move.date = '2020-01-02'
self.test_move.post()
self.test_move.action_post()
self.assertEqual(self.test_move.name, 'MyMISC/2020/0000001')
def test_journal_sequence(self):
self.assertEqual(self.test_move.name, 'MISC/2016/01/0001')
self.test_move.post()
self.test_move.action_post()
self.assertEqual(self.test_move.name, 'MISC/2016/01/0001')
copy1 = self.test_move.copy()
self.assertEqual(copy1.name, '/')
copy1.post()
copy1.action_post()
self.assertEqual(copy1.name, 'MISC/2016/01/0002')
copy2 = self.test_move.copy()
@@ -378,7 +378,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
self.assertEqual(copy2.name, 'MISC2/2016/01/0001')
with Form(copy2) as move_form: # It is editable in the form
move_form.name = 'MyMISC/2099/0001'
copy2.post()
copy2.action_post()
self.assertEqual(copy2.name, 'MyMISC/2099/0001')
copy3 = copy2.copy()
@@ -386,22 +386,22 @@ class TestAccountMove(AccountTestInvoicingCommon):
with self.assertRaises(AssertionError):
with Form(copy2) as move_form: # It is not editable in the form
move_form.name = 'MyMISC/2099/0002'
copy3.post()
copy3.action_post()
self.assertEqual(copy3.name, 'MyMISC/2099/0002')
copy3.name = 'MISC2/2016/00002'
copy4 = copy2.copy()
copy4.post()
copy4.action_post()
self.assertEqual(copy4.name, 'MISC2/2016/00003')
copy5 = copy2.copy()
copy5.date = '2021-02-02'
copy5.post()
copy5.action_post()
self.assertEqual(copy5.name, 'MISC2/2021/00001')
copy5.name = 'N\'importe quoi?'
copy6 = copy5.copy()
copy6.post()
copy6.action_post()
self.assertEqual(copy6.name, 'N\'importe quoi?1')
def test_journal_sequence_format(self):
@@ -428,7 +428,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
next_move_month.date = '2016-04-12'
next_move_year.date = '2017-03-12'
next_moves = (next_move + next_move_month + next_move_year)
next_moves.post()
next_moves.action_post()
for sequence_init, sequence_next, sequence_next_month, sequence_next_year in sequences:
init_move.name = sequence_init
@@ -444,7 +444,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
for c in range(2, 25):
copy = self.test_move.copy()
copy.name = "/"
copy.post()
copy.action_post()
self.assertEqual(copy.name, f"{prefix}{c}")
def test_journal_sequence_multiple_type(self):
@@ -458,7 +458,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
(refund + refund2).move_type = 'out_refund'
all = (entry + entry2 + invoice + invoice2 + refund + refund2)
all.name = False
all.post()
all.action_post()
self.assertEqual(entry.name, 'MISC/2016/01/0002')
self.assertEqual(entry2.name, 'MISC/2016/01/0003')
self.assertEqual(invoice.name, 'INV/2016/01/0001')
@@ -471,7 +471,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
other_moves.unlink() # Do not interfere when trying to get the highest name for new periods
self.test_move.name = '00000876-G 0002/2020'
next = self.test_move.copy()
next.post()
next.action_post()
self.assertEqual(next.name, '00000876-G 0002/2021') # Wait, I didn't want this!
next.journal_id.sequence_override_regex = r'^(?P<seq>\d*)(?P<suffix1>.*?)(?P<year>(\d{4})?)(?P<suffix2>)$'
@@ -481,7 +481,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
next = next = self.test_move.copy()
next.date = "2017-05-02"
next.post()
next.action_post()
self.assertEqual(next.name, '00000001-G 0002/2017')
def test_journal_sequence_ordering(self):
@@ -497,7 +497,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
# that entry is actualy the first one of the period, so it already has a name
# set it to '/' so that it is recomputed at post to be ordered correctly.
copies[0].name = '/'
copies.post()
copies.action_post()
# Ordered by date
self.assertEqual(copies[0].name, 'XMISC/2019/00002')
@@ -565,7 +565,7 @@ class TestAccountMove(AccountTestInvoicingCommon):
partner = self.env['res.partner'].create({'name': 'Belouga'})
move.partner_id = partner
move.post()
move.action_post()
self.assertEqual(move.message_partner_ids, self.env.user.partner_id | existing_partners | partner)
def test_misc_move_onchange(self):
@@ -1112,7 +1112,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon):
], self.move_vals)
def test_in_invoice_create_refund(self):
self.invoice.post()
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'),
@@ -1215,7 +1215,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon):
move_form.currency_id = self.currency_data['currency']
move_form.save()
self.invoice.post()
self.invoice.action_post()
# The currency rate changed from 1/3 to 1/2.
move_reversal = self.env['account.move.reversal'].with_context(active_model="account.move", active_ids=self.invoice.ids).create({
@@ -1651,7 +1651,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon):
}),
]
})
move.post()
move.action_post()
wizard = self.env['account.accrual.accounting.wizard']\
.with_context(active_model='account.move.line', active_ids=move.invoice_line_ids.ids).create({
@@ -1578,7 +1578,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
})
def test_out_invoice_create_refund(self):
self.invoice.post()
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'),
@@ -1682,7 +1682,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
move_form.currency_id = self.currency_data['currency']
move_form.save()
self.invoice.post()
self.invoice.action_post()
# The currency rate changed from 1/3 to 1/2.
move_reversal = self.env['account.move.reversal'].with_context(active_model="account.move", active_ids=self.invoice.ids).create({
@@ -1963,7 +1963,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
],
})
move.post()
move.action_post()
self.assertInvoiceValues(move, [
{
@@ -2064,7 +2064,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
# - As the date changed, the currency rate has changed (1/3 => 1/2).
move.company_id.tax_lock_date = fields.Date.from_string('2016-12-31')
move.post()
move.action_post()
self.assertInvoiceValues(move, [
{
@@ -2328,7 +2328,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
}),
]
})
move.post()
move.action_post()
wizard = self.env['account.accrual.accounting.wizard']\
.with_context(active_model='account.move.line', active_ids=move.invoice_line_ids.ids).create({
@@ -23,7 +23,7 @@ class TestAccountMovePartnerCount(AccountTestInvoicingCommon):
'partner_id': self.partner_a.id,
'invoice_line_ids': [(0, 0, {'name': 'aaaa', 'price_unit': 100.0})],
},
]).post()
]).action_post()
self.assertEqual(self.partner_a.supplier_rank, 1)
self.assertEqual(self.partner_a.customer_rank, 1)
@@ -33,7 +33,7 @@ class TestAccountMovePaymentsWidget(AccountTestInvoicingCommon):
(0, 0, {'debit': 500.0, 'credit': 0.0, 'amount_currency': 0.0, 'currency_id': False, 'account_id': cls.payable_account.id, 'partner_id': cls.partner_a.id}),
],
})
cls.payment_2016_curr_1.post()
cls.payment_2016_curr_1.action_post()
cls.payment_2016_curr_2 = cls.env['account.move'].create({
'date': '2016-01-01',
@@ -42,7 +42,7 @@ class TestAccountMovePaymentsWidget(AccountTestInvoicingCommon):
(0, 0, {'debit': 500.0, 'credit': 0.0, 'amount_currency': 1550.0, 'currency_id': cls.curr_2.id, 'account_id': cls.payable_account.id, 'partner_id': cls.partner_a.id}),
],
})
cls.payment_2016_curr_2.post()
cls.payment_2016_curr_2.action_post()
cls.payment_2017_curr_2 = cls.env['account.move'].create({
'date': '2017-01-01',
@@ -51,7 +51,7 @@ class TestAccountMovePaymentsWidget(AccountTestInvoicingCommon):
(0, 0, {'debit': 500.0, 'credit': 0.0, 'amount_currency': 950.0, 'currency_id': cls.curr_2.id, 'account_id': cls.payable_account.id, 'partner_id': cls.partner_a.id}),
],
})
cls.payment_2017_curr_2.post()
cls.payment_2017_curr_2.action_post()
cls.payment_2016_curr_3 = cls.env['account.move'].create({
'date': '2016-01-01',
@@ -60,7 +60,7 @@ class TestAccountMovePaymentsWidget(AccountTestInvoicingCommon):
(0, 0, {'debit': 500.0, 'credit': 0.0, 'amount_currency': 3050.0, 'currency_id': cls.curr_3.id, 'account_id': cls.payable_account.id, 'partner_id': cls.partner_a.id}),
],
})
cls.payment_2016_curr_3.post()
cls.payment_2016_curr_3.action_post()
cls.payment_2017_curr_3 = cls.env['account.move'].create({
'date': '2017-01-01',
@@ -69,7 +69,7 @@ class TestAccountMovePaymentsWidget(AccountTestInvoicingCommon):
(0, 0, {'debit': 500.0, 'credit': 0.0, 'amount_currency': 1950.0, 'currency_id': cls.curr_3.id, 'account_id': cls.payable_account.id, 'partner_id': cls.partner_a.id}),
],
})
cls.payment_2017_curr_3.post()
cls.payment_2017_curr_3.action_post()
# -------------------------------------------------------------------------
# HELPERS
@@ -123,7 +123,7 @@ class TestAccountMovePaymentsWidget(AccountTestInvoicingCommon):
'currency_id': self.curr_1.id,
'invoice_line_ids': [(0, 0, {'name': '/', 'price_unit': 2500.0})],
})
out_invoice.post()
out_invoice.action_post()
# Vendor bill of 2500.0 in curr_1.
in_invoice = self.env['account.move'].create({
@@ -134,7 +134,7 @@ class TestAccountMovePaymentsWidget(AccountTestInvoicingCommon):
'currency_id': self.curr_1.id,
'invoice_line_ids': [(0, 0, {'name': '/', 'price_unit': 2500.0})],
})
in_invoice.post()
in_invoice.action_post()
expected_amounts = {
self.payment_2016_curr_1.id: 500.0,
@@ -159,7 +159,7 @@ class TestAccountMovePaymentsWidget(AccountTestInvoicingCommon):
'currency_id': self.curr_2.id,
'invoice_line_ids': [(0, 0, {'name': '/', 'price_unit': 7500.0})],
})
out_invoice.post()
out_invoice.action_post()
# Vendor bill of 2500.0 in curr_1.
in_invoice = self.env['account.move'].create({
@@ -170,7 +170,7 @@ class TestAccountMovePaymentsWidget(AccountTestInvoicingCommon):
'currency_id': self.curr_2.id,
'invoice_line_ids': [(0, 0, {'name': '/', 'price_unit': 7500.0})],
})
in_invoice.post()
in_invoice.action_post()
expected_amounts = {
self.payment_2016_curr_1.id: 1500.0,
@@ -240,7 +240,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
(0, 0, {'debit': 0.0, 'credit': 500.0, 'account_id': account_id}),
]
})
move.post()
move.action_post()
line_1 = move.line_ids.filtered(lambda line: line.debit == 1000.0)
line_2 = move.line_ids.filtered(lambda line: line.debit == 200.0)
@@ -344,7 +344,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
}
])
moves.post()
moves.action_post()
line_1 = moves.line_ids.filtered(lambda line: line.debit == 1200.0)
line_2 = moves.line_ids.filtered(lambda line: line.debit == 120.0)
@@ -478,7 +478,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
}
])
moves.post()
moves.action_post()
line_1 = moves.line_ids.filtered(lambda line: line.debit == 1200.0)
line_2 = moves.line_ids.filtered(lambda line: line.debit == 780.0)
@@ -751,7 +751,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
]
})
(cash_basis_move + payment_move).post()
(cash_basis_move + payment_move).action_post()
# Initial amounts by accounts:
@@ -968,7 +968,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
]
})
(cash_basis_move + payment_move).post()
(cash_basis_move + payment_move).action_post()
# Initial amounts by accounts:
@@ -1186,7 +1186,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
]
})
(cash_basis_move + payment_move + end_move).post()
(cash_basis_move + payment_move + end_move).action_post()
self.assertAmountsGroupByAccount([
# Account Balance Amount Currency
@@ -1301,7 +1301,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
]
})
(cash_basis_move + payment_move).post()
(cash_basis_move + payment_move).action_post()
self.assertAmountsGroupByAccount([
# Account Balance Amount Currency
@@ -1399,7 +1399,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
]
})
(invoice_move + payment_move).post()
(invoice_move + payment_move).action_post()
receivable_lines = (invoice_move + payment_move).line_ids\
.filtered(lambda line: line.account_id == self.extra_receivable_account_1)
@@ -1507,7 +1507,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
]
})
(invoice_move + refund_move).post()
(invoice_move + refund_move).action_post()
receivable_lines = (invoice_move + refund_move).line_ids\
.filtered(lambda line: line.account_id == self.extra_receivable_account_1)
@@ -1605,7 +1605,7 @@ class TestAccountMoveReconcile(AccountTestInvoicingCommon):
]
})
(invoice_move + payment_move).post()
(invoice_move + payment_move).action_post()
receivable_lines = (invoice_move + payment_move).line_ids\
.filtered(lambda line: line.account_id == self.extra_receivable_account_1)
+1 -1
View File
@@ -476,7 +476,7 @@ class TestAccountPayment(AccountTestInvoicingCommon):
})
payment.action_post()
invoice.post()
invoice.action_post()
(counterpart_lines + invoice.line_ids.filtered(lambda line: line.account_internal_type == 'receivable'))\
.reconcile()
@@ -51,7 +51,7 @@ class TestAccountPaymentRegister(AccountTestInvoicingCommon):
'currency_id': cls.currency_data['currency'].id,
'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 1000.0})],
})
cls.out_invoice_1.post()
cls.out_invoice_1.action_post()
cls.out_invoice_2 = cls.env['account.move'].create({
'move_type': 'out_invoice',
'date': '2017-01-01',
@@ -60,7 +60,7 @@ class TestAccountPaymentRegister(AccountTestInvoicingCommon):
'currency_id': cls.currency_data['currency'].id,
'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 2000.0})],
})
(cls.out_invoice_1 + cls.out_invoice_2).post()
(cls.out_invoice_1 + cls.out_invoice_2).action_post()
# Vendor bills, in_invoice_1 + in_invoice_2 are sharing the same batch but not in_invoice_3.
cls.in_invoice_1 = cls.env['account.move'].create({
@@ -85,7 +85,7 @@ class TestAccountPaymentRegister(AccountTestInvoicingCommon):
'currency_id': cls.currency_data['currency'].id,
'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 3000.0})],
})
(cls.in_invoice_1 + cls.in_invoice_2 + cls.in_invoice_3).post()
(cls.in_invoice_1 + cls.in_invoice_2 + cls.in_invoice_3).action_post()
def test_register_payment_single_batch_grouped_keep_open_lower_amount(self):
''' Pay 800.0 with 'open' as payment difference handling on two customer invoices (1000 + 2000). '''
+5 -5
View File
@@ -101,7 +101,7 @@ class TestInvoiceTaxes(AccountTestInvoicingCommon):
(121, self.percent_tax_1_incl),
(100, self.percent_tax_2),
])
invoice.post()
invoice.action_post()
self.assertRecordValues(invoice.line_ids.filtered('tax_line_id'), [
{'name': self.percent_tax_1.name, 'tax_base_amount': 100, 'price_unit': 21, 'tax_ids': []},
{'name': self.percent_tax_1_incl.name, 'tax_base_amount': 100, 'price_unit': 21, 'tax_ids': []},
@@ -126,7 +126,7 @@ class TestInvoiceTaxes(AccountTestInvoicingCommon):
(121, self.percent_tax_1_incl + self.percent_tax_2),
(100, self.percent_tax_2),
])
invoice.post()
invoice.action_post()
self.assertRecordValues(invoice.line_ids.filtered('tax_line_id').sorted(lambda x: x.price_unit), [
{'name': self.percent_tax_1_incl.name, 'tax_base_amount': 100, 'price_unit': 21, 'tax_ids': [self.percent_tax_2.id]},
{'name': self.percent_tax_2.name, 'tax_base_amount': 221, 'price_unit': 26.52, 'tax_ids': []},
@@ -150,7 +150,7 @@ class TestInvoiceTaxes(AccountTestInvoicingCommon):
(121, self.group_tax),
(100, self.percent_tax_2),
])
invoice.post()
invoice.action_post()
self.assertRecordValues(invoice.line_ids.filtered('tax_line_id').sorted(lambda x: x.price_unit), [
{'name': self.percent_tax_1_incl.name, 'tax_base_amount': 100, 'price_unit': 21, 'tax_ids': [self.percent_tax_2.id]},
{'name': self.percent_tax_2.name, 'tax_base_amount': 221, 'price_unit': 26.52, 'tax_ids': []},
@@ -224,7 +224,7 @@ class TestInvoiceTaxes(AccountTestInvoicingCommon):
# Test invoice repartition
invoice = self._create_invoice([(100, tax)], inv_type='out_invoice')
invoice.post()
invoice.action_post()
self.assertEqual(len(invoice.line_ids), 4, "There should be 4 account move lines created for the invoice: payable, base and 2 tax lines")
inv_base_line = invoice.line_ids.filtered(lambda x: not x.tax_repartition_line_id and x.account_id.user_type_id.type != 'receivable')
@@ -240,7 +240,7 @@ class TestInvoiceTaxes(AccountTestInvoicingCommon):
# Test refund repartition
refund = self._create_invoice([(100, tax)], inv_type='out_refund')
refund.post()
refund.action_post()
self.assertEqual(len(refund.line_ids), 4, "There should be 4 account move lines created for the refund: payable, base and 2 tax lines")
ref_base_line = refund.line_ids.filtered(lambda x: not x.tax_repartition_line_id and x.account_id.user_type_id.type != 'receivable')
+14 -14
View File
@@ -26,7 +26,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
(0, 0, {'quantity': 1, 'price_unit': 50.0, 'name': 'test'})
],
})
move.post()
move.action_post()
# Create a bank statement of 40 EURO.
bank_stmt = self.env['account.bank.statement'].create({
@@ -94,7 +94,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
})
]
})
invoice.post()
invoice.action_post()
# We create a bank statement with two lines of 1.00 USD each.
statement = self.env['account.bank.statement'].create({
'journal_id': self.bank_journal_usd_id,
@@ -175,7 +175,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
'line_ids': [(0,0, debit_line_vals), (0, 0, credit_line_vals)]
}
move = self.env['account.move'].create(vals)
move.post()
move.action_post()
return move.id
move_list_vals = [
('1', -1.83, 0, self.currency_swiss_id),
@@ -241,7 +241,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
'line_ids': [(0,0, debit_line_vals), (0, 0, credit_line_vals)]
}
move_ids += self.env['account.move'].create(vals)
move_ids.post()
move_ids.action_post()
account_move_line = move_ids.mapped('line_ids').filtered(lambda l: l.account_id == self.account_rcv)
writeoff_vals = [{
@@ -312,7 +312,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
(0, 0, {'product_id': self.product.id, 'quantity': 1, 'price_unit': 50.0})
],
})
(invoice_a + invoice_b).post()
(invoice_a + invoice_b).action_post()
# Preparing Payments
# One partial for invoice_a (fully assigned to it)
@@ -609,7 +609,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
(0, 0, {'quantity': 1, 'price_unit': 100.0, 'name': 'product that cost 100'})
],
})
invoice_cust_1.post()
invoice_cust_1.action_post()
aml = invoice_cust_1.invoice_line_ids[0]
self.assertEqual(aml.credit, 50.0)
#####
@@ -742,7 +742,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
'tax_repartition_line_id': self.tax_cash_basis.invoice_repartition_line_ids.filtered(lambda x: x.repartition_type == 'tax').id,
'tax_base_amount': 100,
})
purchase_move.post()
purchase_move.action_post()
reverse_date = fields.Date.today() + timedelta(days=+7)
revertWidget = self.env['account.move.reversal'].create({
@@ -780,7 +780,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
'credit': 11,
'move_id': general_move1.id,
})
general_move1.post()
general_move1.action_post()
general_move2 = self.env['account.move'].create({
'name': 'general2',
'journal_id': self.general_journal.id,
@@ -797,7 +797,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
'debit': 10,
'move_id': general_move2.id,
})
general_move2.post()
general_move2.action_post()
general_move3 = self.env['account.move'].create({
'name': 'general3',
'journal_id': self.general_journal.id,
@@ -814,7 +814,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
'debit': 1,
'move_id': general_move3.id,
})
general_move3.post()
general_move3.action_post()
to_reconcile = ((general_move1 + general_move2 + general_move3)
.mapped('line_ids')
.filtered(lambda l: l.account_id.id == account_rcv.id))
@@ -866,7 +866,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
]
})
move_balance.post()
move_balance.action_post()
move_balance_receiv = move_balance.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')
(inv1_receivable + inv2_receivable + pay_receivable + move_balance_receiv).reconcile()
@@ -934,7 +934,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
]
})
move_balance.post()
move_balance.action_post()
move_balance_receiv = move_balance.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')
(inv1_receivable + inv2_receivable + pay_receivable + move_balance_receiv).reconcile()
@@ -1015,7 +1015,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
]
})
move_balance.post()
move_balance.action_post()
move_balance_receiv = move_balance.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')
(inv1_receivable + inv2_receivable + pay_receivable + move_balance_receiv).reconcile()
@@ -1331,7 +1331,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon):
(0, False, {'debit': 0.05, 'account_id': self.diff_expense_account.id, 'name': 'Balance WriteOff'}),
]
})
move_balance.post()
move_balance.action_post()
move_balance_receiv = move_balance.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')
(inv1_receivable + payment_receivable + move_balance_receiv).reconcile()
@@ -126,7 +126,7 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
invoice_line_form.price_unit = amount
invoice_line_form.tax_ids.clear()
invoice = invoice_form.save()
invoice.post()
invoice.action_post()
lines = invoice.line_ids
return lines.filtered(lambda l: l.account_id.user_type_id.type in ('receivable', 'payable'))
@@ -420,7 +420,7 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
'credit': 10,
})
move.post()
move.action_post()
move_reversed = move._reverse_moves()
self.assertTrue(move_reversed.exists())
@@ -619,7 +619,7 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
}),
],
})
move.post()
move.action_post()
move_line_1 = move.line_ids.filtered(lambda line: line.debit == 100.0)
move_line_2 = move.line_ids.filtered(lambda line: line.debit == 14.0)
+1 -1
View File
@@ -165,7 +165,7 @@ class TaxReportTest(AccountTestInvoicingCommon):
(0, 0, {'quantity': 1, 'price_unit': 42, 'tax_ids': [(6, 0, test_tax.ids)]}),
],
})
test_invoice.post()
test_invoice.action_post()
self.assertTrue(any(line.tax_tag_ids == self.tax_report_line_1_55.tag_ids[0] for line in test_invoice.line_ids), "The test invoice should contain a tax line with tag 55")
tag_name_before = self.tax_report_line_1_55.tag_name
+2 -2
View File
@@ -122,7 +122,7 @@ class TestTransferWizard(AccountTestInvoicingCommon):
}),
]
})
cls.move_1.post()
cls.move_1.action_post()
cls.move_2 = cls.env['account.move'].create({
'journal_id': cls.journal.id,
@@ -186,7 +186,7 @@ class TestTransferWizard(AccountTestInvoicingCommon):
}),
]
})
cls.move_2.post()
cls.move_2.action_post()
def test_transfer_wizard_reconcile(self):
+7 -3
View File
@@ -486,10 +486,10 @@
<!-- Post -->
<button name="action_post" string="Post" class="oe_highlight"
type="object" groups="account.group_account_invoice"
attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('move_type', '!=', 'entry')]}"/>
attrs="{'invisible': ['|', '|', ('state', '!=', 'draft'), ('auto_post', '=', True), ('move_type', '!=', 'entry')]}"/>
<button name="action_post" string="Validate" class="oe_highlight"
type="object" groups="account.group_account_invoice"
attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('move_type', '=', 'entry')]}"/>
attrs="{'invisible': ['|', '|', ('state', '!=', 'draft'), ('auto_post', '=', True), ('move_type', '=', 'entry')]}"/>
<!-- Send (only invoices) -->
<button name="action_invoice_sent"
type="object"
@@ -542,6 +542,10 @@
attrs="{'invisible': ['|', '|', ('move_type', 'not in', ('in_invoice', 'in_refund')), ('invoice_has_outstanding', '=', False), ('payment_state', 'not in', ('not_paid', 'partial'))]}">
You have <bold><a class="alert-link" href="#outstanding" role="button">outstanding debits</a></bold> for this supplier. You can allocate them to mark this bill as paid.
</div>
<div class="alert alert-info" role="alert" style="margin-bottom:0px;"
attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('auto_post', '=', False)]}">
This move is configured to be posted automatically at the accounting date: <field name="date" readonly="1"/>.
</div>
<sheet>
<div name="button_box" class="oe_button_box">
<button name="open_reconcile_view"
@@ -1023,7 +1027,7 @@
widget="email"
attrs="{'invisible': ['|', ('move_type', 'not in', ('in_invoice', 'in_refund')), ('invoice_source_email', '=', False)]}"/>
<field name="auto_post"
attrs="{'invisible': [('move_type', '!=', 'in_invoice')], 'readonly': ['|',('reversed_entry_id', '!=', False),('state','!=','draft')]}"/>
attrs="{'readonly': ['|',('reversed_entry_id', '!=', False),('state','!=','draft')]}"/>
<field name="to_check"/>
</group>
</group>
@@ -1,4 +1,4 @@
from odoo import models, api, _
from odoo import models, fields, _
from odoo.exceptions import UserError
@@ -6,11 +6,13 @@ class ValidateAccountMove(models.TransientModel):
_name = "validate.account.move"
_description = "Validate Account Move"
force_post = fields.Boolean(string="Force", help="Entries in the future are set to be auto-posted by default. Check this checkbox to post them now.")
def validate_move(self):
context = dict(self._context or {})
moves = self.env['account.move'].browse(context.get('active_ids'))
move_to_post = moves.filtered(lambda m: m.state == 'draft')
if not move_to_post:
raise UserError(_('There are no journal items in the draft state to post.'))
move_to_post.post()
move_to_post._post(not self.force_post)
return {'type': 'ir.actions.act_window_close'}
@@ -8,6 +8,9 @@
<field name="model">validate.account.move</field>
<field name="arch" type="xml">
<form string="Post Journal Entries">
<group>
<field name="force_post"/>
</group>
<span class="o_form_label">All selected journal entries will be validated and posted. You won't be able to modify them afterwards.</span>
<footer>
<button string="Post Journal Entries" name="validate_move" type="object" default_focus="1" class="btn-primary"/>
@@ -56,7 +56,7 @@ class TaxAdjustments(models.TransientModel):
'line_ids': move_line_vals,
}
move = self.env['account.move'].create(vals)
move.post()
move._post()
# Return an action opening the created move
action = self.env.ref(self.env.context.get('action', 'account.action_move_line_form'))
@@ -88,7 +88,7 @@ class AccountPayment(models.Model):
}
}
else:
self.filtered(lambda r: r.state == 'draft').post()
self.filtered(lambda r: r.state == 'draft').action_post()
return self.do_print_checks()
def action_unmark_sent(self):
@@ -39,7 +39,7 @@ class TestPrintCheck(AccountTestInvoicingCommon):
'invoice_date': '2017-01-01',
'invoice_line_ids': [(0, 0, {'product_id': self.product_a.id, 'price_unit': 100.0})]
} for i in range(nb_invoices_to_test)])
out_invoices.post()
out_invoices.action_post()
# Create a single payment.
payment = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=out_invoices.ids).create({
@@ -80,7 +80,7 @@ class TestPrintCheck(AccountTestInvoicingCommon):
'invoice_date': '2017-01-01',
'invoice_line_ids': [(0, 0, {'product_id': self.product_a.id, 'price_unit': 100.0})]
} for i in range(nb_invoices_to_test)])
out_refunds.post()
out_refunds.action_post()
# Create a single payment.
payment = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=out_refunds.ids).create({
@@ -10,7 +10,7 @@ class TestAccountDebitNote(AccountTestInvoicingCommon):
def test_00_debit_note_out_invoice(self):
""" Debit Note of a regular Customer Invoice"""
invoice = self.init_invoice('out_invoice')
invoice.post()
invoice.action_post()
move_debit_note_wiz = self.env['account.debit.note'].with_context(active_model="account.move",
active_ids=invoice.ids).create({
'date': fields.Date.from_string('2019-02-01'),
@@ -29,7 +29,7 @@ class TestAccountDebitNote(AccountTestInvoicingCommon):
def test_10_debit_note_in_refund(self):
""" Debit Note of a vendor refund (is a regular vendor bill) """
invoice = self.init_invoice('in_refund')
invoice.post()
invoice.action_post()
move_debit_note_wiz = self.env['account.debit.note'].with_context(active_model="account.move",
active_ids=invoice.ids).create({
'date': fields.Date.from_string('2019-02-01'),
+4 -4
View File
@@ -9,7 +9,7 @@ class AccountMove(models.Model):
edi_document_ids = fields.One2many('ir.attachment', 'res_id', domain=[('res_model', '=', 'account.move'), ('edi_format_id', '!=', False)])
def post(self):
def _post(self, soft=True):
# OVERRIDE
# Generate the electronic documents for the move.
existing_attachments = self.env['ir.attachment'].search([
@@ -17,11 +17,11 @@ class AccountMove(models.Model):
('res_id', 'in', self.ids),
('edi_format_id', 'in', self.journal_id.edi_format_ids.ids)])
existing_attachments.unlink()
res = super(AccountMove, self).post()
for move in self:
posted = super()._post(soft)
for move in posted:
move.journal_id.edi_format_ids._create_ir_attachments(move)
return res
return posted
@api.returns('mail.message', lambda value: value.id)
def message_post(self, **kwargs):
@@ -157,7 +157,7 @@ class TestAccountEdiFacturx(AccountTestEdiCommon):
def test_facturx(self):
''' Test the generated Facturx Edi attachment without any modification of the invoice. '''
self.invoice.post()
self.invoice.action_post()
xml_content = self.facturx_edi_format._export_invoice_to_attachment(self.invoice)['datas']
current_etree = self.get_xml_tree_from_string(xml_content)
@@ -171,7 +171,7 @@ class TestAccountEdiFacturx(AccountTestEdiCommon):
'invoice_line_ids': [(1, self.invoice.invoice_line_ids.id, {'tax_ids': [(6, 0, self.tax_group.ids)]})],
})
self.invoice.post()
self.invoice.action_post()
xml_content = self.facturx_edi_format._export_invoice_to_attachment(self.invoice)['datas']
current_etree = self.get_xml_tree_from_string(xml_content)
@@ -76,11 +76,11 @@ class StockMoveInvoice(AccountTestInvoicingCommon):
# I confirm the invoice
self.invoice = self.sale_prepaid.invoice_ids
self.invoice.post()
self.invoice.action_post()
# I pay the invoice.
self.invoice = self.sale_prepaid.invoice_ids
self.invoice.post()
self.invoice.action_post()
self.journal = self.AccountJournal.search([('type', '=', 'cash'), ('company_id', '=', self.sale_prepaid.company_id.id)], limit=1)
register_payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=self.invoice.ids).create({
+2 -2
View File
@@ -208,7 +208,7 @@ class HrExpense(models.Model):
if any(attachment.res_id or attachment.res_model != 'hr.expense' for attachment in attachments):
raise UserError(_("Invalid attachments!"))
product = self.env['product.product'].search([('can_be_expensed', '=', True)])
if product:
product = product.filtered(lambda p: p.default_code == "EXP_GEN") or product[0]
@@ -532,7 +532,7 @@ class HrExpense(models.Model):
# post the moves
for move in move_group_by_sheet.values():
move.post()
move._post()
return move_group_by_sheet
+4 -4
View File
@@ -145,7 +145,7 @@ class AccountMove(models.Model):
action = self.env.ref('account.action_account_journal_form')
raise RedirectWarning(msg, action.id, _('Go to Journals'))
def post(self):
def _post(self, soft=True):
ar_invoices = self.filtered(lambda x: x.company_id.country_id == self.env.ref('base.ar') and x.l10n_latam_use_documents)
for rec in ar_invoices:
rec.l10n_ar_afip_responsibility_type_id = rec.commercial_partner_id.l10n_ar_afip_responsibility_type_id.id
@@ -159,9 +159,9 @@ class AccountMove(models.Model):
# We make validations here and not with a constraint because we want validation before sending electronic
# data on l10n_ar_edi
ar_invoices._check_argentinian_invoice_taxes()
res = super().post()
self._set_afip_service_dates()
return res
posted = super()._post(soft)
posted._set_afip_service_dates()
return posted
def _reverse_moves(self, default_values_list=None, cancel=False):
if not default_values_list:
@@ -52,7 +52,7 @@ class ISRTest(AccountTestInvoicingCommon):
'invoice_date': '2019-01-01',
'invoice_line_ids': [(0, 0, {'product_id': self.product_a.id})],
})
invoice_chf.post()
invoice_chf.action_post()
self.assertTrue(self.print_isr(invoice_chf))
invoice_eur = self.env['account.move'].create({
@@ -63,5 +63,5 @@ class ISRTest(AccountTestInvoicingCommon):
'invoice_date': '2019-01-01',
'invoice_line_ids': [(0, 0, {'product_id': self.product_a.id})],
})
invoice_eur.post()
invoice_eur.action_post()
self.assertFalse(self.print_isr(invoice_eur))
+3 -3
View File
@@ -156,7 +156,7 @@ class TestSwissQR(AccountTestInvoicingCommon):
def test_swissQR_missing_bank(self):
# Let us test the generation of a SwissQR for an invoice, first by showing an
# QR is included in the invoice is only generated when Odoo has all the data it needs.
self.invoice1.post()
self.invoice1.action_post()
self.swissqr_not_generated(self.invoice1)
def test_swissQR_iban(self):
@@ -164,7 +164,7 @@ class TestSwissQR(AccountTestInvoicingCommon):
# Here we don't use a structured reference
iban_account = self.create_account(CH_IBAN)
self.invoice1.partner_bank_id = iban_account
self.invoice1.post()
self.invoice1.action_post()
self.swissqr_generated(self.invoice1, ref_type="NON")
def test_swissQR_qriban(self):
@@ -172,5 +172,5 @@ class TestSwissQR(AccountTestInvoicingCommon):
qriban_account = self.create_account(QR_IBAN)
self.assertTrue(qriban_account.acc_type, 'qr-iban')
self.invoice1.partner_bank_id = qriban_account
self.invoice1.post()
self.invoice1.action_post()
self.swissqr_generated(self.invoice1, ref_type="QRR")
+3 -3
View File
@@ -89,9 +89,9 @@ class AccountMove(models.Model):
def _onchange_journal(self):
self.l10n_latam_document_type_id = False
def post(self):
def _post(self, soft=True):
self._check_document_types_post()
super().post()
super()._post(soft)
def _l10n_cl_get_formatted_sequence(self, number=0):
return "%s %06d" % (self.l10n_latam_document_type_id.doc_code_prefix, number)
@@ -113,4 +113,4 @@ class AccountMove(models.Model):
param['journal_ids'] = journals
where_string += " AND l10n_latam_document_type_id = %(l10n_latam_document_type_id)s "
param['l10n_latam_document_type_id'] = self.l10n_latam_document_type_id.id or 0
return where_string, param
return where_string, param
+2 -2
View File
@@ -21,7 +21,7 @@ class AccountTax(models.Model):
class AccountMove(models.Model):
_inherit = 'account.move'
def post(self):
def _post(self, soft=True):
# OVERRIDE to check the invoice lines taxes.
for invoice in self.filtered(lambda move: move.is_invoice()):
for line in invoice.invoice_line_ids:
@@ -32,4 +32,4 @@ class AccountMove(models.Model):
if tax.id not in account_tax:
raise UserError(_('Account %s does not authorize to have tax %s specified on the line. \
Change the tax used in this invoice or remove all taxes from the account') % (account_name, tax.name))
return super(AccountMove, self).post()
return super()._post(soft)
+4 -4
View File
@@ -15,25 +15,25 @@ class InvoiceGetReferenceTest(AccountTestInvoicingCommon):
def test_get_reference_finnish_invoice(self):
self.assertFalse(self.invoice.payment_reference)
self.invoice.journal_id.invoice_reference_model = 'fi'
self.invoice.post()
self.invoice.action_post()
self.assertTrue(self.invoice.payment_reference)
def test_get_reference_finnish_partner(self):
self.assertFalse(self.invoice.payment_reference)
self.invoice.journal_id.invoice_reference_type = 'partner'
self.invoice.journal_id.invoice_reference_model = 'fi'
self.invoice.post()
self.invoice.action_post()
self.assertTrue(self.invoice.payment_reference)
def test_get_reference_finnish_rf_invoice(self):
self.assertFalse(self.invoice.payment_reference)
self.invoice.journal_id.invoice_reference_model = 'fi_rf'
self.invoice.post()
self.invoice.action_post()
self.assertTrue(self.invoice.payment_reference)
def test_get_reference_finnish_rf_partner(self):
self.assertFalse(self.invoice.payment_reference)
self.invoice.journal_id.invoice_reference_type = 'partner'
self.invoice.journal_id.invoice_reference_model = 'fi_rf'
self.invoice.post()
self.invoice.action_post()
self.assertTrue(self.invoice.payment_reference)
@@ -118,7 +118,7 @@
<value name="recompute_tax_base_amount" eval="True"/>
</function>
<function model="account.move" name="post">
<function model="account.move" name="action_post">
<value eval="[
ref('demo_invoice_1'), ref('demo_invoice_2'), ref('demo_invoice_3'),
ref('demo_invoice_followup'), ref('demo_invoice_equipment_purchase'),
@@ -80,7 +80,7 @@ class AccountMove(models.Model):
elif record.l10n_id_tax_number[2] not in ('0', '1'):
raise UserError(_('The third digit of a tax number must be 0 or 1'))
def post(self):
def _post(self, soft=True):
"""Set E-Faktur number after validation."""
for move in self:
if move.l10n_id_need_kode_transaksi:
@@ -96,7 +96,7 @@ class AccountMove(models.Model):
if not efaktur:
raise ValidationError(_('There is no Efaktur number available. Please configure the range you get from the government in the e-Faktur menu. '))
move.l10n_id_tax_number = '%s0%013d' % (str(move.l10n_id_kode_transaksi), efaktur)
return super(AccountMove, self).post()
return super()._post(soft)
def reset_efaktur(self):
"""Reset E-Faktur, so it can be use for other invoice."""
+4 -4
View File
@@ -87,12 +87,12 @@ class AccountMove(models.Model):
"""Overwrite in sale"""
return shipping_partner.vat
def post(self):
def _post(self, soft=True):
"""Use journal type to define document type because not miss state in any entry including POS entry"""
res = super().post()
posted = super()._post(soft)
gst_treatment_name_mapping = {k: v for k, v in
self._fields['l10n_in_gst_treatment']._description_selection(self.env)}
for move in self.filtered(lambda m: m.l10n_in_company_country_code == 'IN'):
for move in posted.filtered(lambda m: m.l10n_in_company_country_code == 'IN'):
"""Check state is set in company/sub-unit"""
company_unit_partner = move.journal_id.l10n_in_gstin_partner_id or move.journal_id.company_id
if not company_unit_partner.state_id:
@@ -120,4 +120,4 @@ class AccountMove(models.Model):
#still state is not set then assumed that transaction is local like PoS so set state of company unit
if not move.l10n_in_state_id:
move.l10n_in_state_id = company_unit_partner.state_id
return res
return posted
+4 -3
View File
@@ -55,12 +55,12 @@ class AccountMove(models.Model):
invoice.l10n_it_einvoice_id = einvoice
invoice.l10n_it_einvoice_name = einvoice.name
def post(self):
def _post(self, soft=True):
# OVERRIDE
super(AccountMove, self).post()
posted = super()._post(soft)
# Retrieve invoices to generate the xml.
invoices_to_export = self.filtered(lambda move:
invoices_to_export = posted.filtered(lambda move:
move.company_id.country_id == self.env.ref('base.it') and
move.is_sale_document() and
move.l10n_it_send_state not in ['sent', 'delivered', 'delivered_accepted'])
@@ -84,6 +84,7 @@ class AccountMove(models.Model):
for invoice in invoices_to_send:
invoice.send_pec_mail()
return posted
def _check_before_xml_exporting(self):
seller = self.company_id
@@ -118,11 +118,11 @@ class AccountMove(models.Model):
remaining.l10n_latam_amount_untaxed = False
remaining.l10n_latam_tax_ids = [(5, 0)]
def post(self):
def _post(self, soft=True):
for rec in self.filtered(lambda x: x.l10n_latam_use_documents and (not x.name or x.name == '/')):
if rec.move_type in ('in_receipt', 'out_receipt'):
raise UserError(_('We do not accept the usage of document types on receipts yet. '))
return super().post()
return super()._post(soft)
@api.constrains('name', 'journal_id', 'state')
def _check_unique_sequence_number(self):
@@ -236,4 +236,3 @@ class AccountMove(models.Model):
]
if rec.search(domain):
raise ValidationError(_('Vendor bill number must be unique per vendor and company.'))
+1 -1
View File
@@ -46,7 +46,7 @@ class TestMembership(TestMembershipCommon):
'membership: new membership should be in waiting state')
# the invoice is open -> customer goes to invoiced status
invoice.post()
invoice.action_post()
self.assertEqual(
self.partner_1.membership_state, 'invoiced',
'membership: after opening the invoice, customer should be in invoiced status')
+2 -2
View File
@@ -674,7 +674,7 @@ class PaymentTransaction(models.Model):
self.payment_id = payment
if self.invoice_ids:
self.invoice_ids.filtered(lambda move: move.state == 'draft').post()
self.invoice_ids.filtered(lambda move: move.state == 'draft')._post()
(payment.line_ids + self.invoice_ids.line_ids)\
.filtered(lambda line: line.account_id == payment.destination_account_id and not line.reconciled)\
@@ -814,7 +814,7 @@ class PaymentTransaction(models.Model):
def _reconcile_after_transaction_done(self):
# Validate invoices automatically upon the transaction is posted.
invoices = self.mapped('invoice_ids').filtered(lambda inv: inv.state == 'draft')
invoices.post()
invoices._post()
# Create & Post the payments.
for trans in self:
+1 -1
View File
@@ -414,7 +414,7 @@ class PosOrder(models.Model):
message = _("This invoice has been created from the point of sale session: <a href=# data-oe-model=pos.order data-oe-id=%d>%s</a>") % (order.id, order.name)
new_move.message_post(body=message)
order.write({'account_move': new_move.id, 'state': 'invoiced'})
new_move.sudo().with_company(order.company_id).post()
new_move.sudo().with_company(order.company_id)._post()
moves += new_move
if not moves:
+1 -1
View File
@@ -369,7 +369,7 @@ class PosSession(models.Model):
data = self._create_stock_output_lines(data)
if account_move.line_ids:
account_move.post()
account_move._post()
data = self._reconcile_account_move_lines(data)
@@ -471,7 +471,7 @@ class TestPointOfSaleFlow(TestPointOfSaleCommon):
# I test that the total of the attached invoice is correct
invoice = self.env['account.move'].browse(res['res_id'])
invoice.post()
invoice.action_post()
self.assertAlmostEqual(
invoice.amount_total, self.pos_order_pos1.amount_total, places=2, msg="Invoice not correct")
@@ -869,7 +869,7 @@ class TestPointOfSaleFlow(TestPointOfSaleCommon):
# I test that the total of the attached invoice is correct
invoice = self.env['account.move'].browse(res['res_id'])
invoice.post()
invoice.action_post()
self.assertAlmostEqual(
invoice.amount_total, self.pos_order_pos1.amount_total, places=2, msg="Invoice not correct")
@@ -21,8 +21,8 @@ class AccountMove(models.Model):
)
return True
def post(self):
def _post(self, soft=True):
# OVERRIDE
res = super(AccountMove, self).post()
self.invoice_validate_send_email()
return res
posted = super()._post(soft)
posted.invoice_validate_send_email()
return posted
@@ -40,7 +40,7 @@ class TestProductMargin(AccountTestInvoicingCommon):
'invoice_line_ids': [(0, 0, {'product_id': ipad.id, 'quantity': 10.0, 'price_unit': 550.0})],
},
])
invoices.post()
invoices.action_post()
result = ipad._compute_product_margin_fields_values()
+1 -1
View File
@@ -66,7 +66,7 @@ class TestPurchaseInvoice(AccountTestInvoicingCommon):
purchase_order.action_create_invoice()
invoice = purchase_order.invoice_ids
with self.assertRaises(AccessError):
invoice.post()
invoice.action_post()
def test_read_purchase_order(self):
""" Check that a purchase user can read all purchase order and 'in' invoices"""
@@ -42,7 +42,7 @@ class TestPurchaseOrderReport(AccountTestInvoicingCommon):
f.partner_id = po.partner_id
f.purchase_id = po
invoice = f.save()
invoice.post()
invoice.action_post()
po.flush()
res_product1 = self.env['purchase.report'].search([
@@ -159,13 +159,13 @@ class AccountMove(models.Model):
lines_vals_list.append(vals)
return lines_vals_list
def post(self):
def _post(self, soft=True):
# OVERRIDE
# Create additional price difference lines for vendor bills.
if self._context.get('move_reverse_cancel'):
return super(AccountMove, self).post()
return super()._post(soft)
self.env['account.move.line'].create(self._stock_account_prepare_anglo_saxon_in_lines_vals())
return super(AccountMove, self).post()
return super()._post(soft)
def _stock_account_get_last_step_stock_moves(self):
""" Overridden from stock_account.
@@ -10,7 +10,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.stock_account_product_categ.property_account_creditor_price_difference_categ = cls.company_data['default_account_stock_price_diff']
@classmethod
@@ -65,7 +65,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon):
self._process_pickings(purchase_order.picking_ids, date=date_po_and_delivery)
invoice = self._create_invoice_for_po(purchase_order, '2018-02-02')
invoice.post()
invoice.action_post()
picking = self.env['stock.picking'].search([('purchase_id','=',purchase_order.id)])
self.check_reconciliation(invoice, picking)
# cancel the invoice
@@ -85,7 +85,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon):
invoice = move_form.save()
# Validate the invoice and refund the goods
invoice.post()
invoice.action_post()
self._process_pickings(purchase_order.picking_ids, date='2017-12-24')
picking = self.env['stock.picking'].search([('purchase_id', '=', purchase_order.id)])
self.check_reconciliation(invoice, picking)
@@ -130,7 +130,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon):
with move_form.invoice_line_ids.edit(0) as line_form:
line_form.quantity = 3.0
invoice = move_form.save()
invoice.post()
invoice.action_post()
self.check_reconciliation(invoice, picking, full_reconcile=False)
invoice2 = self._create_invoice_for_po(purchase_order, '2017-02-15')
@@ -138,7 +138,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon):
with move_form.invoice_line_ids.edit(0) as line_form:
line_form.quantity = 2.0
invoice2 = move_form.save()
invoice2.post()
invoice2.action_post()
self.check_reconciliation(invoice2, picking, full_reconcile=False)
# We don't need to make the date of processing explicit since the very last rate
@@ -109,7 +109,7 @@ class TestPurchaseOrder(ValuationReconciliationTestCommon):
move_form.partner_id = self.partner_a
move_form.purchase_id = self.po
self.invoice = move_form.save()
self.invoice.post()
self.invoice.action_post()
self.assertEqual(self.po.order_line.mapped('qty_invoiced'), [5.0, 5.0], 'Purchase: all products should be invoiced"')
@@ -145,7 +145,7 @@ class TestPurchaseOrder(ValuationReconciliationTestCommon):
with move_form.invoice_line_ids.edit(1) as line_form:
line_form.quantity = 2.0
self.invoice = move_form.save()
self.invoice.post()
self.invoice.action_post()
self.assertEqual(self.po.order_line.mapped('qty_invoiced'), [3.0, 3.0], 'Purchase: Billed quantity should be 3.0')
@@ -382,7 +382,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
move_form.partner_id = self.partner_id
move_form.purchase_id = po1
invoice_po1 = move_form.save()
invoice_po1.post()
invoice_po1.action_post()
# Receive 10@20 ; create the vendor bill
po2 = self.env['purchase.order'].create({
@@ -407,7 +407,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
move_form.partner_id = self.partner_id
move_form.purchase_id = po2
invoice_po2 = move_form.save()
invoice_po2.post()
invoice_po2.action_post()
# valuation of product1 should be 300
self.assertEqual(self.product1.value_svl, 300)
@@ -433,7 +433,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
with move_form.invoice_line_ids.edit(0) as line_form:
line_form.quantity = 10
creditnote_po2 = move_form.save()
creditnote_po2.post()
creditnote_po2.action_post()
# check the anglo saxon entries
price_diff_entry = self.env['account.move.line'].search([('account_id', '=', self.price_diff_account.id)])
@@ -467,7 +467,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
with move_form.invoice_line_ids.edit(0) as line_form:
line_form.price_unit = 15.0
invoice = move_form.save()
invoice.post()
invoice.action_post()
# Check what was posted in the price difference account
price_diff_aml = self.env['account.move.line'].search([('account_id','=', self.price_diff_account.id)])
@@ -590,7 +590,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
})]
})
inv.post()
inv.action_post()
move_lines = inv.line_ids
self.assertEqual(len(move_lines), 2)
@@ -734,7 +734,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
]
})
inv.post()
inv.action_post()
for p in patchers:
p.stop()
@@ -898,7 +898,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
]
})
inv.post()
inv.action_post()
for p in patchers:
p.stop()
@@ -1074,7 +1074,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
]
})
inv.post()
inv.action_post()
today = date_delivery1
backorder_picking = self.env['stock.picking'].search([('backorder_id', '=', picking.id)])
@@ -1104,7 +1104,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
]
})
inv1.post()
inv1.action_post()
for p in patchers:
p.stop()
@@ -1216,7 +1216,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
line_form.price_unit = 100.0
line_form.discount = 10.0
invoice = invoice_form.save()
invoice.post()
invoice.action_post()
# Check what was posted in the price difference account
price_diff_aml = self.env['account.move.line'].search([('account_id','=', self.price_diff_account.id)])
@@ -1262,7 +1262,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
line_form.tax_ids.clear()
line_form.discount = 10.0
invoice = invoice_form.save()
invoice.post()
invoice.action_post()
# Check what was posted in the price difference account
price_diff_aml = self.env['account.move.line'].search([('account_id', '=', self.price_diff_account.id)])
@@ -1308,7 +1308,7 @@ class TestStockValuationWithCOA(AccountTestInvoicingCommon):
line_form.price_unit = 100.0
line_form.discount = 10.0
invoice = invoice_form.save()
invoice.post()
invoice.action_post()
# Check if something was posted in the price difference account
price_diff_aml = self.env['account.move.line'].search([('account_id','=', self.price_diff_account.id)])
+4 -4
View File
@@ -74,18 +74,18 @@ class AccountMove(models.Model):
})
return super()._reverse_moves(default_values_list=default_values_list, cancel=cancel)
def post(self):
def _post(self, soft=True):
# OVERRIDE
# Auto-reconcile the invoice with payments coming from transactions.
# It's useful when you have a "paid" sale order (using a payment transaction) and you invoice it later.
res = super(AccountMove, self).post()
posted = super()._post(soft)
for invoice in self.filtered(lambda move: move.is_invoice()):
for invoice in posted.filtered(lambda move: move.is_invoice()):
payments = invoice.mapped('transaction_ids.payment_id')
move_lines = payments.line_ids.filtered(lambda line: line.account_internal_type in ('receivable', 'payable') and not line.reconciled)
for line in move_lines:
invoice.js_assign_outstanding_line(line.id)
return res
return posted
def action_invoice_paid(self):
# OVERRIDE
+5 -5
View File
@@ -68,7 +68,7 @@ class TestReInvoice(TestSaleCommon):
line_form.quantity = 3.0
line_form.analytic_account_id = self.analytic_account
invoice_a = move_form.save()
invoice_a.post()
invoice_a.action_post()
sale_order_line3 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line1 and sol.product_id == self.company_data['product_order_cost'])
sale_order_line4 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line2 and sol.product_id == self.company_data['product_delivery_cost'])
@@ -96,7 +96,7 @@ class TestReInvoice(TestSaleCommon):
line_form.quantity = 2.0
line_form.analytic_account_id = self.analytic_account
invoice_b = move_form.save()
invoice_b.post()
invoice_b.action_post()
sale_order_line5 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line1 and sol != sale_order_line3 and sol.product_id == self.company_data['product_order_cost'])
sale_order_line6 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line2 and sol != sale_order_line4 and sol.product_id == self.company_data['product_delivery_cost'])
@@ -150,7 +150,7 @@ class TestReInvoice(TestSaleCommon):
line_form.quantity = 3.0
line_form.analytic_account_id = self.analytic_account
invoice_a = move_form.save()
invoice_a.post()
invoice_a.action_post()
sale_order_line3 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line1 and sol.product_id == self.company_data['product_delivery_sales_price'])
sale_order_line4 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line2 and sol.product_id == self.company_data['product_order_sales_price'])
@@ -178,7 +178,7 @@ class TestReInvoice(TestSaleCommon):
line_form.quantity = 2.0
line_form.analytic_account_id = self.analytic_account
invoice_b = move_form.save()
invoice_b.post()
invoice_b.action_post()
sale_order_line5 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line1 and sol != sale_order_line3 and sol.product_id == self.company_data['product_delivery_sales_price'])
sale_order_line6 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line2 and sol != sale_order_line4 and sol.product_id == self.company_data['product_order_sales_price'])
@@ -214,7 +214,7 @@ class TestReInvoice(TestSaleCommon):
line_form.quantity = 3.0
line_form.analytic_account_id = self.analytic_account
invoice_a = move_form.save()
invoice_a.post()
invoice_a.action_post()
self.assertEqual(len(self.sale_order.order_line), 1, "No SO line should have been created (or removed) when validating vendor bill")
self.assertTrue(invoice_a.mapped('line_ids.analytic_line_ids'), "Analytic lines should be generated")
+1 -1
View File
@@ -205,7 +205,7 @@ class TestSaleOrder(TestSaleCommon):
}),
],
})
inv.post()
inv.action_post()
sol = so.order_line.filtered(lambda l: l.product_id == serv_cost)
self.assertTrue(sol, 'Sale: cost invoicing does not add lines when confirming vendor invoice')
self.assertEqual((sol.price_unit, sol.qty_delivered, sol.product_uom_qty, sol.qty_invoiced), (160, 2, 0, 0), 'Sale: line is wrong after confirming vendor invoice')
+5 -5
View File
@@ -75,7 +75,7 @@ class TestSaleToInvoice(TestSaleCommon):
def test_refund_create(self):
# Validate invoice
self.invoice.post()
self.invoice.action_post()
# Check quantity to invoice on SO lines
for line in self.sale_order.order_line:
@@ -135,7 +135,7 @@ class TestSaleToInvoice(TestSaleCommon):
self.assertEqual(len(line.invoice_lines), 2, "The line 'ordered service' is invoiced, so it should be linked to 2 invoice lines (invoice and refund)")
# Validate the refund
invoice_refund.post()
invoice_refund.action_post()
for line in self.sale_order.order_line:
if line.product_id.invoice_policy == 'delivery':
@@ -169,7 +169,7 @@ class TestSaleToInvoice(TestSaleCommon):
line_form.quantity = 4
# Validate invoice
self.invoice.post()
self.invoice.action_post()
# Check quantity to invoice on SO lines
for line in self.sale_order.order_line:
@@ -228,7 +228,7 @@ class TestSaleToInvoice(TestSaleCommon):
line_form.quantity = 2
# Validate invoice
self.invoice.post()
self.invoice.action_post()
# Check quantity to invoice on SO lines
for line in self.sale_order.order_line:
@@ -295,7 +295,7 @@ class TestSaleToInvoice(TestSaleCommon):
invoice_refund = move_form.save()
# Validate the refund
invoice_refund.post()
invoice_refund.action_post()
for line in self.sale_order.order_line:
if line.product_id.invoice_policy == 'delivery':
+2 -2
View File
@@ -133,7 +133,7 @@ class TestSaleToInvoice(TestSaleCommon):
})
payment.create_invoices()
invoice = self.sale_order.invoice_ids[0]
invoice.post()
invoice.action_post()
# Check discount appeared on both SO lines and invoice lines
for line, inv_line in zip(self.sale_order.order_line, invoice.invoice_line_ids):
@@ -195,7 +195,7 @@ class TestSaleToInvoice(TestSaleCommon):
self.assertEqual(line.untaxed_amount_to_invoice, line.product_uom_qty * line.price_unit, "The amount to invoice should the total of the line, as the line is confirmed (no confirmed invoice)")
self.assertEqual(line.untaxed_amount_invoiced, 0.0, "The invoiced amount should be zero, as no invoice are validated for now")
invoice.post()
invoice.action_post()
# Check quantity to invoice on SO lines
for line in self.sale_order.order_line:
+1 -1
View File
@@ -686,7 +686,7 @@ class TestSaleMrpFlow(ValuationReconciliationTestCommon):
with move_form.invoice_line_ids.edit(0) as line_form:
line_form.quantity = 2.0
self.invoice = move_form.save()
self.invoice.post()
self.invoice.action_post()
aml = self.invoice.line_ids
aml_expense = aml.filtered(lambda l: l.is_anglo_saxon_line and l.debit > 0)
aml_output = aml.filtered(lambda l: l.is_anglo_saxon_line and l.credit > 0)
@@ -12,9 +12,9 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.env.user.company_id.anglo_saxon_accounting = True
cls.product = cls.env['product.product'].create({
'name': 'product',
'type': 'product',
@@ -101,7 +101,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -145,7 +145,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
with invoice_form.invoice_line_ids.edit(0) as invoice_line:
invoice_line.quantity = 1
invoice_form.save()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -175,7 +175,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# invoice 1
invoice2 = sale_order._create_invoices()
invoice2.post()
invoice2.action_post()
amls = invoice2.line_ids
self.assertEqual(len(amls), 4)
stock_out_aml = amls.filtered(lambda aml: aml.account_id == self.company_data['default_account_stock_out'])
@@ -220,7 +220,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -284,7 +284,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
with invoice_form.invoice_line_ids.edit(0) as invoice_line:
invoice_line.quantity = 1
invoice_form.save()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -314,7 +314,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# invoice 1
invoice2 = sale_order._create_invoices()
invoice2.post()
invoice2.action_post()
amls = invoice2.line_ids
self.assertEqual(len(amls), 4)
stock_out_aml = amls.filtered(lambda aml: aml.account_id == self.company_data['default_account_stock_out'])
@@ -359,7 +359,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -394,7 +394,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -432,7 +432,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -468,7 +468,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -526,7 +526,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -561,7 +561,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -595,7 +595,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -639,7 +639,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
with invoice_form.invoice_line_ids.edit(0) as invoice_line:
invoice_line.quantity = 2
invoice_form.save()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -673,7 +673,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -735,7 +735,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
with invoice_form.invoice_line_ids.edit(0) as invoice_line:
invoice_line.quantity = 2
invoice_form.save()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -770,7 +770,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -846,7 +846,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Check the resulting accounting entries
amls = invoice.line_ids
@@ -915,7 +915,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
sale_order.picking_ids.move_lines.quantity_done = 1
sale_order.picking_ids.button_validate()
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# sale 6@20, deliver, invoice
sale_order = self.env['sale.order'].create({
@@ -934,7 +934,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
sale_order.picking_ids.move_lines.quantity_done = 6
sale_order.picking_ids.button_validate()
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# check the last anglo saxon invoice line
amls = invoice.line_ids
@@ -983,7 +983,7 @@ class TestAngloSaxonValuation(ValuationReconciliationTestCommon):
# Invoice the sale order.
invoice = sale_order._create_invoices()
invoice.post()
invoice.action_post()
# Make the second receipt
in_move_2 = self.env['stock.move'].create({
@@ -78,7 +78,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon):
self._process_pickings(sale_order.picking_ids)
invoice = self._create_invoice_for_so(sale_order, test_product, '2018-02-12')
invoice.post()
invoice.action_post()
picking = self.env['stock.picking'].search([('sale_id', '=', sale_order.id)])
self.check_reconciliation(invoice, picking, operation='sale')
@@ -94,7 +94,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon):
sale_order = self._create_sale(test_product, '2018-01-01')
invoice = self._create_invoice_for_so(sale_order, test_product, '2018-02-03')
invoice.post()
invoice.action_post()
self._process_pickings(sale_order.picking_ids)
@@ -133,11 +133,11 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon):
picking = self.env['stock.picking'].search([('sale_id', '=', sale_order.id)], order="id asc", limit=1)
invoice = self._create_invoice_for_so(sale_order, test_product, '2018-02-03', quantity=3)
invoice.post()
invoice.action_post()
self.check_reconciliation(invoice, picking, full_reconcile=False, operation='sale')
invoice2 = self._create_invoice_for_so(sale_order, test_product, '2018-03-12', quantity=2)
invoice2.post()
invoice2.action_post()
self.check_reconciliation(invoice2, picking, full_reconcile=False, operation='sale')
self._process_pickings(sale_order.picking_ids.filtered(lambda x: x.state != 'done'), quantity=3.0)
+2 -2
View File
@@ -216,7 +216,7 @@ class TestSaleStock(TestSaleCommon, ValuationReconciliationTestCommon):
self.assertEqual(self.so.invoice_status, 'invoiced', 'Sale Stock: so invoice_status should be "invoiced" instead of "%s" after invoicing' % self.so.invoice_status)
self.assertEqual(len(self.inv_1), 1, 'Sale Stock: only one invoice instead of "%s" should be created' % len(self.inv_1))
self.assertEqual(self.inv_1.amount_untaxed, self.inv_1.amount_untaxed, 'Sale Stock: amount in SO and invoice should be the same')
self.inv_1.post()
self.inv_1.action_post()
# Create return picking
stock_return_picking_form = Form(self.env['stock.return.picking']
@@ -805,7 +805,7 @@ class TestSaleStock(TestSaleCommon, ValuationReconciliationTestCommon):
# create invoice for 3 quantity and post it
inv_1 = so._create_invoices()
inv_1.post()
inv_1.action_post()
self.assertEqual(inv_1.state, 'posted', 'invoice should be in posted state')
pick_2 = so.picking_ids.filtered('backorder_id')
@@ -54,7 +54,7 @@ class TestSaleProject(TestReporting):
action_invoice = payment.with_context(context).create_invoices()
invoice = self.env['account.move'].browse(action_invoice['res_id'])
invoice.post()
invoice.action_post()
# simulate the auto creation of the SO line for expense, like we confirm a vendor bill.
so_line_expense = self.env['sale.order.line'].create({
@@ -93,7 +93,7 @@ class TestReInvoice(TestCommonSaleTimesheet):
line_form.quantity = 3.0
line_form.analytic_account_id = self.analytic_account
invoice_a = move_form.save()
invoice_a.post()
invoice_a.action_post()
sale_order_line3 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line1 and sol.product_id == self.company_data['product_order_cost'])
sale_order_line4 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line2 and sol.product_id == self.company_data['product_delivery_cost'])
@@ -128,7 +128,7 @@ class TestReInvoice(TestCommonSaleTimesheet):
line_form.quantity = 2.0
line_form.analytic_account_id = self.analytic_account
invoice_b = move_form.save()
invoice_b.post()
invoice_b.action_post()
sale_order_line5 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line1 and sol != sale_order_line3 and sol.product_id == self.company_data['product_order_cost'])
sale_order_line6 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line2 and sol != sale_order_line4 and sol.product_id == self.company_data['product_delivery_cost'])
@@ -192,7 +192,7 @@ class TestReInvoice(TestCommonSaleTimesheet):
line_form.quantity = 3.0
line_form.analytic_account_id = self.analytic_account
invoice_a = move_form.save()
invoice_a.post()
invoice_a.action_post()
sale_order_line3 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line1 and sol.product_id == self.company_data['product_delivery_sales_price'])
sale_order_line4 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line2 and sol.product_id == self.company_data['product_order_sales_price'])
@@ -227,7 +227,7 @@ class TestReInvoice(TestCommonSaleTimesheet):
line_form.quantity = 2.0
line_form.analytic_account_id = self.analytic_account
invoice_b = move_form.save()
invoice_b.post()
invoice_b.action_post()
sale_order_line5 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line1 and sol != sale_order_line3 and sol.product_id == self.company_data['product_delivery_sales_price'])
sale_order_line6 = self.sale_order.order_line.filtered(lambda sol: sol != sale_order_line2 and sol != sale_order_line4 and sol.product_id == self.company_data['product_order_sales_price'])
@@ -263,7 +263,7 @@ class TestReInvoice(TestCommonSaleTimesheet):
line_form.quantity = 3.0
line_form.analytic_account_id = self.analytic_account
invoice_a = move_form.save()
invoice_a.post()
invoice_a.action_post()
# let's log some timesheets (on the project created by sale_order_line1)
task_sol1 = sale_order_line.task_id
@@ -232,7 +232,7 @@ class TestReporting(TestCommonSaleTimesheet):
action_invoice = payment.with_context(context).create_invoices()
invoice_id = action_invoice['res_id']
invoice_1 = self.env['account.move'].browse(invoice_id)
invoice_1.post()
invoice_1.action_post()
self.env['project.profitability.report'].flush()
# deliver project should now have cost and something invoiced
@@ -287,7 +287,7 @@ class TestReporting(TestCommonSaleTimesheet):
action_invoice = payment.with_context(context).create_invoices()
invoice_id = action_invoice['res_id']
invoice_2 = self.env['account.move'].browse(invoice_id)
invoice_2.post()
invoice_2.action_post()
self.env['project.profitability.report'].flush()
# deliver project should not be impacted by the invoice of the other SO
@@ -163,7 +163,7 @@ class TestSaleService(TestCommonSaleTimesheet):
# invoice SO, and validate invoice
invoice = self.sale_order._create_invoices()[0]
invoice.post()
invoice.action_post()
# make task non billable
task_serv2.write({'sale_line_id': False})
@@ -145,7 +145,7 @@ class TestSaleTimesheet(TestCommonSaleTimesheet):
self.assertFalse(timesheet4.timesheet_invoice_id, "The timesheet4 should not be linked to the invoice, since we are in ordered quantity")
# validate the first invoice
invoice1.post()
invoice1.action_post()
self.assertEqual(so_line_ordered_global_project.product_uom_qty, invoice_line_1.quantity, "The invoice (ordered) quantity should not change when modifying timesheet")
self.assertFalse(timesheet1.timesheet_invoice_id, "The timesheet1 should not be linked to the invoice, since we are in ordered quantity")
@@ -289,7 +289,7 @@ class TestSaleTimesheet(TestCommonSaleTimesheet):
self.assertFalse(timesheet4.timesheet_invoice_id, "The timesheet4 should not still be linked to the invoice")
# validate the second invoice
invoice2.post()
invoice2.action_post()
self.assertEqual(timesheet1.timesheet_invoice_id, invoice1, "The timesheet1 should not be linked to the invoice 1, even after validation")
self.assertEqual(timesheet2.timesheet_invoice_id, invoice2, "The timesheet2 should not be linked to the invoice 1, even after validation")
@@ -372,7 +372,7 @@ class TestSaleTimesheet(TestCommonSaleTimesheet):
self.assertFalse(timesheet2.timesheet_invoice_id, "The timesheet2 should not be linked to the invoice, since timesheets are used for time tracking in milestone")
# validate the invoice
invoice1.post()
invoice1.action_post()
self.assertFalse(timesheet1.timesheet_invoice_id, "The timesheet1 should not be linked to the invoice, even after invoice validation")
self.assertFalse(timesheet2.timesheet_invoice_id, "The timesheet2 should not be linked to the invoice, even after invoice validation")
@@ -488,7 +488,7 @@ class TestSaleTimesheet(TestCommonSaleTimesheet):
self.assertEqual(so_line_deliver_global_project.qty_invoiced, timesheet1.unit_amount)
# validate invoice
invoice.post()
invoice.action_post()
wizard.write({
'date_invoice_timesheet': today - timedelta(days=4)
@@ -48,7 +48,7 @@ class TestPingenSend(HttpCase):
})],
})
invoice.post()
invoice.action_post()
return invoice
+5 -5
View File
@@ -25,22 +25,22 @@ class AccountMove(models.Model):
move_vals['line_ids'] = [vals for vals in move_vals['line_ids'] if not vals[2]['is_anglo_saxon_line']]
return move_vals
def post(self):
def _post(self, soft=True):
# OVERRIDE
# Don't change anything on moves used to cancel another ones.
if self._context.get('move_reverse_cancel'):
return super(AccountMove, self).post()
return super()._post(soft)
# Create additional COGS lines for customer invoices.
self.env['account.move.line'].create(self._stock_account_prepare_anglo_saxon_out_lines_vals())
# Post entries.
res = super(AccountMove, self).post()
posted = super()._post(soft)
# Reconcile COGS lines in case of anglo-saxon accounting with perpetual valuation.
self._stock_account_anglo_saxon_reconcile_valuation()
return res
posted._stock_account_anglo_saxon_reconcile_valuation()
return posted
def button_draft(self):
res = super(AccountMove, self).button_draft()
+4 -4
View File
@@ -62,7 +62,7 @@ class ProductTemplate(models.Model):
# Create the account moves.
if move_vals_list:
account_moves = self.env['account.move'].sudo().create(move_vals_list)
account_moves.post()
account_moves._post()
return res
# -------------------------------------------------------------------------
@@ -282,7 +282,7 @@ class ProductProduct(models.Model):
account_moves = self.env['account.move'].sudo().create(am_vals_list)
if account_moves:
account_moves.post()
account_moves._post()
def _run_fifo(self, quantity, company):
self.ensure_one()
@@ -489,7 +489,7 @@ class ProductProduct(models.Model):
'stock_move_id': vacuum_svl.stock_move_id.id,
'move_type': 'entry',
})
new_account_move.post()
new_account_move._post()
to_reconcile_account_move_lines = vacuum_svl.account_move_id.line_ids.filtered(lambda l: not l.reconciled and l.account_id == accounts['stock_output'] and l.account_id.reconcile)
to_reconcile_account_move_lines += new_account_move.line_ids.filtered(lambda l: not l.reconciled and l.account_id == accounts['stock_output'] and l.account_id.reconcile)
return to_reconcile_account_move_lines.reconcile()
@@ -783,5 +783,5 @@ class ProductCategory(models.Model):
# Create the account moves.
if move_vals_list:
account_moves = self.env['account.move'].sudo().create(move_vals_list)
account_moves.post()
account_moves._post()
return res
+1 -1
View File
@@ -454,7 +454,7 @@ class StockMove(models.Model):
'stock_valuation_layer_ids': [(6, None, [svl_id])],
'move_type': 'entry',
})
new_account_move.post()
new_account_move._post()
def _account_entry_move(self, qty, description, svl_id, cost):
""" Accounting Valuation Entries """
@@ -116,4 +116,4 @@ class ValuationReconciliationTestCommon(AccountTestInvoicingCommon):
pickings.mapped('move_lines').write({'date': date})
pickings.mapped('move_lines.account_move_ids').write({'name': '/', 'state': 'draft'})
pickings.mapped('move_lines.account_move_ids').write({'date': date})
pickings.move_lines.account_move_ids.post()
pickings.move_lines.account_move_ids.action_post()
@@ -155,6 +155,6 @@ class StockValuationLayerRevaluation(models.TransientModel):
})],
}
account_move = self.env['account.move'].create(move_vals)
account_move.post()
account_move._post()
return True
@@ -73,11 +73,11 @@ class TestStockValuation(ValuationReconciliationTestCommon):
with move_form.invoice_line_ids.edit(i) as line_form:
line_form.tax_ids.clear()
self.vendor_bill1 = move_form.save()
self.vendor_bill1.post()
self.vendor_bill1.action_post()
# create the customer invoice
self.customer_invoice1 = self.sale_order1._create_invoices()
self.customer_invoice1.post()
self.customer_invoice1.action_post()
all_amls = self.vendor_bill1.line_ids + self.customer_invoice1.line_ids
if self.sale_order1.picking_ids.move_lines.account_move_ids:
@@ -173,7 +173,7 @@ class StockLandedCost(models.Model):
move_vals['stock_valuation_layer_ids'] = [(6, None, valuation_layer_ids)]
move = move.create(move_vals)
cost.write({'state': 'done', 'account_move_id': move.id})
move.post()
move._post()
if cost.vendor_bill_id and cost.vendor_bill_id.state == 'posted' and cost.company_id.anglo_saxon_accounting:
all_amls = cost.vendor_bill_id.line_ids | cost.account_move_id.line_ids
@@ -358,7 +358,7 @@ class TestLandedCostsWithPurchaseAndInv(TestStockValuationLCCommon):
move_form.partner_id = order.partner_id
move_form.purchase_id = order
move = move_form.save()
move.post()
move.action_post()
# Check nothing was posted in the price difference account
price_diff_aml = self.env['account.move.line'].search([('account_id','=', self.price_diff_account.id), ('move_id', '=', move.id)])
@@ -338,10 +338,10 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon):
self.assertEqual(valuation_aml.debit, 100)
self.assertEqual(valuation_aml.credit, 0)
# Create a vebdor bill for the RFQ
# Create a vendor bill for the RFQ
action = rfq.action_create_invoice()
vb = self.env['account.move'].search([('id', '=', action['res_id'])])
vb.post()
vb = self.env['account.move'].browse(action['res_id'])
vb.action_post()
input_aml = self._get_stock_input_move_lines()[-1]
self.assertEqual(input_aml.debit, 100)
@@ -361,7 +361,7 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon):
with lcvb.invoice_line_ids.edit(0) as inv_line:
inv_line.tax_ids.clear()
lcvb = lcvb.save()
lcvb.post()
lcvb.action_post()
input_aml = self._get_stock_input_move_lines()[-1]
self.assertEqual(input_aml.debit, 50)
@@ -434,7 +434,7 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon):
inv_line.price_unit = 50
inv_line.is_landed_costs_line = True
vb = vb.save()
vb.post()
vb.action_post()
action = vb.button_create_landed_costs()
lc = Form(self.env[action['res_model']].browse(action['res_id']))
@@ -480,8 +480,8 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon):
# Create a vebdor bill for the RFQ
action = rfq.action_create_invoice()
vb = self.env['account.move'].search([('id', '=', action['res_id'])])
vb.post()
vb = self.env['account.move'].browse(action['res_id'])
vb.action_post()
expense_aml = self._get_expense_move_lines()[-1]
self.assertEqual(expense_aml.debit, 100)
@@ -502,7 +502,7 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon):
with lcvb.invoice_line_ids.edit(0) as inv_line:
inv_line.tax_ids.clear()
lcvb = lcvb.save()
lcvb.post()
lcvb.action_post()
expense_aml = self._get_expense_move_lines()[-1]
self.assertEqual(expense_aml.debit, 50)
@@ -529,4 +529,3 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon):
self.assertEqual(self.product1.quantity_svl, 10)
self.assertEqual(self.product1.value_svl, 150)