Add api decorator on create, write

on pingen ir.attachment.
When multiple module redefine create, write
it can lead to TypeError
This commit is contained in:
Nicolas Bessi (nbessi)
2018-11-01 10:31:19 +01:00
committed by Akim Juillerat
parent e3b2f67dec
commit 0b9574f3cc

View File

@@ -6,7 +6,7 @@
import requests import requests
import base64 import base64
from odoo import models, fields, _ from odoo import models, fields, _, api
from odoo.exceptions import UserError from odoo.exceptions import UserError
@@ -66,12 +66,14 @@ class IrAttachment(models.Model):
document.write({'state': 'canceled'}) document.write({'state': 'canceled'})
return return
@api.model
def create(self, vals): def create(self, vals):
attachment = super(IrAttachment, self).create(vals) attachment = super(IrAttachment, self).create(vals)
if 'send_to_pingen' in vals: if 'send_to_pingen' in vals:
attachment._handle_pingen_document() attachment._handle_pingen_document()
return attachment return attachment
@api.multi
def write(self, vals): def write(self, vals):
res = super(IrAttachment, self).write(vals) res = super(IrAttachment, self).write(vals)
if 'send_to_pingen' in vals: if 'send_to_pingen' in vals: