From 8bf8e3ffe56de5435caefd88e654009a77a98c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20G=C3=B6ttsch?= Date: Fri, 19 Sep 2025 16:51:38 +0200 Subject: [PATCH] [IMP] nfu_product: add image upload in batch --- nfu_product/README.rst | 10 ++++---- nfu_product/__init__.py | 1 + nfu_product/__manifest__.py | 4 +++- nfu_product/readme/HISTORY.rst | 10 ++++---- nfu_product/security/ir.model.access.csv | 2 ++ nfu_product/static/description/index.html | 1 + nfu_product/views/product_product_views.xml | 23 +++++++++++++++++++ nfu_product/wizard/__init__.py | 1 + .../product_variant_bulk_upload_wizard.py | 20 ++++++++++++++++ .../product_variant_bulk_upload_wizard.xml | 17 ++++++++++++++ 10 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 nfu_product/security/ir.model.access.csv create mode 100644 nfu_product/wizard/__init__.py create mode 100644 nfu_product/wizard/product_variant_bulk_upload_wizard.py create mode 100644 nfu_product/wizard/product_variant_bulk_upload_wizard.xml diff --git a/nfu_product/README.rst b/nfu_product/README.rst index 17d8f41..f04ed6f 100644 --- a/nfu_product/README.rst +++ b/nfu_product/README.rst @@ -33,11 +33,11 @@ NFU Product Changelog ========= -- 16.0.1.0.0: Initial module. -- 16.0.1.1.0: Add multi company to product packagings -- 16.0.1.1.1: Avoid unvalid packaging companies -- 16.0.1.2.0: Relate package companies to products - +- 16.0.1.0.0: Initial module. +- 16.0.1.1.0: Add multi company to product packagings +- 16.0.1.1.1: Avoid unvalid packaging companies +- 16.0.1.2.0: Relate package companies to products +- 16.0.1.3.0: Add wizard to bulk upload images to product variants Bug Tracker =========== diff --git a/nfu_product/__init__.py b/nfu_product/__init__.py index 0650744..9b42961 100644 --- a/nfu_product/__init__.py +++ b/nfu_product/__init__.py @@ -1 +1,2 @@ from . import models +from . import wizard diff --git a/nfu_product/__manifest__.py b/nfu_product/__manifest__.py index 61676bd..5321cc6 100644 --- a/nfu_product/__manifest__.py +++ b/nfu_product/__manifest__.py @@ -4,12 +4,14 @@ "author": "BAKEUP", "website": "https://www.bakeup.org", "category": "product", - "version": "16.0.1.1.1", + "version": "16.0.1.3.0", "depends": ["product_multi_company"], "data": [ + "security/ir.model.access.csv", "views/product_packaging_views.xml", "views/product_product_views.xml", "views/product_template_views.xml", + "wizard/product_variant_bulk_upload_wizard.xml", ], "license": "LGPL-3", } diff --git a/nfu_product/readme/HISTORY.rst b/nfu_product/readme/HISTORY.rst index dc46835..c9f6710 100644 --- a/nfu_product/readme/HISTORY.rst +++ b/nfu_product/readme/HISTORY.rst @@ -1,5 +1,5 @@ -- 16.0.1.0.0: Initial module. -- 16.0.1.1.0: Add multi company to product packagings -- 16.0.1.1.1: Avoid unvalid packaging companies -- 16.0.1.2.0: Relate package companies to products - +- 16.0.1.0.0: Initial module. +- 16.0.1.1.0: Add multi company to product packagings +- 16.0.1.1.1: Avoid unvalid packaging companies +- 16.0.1.2.0: Relate package companies to products +- 16.0.1.3.0: Add wizard to bulk upload images to product variants diff --git a/nfu_product/security/ir.model.access.csv b/nfu_product/security/ir.model.access.csv new file mode 100644 index 0000000..52c26a1 --- /dev/null +++ b/nfu_product/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_variant_bulk_upload_wizard,access_product_variant_bulk_upload_wizard,model_product_variant_bulk_upload_wizard,base.group_user,1,1,1,1 diff --git a/nfu_product/static/description/index.html b/nfu_product/static/description/index.html index 86498cc..754ea60 100644 --- a/nfu_product/static/description/index.html +++ b/nfu_product/static/description/index.html @@ -394,6 +394,7 @@ ul.auto-toc {
  • 16.0.1.1.0: Add multi company to product packagings
  • 16.0.1.1.1: Avoid unvalid packaging companies
  • 16.0.1.2.0: Relate package companies to products
  • +
  • 16.0.1.3.0: Add wizard to bulk upload images to product variants
  • diff --git a/nfu_product/views/product_product_views.xml b/nfu_product/views/product_product_views.xml index 5ef9904..0296d22 100644 --- a/nfu_product/views/product_product_views.xml +++ b/nfu_product/views/product_product_views.xml @@ -19,4 +19,27 @@ + + + Bulk Upload Images + product.variant.bulk.upload.wizard + form + new + + + + Upload images + + + code + + action = { + "type": "ir.actions.act_window", + "res_model": "product.variant.bulk.upload.wizard", + "view_mode": "form", + "target": "new", + "context": {"active_ids": records.ids}, + } + + diff --git a/nfu_product/wizard/__init__.py b/nfu_product/wizard/__init__.py new file mode 100644 index 0000000..58a6c8e --- /dev/null +++ b/nfu_product/wizard/__init__.py @@ -0,0 +1 @@ +from . import product_variant_bulk_upload_wizard diff --git a/nfu_product/wizard/product_variant_bulk_upload_wizard.py b/nfu_product/wizard/product_variant_bulk_upload_wizard.py new file mode 100644 index 0000000..417842b --- /dev/null +++ b/nfu_product/wizard/product_variant_bulk_upload_wizard.py @@ -0,0 +1,20 @@ +from odoo import fields, models + + +class ProductVariantBulkUploadWizard(models.TransientModel): + _name = "product.variant.bulk.upload.wizard" + _description = "Bulk Upload Images for Product Variants" + + file = fields.Binary(required=True) + + def action_upload_images(self): + if not self.file: + return + + # Get the active product variants from the context + active_ids = self.env.context.get("active_ids", []) + product_variants = self.env["product.product"].browse(active_ids) + + # Assign the uploaded image to each selected product variant + for product_variant in product_variants: + product_variant.image_1920 = self.file diff --git a/nfu_product/wizard/product_variant_bulk_upload_wizard.xml b/nfu_product/wizard/product_variant_bulk_upload_wizard.xml new file mode 100644 index 0000000..63afdff --- /dev/null +++ b/nfu_product/wizard/product_variant_bulk_upload_wizard.xml @@ -0,0 +1,17 @@ + + + product.variant.bulk.upload.wizard.form + product.variant.bulk.upload.wizard + +
    + + + + +
    +
    +
    +