js:
//绑定周转箱
bind_pass_box_create: function(){
console.log('1111111');
var self = this;
var records = _.map(self.selectedRecords, function (id) {
return self.model.localData[id];
});
var ids1 = _.pluck(records, 'res_id');
this._rpc({
model: 'wms.out.turnbox',
method: 'bind_pass_box',
args: [ids1],
}).then(function (result) {
console.log('2222222');
new dialogs.BiconSelectCreateDialog(self, {
res_model: 'base.container',
title: '选择周转箱',
list_view_id: result.list_view_id || false,
search_view_id: result.search_view_id || false,
disable_multiple_selection: true,
no_create: true,
custom_button: true,
text: '确定',
domain: [['containertype', '=', '1'], ['usestatus', '=', '1']],
on_selected: function (records) {
var ids = _.pluck(records, 'res_id');
self._rpc({
model: 'wms.out.turnbox',
method: 'bind_pass_box_confirm',
args: [ids1, ids],
}).then(function () {
self.reload();
});
}
}).open();
});
},
函数(方法)
@api.model
def bind_pass_box(self, ids1):
"""
绑定周转箱
:return:
"""
logger.critical('绑定周转箱')
if not ids1:
raise ValidationError('请选择至少一条数据')
else:
records = self.env['wms.out.turnbox'].search([('id', 'in', ids1)])
for record in records:
if record.containerno:
raise ValidationError('该周转箱任务已绑定周转箱,不能重复绑定')
else:
view_id = self.env.ref('bicon_wms_base.tree_base_container').id
return {
'list_view_id': view_id,
}
@api.model
def bind_pass_box_confirm(self, ids1, ids):
"""
弹出周转箱选择的确认窗口
周转箱绑定,状态变为待拣货, 容器的使用状态改变,选择是内用周转箱
:return:
"""
logger.critical('弹出周转箱选择的窗口')
container_records = self.env['base.container'].search([('id', 'in', ids)])
container_records.usestatus = USESTATUS.OCCUPY.value # 由空闲变为占用
box_records = self.env['wms.out.turnbox'].search([('id', 'in', ids1)])
box_records.containerno = container_records.containerno
box_records.usestatus = WTB_STATUS.PICKING.value # 状态由待绑定变为 待拣货
box_records.containerid = container_records.id
box_records.binddate = datetime.today().strftime('%Y-%m-%d')
print('bind_pass_box_confirm')
因篇幅问题不能全部显示,请点此查看更多更全内容