初始化更新模板categ_type字段
This commit is contained in:
@@ -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})
|
||||
Reference in New Issue
Block a user