diff --git a/setup/stock_picking_auto_print/odoo/addons/stock_picking_auto_print b/setup/stock_picking_auto_print/odoo/addons/stock_picking_auto_print new file mode 120000 index 0000000..4b9e771 --- /dev/null +++ b/setup/stock_picking_auto_print/odoo/addons/stock_picking_auto_print @@ -0,0 +1 @@ +../../../../stock_picking_auto_print \ No newline at end of file diff --git a/setup/stock_picking_auto_print/setup.py b/setup/stock_picking_auto_print/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/stock_picking_auto_print/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_picking_auto_print/__manifest__.py b/stock_picking_auto_print/__manifest__.py index 85398b8..8245e55 100644 --- a/stock_picking_auto_print/__manifest__.py +++ b/stock_picking_auto_print/__manifest__.py @@ -5,12 +5,12 @@ { "name": "Direct Print", "summary": "Auto print when DO is ready", - "version": "11.0.1.0.0", + "version": "13.0.1.0.0", "license": "AGPL-3", "author": "Open Source Integrators, Odoo Community Association (OCA)", "category": "Generic Modules/Base", "website": "http://www.opensourceintegrators.com", - "depends": ["sale_stock", "base_report_to_printer", ], + "depends": ["sale_stock", "base_report_to_printer"], "data": ["views/ir_action_report_view.xml"], "maintainers": ["bodedra"], "installable": True, diff --git a/stock_picking_auto_print/models/stock_picking.py b/stock_picking_auto_print/models/stock_picking.py index 4692909..6501895 100644 --- a/stock_picking_auto_print/models/stock_picking.py +++ b/stock_picking_auto_print/models/stock_picking.py @@ -2,7 +2,7 @@ # Copyright (C) 2019 Open Source Integrators # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, models +from odoo import models class StockPicking(models.Model): @@ -41,7 +41,6 @@ class StockPicking(models.Model): ) return report_id - @api.multi def _stock_picking_default_auto_print_report(self): user_company_id = self.env.user.company_id.id report_action_pool = self.env["ir.actions.report"] @@ -78,18 +77,16 @@ class StockPicking(models.Model): try: action_report.print_document(picking.id) - except: + except Exception: pass return True - @api.multi def write(self, vals): res = super(StockPicking, self).write(vals) if "date_done" in vals: self._stock_picking_default_auto_print_report() return res - @api.multi def action_assign(self): res = super(StockPicking, self).action_assign() for picking in self: diff --git a/stock_picking_auto_print/tests/test_stock_picking_auto_print.py b/stock_picking_auto_print/tests/test_stock_picking_auto_print.py index 54f9095..ad26cbb 100644 --- a/stock_picking_auto_print/tests/test_stock_picking_auto_print.py +++ b/stock_picking_auto_print/tests/test_stock_picking_auto_print.py @@ -11,9 +11,19 @@ class StockPikcing(TransactionCase): self.stock_location = self.env.ref("stock.stock_location_stock") self.customer_location = self.env.ref("stock.stock_location_customers") - self.scrapped_location = self.env.ref("stock.stock_location_scrapped") + stock_location_locations_virtual = self.env["stock.location"].create( + {"name": "Virtual Locations", "usage": "view", "posz": 1} + ) + self.scrapped_location = self.env["stock.location"].create( + { + "name": "Scrapped", + "location_id": stock_location_locations_virtual.id, + "scrap_location": True, + "usage": "inventory", + } + ) - uom_unit = self.env.ref("product.product_uom_unit") + uom_unit = self.env.ref("uom.product_uom_unit") self.product_A = self.env["product.product"].create( { @@ -55,7 +65,7 @@ class StockPikcing(TransactionCase): } ) - self.uom_unit = self.env.ref("product.product_uom_unit") + self.uom_unit = self.env.ref("uom.product_uom_unit") def test_stock_picking_auto_print(self): """ Auto print when DO is ready or done