当同时使用_inherit和 _name 属性时,DTCloud使用现有模型(通过_inherit提供)作为base创建新模型。新模型从其base中获取所有字段、方法和元信息(默认值等)
class hardware(models.Model):
_name = 'hardware'
_description = '设备'
name = fields.Char()
def call(self):
return self.check("设备")
def check(self, s):
return "This is {} record {}".format(s, self.name)
class hardware_light(models.Model):
_name = 'hardware.light'
_inherit = 'hardware'
_description = '灯'
def call(self):
return self.check("灯")