mirror of
https://github.com/bringout/oca-ocb-mrp.git
synced 2026-04-25 06:12:00 +02:00
19.0 vanilla
This commit is contained in:
parent
accf5918df
commit
6e65e8c877
688 changed files with 225434 additions and 199401 deletions
18
odoo-bringout-oca-ocb-mrp/mrp/models/ir_attachment.py
Normal file
18
odoo-bringout-oca-ocb-mrp/mrp/models/ir_attachment.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class IrAttachment(models.Model):
|
||||
_inherit = "ir.attachment"
|
||||
|
||||
def _post_add_create(self, **kwargs):
|
||||
super()._post_add_create(**kwargs)
|
||||
if self.res_model == "mrp.bom":
|
||||
bom = self.env['mrp.bom'].browse(self.res_id)
|
||||
self.res_model = bom.product_id._name if bom.product_id else bom.product_tmpl_id._name
|
||||
self.res_id = bom.product_id.id if bom.product_id else bom.product_tmpl_id.id
|
||||
self.env['product.document'].create({
|
||||
'ir_attachment_id': self.id,
|
||||
'attached_on_mrp': 'bom'
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue