In default Odoo, when we archived the Product variants and then when we create a new variant then automatic archived variants are visible in product. Have any one have idea to resolve this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Buchhaltung
- Lager
- PoS
- Project
- MRP
Diese Frage wurde gekennzeichnet
Hi,
There are two approaches:
1. Use a computed domain on product variants
Override the product template view to show only active variants in dropdowns.
Example:
<field name="product_variant_ids" domain="[('active','=',True)]"/>
This doesn’t prevent creation, but it hides archived variants from selection.
2. Prevent automatic unarchiving via code
Override _create_variant_ids in product.template:
from odoo import models
class ProductTemplate(models.Model):
_inherit = 'product.template'
def _create_variant_ids(self):
# Prevent archived variants from being reactivated
existing_variants = self.product_variant_ids.filtered(lambda v: not v.active)
super(ProductTemplate, self)._create_variant_ids()
# Re-archive any variants that were previously archived
existing_variants.write({'active': False})
Hope it helps.
Hi,
You should removed this archived variant from the product template before created the new one.
Regards!
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
Registrieren