Skip to content
Open
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_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Stock UX',
'version': "17.0.1.10.0",
'version': "17.0.1.11.0",
'category': 'Warehouse Management',
'sequence': 14,
'summary': '',
Expand Down
29 changes: 14 additions & 15 deletions stock_ux/wizards/stock_label_type.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import _, fields, models,api, Command
from odoo import _, fields, models, api, Command
from odoo.exceptions import ValidationError


class ProductLabelLayout(models.TransientModel):
_inherit = 'product.label.layout'

picking_id = fields.Many2one('stock.picking',string='picking')
line_ids = fields.One2many('stock.picking.zpl.lines','picking_zpl_id', string='Moves')
line_ids = fields.One2many("product.label.layout.lines", "label_layout_id", string="Moves")

@api.model
def default_get(self, default_fields):
rec = super().default_get(default_fields)
Expand All @@ -25,22 +27,19 @@ def action_print_pdf(self):
report_action['close_on_report_download']=True
return report_action

class StockPickingZplLines(models.TransientModel):
_name = 'stock.picking.zpl.lines'
_description = "Print Stock Voucher lines"

picking_zpl_id = fields.Many2one('product.label.layout')
class ProductLabelLayoutLines(models.TransientModel):

move_id = fields.Many2one('stock.move')
_name = "product.label.layout.lines"
_description = "Label layout lines"

label_layout_id = fields.Many2one("product.label.layout")
move_id = fields.Many2one("stock.move")
move_quantity = fields.Float()
move_uom_id = fields.Many2one("uom.uom")
name = fields.Char(related="move_id.name")

move_uom_id = fields.Many2one('uom.uom')

name = fields.Char(related='move_id.name')

@api.constrains('move_quantity')
@api.constrains("move_quantity")
def _check_move_quantity(self):
for line in self:
if line.move_quantity > line.move_id.quantity:
raise exceptions.ValidationError("La cantidad a imprimir no puede ser mayor que la cantidad original.")
raise ValidationError(_("La cantidad a imprimir no puede ser mayor que la cantidad original."))
22 changes: 10 additions & 12 deletions stock_voucher/wizards/stock_picking_wizard.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from odoo import fields, api, models, Command, exceptions
from odoo.exceptions import UserError
from odoo import fields, api, models, Command
from odoo.exceptions import UserError, ValidationError


class StockPickingZpl(models.TransientModel):

_inherit = 'product.label.layout'

picking_id = fields.Many2one('stock.picking',string='picking')
line_ids = fields.One2many('stock.picking.zpl.lines','picking_zpl_id', string='Moves')

@api.model
def default_get(self, default_fields):
rec = super().default_get(default_fields)
Expand All @@ -19,41 +20,38 @@ def default_get(self, default_fields):
move_ids = self.env[active_model].browse(active_ids).mapped('move_ids').filtered(lambda x: x.quantity > 0 )
rec['line_ids'] = [Command.create({'move_id': x.id, 'move_quantity':x.quantity,'move_uom_id': x.product_uom}) for x in move_ids]
return rec

def action_print(self):
self.ensure_one()
report_id = self.env.ref("stock_voucher.action_custom_barcode_transfer_template_view_zpl")
report_action = report_id.report_action(self.ids)
report_action['close_on_report_download']=True
return report_action

def action_print_pdf(self):
self.ensure_one()
picking_id = self.picking_id.id if self.picking_id else False
if not picking_id:
raise UserError("No se encontró un picking asociado al registro.")
raise UserError("No se encontró un picking asociado al registro.")
report_id = self.env.ref("stock_voucher.action_custom_label_transfer_template_view_pdf")
report_action = report_id.report_action([picking_id])
report_action['close_on_report_download'] = True
report_action['close_on_report_download'] = True
return report_action


class StockPickingZplLines(models.TransientModel):

_name = 'stock.picking.zpl.lines'
_description = "Print Stock Voucher lines"

picking_zpl_id = fields.Many2one('product.label.layout')

move_id = fields.Many2one('stock.move')

move_quantity = fields.Float()

move_uom_id = fields.Many2one('uom.uom')

name = fields.Char(related='move_id.name')

@api.constrains('move_quantity')
def _check_move_quantity(self):
for line in self:
if line.move_quantity > line.move_id.quantity:
raise exceptions.ValidationError("La cantidad a imprimir no puede ser mayor que la cantidad original.")
raise ValidationError("La cantidad a imprimir no puede ser mayor que la cantidad original.")