Skip to content

Commit

Permalink
[FIX]stock_voucher_ux:dependencies
Browse files Browse the repository at this point in the history
closes #539

Signed-off-by: Matias Velazquez <[email protected]>
  • Loading branch information
jcadhoc committed Dec 27, 2024
1 parent ad885fd commit af3a978
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion stock_batch_picking_voucher/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from . import stock_picking_voucher
from . import stock_batch_picking
from . import stock_picking_batch
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ def assign_numbers(self, estimated_number_of_pages, book):
estimated_number_of_pages = fields.Integer(
'Number of Pages',
)

lines_per_voucher = fields.Integer(
'Lines Per Voucher',
related='book_id.lines_per_voucher',
)


@api.model
def _get_book(self):
return self.book_id or self.env['stock.book'].search([('company_id', '=', self.picking_ids[:1].company_id.id)], limit=1)
Expand All @@ -78,18 +73,12 @@ def _get_book(self):
def _compute_with_vouchers(self):
for rec in self:
rec.with_vouchers = bool(self.voucher_ids)

# def do_print_voucher(self):
# self.printed = True
# # if self.book_id:
# # self.book_id = self.book_id.id
# return self.do_print_batch_vouchers()


def do_print_and_assign(self):
# We override the method to avoid assignation
if not self.book_id:
raise UserError("Primero debe setear un talonario")
if self.book_id.lines_per_voucher != 0:
if not self.book_id.autoprinted:
self.printed = True
return self.with_context(batch=True).do_print_batch_vouchers()
self.assign_numbers(1,self.book_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<field name="priority">99</field>
<field name="arch" type="xml">
<button name="action_print" position="before">
<button name="do_print_and_assign" invisible="voucher_ids or state not in ('done')" string="Imprimir Remitos" type="object" class="oe_highlight" help="Imprime remite preimpreso y asigna remitos dependiendo de la cantidad de hojas a imprimir (cálculo automático)"/>
<button name="do_print_batch_vouchers" invisible="state not in ('done')" string="Imprimir" type="object" help="Imprime remito preimpreso"/>
<button name="do_print_and_assign" invisible="voucher_ids or state not in ('done')" string="Imprimir Remitos" type="object" class="oe_highlight" help="Prints pre-printed report and assigns vouchers depending on the number of sheets to be printed (automatic calculation)"/>
<button name="do_print_batch_vouchers" invisible="state not in ('done')" string="Imprimir" type="object" help="Print pre-printed report"/>
<button name="do_clean" invisible="not voucher_ids" string="Limpiar remitos" type="object"/>
</button>
<field name="user_id" position="after">
Expand Down
12 changes: 8 additions & 4 deletions stock_voucher_ux/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
<field name="voucher_ids" position="after">
<field name="with_vouchers" invisible="1"/>
</field>
<xpath expr="//button[@name='%(stock_voucher.action_stock_print_voucher)d'][2]" position="replace">
<button name="do_print_and_assign" type="object" class="oe_highlight" string="Print Vouchers" invisible="with_vouchers == True or state != 'done'"/>
<xpath expr="//button[@name='%(stock_voucher.action_stock_print_voucher)d'][1]" position="after">
<button name="do_print_and_assign" type="object" class="oe_highlight" string="Print Vouchers" invisible="with_vouchers == True or state != 'done'"/>
</xpath>
<xpath expr="//button[@name='%(stock_voucher.action_stock_print_voucher)d'][1]" position="replace">
<button name="clean_voucher_data" type="object" string="Clean Voucher Data" invisible="with_vouchers == False"/>
<xpath expr="//button[@name='%(stock_voucher.action_stock_print_voucher)d'][1]" position='attributes'>
<attribute name="invisible">1</attribute>
</xpath>

<!-- <xpath expr="//button[@name='%(stock_voucher.action_stock_print_voucher)d'][2]" position="replace">
<button name="clean_voucher_data" type="object" string="Clean Voucher Data" invisible="with_vouchers == False"/>
</xpath> -->
<xpath expr="//button[@name='%(stock.action_report_delivery)d']" position="replace">
<button name="do_print_voucher" type="object" string="Print" invisible="state != 'done'" />
</xpath>
Expand Down

0 comments on commit af3a978

Please sign in to comment.