mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-26 08:32:02 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -0,0 +1,26 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class IrAttachment(models.Model):
|
||||
_inherit = 'ir.attachment'
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
"""Create product.document for attachments added in products chatters"""
|
||||
attachments = super().create(vals_list)
|
||||
if not self.env.context.get('disable_product_documents_creation'):
|
||||
product_attachments = attachments.filtered(
|
||||
lambda attachment:
|
||||
attachment.res_model in ('product.product', 'product.template')
|
||||
and not attachment.res_field
|
||||
)
|
||||
if product_attachments:
|
||||
self.env['product.document'].sudo().create([
|
||||
{
|
||||
'ir_attachment_id': attachment.id
|
||||
}
|
||||
for attachment in product_attachments
|
||||
])
|
||||
return attachments
|
||||
Loading…
Add table
Add a link
Reference in a new issue