Reputation: 73
I need to automatically create customer invoice after clicking the designated button of the view in the attached screen capture. I already created a module that overrides the behavior of the button ( it actually just calls the method from super i.e, stock.transfer_details' method do_detailed_transfer() ), but I can't figure out how to create the invoice automatically ( which is done in the next view. after clicking the button, odoo shows Create Invoice view, and I want ro skip that view and do it automatically from code)
Any ideas ??
EDIT :
Good morning, I figured out how to do it by inspecting the code that creates the invoice from the stock_account module and here is my attempt :
def create_invoice(self, cr, uid, ids, context=None):
picking_pool = self.pool.get('stock.picking')
inv_ship_obj = self.pool.get('stock.invoice.onshipping')
data = inv_ship_obj.browse(cr, uid, ids[0], context)
context['date_inv'] = data.invoice_date
inv_type = 'out_invoice'
context['inv_type'] = inv_type
active_ids = context.get('active_ids', [])
res = picking_pool.action_invoice_create(cr, uid, active_ids,
journal_id = data.journal_id.id,
group = data.group,
type = inv_type,
context=context)
return res
I just put that method in a class and called it from the method : do_detailed_transfer()
in case anyone needed that.
Upvotes: 1
Views: 688
Reputation: 73
the answer is in the EDIT
I also had another module showing a form which I deactivated by overriding the method responsible for that.
Upvotes: 0