[FIX] product: prevent printing labels for archived products
Steps to reproduce the bug: - Create a storable product - Archive it - Try to print labels Problem: A traceback is triggered, Because when we click on print the label we have to open the wizard, so we load the wizard model `product.label.layout` via an onchange: https://github.com/odoo/odoo/blob/15.0/odoo/models.py#L6357-L6360 thanks to the context, it will find the concerned product (via default_product_id) Except that the product is archived, so ignored in the result returned by the onchange therefore, in the confirmation, we will create the wizard, but it will not have a product filled, so in the `_prepare_report_data` function we do not enter in the if or the elif: https://github.com/odoo/odoo/blob/d9f45ba6941939b3d4b40beb5abbc330be84d695/addons/product/wizard/product_label_layout. py#L49-L54 it will therefore raise a traceback when we want to iterate on it: https://github.com/odoo/odoo/blob/d9f45ba6941939b3d4b40beb5abbc330be84d695/addons/product/wizard/product_label_layout.py#L60 opw-2855659 closes odoo/odoo#97226 X-original-commit: 6dcec12074014434ce1283449700aa352993ac0c Signed-off-by: Adrien Widart <awt@odoo.com>
This commit is contained in:
@@ -1424,6 +1424,14 @@ msgstr ""
|
||||
msgid "Next Activity Type"
|
||||
msgstr ""
|
||||
|
||||
#. module: product
|
||||
#: code:addons/product/wizard/product_label_layout.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"No product to print, if the product is archived please unarchive it before "
|
||||
"printing its label."
|
||||
msgstr ""
|
||||
|
||||
#. module: product
|
||||
#: model_terms:ir.actions.act_window,help:product.product_supplierinfo_type_action
|
||||
msgid "No vendor pricelist found"
|
||||
|
||||
@@ -52,6 +52,8 @@ class ProductLabelLayout(models.TransientModel):
|
||||
elif self.product_ids:
|
||||
products = self.product_ids.ids
|
||||
active_model = 'product.product'
|
||||
else:
|
||||
raise UserError(_("No product to print, if the product is archived please unarchive it before printing its label."))
|
||||
|
||||
# Build data to pass to the report
|
||||
data = {
|
||||
|
||||
Reference in New Issue
Block a user