Accept Merge Request #942: (feature/制造代码优化 -> develop)

Merge Request: 开完库存处新增需求基本完成

Created By: @马广威
Accepted By: @马广威
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/942?initial=true
This commit is contained in:
马广威
2024-04-09 20:43:57 +08:00
committed by Coding
3 changed files with 80 additions and 40 deletions

View File

@@ -21,7 +21,6 @@ class SfLocation(models.Model):
name = fields.Char('Location Name', required=True, size=20) name = fields.Char('Location Name', required=True, size=20)
barcode = fields.Char('Barcode', copy=False, size=15) barcode = fields.Char('Barcode', copy=False, size=15)
# 仓库类别selection库区、库位、货位 # 仓库类别selection库区、库位、货位
# location_type = fields.Selection([ # location_type = fields.Selection([
# ('库区', '库区'), # ('库区', '库区'),
@@ -127,7 +126,7 @@ class SfLocation(models.Model):
for record in self: for record in self:
if record.product_sn_id: if record.product_sn_id:
record.product_id = record.product_sn_id.product_id record.product_id = record.product_sn_id.product_id
record.location_status = '占用' # record.location_status = '占用'
else: else:
record.product_id = False record.product_id = False
# record.location_status = '空闲' # record.location_status = '空闲'
@@ -305,7 +304,7 @@ class SfShelf(models.Model):
class ShelfLocation(models.Model): class ShelfLocation(models.Model):
_name = 'sf.shelf.location' _name = 'sf.shelf.location'
_description = '货位' _description = '货位'
_order = 'create_date desc' _order = 'id asc, create_date asc'
# current_location_id = fields.Many2one('sf.shelf.location', string='当前位置') # current_location_id = fields.Many2one('sf.shelf.location', string='当前位置')
# # 目的位置 # # 目的位置
@@ -356,10 +355,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.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_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): def action_location_status_disable(self):
@@ -376,12 +385,20 @@ class ShelfLocation(models.Model):
""" """
for record in self: for record in self:
if record.product_sn_id: if record.product_sn_id:
record.sudo().product_id = record.product_sn_id.product_id try:
record.sudo().location_status = '占用' 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: else:
record.product_id = False try:
# record.location_status = '空闲' 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): def get_sf_shelf_location_info(self):
@@ -418,6 +435,8 @@ class Sf_stock_move_line(models.Model):
location_dest_id_value = fields.Integer(compute='_compute_location_dest_id_value', store=True) 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)
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', readonly=True) rfid = fields.Char('Rfid', readonly=True)
@@ -689,6 +708,7 @@ class Sf_stock_move_line(models.Model):
def _compute_location_dest_id_value(self): def _compute_location_dest_id_value(self):
for record in self: for record in self:
record.location_dest_id_value = record.location_dest_id.id if record.location_dest_id else False 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( destination_location_id = fields.Many2one(
'sf.shelf.location', string='目标货位') 'sf.shelf.location', string='目标货位')
@@ -696,23 +716,31 @@ class Sf_stock_move_line(models.Model):
@api.onchange('destination_location_id') @api.onchange('destination_location_id')
def _compute_destination_location_id(self): def _compute_destination_location_id(self):
for record in self: for record in self:
shelf_location_obj = self.env['sf.shelf.location'].search( if record.lot_id:
[('product_sn_id', '=', record.lot_id.id)]) shelf_location_obj = self.env['sf.shelf.location'].search(
if shelf_location_obj: [('product_sn_id', '=', record.lot_id.id)])
shelf_location_obj.product_sn_id = False if shelf_location_obj:
# obj = self.env['sf.shelf.location'].search([('location_id', '=', shelf_location_obj.product_sn_id = False
# self.destination_location_id.id)]) # obj = self.env['sf.shelf.location'].search([('location_id', '=',
obj = self.env['sf.shelf.location'].search([('name', '=', # self.destination_location_id.id)])
self.destination_location_id.name)]) obj = self.env['sf.shelf.location'].search([('name', '=',
if obj: self.destination_location_id.name)])
obj.product_sn_id = record.lot_id.id if obj:
obj.product_sn_id = record.lot_id.id
else:
pass
else: else:
pass obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
if obj:
obj.product_sn_id = record.lot_id.id
else: else:
obj = self.env['sf.shelf.location'].search([('name', '=', obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)]) self.destination_location_id.name)])
if obj: 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
class SfStockPicking(models.Model): class SfStockPicking(models.Model):
@@ -737,8 +765,10 @@ class SfStockPicking(models.Model):
for line in self.move_line_ids: for line in self.move_line_ids:
if line: if line:
if line.current_location_id: if line.current_location_id:
line.current_location_id.product_sn_id = False if line.current_location_id.product_sn_id:
line.current_location_id.location_status = '空闲' line.current_location_id.product_sn_id = False
# line.current_location_id.location_status = '空闲'
line.current_location_id.product_num = 0
for move in self.move_ids: for move in self.move_ids:
if move and move.product_id.cutting_tool_material_id.name == '刀柄' or '托盘' in ( if move and move.product_id.cutting_tool_material_id.name == '刀柄' or '托盘' in (
@@ -750,19 +780,20 @@ class SfStockPicking(models.Model):
self.env['stock.lot'].search([('name', '=', item.lot_name)]).write({'rfid': item.rfid}) self.env['stock.lot'].search([('name', '=', item.lot_name)]).write({'rfid': item.rfid})
return res return res
# def print_all_barcode(self):
# """ # def print_all_barcode(self):
# 打印所有编码 # """
# """ # 打印所有编码
# print('================') # """
# for record in self.move_ids_without_package: # print('================')
# print('record', record) # for record in self.move_ids_without_package:
# print('record.move_line_ids', record.move_line_ids) # print('record', record)
# # print('record.move_line_ids', record.move_line_ids)
# # record.move_line_ids.print_qr_code() #
# # # 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) # 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): class SfProcurementGroup(models.Model):

View File

@@ -10,10 +10,18 @@
<field name="current_location_id" force_save="1"/> <field name="current_location_id" force_save="1"/>
</xpath> </xpath>
<xpath expr="//field[@name='location_dest_id'][2]" position="after"> <xpath expr="//field[@name='location_dest_id'][2]" position="after">
<field name="destination_location_id" domain="[ <field name="current_product_id" invisible="1"/>
('location_id', '=', location_dest_id_value), <field name="there_is_no_sn" invisible="1"/>
('location_status', '=', '空闲') <!-- <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)]"/>
<!-- <field name="location_dest_id_product_type"/> --> <!-- <field name="location_dest_id_product_type"/> -->
<!-- <field name="location_dest_id"/> --> <!-- <field name="location_dest_id"/> -->
<field name="location_dest_id_value" invisible="1"/> <field name="location_dest_id_value" invisible="1"/>

View File

@@ -149,6 +149,7 @@
<field name="location_id"/> <field name="location_id"/>
<field name="product_sn_id"/> <field name="product_sn_id"/>
<field name="product_id"/> <field name="product_id"/>
<field name="product_num" readonly="1"/>
<field name="location_status"/> <field name="location_status"/>
<field name="storage_time" widget="datetime"/> <field name="storage_time" widget="datetime"/>
<field name="production_id" readonly="1"/> <field name="production_id" readonly="1"/>