Hello,
I added 1 button in Purchase order that is work for Receive Product and Create Bill at once.
Code :-
@api.multi
def receive_with_bill(self):
new_invoice = self.action_view_invoice()
picking_ids = self.env['stock.picking'].search([('origin', '=', self.name)])
for picking in picking_ids:
picking.action_confirm()
picking.button_validate()
self.env['stock.immediate.transfer'].create({'pick_ids': [(4, picking.id)]}).process()
Here Stock Picking is validated and stock is updated, but Bill isn't create.
I added print statement in action_view_invoice() which is in the purchase.py under puchase module. This method is also called but Bill isn't create.
How to solve this issue in odoo12.0 ?
Any answer will be appreciable.
Thanks,
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
You need to write code for create invoice in your function. action_view_invoice is not a method to create invoice. Below is the code to create invoice after receive product. You need to pass PO id in invoice during creation-
po_invoice = {
'partner_id': self.partner_id.id,
'account_id': self.partner_id.property_account_payable_id.id,
'state': 'draft',
'type': 'in_invoice',
'date_invoice': self.date_order,
'purchase_id': self.id,
}
inv = self.env['account.invoice'].create(po_invoice)
inv.purchase_order_change()
inv.action_invoice_open()
One more suggestion rathen than doing picking search with origin, You can find picking_ids field in PO which show all incoming shipment related to PO.
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é | |
---|---|---|---|---|
|
6
mai 20
|
4640 | ||
|
0
mars 15
|
4251 | ||
|
3
juil. 25
|
2008 | ||
|
1
juin 22
|
3165 | ||
|
2
nov. 21
|
2676 |