1、删除功能刀具组装的取消组装功能和出库功能;2、删除功能刀具组装单的单据来源跳转按钮;3、新增组装单编码字段和自动生成编码的方法;4、新增功能刀具序列号,绑定功能刀具产品序列号;5、完成功能刀具组装后的产品入库到位置【组装后】
This commit is contained in:
@@ -733,10 +733,12 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
|
||||
class FunctionalToolAssembly(models.Model):
|
||||
_name = 'sf.functional.tool.assembly'
|
||||
_description = '功能刀具组装'
|
||||
_description = '功能刀具组装单'
|
||||
_order = 'use_tool_time asc'
|
||||
|
||||
functional_tool_code = fields.Char(string='功能刀具编码', readonly=True)
|
||||
assembly_order_code = fields.Char(string='编码', compute='_get_code', readonly=True)
|
||||
functional_tool_code = fields.Char(string='功能刀具编码', invisible=True)
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
|
||||
name = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=True)
|
||||
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True,
|
||||
group_expand='_read_group_functional_tool_type_ids')
|
||||
@@ -787,6 +789,58 @@ class FunctionalToolAssembly(models.Model):
|
||||
chuck_name = fields.Char('夹头名称', readonly=True)
|
||||
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True)
|
||||
|
||||
@api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id')
|
||||
def _compute_auto_fill(self):
|
||||
for record in self:
|
||||
if record.integral_code_id:
|
||||
record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_material_id.id
|
||||
record.integral_name = record.integral_code_id.product_id.name
|
||||
record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_integral_model_id = None
|
||||
record.integral_name = None
|
||||
record.sf_tool_brand_id_1 = None
|
||||
if record.blade_code_id:
|
||||
record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_material_id.id
|
||||
record.blade_name = record.blade_code_id.product_id.name
|
||||
record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_blade_model_id = None
|
||||
record.blade_name = None
|
||||
record.sf_tool_brand_id_2 = None
|
||||
if record.bar_code_id:
|
||||
record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_material_id.id
|
||||
record.bar_name = record.bar_code_id.product_id.name
|
||||
record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_cutterbar_model_id = None
|
||||
record.bar_name = None
|
||||
record.sf_tool_brand_id_3 = None
|
||||
if record.pad_code_id:
|
||||
record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_material_id.id
|
||||
record.pad_name = record.pad_code_id.product_id.name
|
||||
record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_cutterpad_model_id = None
|
||||
record.pad_name = None
|
||||
record.sf_tool_brand_id_4 = None
|
||||
if record.handle_code_id:
|
||||
record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_material_id.id
|
||||
record.handle_name = record.handle_code_id.product_id.name
|
||||
record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_cutterhandle_model_id = None
|
||||
record.handle_name = None
|
||||
record.sf_tool_brand_id_5 = None
|
||||
if record.chuck_code_id:
|
||||
record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_material_id.id
|
||||
record.chuck_name = record.chuck_code_id.product_id.name
|
||||
record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id
|
||||
else:
|
||||
record.cutting_tool_cutterhead_model_id = None
|
||||
record.chuck_name = None
|
||||
record.sf_tool_brand_id_6 = None
|
||||
|
||||
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
|
||||
tool_loading_length = fields.Char(string='装刀长(mm)', readonly=True)
|
||||
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
|
||||
@@ -795,11 +849,12 @@ class FunctionalToolAssembly(models.Model):
|
||||
cut_length = fields.Char(string='已切削长度(mm)', readonly=True)
|
||||
cut_number = fields.Char(string='已切削次数', readonly=True)
|
||||
|
||||
loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀')], string='装刀任务来源', readonly=True)
|
||||
loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀'), ('2', '按库存组装')],
|
||||
string='装刀任务来源', readonly=True)
|
||||
applicant = fields.Char(string='申请人', readonly=True)
|
||||
reason_for_applying = fields.Char(string='申请原因', readonly=True)
|
||||
apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True)
|
||||
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装'), ('2', '已出库')], string='组装状态',
|
||||
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态',
|
||||
default='0', readonly=True)
|
||||
use_tool_time = fields.Datetime(string='用刀时间', readonly=True)
|
||||
production_line_name_id = fields.Many2one('sf.production.line', string='产线名称', readonly=False)
|
||||
@@ -818,155 +873,29 @@ class FunctionalToolAssembly(models.Model):
|
||||
sf_cam_work_order_program_knife_plan_id = fields.Many2one('sf.cam.work.order.program.knife.plan',
|
||||
'CAM工单程序用刀计划')
|
||||
|
||||
def open_sf_cam_work_order_program_knife_plan(self):
|
||||
@api.depends('loading_task_source')
|
||||
def _get_code(self):
|
||||
"""
|
||||
跳转到CAM工单程序用刀计划界面按钮功能
|
||||
自动生成组装单编码
|
||||
"""
|
||||
action = self.env.ref('sf_tool_management.sf_cam_work_order_program_knife_plan_view_act')
|
||||
result = action.read()[0]
|
||||
result['domain'] = [('sf_functional_tool_assembly_id', '=', self.id)]
|
||||
return result
|
||||
|
||||
def open_sf_machine_table_tool_changing_apply(self):
|
||||
"""
|
||||
跳转到机床换刀申请界面按钮功能
|
||||
"""
|
||||
action = self.env.ref('sf_tool_management.sf_machine_table_tool_changing_apply_view_act')
|
||||
result = action.read()[0]
|
||||
result['domain'] = [('sf_functional_tool_assembly_id', '=', self.id)]
|
||||
return result
|
||||
|
||||
def cancel_functional_tool_assembly(self):
|
||||
"""
|
||||
取消功能刀具组装
|
||||
:return:
|
||||
"""
|
||||
if self.new_former == '0':
|
||||
# 如果是新刀,则删除功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录的记录
|
||||
record = self.env['sf.functional.cutting.tool.entity'].search([
|
||||
('code', '=', self.functional_tool_code)])
|
||||
self.env['sf.functional.tool.warning'].search(
|
||||
[('functional_cutting_tool_id', '=', record.id)]).unlink()
|
||||
self.env['sf.real.time.distribution.of.functional.tools'].search(
|
||||
[('functional_cutting_tool_id', '=', record.id)]).unlink()
|
||||
self.env['sf.inbound.and.outbound.records.of.functional.tools'].search(
|
||||
[('functional_cutting_tool_id', '=', record.id)]).unlink()
|
||||
record.unlink()
|
||||
else:
|
||||
# 获取功能刀具缓存信息
|
||||
record = self.env['sf.functional.cutting.tool.entity.cache'].search([
|
||||
('code', '=', self.functional_tool_code)], limit=1)
|
||||
# # 删除现有功能刀具列表记录
|
||||
# self.env['sf.functional.cutting.tool.entity'].search([
|
||||
# ('code', '=', self.functional_tool_code)]).unlink()
|
||||
# 修改功能刀具列表信息
|
||||
self.env['sf.functional.cutting.tool.entity'].search([
|
||||
('code', '=', self.functional_tool_code)]).sudo().write({
|
||||
'code': record.code,
|
||||
'name': record.name,
|
||||
'mrs_cutting_tool_type_id': record.mrs_cutting_tool_type_id.id,
|
||||
'mrs_cutting_tool_model_id': record.mrs_cutting_tool_model_id.id,
|
||||
'cutting_tool_integral_model_id': record.cutting_tool_integral_model_id.id,
|
||||
'cutting_tool_blade_model_id': record.cutting_tool_blade_model_id.id,
|
||||
'cutting_tool_cutterbar_model_id': record.cutting_tool_cutterbar_model_id.id,
|
||||
'cutting_tool_cutterpad_model_id': record.cutting_tool_cutterpad_model_id.id,
|
||||
'cutting_tool_cutterhandle_model_id': record.cutting_tool_cutterhandle_model_id.id,
|
||||
'cutting_tool_cutterhead_model_id': record.cutting_tool_cutterhead_model_id.id,
|
||||
'diameter': record.diameter,
|
||||
'tool_grade': record.tool_grade,
|
||||
'machining_accuracy': record.machining_accuracy,
|
||||
'tool_length': record.tool_length,
|
||||
'blade_number': record.blade_number,
|
||||
'integral_blade_length': record.integral_blade_length,
|
||||
'effective_blade_length': record.effective_blade_length,
|
||||
'max_life': record.max_life,
|
||||
'is_standard': record.is_standard,
|
||||
'applicable_range': record.applicable_range,
|
||||
'image': record.image,
|
||||
})
|
||||
# 删除功能刀具缓存信息
|
||||
self.env['sf.functional.cutting.tool.entity.cache'].search([
|
||||
('code', '=', self.functional_tool_code)]).unlink()
|
||||
|
||||
# 修改功能刀具组装的组装信息
|
||||
self.env['sf.functional.tool.assembly'].search([
|
||||
('machine_tool_name_id', '=', self.machine_tool_name_id.id),
|
||||
('cutter_spacing_code', '=', self.cutter_spacing_code),
|
||||
('assemble_status', '=', '1')
|
||||
]).write({
|
||||
'cutting_tool_integral_model_id': None,
|
||||
'integral_code_id': None,
|
||||
'integral_name': None,
|
||||
'sf_tool_brand_id_1': None,
|
||||
'cutting_tool_blade_model_id': None,
|
||||
'blade_code_id': None,
|
||||
'blade_name': None,
|
||||
'sf_tool_brand_id_2': None,
|
||||
'cutting_tool_cutterbar_model_id': None,
|
||||
'bar_code_id': None,
|
||||
'bar_name': None,
|
||||
'sf_tool_brand_id_3': None,
|
||||
'cutting_tool_cutterpad_model_id': None,
|
||||
'pad_code_id': None,
|
||||
'pad_name': None,
|
||||
'sf_tool_brand_id_4': None,
|
||||
'cutting_tool_cutterhandle_model_id': None,
|
||||
'handle_code_id': None,
|
||||
'handle_name': None,
|
||||
'sf_tool_brand_id_5': None,
|
||||
'cutting_tool_cutterhead_model_id': None,
|
||||
'chuck_code_id': None,
|
||||
'chuck_name': None,
|
||||
'sf_tool_brand_id_6': None,
|
||||
'coarse_middle_thin': None,
|
||||
'tool_loading_length': None,
|
||||
'new_former': None,
|
||||
'reference_length': None,
|
||||
'cut_time': None,
|
||||
'cut_length': None,
|
||||
'cut_number': None,
|
||||
'assemble_status': '0',
|
||||
'tool_loading_person': None,
|
||||
'tool_loading_time': None
|
||||
})
|
||||
|
||||
def show_popup(self):
|
||||
"""
|
||||
单个功能刀具出库
|
||||
:return:
|
||||
"""
|
||||
self.env['sf.delivery.of.cargo.from.storage'].search([]).unlink()
|
||||
|
||||
vals = self.env['sf.functional.tool.assembly'].search(
|
||||
[('check_box_1', '=', True), ('assemble_status', '=', '1')])
|
||||
if vals:
|
||||
for val in vals:
|
||||
self.env['sf.delivery.of.cargo.from.storage'].create({
|
||||
'functional_tool_code': val.functional_tool_code,
|
||||
'name': val.name.id,
|
||||
'functional_tool_type_id': val.functional_tool_type_id.id,
|
||||
'production_line_name_id': val.production_line_name_id.id,
|
||||
'machine_tool_code': val.machine_tool_code,
|
||||
'receive_person': val.receive_person,
|
||||
'receive_time': val.receive_time})
|
||||
else:
|
||||
self.env['sf.delivery.of.cargo.from.storage'].create({
|
||||
'functional_tool_code': self.functional_tool_code,
|
||||
'name': self.name.id,
|
||||
'functional_tool_type_id': self.functional_tool_type_id.id,
|
||||
'production_line_name_id': self.production_line_name_id.id,
|
||||
'machine_tool_code': self.machine_tool_code,
|
||||
'receive_person': self.receive_person,
|
||||
'receive_time': self.receive_time})
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': '功能刀具出库',
|
||||
'res_model': 'sf.delivery.of.cargo.from.storage',
|
||||
'view_mode': 'tree',
|
||||
'view_type': 'tree',
|
||||
'target': 'new'
|
||||
}
|
||||
for record in self:
|
||||
new_time = str(fields.Date.today())
|
||||
datetime = new_time[2:4] + new_time[5:7] + new_time[-2:]
|
||||
functional_tool_assembly = record.env['sf.functional.tool.assembly'].sudo().search(
|
||||
[('loading_task_source', '=', record.loading_task_source),
|
||||
('assembly_order_code', 'like', new_time)], limit=1, order="id desc")
|
||||
print(functional_tool_assembly)
|
||||
if not functional_tool_assembly:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(functional_tool_assembly.name[-3:]) + 1
|
||||
num = "%03d" % m
|
||||
if record.loading_task_source == '0':
|
||||
record.assembly_order_code = 'CAMZZD' + datetime + str(num)
|
||||
if record.loading_task_source == '1':
|
||||
record.assembly_order_code = 'JTZZD' + datetime + str(num)
|
||||
if record.loading_task_source == '2':
|
||||
record.assembly_order_code = 'MTSZZD' + datetime + str(num)
|
||||
|
||||
def automated_assembly(self):
|
||||
"""
|
||||
|
||||
@@ -997,10 +997,11 @@
|
||||
<field name="model">sf.functional.tool.assembly</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree create="0">
|
||||
<field name="assembly_order_code"/>
|
||||
<field name="functional_tool_code"/>
|
||||
<field name="name"/>
|
||||
<field name="functional_tool_type_id"/>
|
||||
<field name="loading_task_source" optional="hide"/>
|
||||
<field name="loading_task_source"/>
|
||||
<field name="applicant"/>
|
||||
<field name="assemble_status" optional="hide"/>
|
||||
<field name="use_tool_time" />
|
||||
@@ -1034,13 +1035,8 @@
|
||||
'default_whether_standard_tool': None}"
|
||||
attrs="{'invisible': [('assemble_status', '!=', '0')]}"
|
||||
class="btn-primary"/>
|
||||
<button string="取消组装" name="cancel_functional_tool_assembly" type="object" attrs="{'invisible': [('assemble_status', '!=', '1')]}" class="btn-primary" confirm="是否确认取消组装"/>
|
||||
<button string="出库" name="show_popup" type="object" attrs="{'invisible': [('assemble_status', '!=', '1')]}" class="btn-primary"/>
|
||||
<button string="组装单打印" name="assemble_single_print" type="object" attrs="{'invisible': [('assemble_status', '=', '0')]}" class="btn-primary" confirm="是否确认打印组装单"/>
|
||||
<button string="查看CAM工单程序用刀计划" type="object" name="open_sf_cam_work_order_program_knife_plan"
|
||||
class="oe_highlight" attrs="{'invisible': [('loading_task_source', '!=', '0')]}" />
|
||||
<button string="查看机床换刀申请" type="object" name="open_sf_machine_table_tool_changing_apply"
|
||||
class="oe_highlight" attrs="{'invisible': [('loading_task_source', '!=', '1')]}" />
|
||||
<button string="组装单打印" name="assemble_single_print" type="object"
|
||||
attrs="{'invisible': [('assemble_status', '=', '0')]}" class="btn-primary" confirm="是否确认打印组装单"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -1051,7 +1047,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form create="0">
|
||||
<header>
|
||||
<button string="组装"
|
||||
<button string="组装"
|
||||
name="%(sf_tool_management.sf_functional_tool_assembly_order_act)d"
|
||||
type="action"
|
||||
context="{
|
||||
@@ -1071,22 +1067,11 @@
|
||||
attrs="{'invisible': [('assemble_status', '!=', '0')]}"
|
||||
class="btn-primary"/>
|
||||
|
||||
<button string="取消组装" name="cancel_functional_tool_assembly" type="object"
|
||||
attrs="{'invisible': [('assemble_status', '!=', '1')]}" class="btn-primary" confirm="是否确认取消组装"/>
|
||||
|
||||
<button string="打印二维码" name="automatic_printing_of_QR_code" type="object"
|
||||
<button string="打印二维码" name="automatic_printing_of_QR_code" type="object"
|
||||
attrs="{'invisible': [('assemble_status', '=', '0')]}" class="btn-primary" confirm="是否确认打印二维码"/>
|
||||
|
||||
<button string="出库" name="show_popup" type="object"
|
||||
attrs="{'invisible': [('assemble_status', '!=', '1')]}" class="btn-primary"/>
|
||||
|
||||
<button string="组装单打印" name="assemble_single_print" type="object"
|
||||
attrs="{'invisible': [('assemble_status', '=', '0')]}" class="btn-primary" confirm="是否确认打印组装单"/>
|
||||
<button string="查看CAM工单程序用刀计划" type="object" name="open_sf_cam_work_order_program_knife_plan"
|
||||
class="oe_highlight" attrs="{'invisible': [('loading_task_source', '!=', '0')]}" />
|
||||
<button string="查看机床换刀申请" type="object" name="open_sf_machine_table_tool_changing_apply"
|
||||
class="oe_highlight" attrs="{'invisible': [('loading_task_source', '!=', '1')]}" />
|
||||
<field name="assemble_status" widget="statusbar" statusbar_visible="0,1,2"/>
|
||||
<field name="assemble_status" widget="statusbar" statusbar_visible="0,1,2"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
|
||||
@@ -258,7 +258,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', default='1')
|
||||
tool_loading_length = fields.Char(string='装刀长')
|
||||
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', required=True, default='1')
|
||||
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', required=True, default='0')
|
||||
reference_length = fields.Char(string='参考伸出长')
|
||||
cut_time = fields.Char(string='已切削时间')
|
||||
cut_length = fields.Char(string='已切削长度')
|
||||
@@ -269,31 +269,20 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
功能刀具组装
|
||||
:return:
|
||||
"""
|
||||
# 创建组装入库单
|
||||
# 创建功能刀具批次/序列号记录
|
||||
stock_lot = self.create_assemble_warehouse_receipt()
|
||||
# 创建刀具组装入库单
|
||||
self.create_stocking_picking(stock_lot)
|
||||
|
||||
desc_1 = {
|
||||
'cutting_tool_integral_model_id': self.cutting_tool_integral_model_id.id,
|
||||
'barcode_id': stock_lot.id,
|
||||
'integral_code_id': self.integral_code_id.id,
|
||||
'integral_name': self.integral_name,
|
||||
'sf_tool_brand_id_1': self.sf_tool_brand_id_1,
|
||||
'cutting_tool_blade_model_id': self.cutting_tool_blade_model_id.id,
|
||||
'blade_code_id': self.blade_code_id.id,
|
||||
'blade_name': self.blade_name,
|
||||
'sf_tool_brand_id_2': self.sf_tool_brand_id_2,
|
||||
'cutting_tool_cutterbar_model_id': self.cutting_tool_cutterbar_model_id.id,
|
||||
'bar_code_id': self.bar_code_id.id,
|
||||
'bar_name': self.bar_name,
|
||||
'sf_tool_brand_id_3': self.sf_tool_brand_id_3,
|
||||
'cutting_tool_cutterpad_model_id': self.cutting_tool_cutterpad_model_id.id,
|
||||
'pad_code_id': self.pad_code_id.id,
|
||||
'pad_name': self.pad_name,
|
||||
'sf_tool_brand_id_4': self.sf_tool_brand_id_4,
|
||||
'cutting_tool_cutterhandle_model_id': self.cutting_tool_cutterhandle_model_id.id,
|
||||
'handle_code_id': self.handle_code_id.id,
|
||||
'handle_name': self.handle_name,
|
||||
'sf_tool_brand_id_5': self.sf_tool_brand_id_5,
|
||||
'cutting_tool_cutterhead_model_id': self.cutting_tool_cutterhead_model_id.id,
|
||||
'chuck_code_id': self.chuck_code_id.id,
|
||||
'chuck_name': self.chuck_name,
|
||||
'sf_tool_brand_id_6': self.sf_tool_brand_id_6,
|
||||
'coarse_middle_thin': self.coarse_middle_thin,
|
||||
'tool_loading_length': self.tool_loading_length,
|
||||
'new_former': self.new_former,
|
||||
@@ -305,15 +294,13 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
'tool_loading_person': self.env.user.name,
|
||||
'tool_loading_time': fields.Datetime.now()
|
||||
}
|
||||
|
||||
functional_tool_assembly = self.env['sf.functional.tool.assembly'].search([
|
||||
('machine_tool_name_id', '=', self.machine_tool_name_id.id),
|
||||
('cutter_spacing_code', '=', self.cutter_spacing_code),
|
||||
('assemble_status', '=', '0'),
|
||||
])
|
||||
|
||||
# print('功能刀具组装id:', functional_tool_assembly.id)
|
||||
# print('整体式物料信息:', self.cutting_tool_integral_model_id.id)
|
||||
|
||||
# 封装功能刀具数据
|
||||
desc_2 = {
|
||||
'code': self.code,
|
||||
@@ -384,21 +371,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
'applicable_range': record.applicable_range,
|
||||
'image': record.image,
|
||||
})
|
||||
# # 删除功能刀具列表信息
|
||||
# self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).unlink()
|
||||
# # 创建功能刀具列表信息
|
||||
# self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).create(desc_2)
|
||||
# 修改功能刀具列表信息
|
||||
self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).write(desc_2)
|
||||
# 修改功能刀具组装信息
|
||||
functional_tool_assembly.write(desc_1)
|
||||
|
||||
# 创建组装入库单
|
||||
# 创建功能刀具批次/序列号记录
|
||||
stock_lot = self.create_assemble_warehouse_receipt()
|
||||
# 创建刀具组装入库单
|
||||
self.create_stocking_picking(stock_lot)
|
||||
|
||||
# 关闭弹出窗口
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
@@ -432,33 +409,39 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
'product_id': product_id.id,
|
||||
'company_id': self.env.company.id
|
||||
})
|
||||
# 创建功能刀具该批次/序列号位置
|
||||
# 创建功能刀具该批次/序列号 库存移动和移动历史
|
||||
self.create_stock_quant(product_id, stock_lot)
|
||||
|
||||
return stock_lot
|
||||
|
||||
def create_stock_quant(self, product_id, stock_lot):
|
||||
"""
|
||||
创建功能刀具该批次/序列号位置
|
||||
创建功能刀具该批次/序列号 库存移动和移动历史
|
||||
"""
|
||||
# 获取组装后位置对象
|
||||
stock_location = self.env['stock.location'].search([('name', '=', '组装后')])
|
||||
#
|
||||
self.env['stock.move'].create({
|
||||
'':
|
||||
# 获取位置对象
|
||||
stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')])
|
||||
location_inventory_id = self.env['stock.location'].search([('name', '=', 'Inventory adjustment')])
|
||||
|
||||
# 创建库存移动
|
||||
stock_move_id = self.env['stock.move'].create({
|
||||
'name': '更新的产品数量',
|
||||
'product_id': product_id.id,
|
||||
'location_id': location_inventory_id.id,
|
||||
'location_dest_id': stock_location_id.id,
|
||||
'product_uom_qty': 1.00,
|
||||
'state': 'done'
|
||||
})
|
||||
|
||||
# 创建功能刀具该批次/序列号位置
|
||||
# stock_quant = self.env['stock.quant'].create({
|
||||
# 'location_id': stock_location.id,
|
||||
# 'product_id': product_id.id,
|
||||
# 'lot_id': stock_lot.id,
|
||||
# 'quantity': 1.0
|
||||
# })
|
||||
# 创建移动历史
|
||||
stock_move_line_id = self.env['stock.move.line'].create({
|
||||
'product_id': product_id.id,
|
||||
'lot_id': stock_lot.id,
|
||||
'move_id': stock_move_id.id,
|
||||
'qty_done': 1.0,
|
||||
'state': 'done'
|
||||
})
|
||||
|
||||
# # 应用该位置
|
||||
# bool = stock_quant.action_apply_inventory()
|
||||
# return stock_quant
|
||||
return stock_move_id, stock_move_line_id
|
||||
|
||||
def get_stock_lot_name(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user