forked from nhomar/actions_server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
removed_quant.py
18 lines (17 loc) · 1.07 KB
/
removed_quant.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""This action server removed negative quants when this quants was created by 'Moviento extra' in transfer of picking out and the
stock.move was invoiced, this action sever does:
1.- Break reconciliation of stock move by Movimiento extra
2.- Deleted journal items created by stock move by Movimiento extra
3.- Related account.move.line created by invoice with stock.move that did not negative quant
4.- Remove quants created by Movimiento extra stock.move
"""
for move in model.browse(context.get('active_ids')):
if 'Movimiento extra' in move.name:
move.quant_ids.with_context({'force_unlink': True}).unlink()
move_extra_id = move.aml_all_ids.filtered(lambda dat: dat.journal_id.type == 'general')
move_extra_inv_id = move.aml_all_ids.filtered(lambda dat: dat.journal_id.type != 'general')
self.pool.get('account.move.line')._remove_move_reconcile(cr, uid, [move_id.id for move_id in move.aml_all_ids])
move_extra_id.unlink()
else:
move_src_id = move.id
move_extra_inv_id.write({'sm_id': move_src_id})