19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:30:07 +01:00
parent ba20ce7443
commit 768b70e05e
2357 changed files with 1057103 additions and 712486 deletions

View file

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from odoo import api, models, fields, _
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models, _
from odoo.exceptions import UserError
@ -8,7 +9,8 @@ class IrAttachment(models.Model):
@api.ondelete(at_uninstall=False)
def _unlink_except_government_document(self):
linked_edi_documents = self.env['account.edi.document'].search([('attachment_id', 'in', self.ids)])
# sudo: account.edi.document - constraint that must be applied regardless of ACL
linked_edi_documents = self.env['account.edi.document'].sudo().search([('attachment_id', 'in', self.ids)])
linked_edi_formats_ws = linked_edi_documents.edi_format_id.filtered(lambda edi_format: edi_format._needs_web_services())
if linked_edi_formats_ws:
raise UserError(_("You can't unlink an attachment being an EDI document sent to the government."))