Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/刀具物料与夹具物料的反注册
# Conflicts: # sf_base/views/base_view.xml
This commit is contained in:
@@ -285,9 +285,11 @@ class StockPicking(models.Model):
|
||||
res = super().button_validate()
|
||||
# 采购单验证(夹具)
|
||||
for item in self.move_ids_without_package:
|
||||
if item.product_id.categ_type == '夹具':
|
||||
if item.quantity_done > 0:
|
||||
if item.quantity_done > 0:
|
||||
if item.product_id.categ_type == '夹具':
|
||||
item._register_fixture()
|
||||
elif item.product_id.categ_type == '刀具':
|
||||
item._register_cutting_tool()
|
||||
return res
|
||||
|
||||
# 创建 外协出库入单
|
||||
@@ -401,4 +403,72 @@ class ReStockMove(models.Model):
|
||||
except Exception as e:
|
||||
raise UserError("注册夹具到云端失败,请联系管理员!")
|
||||
|
||||
|
||||
# 将采购到的刀具注册到Cloud
|
||||
def _register_cutting_tool(self):
|
||||
create_url = '/api/factory_cutting_tool_material/create'
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||
strurl = config['sf_url'] + create_url
|
||||
for item in self:
|
||||
val = {
|
||||
'token': config['token'],
|
||||
'name': item.product_id.name,
|
||||
'brand_code': self.env['sf.machine.brand'].search([('id', '=', item.product_id.brand_id.id)]).code,
|
||||
'cutting_tool_material_code': self.env['sf.cutting.tool.material'].search(
|
||||
[('id', '=', item.product_id.cutting_tool_material_id.id)]).code,
|
||||
'cutting_tool_type_code': self.env['sf.cutting.tool.type'].search(
|
||||
[('id', '=', item.product_id.cutting_tool_type_id.id)]).code,
|
||||
'material_model_code': self.env['sf.materials.model'].search(
|
||||
[('id', '=', item.product_id.materials_type_id.id)]).materials_no,
|
||||
'tool_length': item.product_id.tool_length,
|
||||
'tool_width': item.product_id.tool_width,
|
||||
'tool_height': item.product_id.tool_height,
|
||||
'tool_thickness': item.product_id.tool_thickness,
|
||||
'tool_weight': item.product_id.tool_weight,
|
||||
'coating_material': item.product_id.coating_material,
|
||||
'amount': int(item.quantity_done),
|
||||
# 'model_file': '' if not item.product_id.fixture_model_file else base64.b64encode(
|
||||
# item.product_id.fixture_model_file).decode(
|
||||
# 'utf-8'),
|
||||
'total_length': item.product_id.cutting_tool_total_length,
|
||||
'shank_length': item.product_id.cutting_tool_shank_length,
|
||||
'blade_length': item.product_id.cutting_tool_blade_length,
|
||||
'diameter': item.product_id.cutting_tool_diameter,
|
||||
'blade_number': item.product_id.cutting_tool_blade_number,
|
||||
'front_angle': item.product_id.cutting_tool_front_angle,
|
||||
'rear_angle': item.product_id.cutting_tool_rear_angle,
|
||||
'main_included_angle': item.product_id.cutting_tool_main_included_angle,
|
||||
'chuck_codes': self.env['product.template']._json_chuck_item_code(item),
|
||||
'cutter_bar_codes': self.env['product.template']._json_cutter_bar_item_code(item),
|
||||
'cutter_pad_codes': self.env['product.template']._json_cutter_pad_item_code(item),
|
||||
'blade_codes': self.env['product.template']._json_blade_item_code(item),
|
||||
'handle_codes': self.env['product.template']._json_handle_item_code(item),
|
||||
'nut': item.product_id.cutting_tool_nut,
|
||||
'top_angle': item.product_id.cutting_tool_top_angle,
|
||||
'jump_accuracy': item.product_id.cutting_tool_jump_accuracy,
|
||||
'working_hardness': item.product_id.cutting_tool_working_hardness,
|
||||
'blade_diameter': item.product_id.cutting_tool_blade_diameter,
|
||||
'wrench': item.product_id.cutting_tool_wrench,
|
||||
'screw': item.product_id.cutting_tool_screw,
|
||||
'accuracy_level': item.product_id.cutting_tool_accuracy_level,
|
||||
'diameter_max': item.product_id.cutting_tool_diameter_max,
|
||||
'clamping_diameter': item.product_id.cutting_tool_clamping_diameter,
|
||||
'flange_length': item.product_id.cutting_tool_flange_length,
|
||||
'flange_diameter': item.product_id.cutting_tool_flange_diameter,
|
||||
'outer_diameter': item.product_id.cutting_tool_outer_diameter,
|
||||
'inner_diameter': item.product_id.cutting_tool_inner_diameter,
|
||||
}
|
||||
try:
|
||||
if item.product_id.industry_code:
|
||||
val['industry_code'] = item.product_id.industry_code
|
||||
ret = requests.post(strurl, json={}, data=val, headers=headers)
|
||||
ret = ret.json()
|
||||
if ret['status'] == 200:
|
||||
if not item.product_id.industry_code:
|
||||
item.product_id.write({'register_state': '已注册', 'industry_code': ret['industry_code']})
|
||||
else:
|
||||
item.product_id.write({'register_state': '已注册'})
|
||||
else:
|
||||
item.product_id.write({'register_state': '注册失败'})
|
||||
except Exception as e:
|
||||
raise UserError("注册刀具到云端失败,请联系管理员!")
|
||||
|
||||
Reference in New Issue
Block a user