如何合并Lot/Serial个数
How to merge Lot/Serial number
我想添加一个向导,其中 'stock.production.lot'
的 Many2many
字段仅显示双倍 Lot/Serial Number
的记录
我做了获取过滤记录的功能,现在我需要显示它
class DoublingNumber(models.TransientModel):
_name = 'doubling.number'
double_number_id =fields.Many2many('stock.production.lot' ,string="Numéros en doublant" )
@api.multi
def _default_double_number(self):
log.warning("Hola")
double_record = []
records =self.env['stock.production.lot'].search([])
for record in records :
for record2 in records :
if record.name == record2.name and record.product_id != record2.product_id :
double_record.append(record2)
break
return double_record
现在怎么显示呢??!
尝试在字段定义中调用默认函数,但在字段之前定义函数并改为按以下方式定义它:
class DoublingNumber(models.TransientModel):
_name = 'doubling.number'
@api.model
def _default_double_number(self):
log.warning("Hola")
double_record = self.env['stock.production.lot']
records =self.env['stock.production.lot'].search([])
for record in records :
for record2 in records :
if record.name == record2.name and record.product_id != record2.product_id :
double_record += record2
break
return double_record
double_number_id =fields.Many2many('stock.production.lot' ,string="Numéros en doublant", default = _default_double_number)
祝你好运:)
我想添加一个向导,其中 'stock.production.lot'
的 Many2many
字段仅显示双倍 Lot/Serial Number
的记录
我做了获取过滤记录的功能,现在我需要显示它
class DoublingNumber(models.TransientModel):
_name = 'doubling.number'
double_number_id =fields.Many2many('stock.production.lot' ,string="Numéros en doublant" )
@api.multi
def _default_double_number(self):
log.warning("Hola")
double_record = []
records =self.env['stock.production.lot'].search([])
for record in records :
for record2 in records :
if record.name == record2.name and record.product_id != record2.product_id :
double_record.append(record2)
break
return double_record
现在怎么显示呢??!
尝试在字段定义中调用默认函数,但在字段之前定义函数并改为按以下方式定义它:
class DoublingNumber(models.TransientModel):
_name = 'doubling.number'
@api.model
def _default_double_number(self):
log.warning("Hola")
double_record = self.env['stock.production.lot']
records =self.env['stock.production.lot'].search([])
for record in records :
for record2 in records :
if record.name == record2.name and record.product_id != record2.product_id :
double_record += record2
break
return double_record
double_number_id =fields.Many2many('stock.production.lot' ,string="Numéros en doublant", default = _default_double_number)
祝你好运:)