[IMP] nfu_product: add image upload in batch
This commit is contained in:
parent
f38049fbf0
commit
8bf8e3ffe5
10 changed files with 78 additions and 11 deletions
|
|
@ -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
|
||||
===========
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
from . import models
|
||||
from . import wizard
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
2
nfu_product/security/ir.model.access.csv
Normal file
2
nfu_product/security/ir.model.access.csv
Normal file
|
|
@ -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
|
||||
|
|
|
@ -394,6 +394,7 @@ ul.auto-toc {
|
|||
<li>16.0.1.1.0: Add multi company to product packagings</li>
|
||||
<li>16.0.1.1.1: Avoid unvalid packaging companies</li>
|
||||
<li>16.0.1.2.0: Relate package companies to products</li>
|
||||
<li>16.0.1.3.0: Add wizard to bulk upload images to product variants</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
|
|
|
|||
|
|
@ -19,4 +19,27 @@
|
|||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_product_variant_bulk_upload" model="ir.actions.act_window">
|
||||
<field name="name">Bulk Upload Images</field>
|
||||
<field name="res_model">product.variant.bulk.upload.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record id="action_product_upload_images" model="ir.actions.server">
|
||||
<field name="name">Upload images</field>
|
||||
<field name="model_id" ref="product.model_product_product"/>
|
||||
<field name="binding_model_id" ref="product.model_product_product"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
action = {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": "product.variant.bulk.upload.wizard",
|
||||
"view_mode": "form",
|
||||
"target": "new",
|
||||
"context": {"active_ids": records.ids},
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
|
|||
1
nfu_product/wizard/__init__.py
Normal file
1
nfu_product/wizard/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import product_variant_bulk_upload_wizard
|
||||
20
nfu_product/wizard/product_variant_bulk_upload_wizard.py
Normal file
20
nfu_product/wizard/product_variant_bulk_upload_wizard.py
Normal file
|
|
@ -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
|
||||
17
nfu_product/wizard/product_variant_bulk_upload_wizard.xml
Normal file
17
nfu_product/wizard/product_variant_bulk_upload_wizard.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<odoo>
|
||||
<record id="view_product_variant_bulk_upload_wizard_form" model="ir.ui.view">
|
||||
<field name="name">product.variant.bulk.upload.wizard.form</field>
|
||||
<field name="model">product.variant.bulk.upload.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Bulk Upload Images">
|
||||
<group>
|
||||
<field name="file" filename="filename" widget="binary"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Upload" type="object" name="action_upload_images" class="btn-primary"/>
|
||||
<button string="Cancel" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Reference in a new issue