コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
7705 ビュー

Hello

I need to move the attachment(At header) from (Purchase Agreement) to (RFQs) when creating new quotation

Thank you in advance

アバター
破棄
最善の回答

on ir.attachment model, there is res_model and res_id field you have to change that

in your case res_model filed value change from 'purchase.requisition' to 'purchase.order'  and res_id will change to your new RFQ record id

アバター
破棄
著作者

in where can i change the (res_model) and (res_id)

著作者

I added below code but odoo server error popup:

Record does not exist or has been deleted.

(Records: [204], User: 1)

rfq= self.env['purchase.order'].create({

'......':

'......':

})

attachment = self.env['ir.attachment'].search([('res_model','=','purchase.requisition'), ('res_id','=', self.id)])

self.env['ir.attachment'].create({

'name': attachment.name ,

'res_name': rfq.name,

'type': 'binary',

'datas': attachment.datas,

'res_model': 'purchase.order',

'res_id': rfq.id,

})

here you are creating new attachment. you should user write method instead of create

attachment.write({res_model': 'purchase.order', 'res_id': rfq.id,})

著作者

Thanks Ravi, Solved

最善の回答

Ravi, in case I need to generate_access_token?



アバター
破棄
関連投稿 返信 ビュー 活動
2
1月 20
5003
4
12月 22
4589
0
10月 21
2606
4
3月 21
10925
2
11月 17
6891