我有四个字段开始,结束,忽略和范围 我需要在范围字段上显示开始和结束的范围,并忽略=忽略字段的元素
方法运行良好,直到我添加了remove方法 我需要首先输入ignore字段才能正常工作,但是即使没有被忽略的记录,我也需要这种方法来工作
class yearrange(models.Model):
_name = 'yearrange'
_rec_name = 'name'
name = fields.Char()
product_id = fields.Many2one(comodel_name="product.template")
class autopart(models.Model):
_inherit = 'product.template'
@api.multi
@api.onchange('start', 'end','ignore')
def years(self):
print('innnnn')
for rec in self:
if rec.start and rec.end:
record = [int(x) for x in range(int(rec.start), int(rec.end) + 1)]
record.remove(int(self.ignore))
for item in record:
print(item)
range_id = self.env['yearrange'].create({'name': str(item)})
list.append(range_id.id)
rec.rang = [(4, x, None) for x in list]
start = fields.Char(string="", required=False, )
end = fields.Char(string="", required=False, )
rang = fields.One2many(comodel_name="yearrange",
inverse_name="product_id",
store=True,
string="Years")
ignore = fields.Char(string="Ignore", required=False, )