Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] stock_voucher_ux: print and assign method #583

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stock_voucher_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': '',
Expand Down
2 changes: 1 addition & 1 deletion stock_voucher_ux/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 13 additions & 5 deletions stock_voucher_ux/wizards/stock_print_stock_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
10 changes: 10 additions & 0 deletions stock_voucher_ux/wizards/stock_print_stock_voucher_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
<xpath expr="//field[@name='estimated_number_of_pages']" position="replace">
<field name="estimated_number_of_pages" string="Number estimated of pages" attrs="{'invisible':[('lines_per_voucher', '=', 0)],'required':[('lines_per_voucher', '!=', 0)]}" help="Estimate calculated to have an idea of the approximate number of pages. The real value will be known after printing" />
</xpath>
<xpath expr="//button[@name='assign_numbers'][1]" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='assign_numbers'][2]" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='do_print_and_assign'][2]" position="attributes">
<attribute name="string">Asignar</attribute>
<attribute name="class">oe_highlight</attribute>
</xpath>
</field>
</record>
</odoo>