Ir al contenido
Menú
Se marcó esta pregunta
from odoo import models, fields, api

class AccountMove(models.Model):
​_inherit='account.move'
​invoice_cash_rounding_id=fields.Many2one('account.cash.rounding', compute='_compute_rounding_id', store=True)

​@api.depends('move_type', 'state', 'line_ids.display_type')
​def_compute_rounding_id(self):
​roundoff_id=self.env.ref('round_off.inv_roundoff')
​for move in self:
​if move.move_type =='out_invoice' and move.state not in ('posted', 'cancel'):
​# Check if any line has display_type set to 'rounding'
​has_rounding_line=any(line.display_type =='rounding' for line in move.line_ids)
​if not has_rounding_line:
​move.invoice_cash_rounding_id =roundoff_id

I have created a custom module to compute the invoice_cash_rounding_id when creating invoice, but the method is trying to delete posted entries and calls this method :
https://github.com/odoo/odoo/blob/0000bfd406d057cfa5d7b6cbbb070b7ecd556bc0/addons/account/models/account_move_line.py#L1536
and then this raises a user error and user is unable to open the invoice


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
may 23
2759
0
feb 24
1778
1
feb 24
4300
0
feb 24
2090
0
jul 23
2070