1
0
forked from Mapan/odoo17e
odoo17e-kedaikipas58/addons/account_invoice_extract/models/ir_attachment.py
2024-12-10 09:04:09 +07:00

21 lines
795 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class IrAttachment(models.Model):
_inherit = 'ir.attachment'
def register_as_main_attachment(self, force=True):
"""Add the automatic scanning of attachments when registered as main.
To avoid double scanning after message_post, we check that the automatic scanning is only made the first time.
"""
self.ensure_one()
super(IrAttachment, self).register_as_main_attachment(force=force)
if self.res_model == 'account.move':
related_record = self.env[self.res_model].browse(self.res_id)
if related_record._needs_auto_extract():
related_record._send_batch_for_digitization()