تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
7689 أدوات العرض

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
يناير 20
4999
4
ديسمبر 22
4580
0
أكتوبر 21
2598
4
مارس 21
10914
2
نوفمبر 17
6887