Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2627 Lượt xem

where copy attachement file from purchase order to account move

Ảnh đại diện
Huỷ bỏ
Tác giả

view code:
if line.purchase_order_id and line.purchase_order_id not in old_orders:
# This is the first time we've added this order - copy the attachment

self.env['ir.attachment'].search([
('res_model', '=', 'purchase.order'),
('res_id', '=', line.purchase_order_id.id),
]).copy(default={
'res_model': 'account.move',
'res_id': line.move_id.id,
})

return line

Câu trả lời hay nhất

Expected singleton means that there are multiple record that successfully fetch but python is unable to show them. You need to iterate it so it can be shown one by one simply using "for" iteration. 

The code below may not fully works but the idea is suggesting you to use "for iteration" to show fetched record from ir.attachment.

if line.purchase_order_id and line.purchase_order_id not in old_orders:    
    for record in self.env['ir.attachment'].search([('res_model', '=', 'purchase.order'),('res_id', '=',line.purchase_order_id.id),]):

    record.copy(default={
            'res_model': 'account.move',
            'res_id': line.move_id.id,
    })

    return line

best regards,

Altela (altelasoftware.com)

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks
Altela Pramardhika; le problem etais deja resolun d'une autre façon ;
votre reponse me semble ausi exacte

Glad it worked then! :D

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 5 23
15446
2
thg 12 23
5455
0
thg 4 22
2082
2
thg 3 19
7783
2
thg 9 17
4545