新增采购入库时实时注册夹具产品到cloud
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
from odoo import models, fields, api
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo.exceptions import ValidationError,UserError
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
class ResProductMo(models.Model):
|
||||
@@ -152,6 +156,12 @@ class ResProductMo(models.Model):
|
||||
fixture_through_hole_size = fields.Integer(string="过孔大小[mm]", size=6)
|
||||
fixture_screw_size = fields.Integer(string="螺牙大小[mm]", size=6)
|
||||
|
||||
def _json_apply_machine_tool_type_item_code(self, item):
|
||||
code_arr = []
|
||||
for i in item.fixture_apply_machine_tool_type_ids:
|
||||
code_arr.append(i.code)
|
||||
return code_arr
|
||||
|
||||
def _get_ids(self, param):
|
||||
type_ids = []
|
||||
if not param:
|
||||
@@ -350,6 +360,42 @@ class ResProductMo(models.Model):
|
||||
item.cutting_tool_standard_speed = False
|
||||
item.image_1920 = False
|
||||
|
||||
# 将采购到的夹具注册到Cloud
|
||||
def _register_fixture(self):
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||
strurl = config['sf_url'] + self.crea_url
|
||||
for item in self:
|
||||
val = {
|
||||
'factory_token': config['token'],
|
||||
'name': item.name,
|
||||
'brand_id': item.brand_id.code,
|
||||
'materials_type_id': item.materials_type_id.code,
|
||||
'fixture_material_code': item.fixture_material_id.code,
|
||||
'fixture_multi_mounting_type_id': item.fixture_multi_mounting_type_id.code,
|
||||
'fixture_clamping_way': item.fixture_clamping_way,
|
||||
'fixture_port_type': item.fixture_port_type,
|
||||
'fixture_clamp_workpiece_length_max': item.fixture_clamp_workpiece_length_max,
|
||||
'fixture_clamp_workpiece_width_max': item.fixture_clamp_workpiece_width_max,
|
||||
'fixture_clamp_workpiece_height_max': item.fixture_clamp_workpiece_height_max.id,
|
||||
'fixture_clamp_workpiece_diameter_max': item.fixture_clamp_workpiece_diameter_max,
|
||||
'fixture_maximum_carrying_weight': item.fixture_maximum_carrying_weight,
|
||||
'fixture_maximum_clamping_force': item.fixture_maximum_clamping_force,
|
||||
'fixture_driving_way': item.fixture_driving_way,
|
||||
'fixture_apply_machine_tool_type_ids': self._json_apply_machine_tool_type_item_code(item),
|
||||
'fixture_through_hole_size': item.fixture_through_hole_size,
|
||||
'fixture_screw_size': item.fixture_screw_size,
|
||||
}
|
||||
try:
|
||||
ret = requests.post(strurl, json={}, data=val, headers=headers)
|
||||
ret = ret.json()
|
||||
if ret['status'] == 200:
|
||||
raise UserError(ret['message'])
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
except Exception as e:
|
||||
raise UserError("注册夹具到云端失败,请联系管理员!")
|
||||
|
||||
|
||||
class ResMrpBomMo(models.Model):
|
||||
_inherit = 'mrp.bom'
|
||||
|
||||
Reference in New Issue
Block a user