[FIX] stock_account: method doesn't wok with a recordset

If you try to get show_reset_to_draft_button for more than one account.move, it can raise.

closes odoo/odoo#107169

X-original-commit: a5b985e8449a1e858c3fb9a0a90a6d203e16f739
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
Florent de Labarre
2022-12-05 10:07:58 +01:00
committed by GitHub
parent 8169f64001
commit 4e98f9902c
+2 -2
View File
@@ -12,13 +12,13 @@ class AccountMove(models.Model):
stock_valuation_layer_ids = fields.One2many('stock.valuation.layer', 'account_move_id', string='Stock Valuation Layer')
def _compute_show_reset_to_draft_button(self):
super()._compute_show_reset_to_draft_button()
for move in self:
for line in move.line_ids:
# if a line has correction layers hide the 'Reset to Darft' button
if line._get_stock_valuation_layers(move).stock_valuation_layer_ids.filtered('account_move_line_id'):
move.show_reset_to_draft_button = False
return
super()._compute_show_reset_to_draft_button()
break
# -------------------------------------------------------------------------
# OVERRIDE METHODS