刀把类型新增bt50 修改同步品牌图片报错问题

This commit is contained in:
qihao.gong@jikimo.com
2023-08-23 14:37:02 +08:00
parent 10292df48d
commit b01a5a4216
3 changed files with 8 additions and 2 deletions

View File

@@ -256,7 +256,7 @@ class MachineToolType(models.Model):
name = fields.Char('名称')
brand_id = fields.Many2one('sf.machine.brand', string='品牌')
knife_type = fields.Selection(
[("BT40", "BT40"), ("BT30", "BT30")],
[("BT40", "BT40"), ("BT30", "BT30"), ("BT50", "BT50")],
default="", string="刀把类型")
number_of_knife_library = fields.Integer('刀库数量')
rotate_speed = fields.Integer('转速')

View File

@@ -30,6 +30,7 @@
<field name="name"/>
<field name="tag_ids" widget="many2many_tags" optional="hide"/>
<field name="remark"/>
<field name="image_brand" widget="image"/>
</tree>
</field>
</record>

View File

@@ -569,15 +569,20 @@ class MachineBrand(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['machine_brand_all_list']:
brand = self.env['sf.machine.brand'].search(
[("code", '=', item['code'])])
if not brand:
if item.get('image_brand'):
image = base64.b64decode(item['image_brand'])
else:
image = ''
self.env['sf.machine.brand'].create({
"id": item['id'],
"name": item['name'],
"code": item['code'],
"remark": item['remark'],
"image_brand": '' if not item['image_brand'] else base64.b64encode(item.image_brand),
"image_brand": image,
"tag_ids": self.env['sf.machine.brand.tags'].search(
[("name", 'in', item['tag_ids'])]).ids
})