where copy attachement file from purchase order to account move
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
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)
Thanks
Altela Pramardhika; le problem etais deja resolun d'une autre façon ;
votre reponse me semble ausi exacte
Glad it worked then! :D
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrirePublications associées | Réponses | Vues | Activité | |
---|---|---|---|---|
|
5
mai 23
|
14666 | ||
|
2
déc. 23
|
4584 | ||
|
0
avr. 22
|
1462 | ||
|
2
mars 19
|
7123 | ||
|
2
sept. 17
|
3891 |
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