Skip to content

Commit

Permalink
Merge pull request #13 from GlodoUK/sale_stock_force_pdf_download
Browse files Browse the repository at this point in the history
[FEAT][FIX] Sale Stock Force PDF Download module
  • Loading branch information
GarethGloSystems authored Apr 25, 2024
2 parents 983bc54 + ec87b14 commit 2954c48
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sale_stock_force_pdf_download/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Sale Stock Force PDF Download
=============================

Force PDF download instead of PDF preview when viewing stock picking records via the sales order portal

This fixes a bug related to certain PDF extensions that run in Chrome whereby the request to "Print" via the portal causes the PDF preview to request the same file repeatedly in a loop, which eventually consumes all available workers.
1 change: 1 addition & 0 deletions sale_stock_force_pdf_download/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import controllers, models
9 changes: 9 additions & 0 deletions sale_stock_force_pdf_download/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Sale Stock Force PDF Download",
"version": "15.0.1.0.0",
"category": "Hidden",
"author": "Glo Networks",
"website": "https://github.com/GlodoUK/sale",
"depends": ["sale_stock"],
"license": "LGPL-3",
}
1 change: 1 addition & 0 deletions sale_stock_force_pdf_download/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import portal
24 changes: 24 additions & 0 deletions sale_stock_force_pdf_download/controllers/portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from odoo import exceptions
from odoo.http import request, route

from odoo.addons.sale_stock.controllers.portal import SaleStockPortal


class DriftworksSaleStockPortal(SaleStockPortal):
# Hard Override https://github.com/odoo/odoo/blob/16.0/addons/sale_stock/controllers/portal.py#L24
@route()
def portal_my_picking_report(self, picking_id, access_token=None, **kw):
try:
picking_sudo = self._stock_picking_check_access(
picking_id,
access_token=access_token,
)
except exceptions.AccessError:
return request.redirect("/my")

return self._show_report(
model=picking_sudo,
report_type="pdf",
report_ref="stock.action_report_delivery",
download=True,
)
1 change: 1 addition & 0 deletions sale_stock_force_pdf_download/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_picking
9 changes: 9 additions & 0 deletions sale_stock_force_pdf_download/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import models


class StockPicking(models.Model):
_inherit = "stock.picking"

def _get_report_base_filename(self):
self.ensure_one()
return "%s" % self.name
6 changes: 6 additions & 0 deletions setup/sale_stock_force_pdf_download/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 2954c48

Please sign in to comment.