Add merge_request581.diff - [account] Post cancelled, grouped, rescheduled and delegated moves

This commit is contained in:
Raimon Esteve 2023-08-16 13:53:58 +02:00
parent 32368787a5
commit 7f8414227d
2 changed files with 83 additions and 0 deletions

81
merge_request581.diff Normal file
View File

@ -0,0 +1,81 @@
diff --git a/tryton/modules/account/move.py b/tryton/modules/account/move.py
index f8a7d3209c..35be14cf1f 100644
--- a/tryton/modules/account/move.py
+++ b/tryton/modules/account/move.py
@@ -2044,6 +2044,7 @@ class CancelMoves(Wizard):
def transition_cancel(self):
pool = Pool()
Line = pool.get('account.move.line')
+ Move = pool.get('account.move')
Warning = pool.get('res.user.warning')
Unreconcile = pool.get('account.move.unreconcile_lines', type='wizard')
@@ -2063,6 +2064,7 @@ class CancelMoves(Wizard):
key, gettext(
'account.msg_cancel_line_delegated', moves=names))
+ to_post = []
for move in moves:
if moves_w_delegation.get(move):
# Skip further warnings
@@ -2070,12 +2072,16 @@ class CancelMoves(Wizard):
Unreconcile.make_unreconciliation(moves_w_delegation[move])
default = self.default_cancel(move)
cancel_move = move.cancel(default=default)
+ if move.state == 'posted':
+ to_post.append(cancel_move)
to_reconcile = defaultdict(list)
for line in move.lines + cancel_move.lines:
if line.account.reconcile:
to_reconcile[(line.account, line.party)].append(line)
for lines in to_reconcile.values():
Line.reconcile(lines)
+ if to_post:
+ Move.post(to_post)
return 'end'
@@ -2096,13 +2102,26 @@ class GroupLines(Wizard):
group = StateAction('account.act_move_form_grouping')
def do_group(self, action):
+ Move = Pool().get('account.move')
+
move, balance_line = self._group_lines(self.records)
+ # Post cancelled, grouped, rescheduled and delegated moves
+ # tryton efdb98eb55e54cea31792f3a1fd1e0fb1e21a8d7
+ if all(l.move.state == 'posted' for l in self.records):
+ Move.post([move])
return action, {'res_id': move.id}
def _group_lines(self, lines, date=None):
+ Move = Pool().get('account.move')
+
move, balance_line = self.group_lines(lines, self.start.journal, date)
move.description = self.start.description
move.save()
+
+ # Post cancelled, grouped, rescheduled and delegated moves
+ # tryton efdb98eb55e54cea31792f3a1fd1e0fb1e21a8d7
+ if all(l.move.state == 'posted' for l in self.records):
+ Move.post([move])
return move, balance_line
@classmethod
@@ -2386,11 +2405,17 @@ class RescheduleLines(Wizard):
return values
def do_reschedule(self, action):
+ Move = Pool().get('account.move')
+
move, balance_line = self.reschedule_lines(
self.records, self.preview.journal, self.preview.terms)
move.origin = self.get_origin()
move.description = self.preview.description
move.save()
+ # Post cancelled, grouped, rescheduled and delegated moves
+ # tryton efdb98eb55e54cea31792f3a1fd1e0fb1e21a8d7
+ if all(l.move.state == 'posted' for l in self.records):
+ Move.post([move])
action['res_id'] = [move.id]
return action, {}

2
series
View File

@ -84,3 +84,5 @@ issue12398.diff # [account_dunning] Missing searc_rec_name in model 'account.dun
issue12414.diff # [stock_lot_sled] Check expiration lot in case Shelf Life Time State is not "none"
issue12315.diff # [stock_product_location] Make production entry move from_location configurable
merge_request581.diff # [account] Post cancelled, grouped, rescheduled and delegated moves