1、货位看板模型添加货位变更弹窗模块及其功能按钮,实现产品在同库区的内部货位移动;
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',
|
||||
|
||||
@@ -829,11 +829,6 @@ class Sf_stock_move_line(models.Model):
|
||||
for record in self:
|
||||
obj = self.env['sf.shelf.location'].search([('name', '=',
|
||||
self.destination_location_id.name)])
|
||||
# if obj.product_id and obj.product_id != record.product_id:
|
||||
# # 判断货位产品和将入到该货位的产品是否是同一种
|
||||
# raise ValidationError(
|
||||
# '【%s】产品和【%s】货位的【%s】产品不同,请重新选择【%s】产品的货位!!!' %
|
||||
# (record.product_id, obj.name, obj.product_id, record.product_id))
|
||||
if record.lot_id:
|
||||
shelf_location_obj = self.env['sf.shelf.location'].search(
|
||||
[('product_sn_id', '=', record.lot_id.id)])
|
||||
|
||||
@@ -132,6 +132,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
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -128,7 +128,17 @@
|
||||
<field name="arch" type="xml">
|
||||
<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"/>
|
||||
<field name="location_status" invisible="1"/>
|
||||
<button string="禁用货位" name="action_location_status_disable" type="object"
|
||||
class="oe_highlight"
|
||||
@@ -155,11 +165,11 @@
|
||||
</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"/>
|
||||
|
||||
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.current_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