def edit(menuitem): with Window(hide_current=True, allow_similar=True): Window.create(model, view_ids=field.attrs.get('view_ids', '').split(','), res_id=id_(record), mode=['form'], name=field.attrs.get('string'))
def gnuhealth_cmd(self,command): cmd = command.split()[0] args = command.split()[1:] domain_name = domain = None search_string = '%' res = RPCExecute('model', 'gnuhealth.command', 'search_read', [('name', '=', cmd)], limit=1,field_names='model.name') if (res): res = res[0] if (res['domain']): domain_name = ast.literal_eval(res['domain']) model_name = res['model'] label = res['label'] if args: arg1 = args.pop() search_string = "%" + arg1 + "%" Window.create(model_name, mode=['tree','form'], name=label, domain=domain_name, limit = CONFIG['client.limit'], search_value = [('rec_name', 'ilike', search_string)] ) else: common.message(_('Command not found.'))
def translate_view(datas): model = datas['model'] Window.create(False, 'ir.translation', res_id=False, domain=[('model', '=', model)], mode=['tree', 'form'])
def __call__(self, resource, obj_id, context): res = super(ConcurrencyDialog, self).__call__(resource, obj_id, context) if res == gtk.RESPONSE_OK: return True if res == gtk.RESPONSE_APPLY: from tryton.gui.window import Window Window.create(False, resource, res_id=obj_id, domain=[('id', '=', obj_id)], context=context, mode=['form', 'tree']) return False
def __call__(self, resource, obj_id, context): res = super(ConcurrencyDialog, self).__call__(resource, obj_id, context) if res == gtk.RESPONSE_OK: return True if res == gtk.RESPONSE_APPLY: from tryton.gui.window import Window Window.create(False, resource, res_id=obj_id, domain=[('id', '=', obj_id)], context=context, mode=['form', 'tree']) return False
def match_selected(completion, model, iter_): model, record_id, model_name = model.get(iter_, 2, 3, 4) if model == self.menu_screen.model_name: # ids is not defined to prevent to add suffix Action.exec_keyword('tree_open', { 'model': model, 'id': record_id, }) else: Window.create(model, res_id=record_id, mode=['form', 'tree'], name=model_name) self.global_search_entry.set_text('') return True
def __call__(self, model, id_, context): res = super(ConcurrencyDialog, self).__call__() if res == Gtk.ResponseType.OK: return True if res == Gtk.ResponseType.APPLY: from tryton.gui.window import Window name = RPCExecute('model', model, 'read', [id_], ['rec_name'], context=context)[0]['rec_name'] with Window(allow_similar=True): Window.create(model, res_id=id_, name=_("Compare: %s", name), domain=[('id', '=', id_)], context=context, mode=['form']) return False
def open_model(path): model, path = (path.split('/', 1) + [''])[:2] if not model: return res_id = None mode = None try: view_ids = json.loads(params.get('views', '[]')) limit = json.loads(params.get('limit', 'null')) name = json.loads(params.get('name', '""')) search_value = json.loads(params.get('search_value', '[]'), object_hook=object_hook) domain = json.loads(params.get('domain', '[]'), object_hook=object_hook) context = json.loads(params.get('context', '{}'), object_hook=object_hook) context_model = params.get('context_model') tab_domain = json.loads(params.get('tab_domain', '[]'), object_hook=object_hook) except ValueError: return if path: try: res_id = int(path) except ValueError: return mode = ['form', 'tree'] try: Window.create(model, view_ids=view_ids, res_id=res_id, domain=domain, context=context, context_model=context_model, mode=mode, name=name, limit=limit, search_value=search_value, tab_domain=tab_domain) except Exception: # Prevent crashing the client return
def _exec_action(action, data=None, context=None): from tryton.gui.window import Window if context is None: context = {} else: context = context.copy() if data is None: data = {} else: data = data.copy() if 'type' not in (action or {}): return context.pop('active_id', None) context.pop('active_ids', None) context.pop('active_model', None) def add_name_suffix(name, context=None): if not data.get('ids') or not data.get('model'): return name max_records = 5 ids = list(filter(lambda id: id >= 0, data['ids']))[:max_records] if not ids: return name rec_names = RPCExecute('model', data['model'], 'read', ids, ['rec_name'], context=context) name_suffix = _(', ').join([x['rec_name'] for x in rec_names]) if len(data['ids']) > len(ids): name_suffix += _(',...') if name_suffix: return _('%s (%s)') % (name, name_suffix) else: return name data['action_id'] = action['id'] if action['type'] == 'ir.action.act_window': view_ids = [] view_mode = None if action.get('views', []): view_ids = [x[0] for x in action['views']] view_mode = [x[1] for x in action['views']] elif action.get('view_id', False): view_ids = [action['view_id'][0]] action.setdefault('pyson_domain', '[]') ctx = { 'active_model': data.get('model'), 'active_id': data.get('id'), 'active_ids': data.get('ids') or [], } ctx.update(rpc.CONTEXT) ctx['_user'] = rpc._USER decoder = PYSONDecoder(ctx) action_ctx = context.copy() action_ctx.update( decoder.decode(action.get('pyson_context') or '{}')) ctx.update(action_ctx) ctx['context'] = ctx decoder = PYSONDecoder(ctx) domain = decoder.decode(action['pyson_domain']) order = decoder.decode(action['pyson_order']) search_value = decoder.decode(action['pyson_search_value'] or '[]') tab_domain = [(n, decoder.decode(d), c) for n, d, c in action['domains']] name = action.get('name', '') if action.get('keyword', ''): name = add_name_suffix(name, action_ctx) res_model = action.get('res_model', data.get('res_model')) res_id = action.get('res_id', data.get('res_id')) limit = action.get('limit') if limit is None: limit = CONFIG['client.limit'] Window.create(res_model, view_ids=view_ids, res_id=res_id, domain=domain, context=action_ctx, order=order, mode=view_mode, name=name, limit=limit, search_value=search_value, icon=(action.get('icon.rec_name') or ''), tab_domain=tab_domain, context_model=action['context_model'], context_domain=action['context_domain']) elif action['type'] == 'ir.action.wizard': name = action.get('name', '') if action.get('keyword', 'form_action') == 'form_action': name = add_name_suffix(name, context) Window.create_wizard(action['wiz_name'], data, direct_print=action.get( 'direct_print', False), name=name, context=context, icon=(action.get('icon.rec_name') or ''), window=action.get('window', False)) elif action['type'] == 'ir.action.report': Action.exec_report(action['report_name'], data, direct_print=action.get('direct_print', False), context=context) elif action['type'] == 'ir.action.url': if action['url']: webbrowser.open(action['url'], new=2)
def _exec_action(action, data=None, context=None): if context is None: context = {} if data is None: data = {} else: data = data.copy() if 'type' not in (action or {}): return if action['type'] == 'ir.action.act_window': view_ids = False view_mode = None if action.get('views', []): view_ids = [x[0] for x in action['views']] view_mode = [x[1] for x in action['views']] elif action.get('view_id', False): view_ids = [action['view_id'][0]] action.setdefault('pyson_domain', '[]') ctx = { 'active_id': data.get('id', False), 'active_ids': data.get('ids', []), } ctx.update(rpc.CONTEXT) eval_ctx = ctx.copy() eval_ctx['_user'] = rpc._USER action_ctx = PYSONDecoder(eval_ctx).decode( action.get('pyson_context') or '{}') ctx.update(action_ctx) ctx.update(context) domain_context = ctx.copy() domain_context['context'] = ctx domain_context['_user'] = rpc._USER domain = PYSONDecoder(domain_context).decode( action['pyson_domain']) search_context = ctx.copy() search_context['context'] = ctx search_context['_user'] = rpc._USER search_value = PYSONDecoder(search_context).decode( action['pyson_search_value'] or '[]') name = False if action.get('window_name', True): name = action.get('name', False) res_model = action.get('res_model', data.get('res_model')) res_id = action.get('res_id', data.get('res_id')) Window.create(view_ids, res_model, res_id, domain, action_ctx, view_mode, name=name, limit=action.get('limit'), auto_refresh=action.get('auto_refresh'), search_value=search_value, icon=(action.get('icon.rec_name') or '')) elif action['type'] == 'ir.action.wizard': Window.create_wizard(action['wiz_name'], data, direct_print=action.get('direct_print', False), email_print=action.get('email_print', False), email=action.get('email'), name=action.get('name', False), context=context, icon=(action.get('icon.rec_name') or ''), window=action.get('window', False)) elif action['type'] == 'ir.action.report': Action.exec_report(action['report_name'], data, direct_print=action.get('direct_print', False), email_print=action.get('email_print', False), email=action.get('email'), context=context) elif action['type'] == 'ir.action.url': if action['url']: webbrowser.open(action['url'], new=2)
def _manage_favorites(widget): Window.create(self.menu_screen.model_name + '.favorite', mode=['tree', 'form'], name=_('Manage Favorites'))
def edit(menuitem): with Window(hide_current=True, allow_similar=True): Window.create(field.attrs.get("view_ids"), model, id_(record), mode=["form"])
def _exec_action(action, data=None, context=None): if context is None: context = {} else: context = context.copy() if 'date_format' not in context: context['date_format'] = rpc.CONTEXT.get('locale', {}).get('date', '%x') if data is None: data = {} else: data = data.copy() if 'type' not in (action or {}): return data['action_id'] = action['id'] if action['type'] == 'ir.action.act_window': view_ids = False view_mode = None if action.get('views', []): view_ids = [x[0] for x in action['views']] view_mode = [x[1] for x in action['views']] elif action.get('view_id', False): view_ids = [action['view_id'][0]] action.setdefault('pyson_domain', '[]') ctx = { 'active_model': data.get('model'), 'active_id': data.get('id'), 'active_ids': data.get('ids', []), } ctx.update(rpc.CONTEXT) ctx['_user'] = rpc._USER decoder = PYSONDecoder(ctx) action_ctx = decoder.decode(action.get('pyson_context') or '{}') action_ctx.update(context) action_ctx.update(ctx) action_ctx.update(data.get('extra_context', {})) action_ctx['context'] = ctx decoder = PYSONDecoder(action_ctx) domain = action['pyson_domain'] order = decoder.decode(action['pyson_order']) search_value = decoder.decode(action['pyson_search_value'] or '[]') tab_domain = [(n, (action_ctx, d)) for n, d in action['domains']] name = False if action.get('window_name', True): name = action.get('name', False) res_model = action.get('res_model', data.get('res_model')) res_id = action.get('res_id', data.get('res_id')) Window.create(view_ids, res_model, res_id, domain, action_ctx, order, view_mode, name=name, limit=action.get('limit'), search_value=search_value, icon=(action.get('icon.rec_name') or ''), tab_domain=tab_domain, context_model=action['context_model']) elif action['type'] == 'ir.action.wizard': context = copy.deepcopy(context) context.update(data.get('extra_context', {})) Window.create_wizard(action['wiz_name'], data, direct_print=action.get( 'direct_print', False), email_print=action.get('email_print', False), email=action.get('email'), name=action.get('name', False), context=context, icon=(action.get('icon.rec_name') or ''), window=action.get('window', False)) elif action['type'] == 'ir.action.report': Action.exec_report(action['report_name'], data, direct_print=action.get('direct_print', False), email_print=action.get('email_print', False), email=action.get('email'), context=context) elif action['type'] == 'ir.action.url': if action['url']: webbrowser.open(action['url'], new=2)
def translate_view(datas): model = datas['model'] Window.create(False, 'ir.translation', res_id=False, domain=[('model', '=', model)], mode=['tree', 'form'])
def _exec_action(action, data=None, context=None): if context is None: context = {} else: context = context.copy() if 'date_format' not in context: context['date_format'] = rpc.CONTEXT.get( 'locale', {}).get('date', '%x') if data is None: data = {} else: data = data.copy() if 'type' not in (action or {}): return data['action_id'] = action['id'] if action['type'] == 'ir.action.act_window': view_ids = False view_mode = None if action.get('views', []): view_ids = [x[0] for x in action['views']] view_mode = [x[1] for x in action['views']] elif action.get('view_id', False): view_ids = [action['view_id'][0]] action.setdefault('pyson_domain', '[]') ctx = { 'active_model': data.get('model'), 'active_id': data.get('id'), 'active_ids': data.get('ids', []), } ctx.update(rpc.CONTEXT) ctx['_user'] = rpc._USER decoder = PYSONDecoder(ctx) action_ctx = decoder.decode(action.get('pyson_context') or '{}') action_ctx.update(context) action_ctx.update(ctx) action_ctx.update(data.get('extra_context', {})) action_ctx['context'] = ctx decoder = PYSONDecoder(action_ctx) domain = action['pyson_domain'] order = decoder.decode(action['pyson_order']) search_value = decoder.decode(action['pyson_search_value'] or '[]') tab_domain = [(n, (action_ctx, d)) for n, d in action['domains']] name = False if action.get('window_name', True): name = action.get('name', False) res_model = action.get('res_model', data.get('res_model')) res_id = action.get('res_id', data.get('res_id')) Window.create(view_ids, res_model, res_id, domain, action_ctx, order, view_mode, name=name, limit=action.get('limit'), search_value=search_value, icon=(action.get('icon.rec_name') or ''), tab_domain=tab_domain, context_model=action['context_model']) elif action['type'] == 'ir.action.wizard': context = copy.deepcopy(context) context.update(data.get('extra_context', {})) Window.create_wizard(action['wiz_name'], data, direct_print=action.get('direct_print', False), email_print=action.get('email_print', False), email=action.get('email'), name=action.get('name', False), context=context, icon=(action.get('icon.rec_name') or ''), window=action.get('window', False)) elif action['type'] == 'ir.action.report': Action.exec_report(action['report_name'], data, direct_print=action.get('direct_print', False), email_print=action.get('email_print', False), email=action.get('email'), context=context) elif action['type'] == 'ir.action.url': if action['url']: webbrowser.open(action['url'], new=2)
def _exec_action(action, data=None, context=None): if context is None: context = {} if data is None: data = {} else: data = data.copy() if 'type' not in (action or {}): return def add_name_suffix(name): if not data.get('ids') or not data.get('model'): return name max_records = 5 rec_names = RPCExecute('model', data['model'], 'read', data['ids'][:max_records], ['rec_name']) name_suffix = _(', ').join([x['rec_name'] for x in rec_names]) if len(data['ids']) > max_records: name_suffix += _(u',\u2026') return _('%s (%s)') % (name, name_suffix) data['action_id'] = action['id'] if action['type'] == 'ir.action.act_window': view_ids = [] view_mode = None if action.get('views', []): view_ids = [x[0] for x in action['views']] view_mode = [x[1] for x in action['views']] elif action.get('view_id', False): view_ids = [action['view_id'][0]] action.setdefault('pyson_domain', '[]') ctx = { 'active_model': data.get('model'), 'active_id': data.get('id'), 'active_ids': data.get('ids', []), } ctx.update(rpc.CONTEXT) ctx['_user'] = rpc._USER decoder = PYSONDecoder(ctx) # TODO: comment changes action_ctx = context.copy() action_ctx.update(decoder.decode( action.get('pyson_context') or '{}')) action_ctx.update(ctx) action_ctx.update(data.get('extra_context', {})) action_ctx['context'] = ctx decoder = PYSONDecoder(action_ctx) domain = action['pyson_domain'] order = decoder.decode(action['pyson_order']) search_value = decoder.decode(action['pyson_search_value'] or '[]') tab_domain = [(n, (action_ctx, d), c) for n, d, c in action['domains']] name = action.get('name', '') if action.get('keyword', '') == 'form_relate': name = add_name_suffix(name) res_model = action.get('res_model', data.get('res_model')) res_id = action.get('res_id', data.get('res_id')) limit = action.get('limit') if limit is None: limit = CONFIG['client.limit'] Window.create(res_model, view_ids=view_ids, res_id=res_id, domain=domain, context=action_ctx, order=order, mode=view_mode, name=name, limit=limit, search_value=search_value, icon=(action.get('icon.rec_name') or ''), tab_domain=tab_domain, context_model=action['context_model'], context_domain=action.get('context_domain', None)) elif action['type'] == 'ir.action.wizard': name = action.get('name', '') if action.get('keyword', 'form_action') == 'form_action': name = add_name_suffix(name) context = copy.deepcopy(context) context.update(data.get('extra_context', {})) Window.create_wizard(action['wiz_name'], data, direct_print=action.get('direct_print', False), email_print=action.get('email_print', False), email=action.get('email'), name=name, context=context, icon=(action.get('icon.rec_name') or ''), window=action.get('window', False)) elif action['type'] == 'ir.action.report': Action.exec_report(action['report_name'], data, direct_print=action.get('direct_print', False), email_print=action.get('email_print', False), email=action.get('email'), context=context) elif action['type'] == 'ir.action.url': if action['url']: webbrowser.open(action['url'], new=2)
def edit(menuitem): with Window(hide_current=True, allow_similar=True): Window.create(field.attrs.get('view_ids'), model, id_(record), mode=['form'])