On the item page, we would like the SKU to be updated with the selection of a different variant. Anytime the variant SKU is updated all variants are updated to the same SKU. Is there a solution?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
Hi,
Create a Computed Field for SKU:
First, create a computed field in your product template or product variant model that will calculate the SKU based on the selected variant.
from odoo import fields, models, api
class ProductTemplate(models.Model):
_inherit = 'product.template'
variant_sku = fields.Char(string='Variant SKU', compute='_compute_variant_sku', store=True)
@api.depends('product_variant_ids')
def _compute_variant_sku(self):
for template in self:
if template.product_variant_ids:
template.variant_sku = template.product_variant_ids[0].sku
else:
template.variant_sku = ''
class ProductProduct(models.Model):
_inherit = 'product.product'
sku = fields.Char(string='SKU')
@api.onchange('sku')
def _onchange_sku(self):
for variant in self.product_tmpl_id.product_variant_ids:
variant.sku = self.sku
sku in ProductProduct is the field where you enter the SKU for each variant.
Hope it helps
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
Parent item with Child SKUs: Reference Numbers
Diselesaikan
|
|
1
Jun 25
|
615 | |
|
1
Jul 25
|
997 | ||
|
0
Sep 24
|
922 | ||
|
0
Jul 24
|
958 | ||
|
0
Apr 24
|
1430 |
It would be awesome if you could do a video of how to implement this. Thanks
This is exactly what I am looking fro as well, so thank you for this.
Can you please provide a step by step as I am new to Odoo and have trouble finding things..such as "Computed Field for SKU" and " create a computed field in your product template or product variant model that will calculate the SKU based on the selected variant". Where do I go to do that?
Thank you for you for your time.