Hi,
I'd like to remove IF statement (just under # OVERRIDE) from the following method which is in AccountMove class in Odoo addons:
@api.model_create_multi
def create(self, vals_list):
# OVERRIDE
if any('state' in vals and vals.get('state') == 'posted' for vals in vals_list):
raise UserError(_('You cannot create a move already in the posted state. Please create a draft move and post it after.'))
vals_list = self._move_autocomplete_invoice_lines_create(vals_list)
moves = super(AccountMove, self).create(vals_list)
# Trigger 'action_invoice_paid' when the invoice is directly paid at its creation.
moves.filtered(lambda move: move.is_invoice(include_receipts=True) and move.invoice_payment_state in ('paid', 'in_payment')).action_invoice_paid()
return moves
The problem is when I override the method (with copy paste) and remove if any('state'...., the super statement call once more the create method and set the if statement.
How can I override this method and remove the if statement correctly?
Thanks in advance,
Regards.