summaryrefslogtreecommitdiff
path: root/addons/account/wizard
diff options
context:
space:
mode:
authorwilliam <wan@odoo.com>2020-03-30 11:46:27 +0000
committerwilliam <wan@odoo.com>2020-08-05 11:57:10 +0000
commit82dc0cb7b91ae59beae7e1c865b670afc5958b31 (patch)
tree949b949b249cdac265310798d5abb82675a1741b /addons/account/wizard
parent276ba8e90c87f8294286f915508766761a58d1e2 (diff)
[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,... )
Diffstat (limited to 'addons/account/wizard')
-rw-r--r--addons/account/wizard/account_validate_account_move.py6
-rw-r--r--addons/account/wizard/account_validate_move_view.xml3
-rw-r--r--addons/account/wizard/wizard_tax_adjustments.py2
3 files changed, 8 insertions, 3 deletions
diff --git a/addons/account/wizard/account_validate_account_move.py b/addons/account/wizard/account_validate_account_move.py
index a7e5bef2e24..2c676d520eb 100644
--- a/addons/account/wizard/account_validate_account_move.py
+++ b/addons/account/wizard/account_validate_account_move.py
@@ -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'}
diff --git a/addons/account/wizard/account_validate_move_view.xml b/addons/account/wizard/account_validate_move_view.xml
index c6439570c6b..e4494cfc272 100644
--- a/addons/account/wizard/account_validate_move_view.xml
+++ b/addons/account/wizard/account_validate_move_view.xml
@@ -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"/>
diff --git a/addons/account/wizard/wizard_tax_adjustments.py b/addons/account/wizard/wizard_tax_adjustments.py
index 18936c49ceb..c771d838044 100644
--- a/addons/account/wizard/wizard_tax_adjustments.py
+++ b/addons/account/wizard/wizard_tax_adjustments.py
@@ -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'))