优化同步代码

This commit is contained in:
mgw
2024-05-18 21:32:24 +08:00
parent cc7963cb5a
commit 3afa76b79c

View File

@@ -2116,19 +2116,21 @@ class CuttingSpeed(models.Model):
for item in result['feed_per_tooth_all_list']:
feed_per_tooth = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if not feed_per_tooth:
self.create({
'name': item['name'],
'standard_library_id': self.env['sf.cutting_tool.standard.library'].search(
[('code', '=', item['standard_library_code'].replace("JKM", result[
'factory_short_name']))]).id,
'materials_type_id': self.env['sf.materials.model'].search(
[('materials_no', '=', item['materials_type_code'])]).id,
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
[('name', '=', item['cutting_width_depth'])]).id,
'blade_diameter': item['blade_diameter'],
'feed_per_tooth': item['feed_per_tooth'],
'active': item['active'],
})
_logger.info("item[standard_library_code] %s" % item.get('standard_library_code'))
if item.get('standard_library_code'):
self.create({
'name': item['name'],
'standard_library_id': self.env['sf.cutting_tool.standard.library'].search(
[('code', '=', item['standard_library_code'].replace("JKM", result[
'factory_short_name']))]).id,
'materials_type_id': self.env['sf.materials.model'].search(
[('materials_no', '=', item['materials_type_code'])]).id,
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
[('name', '=', item['cutting_width_depth'])]).id,
'blade_diameter': item['blade_diameter'],
'feed_per_tooth': item['feed_per_tooth'],
'active': item['active'],
})
else:
feed_per_tooth.write({
'materials_type_id': self.env['sf.materials.model'].search(