Skip to content

Commit

Permalink
[FIX] stock_voucher_ux: print and assign method
Browse files Browse the repository at this point in the history
  • Loading branch information
mav-adhoc committed Dec 4, 2024
1 parent 420fd31 commit 7ecd7cd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
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
17 changes: 13 additions & 4 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 @@ -12,10 +12,19 @@ def do_print_and_assign(self):
# We override the method to avoid assignation
if self.book_id.lines_per_voucher != 0:
return {
'type': 'ir.actions.act_multi',
'actions': [
{'type': 'ir.actions.act_window_close'},
{'type': 'ir.actions.client', 'tag': 'reload'},
self.with_context(assign=True).do_print_voucher(),
],
'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>

0 comments on commit 7ecd7cd

Please sign in to comment.