1、功能刀具拆解单优化;2、完成 需求坯料序列号生成规则优化2;
This commit is contained in:
@@ -675,7 +675,6 @@ class ReStockMove(models.Model):
|
||||
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
|
||||
else:
|
||||
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
|
||||
# self.action_assign_serial_show_details()
|
||||
elif self.product_id.tracking == "lot":
|
||||
self._put_tool_lot(self.company_id, self.product_id, self.origin)
|
||||
|
||||
@@ -702,6 +701,23 @@ class ReStockMove(models.Model):
|
||||
),
|
||||
}
|
||||
|
||||
def put_move_line(self):
|
||||
"""
|
||||
确认订单时,自动分配序列号
|
||||
"""
|
||||
if self.product_id.tracking == "serial":
|
||||
if self.product_id.categ_id.name == '刀具':
|
||||
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
|
||||
else:
|
||||
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
|
||||
self._generate_serial_numbers()
|
||||
for item in self.move_line_nosuggest_ids:
|
||||
if item.lot_name:
|
||||
lot_name = item.lot_name
|
||||
if item.product_id.categ_id.name == '坯料':
|
||||
lot_name = lot_name.split('[', 1)[0]
|
||||
item.lot_qr_code = self.compute_lot_qr_code(lot_name)
|
||||
|
||||
def _put_tool_lot(self, company, product, origin):
|
||||
if product.tracking == "lot" and self.product_id.categ_id.name == '刀具':
|
||||
if not self.move_line_nosuggest_ids:
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
<field name="model">stock.lot</field>
|
||||
<field name="inherit_id" ref="stock.view_production_lot_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='create_date']" position="after">
|
||||
<field name="rfid" invisible="1"/>
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="rfid"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -215,6 +215,16 @@ class RePurchaseOrder(models.Model):
|
||||
if len(product_id) != len(line):
|
||||
raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name)
|
||||
|
||||
def button_confirm(self):
|
||||
result = super(RePurchaseOrder, self).button_confirm()
|
||||
for item in self:
|
||||
if item.picking_ids:
|
||||
for picking_id in item.picking_ids:
|
||||
if picking_id.move_ids:
|
||||
for move_id in picking_id.move_ids:
|
||||
move_id.put_move_line()
|
||||
return result
|
||||
|
||||
|
||||
class ResPartnerToSale(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
@@ -926,7 +926,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
|
||||
# =================刀柄是否[报废]拆解=======
|
||||
location_dest_scrap = self.env['stock.location'].search([('name', '=', 'Scrap')])
|
||||
location_dest_scrap_ids = self.env['stock.location'].search([('name', 'in', ('Scrap', '报废'))])
|
||||
if self.handle_rfid:
|
||||
lot = self.env['stock.lot'].sudo().search([('rfid', '=', self.handle_rfid)])
|
||||
if not lot:
|
||||
@@ -934,30 +934,33 @@ class FunctionalToolDismantle(models.Model):
|
||||
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
|
||||
if self.scrap_boolean:
|
||||
# 刀柄报废 入库到Scrap
|
||||
lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, code,
|
||||
lot.create_stock_quant(location, location_dest_scrap_ids[-1], functional_tool_assembly.id, code,
|
||||
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
||||
lot.tool_material_status = '报废'
|
||||
else:
|
||||
# 刀柄不报废 入库到刀具房
|
||||
lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, code,
|
||||
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
||||
lot.tool_material_status = '可用'
|
||||
|
||||
# ==============功能刀具[报废]拆解================
|
||||
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
|
||||
# 除刀柄外物料报废 入库到Scrap
|
||||
if self.integral_product_id:
|
||||
self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
|
||||
location_dest_scrap, code)
|
||||
location_dest_scrap_ids[-1], code)
|
||||
elif self.blade_product_id:
|
||||
self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap,
|
||||
code)
|
||||
self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location,
|
||||
location_dest_scrap_ids[-1], code)
|
||||
if self.bar_product_id:
|
||||
self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap,
|
||||
code)
|
||||
self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location,
|
||||
location_dest_scrap_ids[-1], code)
|
||||
elif self.pad_product_id:
|
||||
self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap,
|
||||
code)
|
||||
self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location,
|
||||
location_dest_scrap_ids[-1], code)
|
||||
if self.chuck_product_id:
|
||||
self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap,
|
||||
code)
|
||||
self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location,
|
||||
location_dest_scrap_ids[-1], code)
|
||||
# ===========功能刀具[磨削]拆解==============
|
||||
# elif self.dismantle_cause in ['刀具需磨削']:
|
||||
# location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
|
||||
|
||||
@@ -854,10 +854,10 @@ class ProductProduct(models.Model):
|
||||
'company_id': self.env.company.id
|
||||
})
|
||||
# 获取位置对象
|
||||
location_inventory_id = self.env['stock.location'].search([('name', '=', 'Production')])
|
||||
location_inventory_ids = self.env['stock.location'].search([('name', 'in', ('Production', '生产'))])
|
||||
stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')])
|
||||
# 创建功能刀具该批次/序列号 库存移动和移动历史
|
||||
stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id,
|
||||
stock_lot.create_stock_quant(location_inventory_ids[-1], stock_location_id, functional_tool_assembly.id,
|
||||
obj.assembly_order_code, obj, obj.after_tool_groups_id)
|
||||
|
||||
return stock_lot
|
||||
|
||||
@@ -1143,7 +1143,10 @@ class CustomStockMove(models.Model):
|
||||
move_lines = self.move_line_ids # 获取当前 stock.move 对应的所有 stock.move.line 记录
|
||||
for line in move_lines:
|
||||
if line.lot_name: # 确保 lot_name 存在
|
||||
qr_data = self.compute_lot_qr_code(line.lot_name)
|
||||
lot_name = line.lot_name
|
||||
if line.product_id.categ_id.name == '坯料':
|
||||
lot_name = lot_name.split('[', 1)[0]
|
||||
qr_data = self.compute_lot_qr_code(lot_name)
|
||||
# 假设 stock.move.line 模型中有一个字段叫做 lot_qr_code 用于存储二维码数据
|
||||
line.lot_qr_code = qr_data
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user