[FIX] stock: fix zpl label for product without barcode
Current behavior: When printing a ZPL label for a product without barcode, the label was printed with a barcode containing the "False" value Steps to reproduce: - Install the stock module - Create a product without barcode - Print a ZPL label for this product - The label contains a barcode with the "False" value (You can check the rendering on labelary.com) opw-3797462 closes odoo/odoo#158939 X-original-commit: e392027afa245a708a906b484250ed46200e13be Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com> Signed-off-by: Robin Engels (roen) <roen@odoo.com>
This commit is contained in:
@@ -25,7 +25,7 @@ class ReportProductLabel(models.AbstractModel):
|
||||
product = Product.browse(int(p))
|
||||
default_code_markup = markupsafe.Markup(product.default_code) if product.default_code else ''
|
||||
product_info = {
|
||||
'barcode': markupsafe.Markup(product.barcode),
|
||||
'barcode': markupsafe.Markup(product.barcode) if product.barcode else '',
|
||||
'quantity': q,
|
||||
'display_name_markup': markupsafe.Markup(product.display_name),
|
||||
'default_code': (default_code_markup[:15], default_code_markup[15:30])
|
||||
|
||||
@@ -96,6 +96,16 @@ class TestReports(TestReportsCommon):
|
||||
self.assertEqual(target, rendering.replace(b' ', b''), 'The rendering is not good, make sure quotes are correctly escaped')
|
||||
self.assertEqual(qweb_type, 'text', 'the report type is not good')
|
||||
|
||||
def test_reports_product_no_barcode(self):
|
||||
""" Test that product without barcode is correctly rendered without a barcode.
|
||||
"""
|
||||
report = self.env.ref('stock.label_product_product')
|
||||
self.product1.barcode = False
|
||||
target = b'\n\n^XA^CI28\n^FT100,80^A0N,40,30^FD[C4181234""154654654654]Mellohi"^FS\n^FT100,115^A0N,30,24^FDC4181234""15465^FS\n^FT100,150^A0N,30,24^FD4654654^FS\n^XZ\n'
|
||||
rendering, qweb_type = report._render_qweb_text('stock.label_product_product', self.product1.product_tmpl_id.id, {'quantity_by_product': {self.product1.product_tmpl_id.id: 1}, 'active_model': 'product.template'})
|
||||
self.assertEqual(target, rendering.replace(b' ', b''), 'Product name, default code or barcode is not correctly rendered, make sure the quotes are escaped correctly')
|
||||
self.assertEqual(qweb_type, 'text', 'the report type is not good')
|
||||
|
||||
def test_report_quantity_1(self):
|
||||
product_form = Form(self.env['product.product'])
|
||||
product_form.detailed_type = 'product'
|
||||
|
||||
Reference in New Issue
Block a user