我想在确认销售后在odoo website_sale中生成一张发票草稿,所以我继承了控制器,代码如下
@http.route(['/shop/confirmation'], type='http', auth="public", website=True)
def payment_confirmation(self, **post):
sale_order_id = http.request.session.get('sale_last_order_id')
if sale_order_id:
order = http.request.env['sale.order'].sudo().browse(sale_order_id)
# here I want to create a draft invoice
return http.request.render("website_sale.confirmation", {'order': order})
else:
return http.request.redirect('/shop')问题是:如何从订单创建发票底稿?
发布于 2017-08-17 21:56:23
两天后,我找到了解决方案,这是我的解决方案
@http.route(['/shop/confirmation'], type='http', auth="public", website=True)
def payment_confirmation(self, **post):
sale_order_id = http.request.session.get('sale_last_order_id')
if sale_order_id:
order = http.request.env['sale.order'].sudo().browse(sale_order_id)
for line in order.order_line:
line.qty_to_invoice = line.product_uom_qty
order.action_invoice_create()
return http.request.render("website_sale.confirmation", {'order': order})
else:
return http.request.redirect('/shop')https://stackoverflow.com/questions/45696484
复制相似问题