mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 23:52:04 +02:00
Initial commit: Sale packages
This commit is contained in:
commit
14e3d26998
6469 changed files with 2479670 additions and 0 deletions
|
|
@ -0,0 +1,38 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import exceptions, SUPERUSER_ID
|
||||
from odoo.addons.sale.controllers.portal import CustomerPortal
|
||||
from odoo.http import request, route
|
||||
from odoo.tools import consteq
|
||||
|
||||
|
||||
class SaleStockPortal(CustomerPortal):
|
||||
|
||||
def _stock_picking_check_access(self, picking_id, access_token=None):
|
||||
picking = request.env['stock.picking'].browse([picking_id])
|
||||
picking_sudo = picking.sudo()
|
||||
try:
|
||||
picking.check_access_rights('read')
|
||||
picking.check_access_rule('read')
|
||||
except exceptions.AccessError:
|
||||
if not access_token or not consteq(picking_sudo.sale_id.access_token, access_token):
|
||||
raise
|
||||
return picking_sudo
|
||||
|
||||
@route(['/my/picking/pdf/<int:picking_id>'], type='http', auth="public", website=True)
|
||||
def portal_my_picking_report(self, picking_id, access_token=None, **kw):
|
||||
""" Print delivery slip for customer, using either access rights or access token
|
||||
to be sure customer has access """
|
||||
try:
|
||||
picking_sudo = self._stock_picking_check_access(picking_id, access_token=access_token)
|
||||
except exceptions.AccessError:
|
||||
return request.redirect('/my')
|
||||
|
||||
# print report with sudo, since it require access to product, taxes, payment term etc.. and portal does not have those access rights.
|
||||
pdf = request.env['ir.actions.report'].sudo()._render_qweb_pdf('stock.action_report_delivery', [picking_sudo.id])[0]
|
||||
pdfhttpheaders = [
|
||||
('Content-Type', 'application/pdf'),
|
||||
('Content-Length', len(pdf)),
|
||||
]
|
||||
return request.make_response(pdf, headers=pdfhttpheaders)
|
||||
Loading…
Add table
Add a link
Reference in a new issue