From 47f7c057ee47b5c1a092b9f37b10e49a862577a1 Mon Sep 17 00:00:00 2001 From: mav-adhoc Date: Fri, 15 Nov 2024 14:12:11 -0300 Subject: [PATCH] [FIX] stock_voucher_ux: print and assign method --- stock_voucher_ux/__manifest__.py | 2 +- stock_voucher_ux/controllers/main.py | 2 +- .../wizards/stock_print_stock_voucher.py | 18 +++++++++++++----- .../stock_print_stock_voucher_views.xml | 10 ++++++++++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/stock_voucher_ux/__manifest__.py b/stock_voucher_ux/__manifest__.py index be31813fb..621307459 100644 --- a/stock_voucher_ux/__manifest__.py +++ b/stock_voucher_ux/__manifest__.py @@ -19,7 +19,7 @@ ############################################################################## { 'name': 'Stock Voucher UX', - 'version': "16.0.1.1.0", + 'version': "16.0.1.2.0", 'category': 'Warehouse Management', 'sequence': 14, 'summary': '', diff --git a/stock_voucher_ux/controllers/main.py b/stock_voucher_ux/controllers/main.py index 70a4bf623..d04244923 100644 --- a/stock_voucher_ux/controllers/main.py +++ b/stock_voucher_ux/controllers/main.py @@ -37,7 +37,7 @@ def report_download(self, data, context=None): if store_pags_picking_id: pdf_response = response.response[0] reader = PdfFileReader(io.BytesIO(pdf_response)) - number_pages = reader.getNumPages() + number_pages = len(reader.pages) if not request.env['stock.picking'].browse(store_pags_picking_id).voucher_ids: request.env['stock.picking'].browse(store_pags_picking_id).assign_numbers(number_pages, book_id) diff --git a/stock_voucher_ux/wizards/stock_print_stock_voucher.py b/stock_voucher_ux/wizards/stock_print_stock_voucher.py index 3d85b7f73..1bfae7928 100644 --- a/stock_voucher_ux/wizards/stock_print_stock_voucher.py +++ b/stock_voucher_ux/wizards/stock_print_stock_voucher.py @@ -2,8 +2,8 @@ # For copyright and license notices, see __manifest__.py file in module root # directory ############################################################################## -from odoo import fields, api, models - +from odoo import fields, api, models, _ +from odoo.exceptions import UserError class StockPrintStockVoucher(models.TransientModel): _inherit = 'stock.print_stock_voucher' @@ -13,9 +13,17 @@ def do_print_and_assign(self): if self.book_id.lines_per_voucher != 0: return { 'actions': [ - {'type': 'ir.actions.act_window_close'}, - self.with_context(assign=True).do_print_voucher(), + self.with_context(assign=True).do_print_voucher(), + {'type': 'ir.actions.client', 'tag': 'soft_reload'}, ], - 'type': 'ir.actions.act_multi' + 'type': 'ir.actions.act_multi', } return super().do_print_and_assign() + + def do_print_voucher(self): + self.printed = True + if self.book_id: + self.picking_id.write({'book_id': self.book_id.id}) + if not self.picking_id.book_id: + raise UserError(_('You must enter a voucher book')) + return self.picking_id.do_print_voucher() diff --git a/stock_voucher_ux/wizards/stock_print_stock_voucher_views.xml b/stock_voucher_ux/wizards/stock_print_stock_voucher_views.xml index 210d3ef42..a1c50b743 100644 --- a/stock_voucher_ux/wizards/stock_print_stock_voucher_views.xml +++ b/stock_voucher_ux/wizards/stock_print_stock_voucher_views.xml @@ -9,6 +9,16 @@ + + 1 + + + 1 + + + Asignar + oe_highlight +