Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/修改机床参数bug
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
# -*-coding:utf-8-*-
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
'data/ir_cron_data.xml',
|
||||
'security/sf_stock_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/wizard_view.xml',
|
||||
'views/view.xml',
|
||||
'views/shelf_location.xml',
|
||||
'views/change_stock_move_views.xml',
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import base64
|
||||
@@ -19,14 +21,6 @@ class SfLocation(models.Model):
|
||||
name = fields.Char('Location Name', required=True, size=20)
|
||||
barcode = fields.Char('Barcode', copy=False, size=15)
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '启用'),
|
||||
('close', '关闭')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
# 仓库类别(selection:库区、库位、货位)
|
||||
# location_type = fields.Selection([
|
||||
# ('库区', '库区'),
|
||||
@@ -132,7 +126,7 @@ class SfLocation(models.Model):
|
||||
for record in self:
|
||||
if record.product_sn_id:
|
||||
record.product_id = record.product_sn_id.product_id
|
||||
record.location_status = '占用'
|
||||
# record.location_status = '占用'
|
||||
else:
|
||||
record.product_id = False
|
||||
# record.location_status = '空闲'
|
||||
@@ -197,6 +191,7 @@ class SfLocation(models.Model):
|
||||
# return res
|
||||
|
||||
# 生成货位
|
||||
|
||||
def create_location(self):
|
||||
"""
|
||||
当仓库类型为货架时,自动生成其下面的货位,数量为货架层数*层数容量
|
||||
@@ -228,11 +223,14 @@ class SfLocation(models.Model):
|
||||
|
||||
class SfShelf(models.Model):
|
||||
_name = 'sf.shelf'
|
||||
_inherit = ['printing.utils']
|
||||
_description = '货架'
|
||||
_order = 'name'
|
||||
_order = 'create_date desc'
|
||||
|
||||
name = fields.Char('货架名称', required=True, size=20)
|
||||
active = fields.Boolean("有效", default=True)
|
||||
barcode = fields.Char('编码', copy=False, size=15, required=True)
|
||||
|
||||
# 货位
|
||||
location_ids = fields.One2many('sf.shelf.location', 'shelf_id', string='货位')
|
||||
|
||||
@@ -306,11 +304,41 @@ class SfShelf(models.Model):
|
||||
j_str = str(j + 1).zfill(3) # 确保是两位数,如果不足两位,左侧补0
|
||||
return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + i_str + '-' + j_str
|
||||
|
||||
def print_all_location_barcode(self):
|
||||
"""
|
||||
打印所有货位编码
|
||||
"""
|
||||
print('=======打印货架所有货位编码=========')
|
||||
for record in self.location_ids:
|
||||
print('record', record)
|
||||
if not record.barcode:
|
||||
continue
|
||||
record.ensure_one()
|
||||
# qr_code_data = record.lot_qr_code
|
||||
# if not qr_code_data:
|
||||
# raise UserError("没有找到二维码数据。")
|
||||
barcode = record.barcode
|
||||
# todo 待控制
|
||||
if not barcode:
|
||||
raise ValidationError("请先分配序列号")
|
||||
# host = "192.168.50.110" # 可以根据实际情况修改
|
||||
# port = 9100 # 可以根据实际情况修改
|
||||
|
||||
# 获取默认打印机配置
|
||||
printer_config = self.env['printer.configuration'].sudo().search([('model', '=', self._name)], limit=1)
|
||||
if not printer_config:
|
||||
raise UserError('请先配置打印机')
|
||||
host = printer_config.printer_id.ip_address
|
||||
port = printer_config.printer_id.port
|
||||
self.print_qr_code(barcode, host, port)
|
||||
|
||||
|
||||
class ShelfLocation(models.Model):
|
||||
_name = 'sf.shelf.location'
|
||||
_inherit = ['printing.utils']
|
||||
_description = '货位'
|
||||
_order = 'name, id'
|
||||
_rec_name = 'barcode'
|
||||
_order = 'id asc, create_date asc'
|
||||
|
||||
# current_location_id = fields.Many2one('sf.shelf.location', string='当前位置')
|
||||
# # 目的位置
|
||||
@@ -319,6 +347,7 @@ class ShelfLocation(models.Model):
|
||||
destination_move_ids = fields.One2many('stock.move.line', 'destination_location_id', '目标位置调拨单')
|
||||
storage_time = fields.Datetime('入库时间', compute='_compute_location_status')
|
||||
production_id = fields.Many2one('mrp.production', string='制造订单')
|
||||
active = fields.Boolean("有效", default=True)
|
||||
|
||||
@api.depends('location_status')
|
||||
def _compute_location_status(self):
|
||||
@@ -332,6 +361,8 @@ class ShelfLocation(models.Model):
|
||||
|
||||
name = fields.Char('货位名称', required=True, size=20)
|
||||
barcode = fields.Char('货位编码', copy=False, size=50)
|
||||
qr_code = fields.Binary(string='二维码', compute='_compute_location_qr_code', store=True)
|
||||
|
||||
# 货架
|
||||
shelf_id = fields.Many2one('sf.shelf', string='货架')
|
||||
|
||||
@@ -343,6 +374,62 @@ class ShelfLocation(models.Model):
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
@api.depends('barcode')
|
||||
def _compute_location_qr_code(self):
|
||||
for record in self:
|
||||
if record.barcode:
|
||||
# 创建一个QRCode对象
|
||||
qr = qrcode.QRCode(
|
||||
version=1, # 设置版本, 1-40,控制二维码的大小
|
||||
error_correction=qrcode.constants.ERROR_CORRECT_L, # 设置错误校正等级
|
||||
box_size=10, # 设置每个格子的像素大小
|
||||
border=4, # 设置边框的格子宽度
|
||||
)
|
||||
# 添加数据
|
||||
qr.add_data(record.barcode)
|
||||
qr.make(fit=True)
|
||||
# 创建二维码图像
|
||||
img = qr.make_image(fill_color="black", back_color="white")
|
||||
# 创建一个内存文件
|
||||
buffer = io.BytesIO()
|
||||
img.save(buffer, format="PNG") # 将图像保存到内存文件中
|
||||
# 获取二进制数据
|
||||
binary_data = buffer.getvalue()
|
||||
# 使用Base64编码这些二进制数据
|
||||
data = base64.b64encode(binary_data)
|
||||
self.qr_code = data
|
||||
else:
|
||||
record.qr_code = False
|
||||
|
||||
def print_single_location_qr_code(self):
|
||||
self.ensure_one()
|
||||
qr_code_data = self.qr_code
|
||||
if not qr_code_data:
|
||||
raise UserError("没有找到二维码数据。")
|
||||
barcode = self.barcode
|
||||
# host = "192.168.50.110" # 可以根据实际情况修改
|
||||
# port = 9100 # 可以根据实际情况修改
|
||||
# 获取默认打印机配置
|
||||
printer_config = self.env['printer.configuration'].sudo().search([('model', '=', self._name)], limit=1)
|
||||
if not printer_config:
|
||||
raise UserError('请先配置打印机')
|
||||
host = printer_config.printer_id.ip_address
|
||||
port = printer_config.printer_id.port
|
||||
self.print_qr_code(barcode, host, port)
|
||||
# 获取当前wizard的视图ID或其他标识信息
|
||||
view_id = self.env.context.get('view_id')
|
||||
# 构造返回wizard页面的action字典
|
||||
action = {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': '返回 Wizard',
|
||||
'res_model': 'sf.shelf', # 替换为你的wizard模型名称
|
||||
'view_mode': 'form',
|
||||
'view_id': view_id, # 如果需要基于特定的视图返回
|
||||
'target': 'new', # 如果需要在新的窗口或标签页打开
|
||||
'res_id': self.shelf_id, # 如果你想要返回当前记录的视图
|
||||
}
|
||||
return action
|
||||
|
||||
# # 仓库类别(selection:库区、库位、货位)
|
||||
# location_type = fields.Selection([
|
||||
# ('货架', '货架'),
|
||||
@@ -361,10 +448,20 @@ class ShelfLocation(models.Model):
|
||||
('空闲', '空闲'),
|
||||
('占用', '占用'),
|
||||
('禁用', '禁用')
|
||||
], string='货位状态', default='空闲', readonly=True)
|
||||
], string='货位状态', default='空闲', compute='_compute_product_num', store=True)
|
||||
# product_id = fields.Many2one('product.template', string='产品')
|
||||
product_id = fields.Many2one('product.product', string='产品', readonly=True)
|
||||
product_id = fields.Many2one('product.product', string='产品', compute='_compute_product_id', store=True)
|
||||
product_sn_id = fields.Many2one('stock.lot', string='产品序列号')
|
||||
# 产品数量
|
||||
product_num = fields.Integer('数量')
|
||||
|
||||
@api.depends('product_num')
|
||||
def _compute_product_num(self):
|
||||
for record in self:
|
||||
if record.product_num > 0:
|
||||
record.location_status = '占用'
|
||||
elif record.product_num == 0:
|
||||
record.location_status = '空闲'
|
||||
|
||||
# 修改货位状态为禁用
|
||||
def action_location_status_disable(self):
|
||||
@@ -381,12 +478,20 @@ class ShelfLocation(models.Model):
|
||||
"""
|
||||
for record in self:
|
||||
if record.product_sn_id:
|
||||
record.sudo().product_id = record.product_sn_id.product_id
|
||||
record.sudo().location_status = '占用'
|
||||
try:
|
||||
record.sudo().product_id = record.product_sn_id.product_id
|
||||
# record.sudo().location_status = '占用'
|
||||
record.sudo().product_num = 1
|
||||
except Exception as e:
|
||||
print('eeeeeee占用', e)
|
||||
|
||||
else:
|
||||
record.product_id = False
|
||||
# record.location_status = '空闲'
|
||||
try:
|
||||
record.sudo().product_id = False
|
||||
# record.sudo().location_status = '空闲'
|
||||
record.sudo().product_num = 0
|
||||
except Exception as e:
|
||||
print('eeeeeee空闲', e)
|
||||
|
||||
# 调取获取货位信息接口
|
||||
def get_sf_shelf_location_info(self):
|
||||
@@ -411,6 +516,19 @@ class ShelfLocation(models.Model):
|
||||
else:
|
||||
raise UserError("该库位无产品")
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
# 编码重复校验
|
||||
barcode_list = []
|
||||
for val in vals_list:
|
||||
location = self.search([('barcode', '=', val['barcode'])])
|
||||
if location:
|
||||
barcode_list.append(val['name'])
|
||||
if barcode_list:
|
||||
raise UserError("货位编码【%s】存在重复" % barcode_list)
|
||||
records = super(ShelfLocation, self).create(vals_list)
|
||||
return records
|
||||
|
||||
|
||||
class Sf_stock_move_line(models.Model):
|
||||
_name = 'stock.move.line'
|
||||
@@ -423,6 +541,16 @@ class Sf_stock_move_line(models.Model):
|
||||
location_dest_id_value = fields.Integer(compute='_compute_location_dest_id_value', store=True)
|
||||
# lot_qr_code = fields.Binary(string='二维码', compute='_compute_lot_qr_code', store=True)
|
||||
lot_qr_code = fields.Binary(string='二维码', compute='_compute_lot_qr_code', store=True)
|
||||
current_product_id = fields.Integer(compute='_compute_location_dest_id_value', store=True)
|
||||
there_is_no_sn = fields.Boolean('是否有序列号', default=False)
|
||||
|
||||
rfid = fields.Char('Rfid')
|
||||
rfid_barcode = fields.Char('Rfid', compute='_compute_rfid')
|
||||
|
||||
@api.depends('lot_id')
|
||||
def _compute_rfid(self):
|
||||
for item in self:
|
||||
item.rfid_barcode = item.lot_id.rfid
|
||||
|
||||
def action_revert_inventory(self):
|
||||
# 检查用户是否有执行操作的权限
|
||||
@@ -430,7 +558,7 @@ class Sf_stock_move_line(models.Model):
|
||||
raise UserError(_('抱歉,只有库管人员可以执行此动作'))
|
||||
|
||||
# 如果用户有权限,调用父类方法
|
||||
return super(CustomStockMoveLine, self).action_revert_inventory()
|
||||
return super().action_revert_inventory()
|
||||
|
||||
@api.depends('lot_name')
|
||||
def _compute_lot_qr_code(self):
|
||||
@@ -475,7 +603,7 @@ class Sf_stock_move_line(models.Model):
|
||||
# port = 9100 # 可以根据实际情况修改
|
||||
|
||||
# 获取默认打印机配置
|
||||
printer_config = self.env['printer.configuration'].search([('model', '=', self._name)], limit=1)
|
||||
printer_config = self.env['printer.configuration'].sudo().search([('model', '=', self._name)], limit=1)
|
||||
if not printer_config:
|
||||
raise UserError('请先配置打印机')
|
||||
host = printer_config.printer_id.ip_address
|
||||
@@ -692,30 +820,43 @@ class Sf_stock_move_line(models.Model):
|
||||
def _compute_location_dest_id_value(self):
|
||||
for record in self:
|
||||
record.location_dest_id_value = record.location_dest_id.id if record.location_dest_id else False
|
||||
record.current_product_id = record.product_id.id if record.product_id else False
|
||||
|
||||
destination_location_id = fields.Many2one(
|
||||
'sf.shelf.location', string='目标货位')
|
||||
|
||||
@api.onchange('destination_location_id')
|
||||
def _compute_destination_location_id(self):
|
||||
def compute_destination_location_id(self):
|
||||
for record in self:
|
||||
shelf_location_obj = self.env['sf.shelf.location'].search(
|
||||
[('product_sn_id', '=', record.lot_id.id)])
|
||||
if shelf_location_obj:
|
||||
shelf_location_obj.product_sn_id = False
|
||||
# obj = self.env['sf.shelf.location'].search([('location_id', '=',
|
||||
# self.destination_location_id.id)])
|
||||
obj = self.env['sf.shelf.location'].search([('name', '=',
|
||||
self.destination_location_id.name)])
|
||||
if obj:
|
||||
obj.product_sn_id = record.lot_id.id
|
||||
obj = self.env['sf.shelf.location'].search([('name', '=',
|
||||
self.destination_location_id.name)])
|
||||
if record.lot_id:
|
||||
shelf_location_obj = self.env['sf.shelf.location'].search(
|
||||
[('product_sn_id', '=', record.lot_id.id)])
|
||||
if shelf_location_obj:
|
||||
shelf_location_obj.product_sn_id = False
|
||||
if obj:
|
||||
obj.product_sn_id = record.lot_id.id
|
||||
else:
|
||||
pass
|
||||
if obj:
|
||||
obj.product_sn_id = record.lot_id.id
|
||||
else:
|
||||
obj = self.env['sf.shelf.location'].search([('name', '=',
|
||||
self.destination_location_id.name)])
|
||||
if obj:
|
||||
obj.product_sn_id = record.lot_id.id
|
||||
obj.product_id = record.product_id.id
|
||||
# obj.location_status = '占用'
|
||||
obj.product_num += record.reserved_uom_qty
|
||||
|
||||
@api.onchange('destination_location_id')
|
||||
def _check_destination_location_id(self):
|
||||
for item in self:
|
||||
if item:
|
||||
i = 0
|
||||
barcode = item.destination_location_id.barcode
|
||||
for line in item.picking_id.move_line_ids_without_package:
|
||||
if barcode and barcode == line.destination_location_id.barcode:
|
||||
i += 1
|
||||
if i > 1:
|
||||
raise ValidationError(
|
||||
'【%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)
|
||||
|
||||
|
||||
class SfStockPicking(models.Model):
|
||||
@@ -739,24 +880,39 @@ class SfStockPicking(models.Model):
|
||||
res = super(SfStockPicking, self).button_validate()
|
||||
for line in self.move_line_ids:
|
||||
if line:
|
||||
# 调用入库方法进行入库
|
||||
line.compute_destination_location_id()
|
||||
if line.current_location_id:
|
||||
line.current_location_id.product_sn_id = False
|
||||
line.current_location_id.location_status = '空闲'
|
||||
if line.current_location_id.product_sn_id:
|
||||
line.current_location_id.product_sn_id = False
|
||||
# line.current_location_id.location_status = '空闲'
|
||||
line.current_location_id.product_num = 0
|
||||
|
||||
# 对入库作业的刀柄和托盘进行Rfid绑定校验
|
||||
for move in self.move_ids:
|
||||
if move and move.product_id.cutting_tool_material_id.name == '刀柄' or '托盘' in (
|
||||
move.product_id.fixture_material_id.name or ''):
|
||||
for item in move.move_line_nosuggest_ids:
|
||||
if item.location_dest_id.name == '进货':
|
||||
if not item.rfid:
|
||||
raise ValidationError('你需要提供%s的Rfid' % move.product_id.name)
|
||||
self.env['stock.lot'].search([('name', '=', item.lot_name)]).write({'rfid': item.rfid})
|
||||
return res
|
||||
|
||||
# def print_all_barcode(self):
|
||||
# """
|
||||
# 打印所有编码
|
||||
# """
|
||||
# print('================')
|
||||
# for record in self.move_ids_without_package:
|
||||
# print('record', record)
|
||||
# print('record.move_line_ids', record.move_line_ids)
|
||||
#
|
||||
# # record.move_line_ids.print_qr_code()
|
||||
#
|
||||
# print('record.move_line_ids.lot_id', record.move_line_ids.lot_id)
|
||||
# print('record.move_line_ids.lot_id.name', record.move_line_ids.lot_id.name)
|
||||
|
||||
# def print_all_barcode(self):
|
||||
# """
|
||||
# 打印所有编码
|
||||
# """
|
||||
# print('================')
|
||||
# for record in self.move_ids_without_package:
|
||||
# print('record', record)
|
||||
# print('record.move_line_ids', record.move_line_ids)
|
||||
#
|
||||
# # record.move_line_ids.print_qr_code()
|
||||
#
|
||||
# print('record.move_line_ids.lot_id', record.move_line_ids.lot_id)
|
||||
# print('record.move_line_ids.lot_id.name', record.move_line_ids.lot_id.name)
|
||||
|
||||
|
||||
class SfProcurementGroup(models.Model):
|
||||
@@ -822,117 +978,55 @@ class SfProcurementGroup(models.Model):
|
||||
return res
|
||||
|
||||
|
||||
class SfWarehouse(models.Model):
|
||||
_inherit = 'stock.warehouse'
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '启用'),
|
||||
('close', '关闭')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
|
||||
class SfRule(models.Model):
|
||||
_inherit = 'stock.rule'
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '启用'),
|
||||
('close', '关闭')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
|
||||
class SfRoute(models.Model):
|
||||
_inherit = 'stock.route'
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '启用'),
|
||||
('close', '关闭')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
# class SfPickingType(models.Model):
|
||||
# _inherit = 'stock.picking.type'
|
||||
#
|
||||
# def _default_show_operations(self):
|
||||
# return self.user_has_groups('stock.group_production_lot,'
|
||||
# 'stock.group_stock_multi_locations,'
|
||||
# 'stock.group_tracking_lot',
|
||||
# 'sf_warehouse.group_sf_stock_user',
|
||||
# 'sf_warehouse.group_sf_stock_manager')
|
||||
|
||||
class SfPickingType(models.Model):
|
||||
_inherit = 'stock.picking.type'
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '启用'),
|
||||
('close', '关闭')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
|
||||
class SfBarcodeNomenclature(models.Model):
|
||||
_inherit = 'barcode.nomenclature'
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '启用'),
|
||||
('close', '关闭')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
|
||||
class SfPutawayRule(models.Model):
|
||||
_inherit = 'stock.putaway.rule'
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '同意'),
|
||||
('close', '不同意')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
|
||||
class SfWarehouseOrderpoint(models.Model):
|
||||
_inherit = 'stock.warehouse.orderpoint'
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '同意'),
|
||||
('close', '不同意')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
|
||||
class SfStockQuant(models.Model):
|
||||
_inherit = 'stock.quant'
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '同意'),
|
||||
('close', '不同意')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
|
||||
|
||||
class SfStockScrap(models.Model):
|
||||
_inherit = 'stock.scrap'
|
||||
|
||||
check_state = fields.Selection([
|
||||
('enable', '启用'),
|
||||
('close', '关闭')
|
||||
], string='审核状态', default='close')
|
||||
|
||||
def action_check(self):
|
||||
self.check_state = 'enable'
|
||||
def _default_show_operations(self):
|
||||
return self.user_has_groups(
|
||||
'stock.group_production_lot,'
|
||||
'stock.group_stock_multi_locations,'
|
||||
'stock.group_tracking_lot,'
|
||||
'sf_warehouse.group_sf_stock_user,'
|
||||
'sf_warehouse.group_sf_stock_manager'
|
||||
)
|
||||
|
||||
|
||||
class CustomStockMove(models.Model):
|
||||
_name = 'stock.move'
|
||||
_inherit = ['stock.move', 'printing.utils']
|
||||
_inherit = ['stock.move', 'printing.utils', 'barcodes.barcode_events_mixin']
|
||||
|
||||
def on_barcode_scanned(self, barcode):
|
||||
"""
|
||||
采购入库扫码绑定Rfid码
|
||||
"""
|
||||
for record in self:
|
||||
if record:
|
||||
if '刀柄' in (record.product_id.cutting_tool_material_id.name or '') or '托盘' in (
|
||||
record.product_id.fixture_material_id.name or ''):
|
||||
for move_line_nosuggest_id in record.move_line_nosuggest_ids:
|
||||
if move_line_nosuggest_id.rfid:
|
||||
if move_line_nosuggest_id.rfid == barcode:
|
||||
if record.product_id.cutting_tool_material_id.name:
|
||||
raise ValidationError('该刀柄的Rfid已经录入,请勿重复录入!!!')
|
||||
else:
|
||||
raise ValidationError('该托盘的Rfid已经录入,请勿重复录入!!!')
|
||||
else:
|
||||
line_id = int(re.sub(r"\D", "", str(move_line_nosuggest_id.id)))
|
||||
self.env['stock.move.line'].sudo().search([('id', '=', line_id)]).write({'rfid': barcode})
|
||||
move_line_nosuggest_id.rfid = barcode
|
||||
break
|
||||
else:
|
||||
raise ValidationError('该产品不需要录入Rfid!!!')
|
||||
|
||||
def action_assign_serial_show_details(self):
|
||||
# 首先执行原有逻辑
|
||||
@@ -983,7 +1077,7 @@ class CustomStockMove(models.Model):
|
||||
# port = 9100 # 可以根据实际情况修改
|
||||
|
||||
# 获取默认打印机配置
|
||||
printer_config = self.env['printer.configuration'].search([('model', '=', self._name)], limit=1)
|
||||
printer_config = self.env['printer.configuration'].sudo().search([('model', '=', self._name)], limit=1)
|
||||
if not printer_config:
|
||||
raise UserError('请先配置打印机')
|
||||
host = printer_config.printer_id.ip_address
|
||||
|
||||
@@ -104,17 +104,11 @@ access_mrp_production_group_sf_stock_user,mrp.production,mrp.model_mrp_productio
|
||||
|
||||
access_sf_shelf_location_group_plan_dispatch,sf.shelf.location,model_sf_shelf_location,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_stock_move,stock.move,stock.model_stock_move,sf_base.group_plan_dispatch,1,1,1,0
|
||||
access_stock_picking,stock.picking,stock.model_stock_picking,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_stock_picking_group_plan_dispatch,stock.picking,stock.model_stock_picking,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_stock_lot_group_plan_dispatch,stock.lot,stock.model_stock_lot,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_stock_lot_group_plan_director,stock.lot,stock.model_stock_lot,sf_base.group_plan_director,1,1,1,0
|
||||
access_stock_warehouse_orderpoint,stock.warehouse.orderpoint,stock.model_stock_warehouse_orderpoint,sf_base.group_plan_dispatch,1,1,0,0
|
||||
|
||||
|
||||
access_product_product,product.product,product.model_product_product,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_product_template,product.template,product.model_product_template,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_product_product,product.product,product.model_product_product,sf_base.group_plan_director,1,1,1,0
|
||||
access_product_template,product.template,product.model_product_template,sf_base.group_plan_director,1,1,1,0
|
||||
|
||||
access_stock_inventory_conflict,stock.inventory.conflict,stock.model_stock_inventory_conflict,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_stock_inventory_warning,stock.inventory.warning,stock.model_stock_inventory_warning,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_stock_inventory_adjustment_name,stock.inventory.adjustment.name,stock.model_stock_inventory_adjustment_name,sf_base.group_plan_dispatch,1,0,0,0
|
||||
@@ -140,6 +134,9 @@ access_sf_cutting_tool_material_group_sf_stock_manager,sf_cutting_tool_material_
|
||||
access_sf_cutting_tool_standard_library_group_sf_stock_manager,sf_cutting_tool_standard_library_group_sf_stock_manager,sf_base.model_sf_cutting_tool_standard_library,sf_warehouse.group_sf_stock_manager,1,0,1,0
|
||||
access_sf_tool_materials_basic_parameters_group_sf_stock_manager,sf_tool_materials_basic_parameters_group_sf_stock_manager,sf_base.model_sf_tool_materials_basic_parameters,sf_warehouse.group_sf_stock_manager,1,0,1,0
|
||||
|
||||
access_sf_shelf_location_wizard_group_plan_dispatch,sf_shelf_location_wizard_group_plan_dispatch,model_sf_shelf_location_wizard,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_shelf_location_wizard_group_sf_stock_user_group_sf_stock_user,sf_shelf_location_wizard_group_sf_stock_user_group_sf_stock_user,model_sf_shelf_location_wizard,sf_warehouse.group_sf_stock_user,1,0,0,0
|
||||
access_sf_shelf_location_wizard_group_sf_stock_manager,sf_shelf_location_wizard_group_sf_stock_manager,model_sf_shelf_location_wizard,sf_warehouse.group_sf_stock_manager,1,1,1,0
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -10,10 +10,18 @@
|
||||
<field name="current_location_id" force_save="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='location_dest_id'][2]" position="after">
|
||||
<field name="destination_location_id" domain="[
|
||||
('location_id', '=', location_dest_id_value),
|
||||
('location_status', '=', '空闲')
|
||||
]"/>
|
||||
<field name="current_product_id" invisible="1"/>
|
||||
<field name="there_is_no_sn" invisible="1"/>
|
||||
<!-- <field name="destination_location_id" domain="[('location_id', '=', location_dest_id_value), -->
|
||||
<!-- '|', -->
|
||||
<!-- ('location_status', '=', '空闲'), -->
|
||||
<!-- ('location_status', '=', '占用'), ('product_id', '=', current_product_id) -->
|
||||
<!-- ]"/> -->
|
||||
<field name="destination_location_id" domain="[('location_id', '=', location_dest_id_value), '|',
|
||||
('location_status', '=', '空闲'), ('product_id', '=', current_product_id), ('product_sn_id',
|
||||
'=', there_is_no_sn)]" options="{'no_create': True,'no_create_edit':True}"/>
|
||||
<field name="rfid_barcode" string="Rfid"/>
|
||||
|
||||
<!-- <field name="location_dest_id_product_type"/> -->
|
||||
<!-- <field name="location_dest_id"/> -->
|
||||
<field name="location_dest_id_value" invisible="1"/>
|
||||
@@ -31,15 +39,16 @@
|
||||
<field name="current_location_id" force_save="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='location_dest_id']" position="after">
|
||||
<field name="destination_location_id" />
|
||||
<!-- <field name="location_dest_id_product_type"/> -->
|
||||
<!-- <field name="location_dest_id"/> -->
|
||||
<field name="destination_location_id"/>
|
||||
<!-- <field name="location_dest_id_product_type"/> -->
|
||||
<!-- <field name="location_dest_id"/> -->
|
||||
<field name="location_dest_id_value" invisible="1"/>
|
||||
<!-- <button name="button_test" string="测试" type="object" class="oe_highlight"/> -->
|
||||
<!-- <button name="button_test" string="测试" type="object" class="oe_highlight"/> -->
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="sf_stock_move_line_form" model="ir.ui.view">
|
||||
<field name="name">sf.stock.move.line.form</field>
|
||||
<field name="model">stock.move.line</field>
|
||||
@@ -63,6 +72,9 @@
|
||||
<field name="model">stock.move.line</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='lot_name']" position="after">
|
||||
<field name="rfid"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='product_uom_id']" position="after">
|
||||
<field name="lot_qr_code" widget="image"/>
|
||||
<button name="print_single_method" string="打印编码" type="object" class="oe_highlight"/>
|
||||
@@ -103,10 +115,10 @@
|
||||
groups="sf_warehouse.group_sf_stock_user" data-hotkey="k"/>
|
||||
</xpath>
|
||||
|
||||
<!-- <xpath expr="//form//sheet//notebook//page//field[@name='move_ids_without_package']" position="before"> -->
|
||||
<!-- <field name="check_in" invisible="True"/> -->
|
||||
<!-- <button name="print_all_barcode" string="打印所有编码" type="object" attrs="{'invisible': [('check_in', '!=', 'IN')]}"/> -->
|
||||
<!-- </xpath> -->
|
||||
<!-- <xpath expr="//form//sheet//notebook//page//field[@name='move_ids_without_package']" position="before"> -->
|
||||
<!-- <field name="check_in" invisible="True"/> -->
|
||||
<!-- <button name="print_all_barcode" string="打印所有编码" type="object" attrs="{'invisible': [('check_in', '!=', 'IN')]}"/> -->
|
||||
<!-- </xpath> -->
|
||||
|
||||
</field>
|
||||
</record>
|
||||
@@ -117,7 +129,7 @@
|
||||
<field name="inherit_id" ref="stock.stock_scrap_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//header//button[@name='action_validate']" position="replace">
|
||||
<button name="action_validate" states="draft" string="Validate" type="object" class="oe_highlight"
|
||||
<button name="action_validate" states="draft" string="确认" type="object" class="oe_highlight"
|
||||
context="{'not_unlink_on_discard': True}" data-hotkey="v"
|
||||
groups="sf_warehouse.group_sf_stock_user"/>
|
||||
</xpath>
|
||||
@@ -145,11 +157,23 @@
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_move_operations"/>
|
||||
<field name="arch" type="xml">
|
||||
<!-- <xpath expr="//form//field[@name='move_line_ids']" position="before"> -->
|
||||
<!-- <button name="print_all_barcode" type="object" string="打印所有编码"/> -->
|
||||
<!-- </xpath> -->
|
||||
<!-- <xpath expr="//form//field[@name='move_line_ids']" position="before"> -->
|
||||
<!-- <button name="print_all_barcode" type="object" string="打印所有编码"/> -->
|
||||
<!-- </xpath> -->
|
||||
<xpath expr="//form//field[@name='product_id']" position="before">
|
||||
<button name="print_all_barcode" type="object" string="打印所有编码" class="oe_highlight"/> -->
|
||||
<button name="print_all_barcode" type="object" string="打印所有编码" class="oe_highlight"/>
|
||||
-->
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_subcontracting_view_stock_move_barcode_scanned" model="ir.ui.view">
|
||||
<field name="name">mrp.subcontracting.stock.move.barcode.scanned.form</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_move_nosuggest_operations"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='move_line_nosuggest_ids']" position="before">
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- 货架视图 -->
|
||||
<!-- 货架视图 -->
|
||||
<record id="view_sf_shelf" model="ir.ui.view">
|
||||
<field name="name">Sf Shelf</field>
|
||||
<field name="model">sf.shelf</field>
|
||||
@@ -9,7 +9,8 @@
|
||||
<form string="Sf Shelf">
|
||||
<header>
|
||||
<field name="is_there_area" invisible="1"/>
|
||||
<button string="生成货位" name="create_location" type="object" class="oe_highlight" attrs="{'invisible': [('is_there_area', '=', True)]}"/>
|
||||
<button string="生成货位" name="create_location" type="object" class="oe_highlight"
|
||||
attrs="{'invisible': [('is_there_area', '=', True)]}"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
@@ -23,12 +24,21 @@
|
||||
<field name="shelf_layer" string="货架层数"/>
|
||||
<field name="layer_capacity" string="层数容量"/>
|
||||
</group>
|
||||
<field name="location_ids" widget="one2many_list">
|
||||
<tree string="Shelf Location">
|
||||
<field name="barcode" string="编码"/>
|
||||
<field name="name" string="名称"/>
|
||||
</tree>
|
||||
</field>
|
||||
<notebook>
|
||||
<page string="货位">
|
||||
<button name="print_all_location_barcode" type="object" string="一键打印"
|
||||
class="oe_highlight"/>
|
||||
<field name="location_ids" widget="one2many_list">
|
||||
<tree string="Shelf Location">
|
||||
<field name="barcode" string="编码"/>
|
||||
<field name="name" string="名称"/>
|
||||
<field name="qr_code" string="条码" widget="image"/>
|
||||
<button string="打印" name="print_single_location_qr_code" type="object"
|
||||
class="oe_highlight"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
@@ -46,23 +56,23 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 货架action -->
|
||||
<!-- 货架action -->
|
||||
<record id="sf_shelf_action" model="ir.actions.act_window">
|
||||
<field name="name">货架</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.shelf</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<!-- <field name="view_id" ref="view_sf_shelf_tree"/> -->
|
||||
<!-- <field name="view_id" ref="view_sf_shelf_tree"/> -->
|
||||
</record>
|
||||
|
||||
<!-- 货架菜单 -->
|
||||
<!-- 货架菜单 -->
|
||||
<menuitem
|
||||
id="sf_shelf_menu"
|
||||
name="货架"
|
||||
parent="stock.menu_warehouse_config"
|
||||
sequence="19"
|
||||
action="sf_shelf_action"
|
||||
groups="sf_warehouse.group_sf_stock_user"/>
|
||||
id="sf_shelf_menu"
|
||||
name="货架"
|
||||
parent="stock.menu_warehouse_config"
|
||||
sequence="19"
|
||||
action="sf_shelf_action"
|
||||
groups="sf_warehouse.group_sf_stock_user"/>
|
||||
|
||||
|
||||
<record id="view_shelf_location_tree" model="ir.ui.view">
|
||||
@@ -116,13 +126,25 @@
|
||||
<field name="name">Shelf Location form</field>
|
||||
<field name="model">sf.shelf.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Shelf Location">
|
||||
<form string="Shelf Location" create="0">
|
||||
<header>
|
||||
|
||||
<button string="货位变更"
|
||||
name="%(sf_warehouse.sf_shelf_location_wizard_act)d"
|
||||
type="action"
|
||||
context="{'default_name':name,
|
||||
'default_current_name':name,
|
||||
'default_current_shelf_id':shelf_id,
|
||||
'default_current_location_id':location_id,
|
||||
'default_current_barcode':barcode,
|
||||
'default_current_product_id':product_id,
|
||||
}"
|
||||
class="btn-primary" attrs="{'invisible':[('location_status','!=','占用')]}"/>
|
||||
<field name="location_status" invisible="1"/>
|
||||
<button string="禁用货位" name="action_location_status_disable" type="object" class="oe_highlight"
|
||||
<button string="禁用货位" name="action_location_status_disable" type="object"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible': [('location_status', '!=', '空闲')]}"/>
|
||||
<button string="启用货位" name="action_location_status_enable" type="object" class="oe_highlight"
|
||||
<button string="启用货位" name="action_location_status_enable" type="object"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible': [('location_status', '!=', '禁用')]}"/>
|
||||
</header>
|
||||
<sheet>
|
||||
@@ -143,12 +165,13 @@
|
||||
</button>
|
||||
</div>
|
||||
<group>
|
||||
<field name="barcode"/>
|
||||
<field name="name"/>
|
||||
<field name="shelf_id"/>
|
||||
<field name="location_id"/>
|
||||
<field name="product_sn_id"/>
|
||||
<field name="barcode" readonly="1"/>
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="shelf_id" readonly="1"/>
|
||||
<field name="location_id" readonly="1"/>
|
||||
<field name="product_sn_id" options="{'no_create': True}"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_num" readonly="1"/>
|
||||
<field name="location_status"/>
|
||||
<field name="storage_time" widget="datetime"/>
|
||||
<field name="production_id" readonly="1"/>
|
||||
@@ -162,20 +185,20 @@
|
||||
<field name="name">shelf.location.kanban</field>
|
||||
<field name="model">sf.shelf.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban class="o_kanban_mobile" js_class="custom_kanban">
|
||||
<kanban class="o_kanban_mobile" js_class="custom_kanban" create="0">
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="oe_kanban_card oe_kanban_global_click
|
||||
#{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''}
|
||||
#{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''}
|
||||
#{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}">
|
||||
<!-- 标题 -->
|
||||
<!-- 标题 -->
|
||||
<div class="o_kanban_card_header">
|
||||
<div class="o_kanban_card_header_title">
|
||||
<field name="name"/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 内容 -->
|
||||
<!-- 内容 -->
|
||||
<div class="o_kanban_record_bottom">
|
||||
<field name="location_status"/>
|
||||
</div>
|
||||
@@ -186,31 +209,31 @@
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
<!-- <t t-name="kanban-box"> -->
|
||||
<!-- <div t-attf-class="oe_kanban_card oe_kanban_global_click -->
|
||||
<!-- #{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''} -->
|
||||
<!-- #{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''} -->
|
||||
<!-- #{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}"> -->
|
||||
<!-- 看板内容 -->
|
||||
<!-- </div> -->
|
||||
<!-- <div t-attf-class="oe_kanban_card"> -->
|
||||
<!-- 标题 -->
|
||||
<!-- <div class="o_kanban_card_header"> -->
|
||||
<!-- <div class="o_kanban_card_header_title"> -->
|
||||
<!-- <field name="name"/> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- 内容 -->
|
||||
<!-- <div class="o_kanban_record_bottom"> -->
|
||||
<!-- <field name="location_status"/> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div class="o_kanban_record_bottom"> -->
|
||||
<!-- <field name="product_sn_id"/> -->
|
||||
<!-- <span> | </span> -->
|
||||
<!-- <field name="product_id"/> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </t> -->
|
||||
<!-- <t t-name="kanban-box"> -->
|
||||
<!-- <div t-attf-class="oe_kanban_card oe_kanban_global_click -->
|
||||
<!-- #{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''} -->
|
||||
<!-- #{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''} -->
|
||||
<!-- #{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}"> -->
|
||||
<!-- 看板内容 -->
|
||||
<!-- </div> -->
|
||||
<!-- <div t-attf-class="oe_kanban_card"> -->
|
||||
<!-- 标题 -->
|
||||
<!-- <div class="o_kanban_card_header"> -->
|
||||
<!-- <div class="o_kanban_card_header_title"> -->
|
||||
<!-- <field name="name"/> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- 内容 -->
|
||||
<!-- <div class="o_kanban_record_bottom"> -->
|
||||
<!-- <field name="location_status"/> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div class="o_kanban_record_bottom"> -->
|
||||
<!-- <field name="product_sn_id"/> -->
|
||||
<!-- <span> | </span> -->
|
||||
<!-- <field name="product_id"/> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </t> -->
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
@@ -222,9 +245,10 @@
|
||||
<field name="model">sf.shelf.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="货位">
|
||||
<field name="barcode"/>
|
||||
<searchpanel class="account_root">
|
||||
<!-- <field name="location_type" icon="fa-filter"/> -->
|
||||
<!-- <field name="location_id" select="multi" icon="fa-filter"/> -->
|
||||
<!-- <field name="location_id" select="multi" icon="fa-filter"/> -->
|
||||
<field name="location_id" string="所属库区" icon="fa-filter"/>
|
||||
<field name="shelf_id" string="货架"/>
|
||||
<!-- <field name="location_status" icon="fa-filter"/> -->
|
||||
@@ -238,7 +262,7 @@
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.shelf.location</field>
|
||||
<field name="view_mode">kanban,form</field>
|
||||
<!-- <field name="domain">[('check_state','=','enable')]</field> -->
|
||||
<!-- <field name="domain">[('check_state','=','enable')]</field> -->
|
||||
</record>
|
||||
|
||||
<!-- <record id="example_action" model="ir.actions.act_window"> -->
|
||||
|
||||
@@ -67,16 +67,16 @@
|
||||
</notebook>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//sheet" position="before">
|
||||
<header>
|
||||
<field name="check_state" invisible="1"/>
|
||||
<button name="action_check" string="审核" type="object"
|
||||
attrs="{'invisible': [('check_state','=', 'enable')]}"
|
||||
groups="sf_warehouse.group_sf_stock_manager"
|
||||
class="oe_highlight"/>
|
||||
</header>
|
||||
<!-- <xpath expr="//sheet" position="before">-->
|
||||
<!-- <header>-->
|
||||
<!-- <field name="check_state" invisible="1"/>-->
|
||||
<!-- <button name="action_check" string="审核" type="object"-->
|
||||
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
|
||||
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
|
||||
<!-- class="oe_highlight"/>-->
|
||||
<!-- </header>-->
|
||||
|
||||
</xpath>
|
||||
<!-- </xpath>-->
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -188,23 +188,23 @@
|
||||
<!-- </record>-->
|
||||
|
||||
<!--仓库根据权限增加审核按钮-->
|
||||
<record id="view_warehouse_form_sf_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.warehouse.form.sf.inherit</field>
|
||||
<field name="model">stock.warehouse</field>
|
||||
<field name="inherit_id" ref="stock.view_warehouse"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//sheet" position="before">
|
||||
<header>
|
||||
<field name="check_state" invisible="1"/>
|
||||
<button name="action_check" string="审核" type="object"
|
||||
attrs="{'invisible': [('check_state','=', 'enable')]}"
|
||||
groups="sf_warehouse.group_sf_stock_manager"
|
||||
class="oe_highlight"/>
|
||||
</header>
|
||||
<!-- <record id="view_warehouse_form_sf_inherit" model="ir.ui.view">-->
|
||||
<!-- <field name="name">stock.warehouse.form.sf.inherit</field>-->
|
||||
<!-- <field name="model">stock.warehouse</field>-->
|
||||
<!-- <field name="inherit_id" ref="stock.view_warehouse"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <xpath expr="//sheet" position="before">-->
|
||||
<!-- <header>-->
|
||||
<!-- <field name="check_state" invisible="1"/>-->
|
||||
<!-- <button name="action_check" string="审核" type="object"-->
|
||||
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
|
||||
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
|
||||
<!-- class="oe_highlight"/>-->
|
||||
<!-- </header>-->
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record id="view_warehouse_tree_sf_inherit" model="ir.ui.view">-->
|
||||
<!-- <field name="name">stock.warehouse.tree.sf.inherit</field>-->
|
||||
@@ -220,23 +220,23 @@
|
||||
|
||||
|
||||
<!--路线根据权限增加审核按钮-->
|
||||
<record id="view_route_form_sf_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.route.form.sf.inherit</field>
|
||||
<field name="model">stock.route</field>
|
||||
<field name="inherit_id" ref="stock.stock_location_route_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//sheet" position="before">
|
||||
<header>
|
||||
<field name="check_state" invisible="1"/>
|
||||
<button name="action_check" string="审核" type="object"
|
||||
attrs="{'invisible': [('check_state','=', 'enable')]}"
|
||||
groups="sf_warehouse.group_sf_stock_manager"
|
||||
class="oe_highlight"/>
|
||||
</header>
|
||||
<!-- <record id="view_route_form_sf_inherit" model="ir.ui.view">-->
|
||||
<!-- <field name="name">stock.route.form.sf.inherit</field>-->
|
||||
<!-- <field name="model">stock.route</field>-->
|
||||
<!-- <field name="inherit_id" ref="stock.stock_location_route_form_view"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <xpath expr="//sheet" position="before">-->
|
||||
<!-- <header>-->
|
||||
<!-- <field name="check_state" invisible="1"/>-->
|
||||
<!-- <button name="action_check" string="审核" type="object"-->
|
||||
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
|
||||
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
|
||||
<!-- class="oe_highlight"/>-->
|
||||
<!-- </header>-->
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record id="view_route_tree_sf_inherit" model="ir.ui.view">-->
|
||||
<!-- <field name="name">stock.route.tree.sf.inherit</field>-->
|
||||
@@ -251,23 +251,23 @@
|
||||
<!-- </record>-->
|
||||
|
||||
<!--规则根据权限增加审核按钮-->
|
||||
<record id="view_rule_form_sf_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.rule.form.sf.inherit</field>
|
||||
<field name="model">stock.rule</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_rule_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//sheet" position="before">
|
||||
<header>
|
||||
<field name="check_state" invisible="1"/>
|
||||
<button name="action_check" string="审核" type="object"
|
||||
attrs="{'invisible': [('check_state','=', 'enable')]}"
|
||||
groups="sf_warehouse.group_sf_stock_manager"
|
||||
class="oe_highlight"/>
|
||||
</header>
|
||||
<!-- <record id="view_rule_form_sf_inherit" model="ir.ui.view">-->
|
||||
<!-- <field name="name">stock.rule.form.sf.inherit</field>-->
|
||||
<!-- <field name="model">stock.rule</field>-->
|
||||
<!-- <field name="inherit_id" ref="stock.view_stock_rule_form"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <xpath expr="//sheet" position="before">-->
|
||||
<!-- <header>-->
|
||||
<!-- <field name="check_state" invisible="1"/>-->
|
||||
<!-- <button name="action_check" string="审核" type="object"-->
|
||||
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
|
||||
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
|
||||
<!-- class="oe_highlight"/>-->
|
||||
<!-- </header>-->
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record id="view_rule_tree_sf_inherit" model="ir.ui.view">-->
|
||||
<!-- <field name="name">stock.rule.tree.sf.inherit</field>-->
|
||||
@@ -282,23 +282,23 @@
|
||||
<!-- </record>-->
|
||||
|
||||
<!--作业类型根据权限增加审核按钮-->
|
||||
<record id="view_picking_type_form_sf_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.picking.type.form.sf.inherit</field>
|
||||
<field name="model">stock.picking.type</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_type_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//sheet" position="before">
|
||||
<header>
|
||||
<field name="check_state" invisible="1"/>
|
||||
<button name="action_check" string="审核" type="object"
|
||||
attrs="{'invisible': [('check_state','=', 'enable')]}"
|
||||
groups="sf_warehouse.group_sf_stock_manager"
|
||||
class="oe_highlight"/>
|
||||
</header>
|
||||
<!-- <record id="view_picking_type_form_sf_inherit" model="ir.ui.view">-->
|
||||
<!-- <field name="name">stock.picking.type.form.sf.inherit</field>-->
|
||||
<!-- <field name="model">stock.picking.type</field>-->
|
||||
<!-- <field name="inherit_id" ref="stock.view_picking_type_form"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <xpath expr="//sheet" position="before">-->
|
||||
<!-- <header>-->
|
||||
<!-- <field name="check_state" invisible="1"/>-->
|
||||
<!-- <button name="action_check" string="审核" type="object"-->
|
||||
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
|
||||
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
|
||||
<!-- class="oe_highlight"/>-->
|
||||
<!-- </header>-->
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<!-- </xpath>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record id="view_picking_type_tree_sf_inherit" model="ir.ui.view">-->
|
||||
<!-- <field name="name">stock.picking.type.tree.sf.inherit</field>-->
|
||||
|
||||
1
sf_warehouse/wizard/__init__.py
Normal file
1
sf_warehouse/wizard/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import wizard
|
||||
64
sf_warehouse/wizard/wizard.py
Normal file
64
sf_warehouse/wizard/wizard.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from odoo import fields, models, api
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
class ShelfLocationWizard(models.TransientModel):
|
||||
_name = 'sf.shelf.location.wizard'
|
||||
_description = '货位变更'
|
||||
|
||||
name = fields.Char('')
|
||||
|
||||
current_location_id = fields.Many2one('stock.location', string='所属库区', readonly=True)
|
||||
|
||||
current_shelf_id = fields.Many2one('sf.shelf', string='当前货架', readonly=True)
|
||||
current_barcode = fields.Char('当前货位编码', readonly=True)
|
||||
current_name = fields.Char('当前货位名称', readonly=True)
|
||||
current_product_id = fields.Many2one('product.product', string='产品', readonly=True)
|
||||
|
||||
destination_shelf_id = fields.Many2one('sf.shelf', string='目标货架', compute='_compute_destination_name')
|
||||
destination_barcode_id = fields.Many2one('sf.shelf.location', string='目标货位编码', required=True,
|
||||
domain="")
|
||||
destination_name = fields.Char('目标货位名称', compute='_compute_destination_name')
|
||||
|
||||
def return_domain(self):
|
||||
val = [('location_status', '=', '空闲')]
|
||||
if self.current_product_id:
|
||||
val = ['|', ('location_status', '=', '空闲'), ('product_id', '=', self.current_product_id)]
|
||||
if self.destination_shelf_id:
|
||||
val.append(('shelf_id', '=', self.destination_shelf_id))
|
||||
return "%s" % val
|
||||
|
||||
@api.depends('destination_barcode_id')
|
||||
def _compute_destination_name(self):
|
||||
if self.destination_barcode_id:
|
||||
self.destination_name = self.destination_barcode_id.name
|
||||
self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
||||
else:
|
||||
self.destination_name = ''
|
||||
self.destination_shelf_id = False
|
||||
|
||||
#
|
||||
# @api.onchange('destination_barcode_id')
|
||||
# def _onchange_destination_shelf_id(self):
|
||||
# if self.destination_barcode_id:
|
||||
# self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
||||
|
||||
def confirm_the_change(self):
|
||||
shelf_location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.current_barcode)])
|
||||
# 变更货位
|
||||
if self.destination_barcode_id and shelf_location:
|
||||
if self.destination_barcode_id.product_id and self.destination_barcode_id.product_id == shelf_location.product_id and not self.destination_barcode_id.product_sn_id:
|
||||
self.destination_barcode_id.product_num += shelf_location.product_num
|
||||
else:
|
||||
self.destination_barcode_id.product_sn_id = shelf_location.product_sn_id.id
|
||||
self.destination_barcode_id.product_id = shelf_location.product_id.id
|
||||
self.destination_barcode_id.product_num = shelf_location.product_num
|
||||
|
||||
shelf_location.product_sn_id = False
|
||||
shelf_location.product_id = False
|
||||
shelf_location.product_num = 0
|
||||
else:
|
||||
raise ValidationError('目标货位出错,请联系管理员!')
|
||||
|
||||
# 关闭弹出窗口
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
49
sf_warehouse/wizard/wizard_view.xml
Normal file
49
sf_warehouse/wizard/wizard_view.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="sf_shelf_location_wizard_form" model="ir.ui.view">
|
||||
<field name="name">货位变更</field>
|
||||
<field name="model">sf.shelf.location.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="货位变更">
|
||||
<sheet>
|
||||
<group>
|
||||
<group string="初始货位">
|
||||
<group>
|
||||
<field name="current_location_id"/>
|
||||
<field name="current_shelf_id" string="货架"/>
|
||||
<field name="current_barcode" string="编码"/>
|
||||
<field name="current_name" string="名称"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="目标货位">
|
||||
<group>
|
||||
<field name="current_location_id"/>
|
||||
<field name="destination_shelf_id" string="货架" options="{'no_create': True}"
|
||||
placeholder="请选择目标货架"/>
|
||||
<field name="destination_barcode_id" string="编码" options="{'no_create': True}"
|
||||
placeholder="请选择目标货位"
|
||||
domain="['|', ('location_status', '=', '空闲'), ('product_id', '=', current_product_id)]"/>
|
||||
<field name="destination_name" string="名称"/>
|
||||
<field name="current_product_id" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button string="确定" name="confirm_the_change" type="object" class="btn-primary"
|
||||
confirm="是否确认变更货位"/>
|
||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_shelf_location_wizard_act" model="ir.actions.act_window">
|
||||
<field name="name">货位变更</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.shelf.location.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="sf_shelf_location_wizard_form"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user