예제 #1
0
파일: form.py 프로젝트: gisce/erpclient
 def _action(button, action, type):
     data={}
     context=self.screen.context
     act=action.copy()
     if type in ('print', 'action'):
         self.screen.save_current()
         id = self.screen.current_model and self.screen.current_model.id
         if not (id):
             common.message(_('You must save this record to use the relate button !'))
             return False
         self.screen.display()
         data = {
             'model': self.screen.name,
             'id': id,
             'ids': [id],
             'report_type': act.get('report_type', 'pdf'),
         }
     if type == 'relate':
         id = self.screen.current_model and self.screen.current_model.id
         if not (id):
             common.message(_('You must select a record to use the relate button !'))
             return False
         act['domain'] = self.screen.current_model.expr_eval(act['domain'], check_load=False)
         act['context'] = str(self.screen.current_model.expr_eval(act['context'], check_load=False))
     obj = service.LocalService('action.main')
     value = obj._exec_action(act, data, context)
     if type in ('print', 'action'):
         self.screen.reload()
     return value
예제 #2
0
 def _action_submenu(but, action):
     act_id = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.model.data', 'search', [('name','=',action['action_id'])])
     res_model = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.model.data', 'read', act_id, ['res_id'])
     data = {}
     context = self.screen.context
     act = action.copy()
     self.screen.save_current()
     id = self.screen.current_model and self.screen.current_model.id
     if not (id):
         common.message(_('You must save this record to use the relate button !'))
         return False
     self.screen.display()
     obj = service.LocalService('action.main')
     if not res_model:
         common.message(_('Action not defined !'))
         return None
     res = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.actions.act_window', 'read', res_model[0]['res_id'], False)
     res['domain'] = self.screen.current_model.expr_eval(res['domain'], check_load=False)
     res['context'] = str(self.screen.current_model.expr_eval(res['context'], check_load=False))
     value = obj._exec_action(res, data, context)
     self.screen.reload()
     return value
예제 #3
0
파일: form.py 프로젝트: goldenboy/razvoj
 def _action(button, action, type):
     data = {}
     context = copy.copy(self.screen.context)
     for key in self.screen.context.keys():
         if key.startswith('default_') or key == 'group_by':
             del context[key]
     act = action.copy()
     if type in ('print', 'action'):
         self.screen.save_current()
         id = self.screen.current_model and self.screen.current_model.id
         if not (id):
             common.message(_('You must save this record to use the action button !'))
             return False
         self.screen.display()
         data = {
             'model': self.screen.name,
             'id': id,
             'ids': [id],
             'report_type': act.get('report_type', 'pdf'),
         }
     if type == 'relate':
         id = self.screen.current_model and self.screen.current_model.id
         if not (id):
             common.message(_('You must save a record to use the relate button !'))
             return False
         if act.get('domain',False):
             act['domain'] = self.screen.current_model.expr_eval(act['domain'], check_load=False)
         if act.get('context',False):
             act['context'] = str(self.screen.current_model.expr_eval(act['context'], check_load=False))
         data = {
             'model': self.screen.name,
             'id': id,
             'ids': [id],
         }
     obj = service.LocalService('action.main')
     value = obj._exec_action(act, data, context)
     if type in ('print', 'action') or type == 'relate' and act.get('target') == 'new':
         self.screen.reload()
     return value
예제 #4
0
 def _action(button, action, type):
     data = {}
     context = self.screen.context
     if 'group_by' in context:
         del context['group_by']
     act = action.copy()
     if type in ('print', 'action'):
         self.screen.save_current()
         id = self.screen.current_model and self.screen.current_model.id
         if not (id):
             common.message(_('You must save this record to use the action button !'))
             return False
         self.screen.display()
         data = {
             'model': self.screen.name,
             'id': id,
             'ids': [id],
             'report_type': act.get('report_type', 'pdf'),
         }
     if type == 'relate':
         id = self.screen.current_model and self.screen.current_model.id
         if not (id):
             common.message(_('You must select a record to use the relate button !'))
             return False
         if act.get('domain',False):
             act['domain'] = self.screen.current_model.expr_eval(act['domain'], check_load=False)
         if act.get('context',False):
             act['context'] = str(self.screen.current_model.expr_eval(act['context'], check_load=False))
         data = {
             'model': self.screen.name,
             'id': id,
             'ids': [id],
         }
     obj = service.LocalService('action.main')
     value = obj._exec_action(act, data, context)
     if type in ('print', 'action') or type == 'relate' and act.get('target') == 'new':
         self.screen.reload()
     return value