首页 > 解决方案 > Odoo12 类型错误

问题描述

from odoo import models,fields

# car/models/car.py
class Car(models.Model):
   _name = 'car.car'

   name  = fields.Char('Car name', size=25)
   brand = fields.Char('Car brand',default='Citroën DS',size=25)
   country = fields.Char('Country name ',default='France',size=30)

   def __init__(self):

      return 'The car name is : %s,\nIts brand is : %s,\nIts manufactured country is : %s.\n' %    (self.name,self.brand,self.country)

# car/models/product_template.py

class ProductTemplate(models.Model):
   _inherits = 'product.template'
   _name     = 'product.template'

   car       = fields.Many2one('car.car', string='Car name', ondelete='SET NULL', auto_join=True)

我的错误是:在“销售/产品/产品”中填写汽车信息之前,我在“产品类型”字段中选择了“可存储产品”值。现在我正在填写汽车信息,“保存”成功。我想编辑“产品类型”的值,从“可存储产品”到“消费品”或“服务”,我收到了这个错误:

文件“/odoo/odoo12/odoo/models.py”,第 5384 行,在值 [名称] 中的 cmd 的 onchange 中:TypeError:'int' 对象不可迭代”

请帮忙。

标签: eventstypeerrorhandlerodoo-12

解决方案


car_id       = fields.Many2one('car.car', string='Car name', ... )

推荐阅读