初始化更新模板categ_type字段

This commit is contained in:
胡尧
2024-11-13 11:37:16 +08:00
parent 5365211f49
commit 012bb9fd54
2 changed files with 10 additions and 0 deletions

View File

@@ -30,3 +30,11 @@ class ProductTemplate(models.Model):
self.is_manual_processing = product_template_id.is_manual_processing
# 复制 seller_ids
self.seller_ids = [(0, 0, {'partner_id': seller.partner_id.id, 'delay': 1.0}) for seller in product_template_id.seller_ids]
@api.model
def update_related_fields(self):
# 获取所有记录
products = self.search([('categ_type', '=', False), ('active', '=', False)])
for product in products:
# 通过调用 write 方法来触发 related 字段的更新
product.write({'categ_type': product.categ_id.type})