返回给js的action已配置成功
This commit is contained in:
@@ -7,7 +7,7 @@ import hashlib
|
||||
import time
|
||||
import requests
|
||||
from datetime import datetime
|
||||
|
||||
from odoo.http import request
|
||||
from odoo import fields, models, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
@@ -482,6 +482,57 @@ class WorkCenterBarcode(models.Model):
|
||||
url = 'https://bfm.cs.jikimo.com/api/get/state'
|
||||
requests.post(url, json=json, data=None)
|
||||
|
||||
def action_test(self, barcode=12345):
|
||||
|
||||
workorder_obj = self.env['mrp.workorder'].sudo().search([('tray_code', '=', barcode)])
|
||||
action = {
|
||||
'name': '工单',
|
||||
# 'name': name,
|
||||
'type': 'ir.actions.act_window',
|
||||
# 'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mrp.workorder',
|
||||
'view_id': self.env.ref('mrp.mrp_production_workorder_form_view_inherit').id,
|
||||
'res_id': 1023,
|
||||
'target': 'current',
|
||||
'context': {'id': workorder_obj.id},
|
||||
# 'flags': {'initial_mode': 'edit'},
|
||||
}
|
||||
return action
|
||||
# result = request.env['ir.actions.act_window'].sudo().create(action).read()[0]
|
||||
# action = {'action': action}
|
||||
# return result
|
||||
|
||||
@api.model
|
||||
def get_product_id_by_barcode(self, barcode, **kwargs):
|
||||
print(kwargs)
|
||||
print(barcode)
|
||||
print('111111111111111111111')
|
||||
workorder_obj = self.env['mrp.workorder'].sudo().search([('tray_code', '=', barcode)])
|
||||
workorder_cnc = self.env['mrp.workorder'].sudo().search(['&', ('production_id', '=', workorder_obj.production_id.id), ('name', '=', 'CNC加工')])
|
||||
print('222222222222222222222222')
|
||||
if workorder_obj:
|
||||
print(workorder_obj)
|
||||
print(workorder_obj.id)
|
||||
action = {
|
||||
'name': '工单',
|
||||
'type': 'ir.actions.act_window',
|
||||
# 'view_type': 'form',
|
||||
'views': [[False, 'form']],
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mrp.workorder',
|
||||
'view_id': request.env.ref('mrp.mrp_production_workorder_form_view_inherit').id,
|
||||
'res_id': workorder_cnc.id,
|
||||
'target': 'current',
|
||||
'context': {'id': workorder_obj.id},
|
||||
# 'flags': {'initial_mode': 'edit'},
|
||||
}
|
||||
action = {'result': action, 'error': '返回错误'}
|
||||
action1 = json.dumps(action)
|
||||
return action1
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class CuttingTimeToolType(models.Model):
|
||||
_inherit = 'sf.cutting_tool.type'
|
||||
|
||||
Reference in New Issue
Block a user