Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2337 Zobrazení

where copy attachement file from purchase order to account move

Avatar
Zrušit
Autor

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

Nejlepší odpověď

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)

Avatar
Zrušit
Autor

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

Glad it worked then! :D

Related Posts Odpovědi Zobrazení Aktivita
5
kvě 23
15101
2
pro 23
5077
0
dub 22
1798
2
bře 19
7470
2
zář 17
4243