odoo根据最后一条记录而批量生成然后删除最后的那条记录

@api.multi
    def create_form(self):
        lasts = self.env['base.gather.zone.pos'].search([('id', '=', self.id)])
        last = lasts[-1]
        rows = int(last.rowno) + 1
        columnnos = int(last.columnno) + 1
        layernos = int(last.layerno) + 1
        print(rows, columnnos, layernos)
        records = []
        print('gatherzone = %s' % last.gatherzone)
        for row in range(1, rows):
            for column in range(1, columnnos):
                for layer in range(1, layernos):
                    if 0 < row < 10:
                        last.gatherpos = '12' + '-0' + str(row)
                    else:
                        last.gatherpos = '12' + '-' + str(row)
                    if 0 < column < 10:
                        last.gatherpos = str(last.gatherpos) + '-0' + str(column)
                    else:
                        last.gatherpos = str(last.gatherpos) + '-' + str(column)
                    if 0 < layer < 10:
                        last.gatherpos = str(last.gatherpos) + '-0' + str(layer)
                    else:
                        last.gatherpos = str(last.gatherpos) + '-' + str(layer)
                    last.gatherposno = last.gatherpos
                    record = {
                        'gatherzone': last.gatherzone,
                        'routename': last.routename.id,
                        'gatherpos': last.gatherpos,
                        'gatherposno': last.gatherposno,
                        'packs': last.packs,
                        'volume': last.volume,
                        'companynum': last.companynum,
                        'existspacks': last.existspacks,
                        'existsvolume': last.existsvolume,
                        'existcompanynum': last.existcompanynum,
                        'rowno': row,
                        'columnno': column,
                        'layerno': layer,
                        'gatherorder': last.gatherorder,
                        'usestatus': last.usestatus,
                        'memo': last.memo,
                        'gatherzoneid': last.gatherzoneid,
                        'routeid': last.routeid,
                        'seqid': last.seqid,


                    }
                    records.append(record)
        for record in records:
            self.env['base.gather.zone.pos'].create(record)
        lasts.unlink()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值