bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def upgrade_graph(graph, cr, module_list, force=None): if force is None: force = [] packages = [] len_graph = len(graph) for module in module_list: mod_path = get_module_path(module) terp_file = get_module_resource(module, '__openerp__.py') if not terp_file or not os.path.isfile(terp_file): terp_file = get_module_resource(module, '__terp__.py') if not mod_path or not terp_file: global not_loaded not_loaded.append(module) logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable' % (module)) continue #raise osv.osv.except_osv('Error!',"Module '%s' was not found" % (module,)) if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'): try: info = eval(tools.file_open(terp_file).read()) except: logger.notifyChannel('init', netsvc.LOG_ERROR, 'module %s: eval file %s' % (module, terp_file)) raise if info.get('installable', True): packages.append((module, info.get('depends', []), info)) dependencies = dict([(p, deps) for p, deps, data in packages]) current, later = set([p for p, dep, data in packages]), set() while packages and current > later: package, deps, data = packages[0] # if all dependencies of 'package' are already in the graph, add 'package' in the graph if reduce(lambda x, y: x and y in graph, deps, True): if not package in current: packages.pop(0) continue later.clear() current.remove(package) graph.addNode(package, deps) node = Node(package, graph) node.data = data for kind in ('init', 'demo', 'update'): if package in tools.config[kind] or 'all' in tools.config[kind] or kind in force: setattr(node, kind, True) else: later.add(package) packages.append((package, deps, data)) packages.pop(0) graph.update_from_db(cr) for package in later: unmet_deps = filter(lambda p: p not in graph, dependencies[package]) logger.notifyChannel('init', netsvc.LOG_ERROR, 'module %s: Unmet dependencies: %s' % (package, ', '.join(unmet_deps))) result = len(graph) - len_graph if result != len(module_list): logger.notifyChannel('init', netsvc.LOG_WARNING, 'Not all modules have loaded.') return result
defelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) upgrade_graph(graph,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) cr,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) module_list,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) force=None):else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) forceelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) iselse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) None:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) forceelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) []else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packageselse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) []else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) len_graphelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) len(graph)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) forelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) moduleelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) module_list:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) mod_pathelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) get_module_path(module)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) terp_fileelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) get_module_resource(module,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) '__openerp__.py')else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) notelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) terp_fileelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) orelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) notelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) os.path.isfile(terp_file):else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) terp_fileelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) get_module_resource(module,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) '__terp__.py')else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) notelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) mod_pathelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) orelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) notelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) terp_file:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) globalelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) not_loadedelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) not_loaded.append(module)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) logger.notifyChannel('init',else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) netsvc.LOG_WARNING,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) 'moduleelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) %s:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) notelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) installable'else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) %else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) (module))else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) continueelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) #raiseelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) osv.osv.except_osv('Error!',"Moduleelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) '%s'else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) waselse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) notelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) found"else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) %else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) (module,))else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) os.path.isfile(terp_file)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) orelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) zipfile.is_zipfile(mod_path+'.zip'):else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) try:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) infoelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) eval(tools.file_open(terp_file).read())else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) except:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) logger.notifyChannel('init',else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) netsvc.LOG_ERROR,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) 'moduleelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) %s:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) evalelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) fileelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) %s'else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) %else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) (module,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) terp_file))else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) raiseelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) info.get('installable',else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) True):else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packages.append((module,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) info.get('depends',else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) []),else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) info))else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dependencieselse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dict([(p,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) deps)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) forelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) p,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) deps,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dataelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packages])else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) current,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) laterelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) set([pelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) forelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) p,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dep,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dataelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packages]),else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) set()else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) whileelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packageselse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) andelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) currentelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) >else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) later:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) package,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) deps,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dataelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packages[0]else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) #else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) allelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dependencieselse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ofelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) 'package'else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) areelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) alreadyelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) theelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) graph,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) addelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) 'package'else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) theelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) graphelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) reduce(lambdaelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) x,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) y:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) xelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) andelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) yelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) graph,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) deps,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) True):else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) notelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packageelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) current:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packages.pop(0)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) continueelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) later.clear()else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) current.remove(package)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) graph.addNode(package,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) deps)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) nodeelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) Node(package,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) graph)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) node.dataelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dataelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) forelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) kindelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ('init',else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) 'demo',else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) 'update'):else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packageelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) tools.config[kind]else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) orelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) 'all'else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) tools.config[kind]else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) orelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) kindelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) force:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) setattr(node,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) kind,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) True)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) later.add(package)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packages.append((package,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) deps,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) data))else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packages.pop(0)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) graph.update_from_db(cr)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) forelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) packageelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) later:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) unmet_depselse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) filter(lambdaelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) p:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) pelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) notelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) inelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) graph,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dependencies[package])else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) logger.notifyChannel('init',else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) netsvc.LOG_ERROR,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) 'moduleelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) %s:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) Unmetelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) dependencies:else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) %s'else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) %else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) (package,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ',else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) '.join(unmet_deps)))else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) resultelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) =else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) len(graph)else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) -else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) len_graphelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) ifelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) resultelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) !=else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) len(module_list):else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) logger.notifyChannel('init',else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) netsvc.LOG_WARNING,else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) 'Notelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) allelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) moduleselse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) haveelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) loaded.')else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) returnelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) resultelse: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module)) else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module))
469,200
def check_module_name(cr, mods, state): for mod in mods: id = modobj.search(cr, 1, ['&', ('state', '=', state), ('name', '=', mod)]) if id: getattr(modobj, states[state])(cr, 1, id) elif mod != 'all': logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: invalid module name!' % (mod))
def check_module_name(cr, mods, state): for mod in mods: id = modobj.search(cr, 1, ['&', ('state', '=', state), ('name', '=', mod)]) if id: getattr(modobj, states[state])(cr, 1, id) elif mod != 'all': logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: invalid module name!' % (mod))
469,201
def init(self, cr): drop_view_if_exists(cr, 'report_intrastat') cr.execute(""" create or replace view report_intrastat as ( select to_char(inv.create_date, 'YYYY') as name, to_char(inv.create_date, 'MM') as month, min(inv_line.id) as id, intrastat.id as intrastat_id, upper(inv_country.code) as code, sum(case when inv_line.price_unit is not null then inv_line.price_unit * inv_line.quantity else 0 end) as value, sum( case when uom.category_id != puom.category_id then pt.weight_net * inv_line.quantity else case when uom.factor_inv_data > 0 then pt.weight_net * inv_line.quantity * uom.factor_inv_data else pt.weight_net * inv_line.quantity / uom.factor end end ) as weight, sum( case when uom.category_id != puom.category_id then inv_line.quantity else case when uom.factor_inv_data > 0 then inv_line.quantity * uom.factor_inv_data else inv_line.quantity / uom.factor end end ) as supply_units,
def init(self, cr): drop_view_if_exists(cr, 'report_intrastat') cr.execute(""" create or replace view report_intrastat as ( select to_char(inv.create_date, 'YYYY') as name, to_char(inv.create_date, 'MM') as month, min(inv_line.id) as id, intrastat.id as intrastat_id, upper(inv_country.code) as code, sum(case when inv_line.price_unit is not null then inv_line.price_unit * inv_line.quantity else 0 end) as value, sum( case when uom.category_id != puom.category_id then (pt.weight_net * inv_line.quantity) else (pt.weight_net * inv_line.quantity * uom.factor) end ) as weight, sum( case when uom.category_id != puom.category_id then inv_line.quantity else case when uom.factor_inv_data > 0 then inv_line.quantity * uom.factor_inv_data else inv_line.quantity / uom.factor end end ) as supply_units,
469,202
def init(self, cr): drop_view_if_exists(cr, 'report_intrastat') cr.execute(""" create or replace view report_intrastat as ( select to_char(inv.create_date, 'YYYY') as name, to_char(inv.create_date, 'MM') as month, min(inv_line.id) as id, intrastat.id as intrastat_id, upper(inv_country.code) as code, sum(case when inv_line.price_unit is not null then inv_line.price_unit * inv_line.quantity else 0 end) as value, sum( case when uom.category_id != puom.category_id then pt.weight_net * inv_line.quantity else case when uom.factor_inv_data > 0 then pt.weight_net * inv_line.quantity * uom.factor_inv_data else pt.weight_net * inv_line.quantity / uom.factor end end ) as weight, sum( case when uom.category_id != puom.category_id then inv_line.quantity else case when uom.factor_inv_data > 0 then inv_line.quantity * uom.factor_inv_data else inv_line.quantity / uom.factor end end ) as supply_units,
def init(self, cr): drop_view_if_exists(cr, 'report_intrastat') cr.execute(""" create or replace view report_intrastat as ( select to_char(inv.create_date, 'YYYY') as name, to_char(inv.create_date, 'MM') as month, min(inv_line.id) as id, intrastat.id as intrastat_id, upper(inv_country.code) as code, sum(case when inv_line.price_unit is not null then inv_line.price_unit * inv_line.quantity else 0 end) as value, sum( case when uom.category_id != puom.category_id then pt.weight_net * inv_line.quantity else case when uom.factor_inv_data > 0 then pt.weight_net * inv_line.quantity * uom.factor_inv_data else pt.weight_net * inv_line.quantity / uom.factor end end ) as weight, sum( case when uom.category_id != puom.category_id then inv_line.quantity else (inv_line.quantity * uom.factor) end ) as supply_units,
469,203
def action_ship_create(self, cr, uid, ids, *args): wf_service = netsvc.LocalService("workflow") picking_id = False move_obj = self.pool.get('stock.move') proc_obj = self.pool.get('procurement.order') company = self.pool.get('res.users').browse(cr, uid, uid).company_id for order in self.browse(cr, uid, ids, context={}): proc_ids = [] output_id = order.shop_id.warehouse_id.lot_output_id.id picking_id = False for line in order.order_line: proc_id = False date_planned = datetime.now() + relativedelta(days=line.delay or 0.0) date_planned = (date_planned - timedelta(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
def action_ship_create(self, cr, uid, ids, *args): wf_service = netsvc.LocalService("workflow") picking_id = False move_obj = self.pool.get('stock.move') proc_obj = self.pool.get('procurement.order') company = self.pool.get('res.users').browse(cr, uid, uid).company_id for order in self.browse(cr, uid, ids, context={}): proc_ids = [] output_id = order.shop_id.warehouse_id.lot_output_id.id picking_id = False for line in order.order_line: proc_id = False date_planned = datetime.now() + relativedelta(days=line.delay or 0.0) date_planned = (date_planned - timedelta(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
469,204
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } inv_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: if not repair.partner_id.property_account_receivable: raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name ) account_id = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': account_id, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } inv_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: if not repair.partner_id.property_account_receivable: raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name ) account_id = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': account_id, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
469,205
def FindCustomFonts(): """Fill the __foundFonts list with those filenames, whose fonts can be found in the reportlab ttf font path. This process needs only be done once per loading of this module, it is cached. But, if the system admin adds some font in the meanwhile, the server must be restarted eventually. """ dirpath = [] log = logging.getLogger('report.fonts') global __foundFonts for dirname in rl_config.TTFSearchPath: abp = os.path.abspath(dirname) if os.path.isdir(abp): dirpath.append(abp) for k, (name, font, fname, mode) in enumerate(CustomTTFonts): if fname in __foundFonts: continue for d in dirpath: if os.path.exists(os.path.join(d, fname)): log.debug("Found font %s in %s as %s", fname, d, name) __foundFonts.append(fname) break # print "Found fonts:", __foundFonts
def FindCustomFonts(): """Fill the __foundFonts list with those filenames, whose fonts can be found in the reportlab ttf font path. This process needs only be done once per loading of this module, it is cached. But, if the system admin adds some font in the meanwhile, the server must be restarted eventually. """ dirpath = [] log = logging.getLogger('report.fonts') global __foundFonts searchpath = [] if config.get_misc('ttfonts', 'search_path', False): searchpath += map(str.strip, config.get_misc('ttfonts', 'search_path').split(',')) if os.name == 'nt': pass elif os.uname()[0] == 'Linux': searchpath += TTFSearchPath_Linux else: pass if config.get_misc('ttfonts', 'use_default_path', True): searchpath += rl_config.TTFSearchPath for dirglob in searchpath: dirglob = os.path.expanduser(dirglob) for dirname in glob.iglob(dirglob): abp = os.path.abspath(dirname) if os.path.isdir(abp): dirpath.append(abp) for k, (name, font, fname, mode) in enumerate(CustomTTFonts): if fname in __foundFonts: continue for d in dirpath: if os.path.exists(os.path.join(d, fname)): log.debug("Found font %s in %s as %s", fname, d, name) __foundFonts.append(fname) break # print "Found fonts:", __foundFonts
469,206
def FindCustomFonts(): """Fill the __foundFonts list with those filenames, whose fonts can be found in the reportlab ttf font path. This process needs only be done once per loading of this module, it is cached. But, if the system admin adds some font in the meanwhile, the server must be restarted eventually. """ dirpath = [] log = logging.getLogger('report.fonts') global __foundFonts for dirname in rl_config.TTFSearchPath: abp = os.path.abspath(dirname) if os.path.isdir(abp): dirpath.append(abp) for k, (name, font, fname, mode) in enumerate(CustomTTFonts): if fname in __foundFonts: continue for d in dirpath: if os.path.exists(os.path.join(d, fname)): log.debug("Found font %s in %s as %s", fname, d, name) __foundFonts.append(fname) break # print "Found fonts:", __foundFonts
def FindCustomFonts(): """Fill the __foundFonts list with those filenames, whose fonts can be found in the reportlab ttf font path. This process needs only be done once per loading of this module, it is cached. But, if the system admin adds some font in the meanwhile, the server must be restarted eventually. """ dirpath = [] log = logging.getLogger('report.fonts') global __foundFonts for dirname in rl_config.TTFSearchPath: abp = os.path.abspath(dirname) if os.path.isdir(abp): dirpath.append(abp) for k, (name, font, fname, mode) in enumerate(CustomTTFonts): if fname in __foundFonts: continue for d in dirpath: if os.path.exists(os.path.join(d, fname)): log.debug("Found font %s in %s as %s", fname, d, name) __foundFonts.append(fname) break # print "Found fonts:", __foundFonts
469,207
def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ 'WHERE id IN %s', (tuple(ids),)) inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: tmp_context = { 'fiscalyear_id': inv.period_id.fiscalyear_id.id } if inv.journal_id.invoice_sequence_id: sid = inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': inv.period_id.fiscalyear_id.id}) else: number = obj_seq.get_id(cr, uid, 'account.invoice.%s' % invtype, 'code=%s', context=tmp_context) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True
def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ 'WHERE id IN %s', (tuple(ids),)) inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: tmp_context = { 'fiscalyear_id': inv.period_id.fiscalyear_id.id } if inv.journal_id.invoice_sequence_id: sequence_id = inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sequence_id, 'id', context=tmp_context) else: number = obj_seq.get_id(cr, uid, 'account.invoice.%s' % invtype, 'code=%s', context=tmp_context) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True
469,208
def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ 'WHERE id IN %s', (tuple(ids),)) inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: tmp_context = { 'fiscalyear_id': inv.period_id.fiscalyear_id.id } if inv.journal_id.invoice_sequence_id: sid = inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': inv.period_id.fiscalyear_id.id}) else: number = obj_seq.get_id(cr, uid, 'account.invoice.%s' % invtype, 'code=%s', context=tmp_context) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True
def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ 'WHERE id IN %s', (tuple(ids),)) inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: tmp_context = { 'fiscalyear_id': inv.period_id.fiscalyear_id.id } if inv.journal_id.invoice_sequence_id: sid = inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': inv.period_id.fiscalyear_id.id}) else: number = self.pool.get('ir.sequence').get_id(cr, uid, 'account.invoice.%s' % invtype, 'code', context=tmp_context) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True
469,209
def _get_group(self,cr, uid, context=None): dataobj = self.pool.get('ir.model.data') data_id = dataobj._get_id(cr, 1, 'base', 'group_user') return data_id and [data_id] or False
def _get_group(self,cr, uid, context=None): dataobj = self.pool.get('ir.model.data') data_id = dataobj._get_id(cr, 1, 'base', 'group_user') return data_id and [data_id] or False
469,210
def _create_returns2(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) order_obj = pool.get('pos.order') line_obj = pool.get('pos.order.line') picking_obj = pool.get('stock.picking') stock_move_obj = pool.get('stock.move') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', data['ids']), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = pool.get('product.uom') wf_service = netsvc.LocalService("workflow") for order_id in order_obj.browse(cr, uid, data['ids'], context=context): prop_ids = pool.get("ir.property").search(cr, uid,[('name', '=', 'property_stock_customer')]) val = pool.get("ir.property").browse(cr, uid,prop_ids[0]).value cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = int(val.split(',')[1]) new_picking=picking_obj.copy(cr, uid, order_id.last_out_picking.id, {'name':'%s (return)' % order_id.name, 'move_lines':[], 'state':'draft', 'type':'in', 'type':'in', 'date':date_cur, }) new_order=order_obj.copy(cr,uid,order_id.id, {'name': 'Refund %s'%order_id.name, 'lines':[], 'statement_ids':[], 'last_out_picking':[]}) for line in order_id.lines: for r in data['form'].get('returns',[]): if line.id==r and (data['form']['return%s' %r]!=0.0): new_move=stock_move_obj.create(cr, uid,{ 'product_qty': data['form']['return%s' %r], 'product_uos_qty': uom_obj._compute_qty(cr, uid,data['form']['return%s' %r] ,line.product_id.uom_id.id), 'picking_id':new_picking, 'product_uom':line.product_id.uom_id.id, 'location_id':location_id, 'product_id':line.product_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) line_obj.copy(cr,uid,line.id,{'qty':-data['form']['return%s' %r], 'order_id': new_order, }) order_obj.write(cr,uid, new_order, {'state':'done'}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) act = { 'domain': "[('id', 'in', ["+str(new_order)+"])]", 'name': 'Refunded Orders', 'view_type': 'form', 'view_mode': 'form,tree', 'res_model': 'pos.order', 'auto_refresh':0, 'res_id':new_order, 'view_id': False, 'type': 'ir.actions.act_window' } return act
def _create_returns2(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) order_obj = pool.get('pos.order') line_obj = pool.get('pos.order.line') picking_obj = pool.get('stock.picking') stock_move_obj = pool.get('stock.move') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', data['ids']), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = pool.get('product.uom') wf_service = netsvc.LocalService("workflow") for order_id in order_obj.browse(cr, uid, data['ids'], context=context): prop_ids = pool.get("ir.property").search(cr, uid,[('name', '=', 'property_stock_customer')]) val = pool.get("ir.property").browse(cr, uid,prop_ids[0]).value cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = int(val.split(',')[1]) if order_id.last_out_picking.id: new_picking=picking_obj.copy(cr, uid, order_id.last_out_picking.id, {'name':'%s (return)' % order_id.name, 'move_lines':[], 'state':'draft', 'type':'in', 'type':'in', 'date':date_cur, }) new_order=order_obj.copy(cr,uid,order_id.id, {'name': 'Refund %s'%order_id.name, 'lines':[], 'statement_ids':[], 'last_out_picking':[]}) for line in order_id.lines: for r in data['form'].get('returns',[]): if line.id==r and (data['form']['return%s' %r]!=0.0): new_move=stock_move_obj.create(cr, uid,{ 'product_qty': data['form']['return%s' %r], 'product_uos_qty': uom_obj._compute_qty(cr, uid,data['form']['return%s' %r] ,line.product_id.uom_id.id), 'picking_id':new_picking, 'product_uom':line.product_id.uom_id.id, 'location_id':location_id, 'product_id':line.product_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) line_obj.copy(cr,uid,line.id,{'qty':-data['form']['return%s' %r], 'order_id': new_order, }) order_obj.write(cr,uid, new_order, {'state':'done'}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) act = { 'domain': "[('id', 'in', ["+str(new_order)+"])]", 'name': 'Refunded Orders', 'view_type': 'form', 'view_mode': 'form,tree', 'res_model': 'pos.order', 'auto_refresh':0, 'res_id':new_order, 'view_id': False, 'type': 'ir.actions.act_window' } else: raise wizard.except_wizard(_('Error'), _('Last out picking No find!')) return act
469,211
def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} default = default.copy() default.update({'line_ids': []}) return super(account_tax_code, self).copy(cr, uid, id, default, context)
def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} default = default.copy() default.update({'line_ids': []}) return super(account_tax_code, self).copy(cr, uid, id, default, context)
469,212
def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): """ RETURN: { 'total': 0.0, # Total without taxes 'total_included: 0.0, # Total with taxes 'taxes': [] # List of taxes, see compute for the format } """ precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') totalin = totalex = round(price_unit * quantity, precision) totalex = totalex = round(price_unit * quantity, precision) tin = [] tex = [] for tax in taxes: if tax.price_include: tin.append(tax) else: tex.append(tax) tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner) tex = self._compute(cr, uid, tex, price_unit, quantity, address_id=address_id, product=product, partner=partner) for r in tin: totalex -= r['amount'] for r in tex: totalin += r['amount'] return { 'total': totalex, 'total_included': totalin, 'taxes': tin + tex }
def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): """ RETURN: { 'total': 0.0, # Total without taxes 'total_included: 0.0, # Total with taxes 'taxes': [] # List of taxes, see compute for the format } """ precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') totalex = totalex = round(price_unit * quantity, precision) tin = [] tex = [] for tax in taxes: if tax.price_include: tin.append(tax) else: tex.append(tax) tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner) tex = self._compute(cr, uid, tex, price_unit, quantity, address_id=address_id, product=product, partner=partner) for r in tin: totalex -= r['amount'] for r in tex: totalin += r['amount'] return { 'total': totalex, 'total_included': totalin, 'taxes': tin + tex }
469,213
def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): """ RETURN: { 'total': 0.0, # Total without taxes 'total_included: 0.0, # Total with taxes 'taxes': [] # List of taxes, see compute for the format } """ precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') totalin = totalex = round(price_unit * quantity, precision) totalex = totalex = round(price_unit * quantity, precision) tin = [] tex = [] for tax in taxes: if tax.price_include: tin.append(tax) else: tex.append(tax) tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner) tex = self._compute(cr, uid, tex, price_unit, quantity, address_id=address_id, product=product, partner=partner) for r in tin: totalex -= r['amount'] for r in tex: totalin += r['amount'] return { 'total': totalex, 'total_included': totalin, 'taxes': tin + tex }
def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): """ RETURN: { 'total': 0.0, # Total without taxes 'total_included: 0.0, # Total with taxes 'taxes': [] # List of taxes, see compute for the format } """ precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') totalin = totalex = round(price_unit * quantity, precision) totalex = totalex = round(price_unit * quantity, precision) tin = [] tex = [] for tax in taxes: if tax.price_include: tin.append(tax) else: tex.append(tax) tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner) for r in tin: totalex -= r['amount'] for r in tex: totalin += r['amount'] return { 'total': totalex, 'total_included': totalin, 'taxes': tin + tex }
469,214
def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): print "Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included" return self._compute(cr, uid, taxes, price_unit, quantity, address_id, product, partner)
def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): logger = netsvc.Logger() logger.notifyChannel("warning", netsvc.LOG_WARNING, "Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included") return self._compute(cr, uid, taxes, price_unit, quantity, address_id, product, partner)
469,215
def init(self, cr, uid=1): """ This view will be used in dashboard The reason writing this code here is, we need to check date range from today to first date of fiscal year. """ pool_obj_fy = pooler.get_pool(cr.dbname).get('account.fiscalyear') today = time.strftime('%Y-%m-%d') fy_id = pool_obj_fy.find(cr, uid, exception=False) LIST_RANGES = [] if fy_id: fy_start_date = pool_obj_fy.read(cr, uid, fy_id, ['date_start'])['date_start'] fy_start_date = datetime.strptime(fy_start_date, '%Y-%m-%d') last_month_date = datetime.strptime(today, '%Y-%m-%d') - relativedelta(months=1)
def init(self, cr, uid=1): """ This view will be used in dashboard The reason writing this code here is, we need to check date range from today to first date of fiscal year. """ pool_obj_fy = pooler.get_pool(cr.dbname).get('account.fiscalyear') today = time.strftime('%Y-%m-%d') fy_id = pool_obj_fy.find(cr, uid, exception=False) LIST_RANGES = [] if fy_id: fy_start_date = pool_obj_fy.read(cr, uid, fy_id, ['date_start'])['date_start'] fy_start_date = datetime.strptime(fy_start_date, '%Y-%m-%d') last_month_date = datetime.strptime(today, '%Y-%m-%d') - relativedelta(months=1)
469,216
def edit(self, template, template_text): output = super(SidebarTemplateEditor, self).edit(template, template_text)
def edit(self, template, template_text): output = super(SidebarTemplateEditor, self).edit(template, template_text)
469,217
def sign_out(self, cr, uid, ids, context=None): emp_obj = self.pool.get('hr.employee') if context is None: context = {} if not self.browse(cr, uid, ids, context=context)[0].date_current == time.strftime('%Y-%m-%d'): raise osv.except_osv(_('Error !'), _('You can not sign out from an other date than today')) emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)]) context['sheet_id']=ids[0] emp_obj.attendance_action_change(cr, uid, emp_ids, type='sign_out', context=context,) return True
def sign_out(self, cr, uid, ids, context=None): emp_obj = self.pool.get('hr.employee') if context is None: context = {} if not self.browse(cr, uid, ids, context=context)[0].date_current == time.strftime('%Y-%m-%d'): raise osv.except_osv(_('Error !'), _('You can not sign out from an other date than today')) emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)]) context['sheet_id']=ids[0] emp_obj.attendance_action_change(cr, uid, emp_ids, type='sign_out', context=context,) return True
469,218
def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] cur_obj = self.pool.get('res.currency')
def_get_analytic_lines(self,cr,uid,id):inv=self.browse(cr,uid,[id])[0]cur_obj=self.pool.get('res.currency')
469,219
def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] cur_obj = self.pool.get('res.currency')
def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] cur_obj = self.pool.get('res.currency')
469,220
def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] cur_obj = self.pool.get('res.currency')
def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] cur_obj = self.pool.get('res.currency')
469,221
def invoice_line_create(self, cr, uid, ids, context=None): create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context) if ids: sale_line = self.browse(cr, uid, ids[0], context) inv_line_obj = self.pool.get('account.invoice.line') acct_anal_def_obj = self.pool.get('account.analytic.default')
def invoice_line_create(self, cr, uid, ids, context=None): create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context) if ids: sale_line = self.browse(cr, uid, ids[0], context) inv_line_obj = self.pool.get('account.invoice.line') acct_anal_def_obj = self.pool.get('account.analytic.default')
469,222
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Changes the view dynamically @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return: New arch of view. """ record_id = context and context.get('active_id', False) or False res = super(repair_cancel, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) if record_id: repair_order = self.pool.get('mrp.repair').browse(cr, uid, record_id) if not repair_order.invoiced: res['arch'] = """ <form string="Cancel Repair" colspan="4"> <group col="2" colspan="2"> <label string="Do you want to continue?" colspan="4"/> <separator colspan="4"/> <button icon="gtk-cancel" special="cancel" string="No" readonly="0"/> <button name="cancel_repair" string="Yes" type="object" icon="gtk-ok"/> </group> </form> """ return res
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Changes the view dynamically @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return: New arch of view. """ record_id = context and context.get('active_id', False) or False res = super(repair_cancel, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) if record_id: try: repair_order = self.pool.get('mrp.repair').browse(cr, uid, record_id) if not repair_order.invoiced: res['arch'] = """ <form string="Cancel Repair" colspan="4"> <group col="2" colspan="2"> <label string="Do you want to continue?" colspan="4"/> <separator colspan="4"/> <button icon="gtk-cancel" special="cancel" string="No" readonly="0"/> <button name="cancel_repair" string="Yes" type="object" icon="gtk-ok"/> </group> </form> """ except: return res return res
469,223
def action_move_create(self, cr, uid, ids, *args): """Creates invoice related analytics and financial move lines""" ait_obj = self.pool.get('account.invoice.tax') cur_obj = self.pool.get('res.currency') context = {} for inv in self.browse(cr, uid, ids): if not inv.journal_id.sequence_id: raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal')) if not inv.invoice_line: raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.')) if inv.move_id: continue
def action_move_create(self, cr, uid, ids, *args): """Creates invoice related analytics and financial move lines""" ait_obj = self.pool.get('account.invoice.tax') cur_obj = self.pool.get('res.currency') context = {} for inv in self.browse(cr, uid, ids): if not inv.journal_id.sequence_id: raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal')) if not inv.invoice_line: raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.')) if inv.move_id: continue
469,224
def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency=False if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount':amount}}
def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency = False tax_amount = self.read(cr, uid, ids[0], ['tax_amount'])['tax_amount'] tax_sign=1 if tax_amount < 0: tax_sign = -1 elif tax_amount == 0: tax_sign = 0 if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount':amount}}
469,225
def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency=False if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount':amount}}
def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency=False if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount':amount}}
469,226
def _get_account_line(self, cr, uid, ids, context={}): aac_ids = {} for acc in self.pool.get('account.analytic.account').browse(cr, uid, ids): aac_ids[acc.id] = True aal_ids = [] if aac_ids: aal_ids = self.pool.get('account.analytic.line').search(cr, uid, [('account_id','in',aac_ids.keys())], context=context) return aal_ids
def _get_account_line(self, cr, uid, ids, context={}): aac_ids = {} for acc in self.pool.get('account.analytic.account').browse(cr, uid, ids): aac_ids[acc.id] = True aal_ids = [] if aac_ids: aal_ids = self.pool.get('account.analytic.line').search(cr, uid, [('account_id','in',aac_ids.keys())], context=context) return aal_ids
469,227
def _get_case_history(self, cr, uid, history_type, res_id, context=None): if not res_id: return
def _get_case_history(self, cr, uid, history_type, res_id, context=None): if not res_id: return
469,228
def __eq__(self, other): if not self.context == other.context: return False if type(self) != type(other): return False # Two directory nodes, for the same document.directory, may have a # different context! (dynamic folders) if self.dctx != other.dctx: return False return self.dir_id == other.dir_id
def __eq__(self, other): if not self.context == other.context: return False # Two directory nodes, for the same document.directory, may have a # different context! (dynamic folders) if self.dctx != other.dctx: return False return self.dir_id == other.dir_id
469,229
def __eq__(self, other): if not self.context == other.context: return False if type(self) != type(other): return False # Two nodes, for the same document.directory, may have a # different context! (dynamic folders) if self.dctx != other.dctx: return False return self.dir_id == other.dir_id
def __eq__(self, other): if not self.context == other.context: return False # Two nodes, for the same document.directory, may have a # different context! (dynamic folders) if self.dctx != other.dctx: return False return self.dir_id == other.dir_id
469,230
def __eq__(self, other): if not self.context == other.context: return False if type(self) != type(other): return False if not self.res_model == other.res_model: return False if not self.res_id == other.res_id: return False if self.domain != other.domain: return False if self.dctx != other.dctx: return False return self.dir_id == other.dir_id
def __eq__(self, other): if not self.context == other.context: return False if not self.res_model == other.res_model: return False if not self.res_id == other.res_id: return False if self.domain != other.domain: return False if self.dctx != other.dctx: return False return self.dir_id == other.dir_id
469,231
def __eq__(self, other): if not self.context == other.context: return False if type(self) != type(other): return False if self.dctx != other.dctx: return False return self.file_id == other.file_id
def __eq__(self, other): if not self.context == other.context: return False if self.dctx != other.dctx: return False return self.file_id == other.file_id
469,232
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''): if context is None: context = {} #TODO check if we can use different period for payment and the writeoff line assert len(ids)==1, "Can only pay one invoice at a time" invoice = self.browse(cr, uid, ids[0]) src_account_id = invoice.account_id.id # Take the seq as name for move types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} direction = types[invoice.type] #take the choosen date if 'date_p' in context and context['date_p']: date=context['date_p'] else: date=time.strftime('%Y-%m-%d')
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''): if context is None: context = {} #TODO check if we can use different period for payment and the writeoff line assert len(ids)==1, "Can only pay one invoice at a time" invoice = self.browse(cr, uid, ids[0]) src_account_id = invoice.account_id.id # Take the seq as name for move types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} direction = types[invoice.type] #take the choosen date if 'date_p' in context and context['date_p']: date=context['date_p'] else: date=time.strftime('%Y-%m-%d')
469,233
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''): if context is None: context = {} #TODO check if we can use different period for payment and the writeoff line assert len(ids)==1, "Can only pay one invoice at a time" invoice = self.browse(cr, uid, ids[0]) src_account_id = invoice.account_id.id # Take the seq as name for move types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} direction = types[invoice.type] #take the choosen date if 'date_p' in context and context['date_p']: date=context['date_p'] else: date=time.strftime('%Y-%m-%d')
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''): if context is None: context = {} #TODO check if we can use different period for payment and the writeoff line assert len(ids)==1, "Can only pay one invoice at a time" invoice = self.browse(cr, uid, ids[0]) src_account_id = invoice.account_id.id # Take the seq as name for move types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} direction = types[invoice.type] #take the choosen date if 'date_p' in context and context['date_p']: date=context['date_p'] else: date=time.strftime('%Y-%m-%d')
469,234
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
469,235
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
469,236
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
469,237
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
469,238
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
def subscribe(self, cr, uid, ids, *args): """ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') obj_model = self.pool.get('ir.model.data') #start Loop for thisrule in self.browse(cr, uid, ids): obj = self.pool.get(thisrule.object_id.model) if not obj: raise osv.except_osv( _('WARNING: audittrail is not part of the pool'), _('Change audittrail depends -- Setting rule as DRAFT')) self.write(cr, uid, [thisrule.id], {"state": "draft"}) val = { "name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model, "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
469,239
def unsubscribe(self, cr, uid, ids, *args): """ Unsubscribe Auditing Rule on object @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') val_obj = self.pool.get('ir.values') #start Loop for thisrule in self.browse(cr, uid, ids): if thisrule.id in self.__functions: for function in self.__functions[thisrule.id]: setattr(function[0], function[1], function[2]) w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)]) obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0]) val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)]) if val_id: res = ir.ir_del(cr, uid, val_id[0]) self.write(cr, uid, [thisrule.id], {"state": "draft"}) #End Loop return True
def unsubscribe(self, cr, uid, ids, *args): """ Unsubscribe Auditing Rule on object @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') val_obj = self.pool.get('ir.values') #start Loop for thisrule in self.browse(cr, uid, ids): if thisrule.id in self.__functions: for function in self.__functions[thisrule.id]: setattr(function[0], function[1], function[2]) w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)]) obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0]) val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)]) if val_id: res = ir.ir_del(cr, uid, val_id[0]) self.write(cr, uid, [thisrule.id], {"state": "draft"}) #End Loop return True
469,240
def unsubscribe(self, cr, uid, ids, *args): """ Unsubscribe Auditing Rule on object @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') val_obj = self.pool.get('ir.values') #start Loop for thisrule in self.browse(cr, uid, ids): if thisrule.id in self.__functions: for function in self.__functions[thisrule.id]: setattr(function[0], function[1], function[2]) w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)]) obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0]) val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)]) if val_id: res = ir.ir_del(cr, uid, val_id[0]) self.write(cr, uid, [thisrule.id], {"state": "draft"}) #End Loop return True
def unsubscribe(self, cr, uid, ids, *args): """ Unsubscribe Auditing Rule on object @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') val_obj = self.pool.get('ir.values') #start Loop for thisrule in self.browse(cr, uid, ids): if thisrule.id in self.__functions: for function in self.__functions[thisrule.id]: setattr(function[0], function[1], function[2]) w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)]) obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0]) val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)]) if val_id: res = ir.ir_del(cr, uid, val_id[0]) self.write(cr, uid, [thisrule.id], {"state": "draft"}) #End Loop return True
469,241
def unsubscribe(self, cr, uid, ids, *args): """ Unsubscribe Auditing Rule on object @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') val_obj = self.pool.get('ir.values') #start Loop for thisrule in self.browse(cr, uid, ids): if thisrule.id in self.__functions: for function in self.__functions[thisrule.id]: setattr(function[0], function[1], function[2]) w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)]) obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0]) val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)]) if val_id: res = ir.ir_del(cr, uid, val_id[0]) self.write(cr, uid, [thisrule.id], {"state": "draft"}) #End Loop return True
def unsubscribe(self, cr, uid, ids, *args): """ Unsubscribe Auditing Rule on object @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') val_obj = self.pool.get('ir.values') #start Loop for thisrule in self.browse(cr, uid, ids): if thisrule.id in self.__functions: for function in self.__functions[thisrule.id]: setattr(function[0], function[1], function[2]) w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)]) obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0]) val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)]) if val_id: res = ir.ir_del(cr, uid, val_id[0]) self.write(cr, uid, [thisrule.id], {"state": "draft"}) #End Loop return True
469,242
def unsubscribe(self, cr, uid, ids, *args): """ Unsubscribe Auditing Rule on object @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') val_obj = self.pool.get('ir.values') #start Loop for thisrule in self.browse(cr, uid, ids): if thisrule.id in self.__functions: for function in self.__functions[thisrule.id]: setattr(function[0], function[1], function[2]) w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)]) obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0]) val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)]) if val_id: res = ir.ir_del(cr, uid, val_id[0]) self.write(cr, uid, [thisrule.id], {"state": "draft"}) #End Loop return True
def unsubscribe(self, cr, uid, ids, *args): """ Unsubscribe Auditing Rule on object @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') val_obj = self.pool.get('ir.values') #start Loop for thisrule in self.browse(cr, uid, ids): if thisrule.id in self.__functions: for function in self.__functions[thisrule.id]: setattr(function[0], function[1], function[2]) w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)]) obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0]) val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)]) if val_id: res = ir.ir_del(cr, uid, val_id[0]) self.write(cr, uid, [thisrule.id], {"state": "draft"}) #End Loop return True
469,243
def get_value_text(self, cr, uid, field_name, values, object, context=None): """ Gets textual values for the fields e.g.: For field of type many2one it gives its name value instead of id
def get_value_text(self, cr, uid, field_name, values, object, context=None): """ Gets textual values for the fields e.g.: For field of type many2one it gives its name value instead of id
469,244
def get_value_text(self, cr, uid, field_name, values, object, context=None): """ Gets textual values for the fields e.g.: For field of type many2one it gives its name value instead of id
def get_value_text(self, cr, uid, field_name, values, object, context=None): """ Gets textual values for the fields e.g.: For field of type many2one it gives its name value instead of id
469,245
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
469,246
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
defcreate_log_line(self,cr,uid,id,object,lines=[]):"""Createslinesforchangedfieldswithitsoldandnewvalues
469,247
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
469,248
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
469,249
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
469,250
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, model, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,251
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,252
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ res2 = args pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,253
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() resource_pool = pool.get(model) log_pool = pool.get('audittrail.log') model_pool = pool.get('ir.model') model_ids = model_pool.search(cr, uid, [('model', '=', model)]) model_id = model_ids and model_ids[0] or False assert model_id, _("'%s' Model is not exits..." %(model)) model = model_pool.browse(cr, uid, model_id) if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,254
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, model.model, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,255
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() resource = resource_pool.read(cr, uid, res_id, args[0].keys()) vals = { "method": method, "object_id": model.id, "user_id": uid, "res_id": resource['id'], } if 'id' in resource: del resource['id'] log_id = log_pool.create(cr, uid, vals) lines = [] for field in resource: line = { 'name': field, 'new_value': resource[field], 'new_value_text': self.get_value_text(cr, uid, field, resource[field], model) } lines.append(line) self.create_log_line(cr, uid, log_id, model, lines) cr.commit() cr.close() return res_id
469,256
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,257
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,258
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
deflog_fct(self,db,uid,object,method,fct_src,*args):"""Loggingfunction:Thisfunctionisperformsloggingoprationsaccordingtomethod@paramdb:thecurrentdatabase@paramuid:thecurrentuser’sIDforsecuritychecks,@paramobject:Objectwho'svaluesarebeingchanged@parammethod:methodtolog:create,read,write,unlink@paramfct_src:executemethodofObjectproxy@return:ReturnsresultaspermethodofObjectproxy"""logged_uids=[]pool=pooler.get_pool(db)cr=pooler.get_db(db).cursor()obj_ids=pool.get('ir.model').search(cr,uid,[('model','=',object)])model_object=pool.get('ir.model').browse(cr,uid,obj_ids)[0]ifmethodin('create'):res_id=fct_src(db,uid,object,method,*args)cr.commit()new_value=pool.get(model_object.model).read(cr,uid,[res_id],args[0].keys())[0]if'id'innew_value:delnew_value['id']ifnotlogged_uidsoruidinlogged_uids:resource_name=pool.get(model_object.model).name_get(cr,uid,[res_id])resource_name=resource_nameandresource_name[0][1]or''vals={"method":method,"object_id":model_object.id,"user_id":uid,"res_id":res_id,"name":resource_name}id=pool.get('audittrail.log').create(cr,uid,vals)lines=[]forfieldinnew_value:ifnew_value[field]:line={'name':field,'new_value':new_value[field],'new_value_text':self.get_value_text(cr,uid,field,new_value[field],model_object)}lines.append(line)self.create_log_line(cr,uid,id,model_object,lines)cr.commit()cr.close()returnres_id
469,259
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,260
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,261
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,262
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,263
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,264
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
469,265
def execute(self, db, uid, object, method, *args, **kw): """ Overrides Object Proxy execute method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @return: Returns result as per method of Object proxy """ pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] fct_src = super(audittrail_objects_proxy, self).execute
def execute(self, db, uid, object, method, *args, **kw): """ Overrides Object Proxy execute method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: get any method and create log @return: Returns result as per method of Object proxy """ pool = pooler.get_pool(db) model_pool = pool.get('ir.model') rule_pool = pool.get('audittrail.rule') cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] fct_src = super(audittrail_objects_proxy, self).execute def my_fct(db, uid, model, method, *args): rule = False model_ids = model_pool.search(cr, uid, [('model', '=', model)]) model_id = model_ids and model_ids[0] or False for model_name in pool.obj_list(): if model_name == 'audittrail.rule': rule = True if not rule: return fct_src(db, uid, model, method, *args) if not model_id: return fct_src(db, uid, model, method, *args) rule_ids = rule_pool.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'subscribed')]) if not rule_ids: return fct_src(db, uid, model, method, *args) for thisrule in rule_pool.browse(cr, uid, rule_ids): for user in thisrule.user_id: logged_uids.append(user.id) if not logged_uids or uid in logged_uids: if method in ('read', 'write', 'create', 'unlink'): if getattr(thisrule, 'log_' + method): return self.log_fct(db, uid, model, method, fct_src, *args) elif method not in ('default_get','read','fields_view_get','fields_get','search','search_count','name_search','name_get','get','request_get', 'get_sc', 'unlink', 'write', 'create'): if thisrule.log_action: return self.log_fct(db, uid, model, method, fct_src, *args) return fct_src(db, uid, model, method, *args) res = my_fct(db, uid, model, method, *args) cr.close() return res def exec_workflow(self, db, uid, model, method, *args, **argv): pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] fct_src = super(audittrail_objects_proxy, self).execute
469,266
def execute(self, db, uid, object, method, *args, **kw): """ Overrides Object Proxy execute method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @return: Returns result as per method of Object proxy """ pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] fct_src = super(audittrail_objects_proxy, self).execute
def execute(self, db, uid, object, method, *args, **kw): """ Overrides Object Proxy execute method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @return: Returns result as per method of Object proxy """ pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] fct_src = super(audittrail_objects_proxy, self).execute
469,267
def my_fct(db, uid, object, method, *args): field = method rule = False obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) for obj_name in pool.obj_list(): if obj_name == 'audittrail.rule': rule = True if not rule: return fct_src(db, uid, object, method, *args) if not obj_ids: return fct_src(db, uid, object, method, *args) rule_ids = pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')]) if not rule_ids: return fct_src(db, uid, object, method, *args)
def my_fct(db, uid, object, method, *args): field = method rule = False obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) for obj_name in pool.obj_list(): if obj_name == 'audittrail.rule': rule = True if not rule: return fct_src(db, uid, object, method, *args) if not obj_ids: return fct_src(db, uid, object, method, *args) rule_ids = pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')]) if not rule_ids: return fct_src(db, uid, object, method, *args)
469,268
def default_vat_check(cn, vn): # by default, a VAT number is valid if: # it starts with 2 letters # has more than 3 characters return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
defdefault_vat_check(cn,vn):#bydefault,aVATnumberisvalidif:#itstartswith2letters#hasmorethan3charactersreturncn[0]instring.ascii_lowercaseandcn[1]instring.ascii_lowercase
469,269
def check_vat_it(self, vat): ''' Check Italy VAT number. ''' if len(vat) != 11: return False try: int(vat) except: return False if int(vat[0:7]) <= 0: return False if int(vat[7:10]) <= 0: return False if int(vat[7:10]) > 100 and int(vat[7:10]) < 120: return False if int(vat[7:10]) > 121: return False
def check_vat_it(self, vat): ''' Check Italy VAT number. ''' if len(vat) != 11: return False try: int(vat) except: return False if int(vat[0:7]) <= 0: return False if int(vat[7:10]) <= 0: return False if int(vat[7:10]) > 100 and int(vat[7:10]) < 120: return False if int(vat[7:10]) > 121: return False
469,270
def __call__(self, source): try: frame = inspect.stack()[1][0] except: return source
def __call__(self, source): try: frame = inspect.stack()[1][0] except: return source
469,271
def write(self, cr, uid, ids, vals, context=None): """ Writes values in one or several fields. @param ids: List of Event registration type's IDs @param vals: dictionary with values to update. @return: True """ register_pool = self.pool.get('event.registration') res = super(event_event, self).write(cr, uid, ids, vals, context=context) if vals.get('date_begin', False) or vals.get('mail_auto_confirm', False) or vals.get('mail_confirm', False): for event in self.browse(cr, uid, ids, context=context): #change the deadlines of the registration linked to this event register_values = {} if vals.get('date_begin', False): register_values['date_deadline'] = vals['date_begin']
def write(self, cr, uid, ids, vals, context=None): """ Writes values in one or several fields. @param ids: List of Event registration type's IDs @param vals: dictionary with values to update. @return: True """ register_pool = self.pool.get('event.registration') res = super(event_event, self).write(cr, uid, ids, vals, context=context) if vals.get('date_begin', False) or vals.get('mail_auto_confirm', False) or vals.get('mail_confirm', False): for event in self.browse(cr, uid, ids, context=context): #change the deadlines of the registration linked to this event register_values = {} if vals.get('date_begin', False): register_values['date_deadline'] = vals['date_begin']
469,272
def _check_recursion(self, cr, uid, ids): """ Checks for recursion level for event """ level = 100
def _check_recursion(self, cr, uid, ids): """ Checks for recursion level for event """ level = 100
469,273
def change_price(self, cr, uid, ids, context): """ Changes the Standard Price of Product. And creates an account move accordingly. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: """ rec_id = context and context.get('active_id', False) prod_obj = self.pool.get('product.template') location_obj = self.pool.get('stock.location') lot_obj = self.pool.get('stock.report.prodlots') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line') data_obj = self.pool.get('ir.model.data') res = self.read(cr, uid, ids[0], ['new_price']) new_price = res.get('new_price',[]) data = prod_obj.browse(cr, uid, rec_id) diff = data.standard_price - new_price prod_obj.write(cr, uid, rec_id, {'standard_price': new_price}) loc_ids = location_obj.search(cr, uid, [('account_id','<>',False),('usage','=','internal')]) lot_ids = lot_obj.search(cr, uid, [('location_id', 'in', loc_ids),('product_id','=',rec_id)]) qty = 0 debit = 0.0 credit = 0.0 stock_input_acc = data.property_stock_account_input.id or data.categ_id.property_stock_account_input_categ.id stock_output_acc = data.property_stock_account_output.id or data.categ_id.property_stock_account_output_categ.id for lots in lot_obj.browse(cr, uid, lot_ids): qty += lots.name if stock_input_acc and stock_output_acc and lot_ids: move_id = move_obj.create(cr, uid, {'journal_id': data.categ_id.property_stock_journal.id}) if diff > 0: credit = qty * diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_input_acc, 'credit': credit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): credit = lots.name * diff move_line_obj.create(cr, uid, { 'name': 'Expense', 'account_id': lots.location_id.account_id.id, 'debit': credit, 'move_id': move_id }) elif diff < 0: debit = qty * -diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_output_acc, 'debit': debit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): debit = lots.name * -diff move_line_obj.create(cr, uid, { 'name': 'Income', 'account_id': lots.location_id.account_id.id, 'credit': debit, 'move_id': move_id }) else: raise osv.except_osv(_('Warning!'),_('No Change in Price.')) else: raise osv.except_osv(_('Warning!'),_('No Accounts are defined for ' 'this product on its location.\nCan\'t create Move.')) id2 = data_obj._get_id(cr, uid, 'account', 'view_move_tree') id3 = data_obj._get_id(cr, uid, 'account', 'view_move_form') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'account.move', 'res_id' : move_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window', } prod_obj.do_change_standard_price(cr, uid, [rec_id], datas, context) return {}
def change_price(self, cr, uid, ids, context): """ Changes the Standard Price of Product. And creates an account move accordingly. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: """ rec_id = context and context.get('active_id', False) assert rec_id, _('Active ID is not set in Context') prod_obj = self.pool.get('product.product') res = self.browse(cr, uid, ids) datas = { 'new_price' : res[0].new_price, 'stock_output_account' : res[0].stock_account_output.id, 'stock_input_account' : res[0].stock_account_input.id, 'stock_journal' : res[0].stock_journal.id } prod_obj.do_change_standard_price(cr, uid, [rec_id], datas, context) return {}
469,274
def change_price(self, cr, uid, ids, context): """ Changes the Standard Price of Product. And creates an account move accordingly. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: """ rec_id = context and context.get('active_id', False) prod_obj = self.pool.get('product.template') location_obj = self.pool.get('stock.location') lot_obj = self.pool.get('stock.report.prodlots') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line') data_obj = self.pool.get('ir.model.data') res = self.read(cr, uid, ids[0], ['new_price']) new_price = res.get('new_price',[]) data = prod_obj.browse(cr, uid, rec_id) diff = data.standard_price - new_price prod_obj.write(cr, uid, rec_id, {'standard_price': new_price}) loc_ids = location_obj.search(cr, uid, [('account_id','<>',False),('usage','=','internal')]) lot_ids = lot_obj.search(cr, uid, [('location_id', 'in', loc_ids),('product_id','=',rec_id)]) qty = 0 debit = 0.0 credit = 0.0 stock_input_acc = data.property_stock_account_input.id or data.categ_id.property_stock_account_input_categ.id stock_output_acc = data.property_stock_account_output.id or data.categ_id.property_stock_account_output_categ.id for lots in lot_obj.browse(cr, uid, lot_ids): qty += lots.name if stock_input_acc and stock_output_acc and lot_ids: move_id = move_obj.create(cr, uid, {'journal_id': data.categ_id.property_stock_journal.id}) if diff > 0: credit = qty * diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_input_acc, 'credit': credit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): credit = lots.name * diff move_line_obj.create(cr, uid, { 'name': 'Expense', 'account_id': lots.location_id.account_id.id, 'debit': credit, 'move_id': move_id }) elif diff < 0: debit = qty * -diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_output_acc, 'debit': debit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): debit = lots.name * -diff move_line_obj.create(cr, uid, { 'name': 'Income', 'account_id': lots.location_id.account_id.id, 'credit': debit, 'move_id': move_id }) else: raise osv.except_osv(_('Warning!'),_('No Change in Price.')) else: raise osv.except_osv(_('Warning!'),_('No Accounts are defined for ' 'this product on its location.\nCan\'t create Move.')) id2 = data_obj._get_id(cr, uid, 'account', 'view_move_tree') id3 = data_obj._get_id(cr, uid, 'account', 'view_move_form') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'account.move', 'res_id' : move_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window', } prod_obj.do_change_standard_price(cr, uid, [rec_id], datas, context) return {}
def change_price(self, cr, uid, ids, context): """ Changes the Standard Price of Product. And creates an account move accordingly. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: """ rec_id = context and context.get('active_id', False) prod_obj = self.pool.get('product.template') location_obj = self.pool.get('stock.location') lot_obj = self.pool.get('stock.report.prodlots') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line') data_obj = self.pool.get('ir.model.data') res = self.read(cr, uid, ids[0], ['new_price']) new_price = res.get('new_price',[]) data = prod_obj.browse(cr, uid, rec_id) diff = data.standard_price - new_price prod_obj.write(cr, uid, rec_id, {'standard_price': new_price}) loc_ids = location_obj.search(cr, uid, [('account_id','<>',False),('usage','=','internal')]) lot_ids = lot_obj.search(cr, uid, [('location_id', 'in', loc_ids),('product_id','=',rec_id)]) qty = 0 debit = 0.0 credit = 0.0 stock_input_acc = data.property_stock_account_input.id or data.categ_id.property_stock_account_input_categ.id stock_output_acc = data.property_stock_account_output.id or data.categ_id.property_stock_account_output_categ.id for lots in lot_obj.browse(cr, uid, lot_ids): qty += lots.name if stock_input_acc and stock_output_acc and lot_ids: move_id = move_obj.create(cr, uid, {'journal_id': data.categ_id.property_stock_journal.id}) if diff > 0: credit = qty * diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_input_acc, 'credit': credit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): credit = lots.name * diff move_line_obj.create(cr, uid, { 'name': 'Expense', 'account_id': lots.location_id.account_id.id, 'debit': credit, 'move_id': move_id }) elif diff < 0: debit = qty * -diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_output_acc, 'debit': debit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): debit = lots.name * -diff move_line_obj.create(cr, uid, { 'name': 'Income', 'account_id': lots.location_id.account_id.id, 'credit': debit, 'move_id': move_id }) else: raise osv.except_osv(_('Warning!'),_('No Change in Price.')) else: raise osv.except_osv(_('Warning!'),_('No Accounts are defined for ' 'this product on its location.\nCan\'t create Move.')) id2 = data_obj._get_id(cr, uid, 'account', 'view_move_tree') id3 = data_obj._get_id(cr, uid, 'account', 'view_move_form') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'account.move', 'res_id' : move_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window', } prod_obj.do_change_standard_price(cr, uid, [rec_id], datas, context) return {}
469,275
def draft_validate(self, cr, uid, ids, *args): """ Validates picking directly from draft state. @return: True """ wf_service = netsvc.LocalService("workflow") self.draft_force_assign(cr, uid, ids) for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines] self.pool.get('stock.move').force_assign(cr, uid, move_ids) wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
def draft_validate(self, cr, uid, ids, context=None): """ Validates picking directly from draft state. @return: True """ wf_service = netsvc.LocalService("workflow") self.draft_force_assign(cr, uid, ids) for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines] self.pool.get('stock.move').force_assign(cr, uid, move_ids) wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
469,276
def draft_validate(self, cr, uid, ids, *args): """ Validates picking directly from draft state. @return: True """ wf_service = netsvc.LocalService("workflow") self.draft_force_assign(cr, uid, ids) for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines] self.pool.get('stock.move').force_assign(cr, uid, move_ids) wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
def draft_validate(self, cr, uid, ids, *args): """ Validates picking directly from draft state. @return: True """ wf_service = netsvc.LocalService("workflow") self.draft_force_assign(cr, uid, ids) for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines] self.pool.get('stock.move').force_assign(cr, uid, move_ids) wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
469,277
def _parent_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} result = {} obj_dept = self.pool.get('hr.department') for user_id in ids: emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)], context=context) cr.execute('SELECT emp.department_id FROM hr_employee AS emp \ JOIN resource_resource AS res ON res.id = emp.resource_id \ JOIN hr_department as dept ON dept.id = emp.department_id \ WHERE res.user_id = %s AND emp.department_id IS NOT NULL AND dept.manager_id IS NOT NULL', (user_id,)) ids_dept = [x[0] for x in cr.fetchall()] parent_ids = [] if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['manager_id'], context=context) parent_ids = map(lambda x: x['manager_id'][0], data_dept) cr.execute('SELECT res.user_id FROM hr_employee AS emp JOIN resource_resource AS res ON res.id=emp.resource_id \ WHERE emp.id IN %s', (tuple(parent_ids),)) parent_ids = [x[0] for x in cr.fetchall() if x[0]] result[user_id] = parent_ids return result
def _parent_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} result = {} obj_dept = self.pool.get('hr.department') for user_id in ids: emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)], context=context) cr.execute('SELECT emp.department_id FROM hr_employee AS emp \ JOIN resource_resource AS res ON res.id = emp.resource_id \ JOIN hr_department as dept ON dept.id = emp.department_id \ WHERE res.user_id = %s AND emp.department_id IS NOT NULL AND dept.manager_id IS NOT NULL', (user_id,)) ids_dept = [x[0] for x in cr.fetchall()] parent_ids = [] if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['manager_id'], context=context) parent_ids = map(lambda x: x['manager_id'][0], data_dept) cr.execute('SELECT res.user_id FROM hr_employee AS emp JOIN resource_resource AS res ON res.id=emp.resource_id \ WHERE emp.id IN %s AND res.user_id IS NOT NULL', (tuple(parent_ids),)) parent_ids = [x[0] for x in cr.fetchall()] result[user_id] = parent_ids return result
469,278
def convert_field(f): f_qual = "%s.%s" % (self._table, f) # need fully-qualified references in case len(tables) > 1 if f in ('create_date', 'write_date'): return "date_trunc('second', %s) as %s" % (f_qual, f) if f == self.CONCURRENCY_CHECK_FIELD: if self._log_access: return "COALESCE(%s.write_date, %s.create_date, now())::timestamp AS %s" % (self._table, self._table, f,) return "now()::timestamp AS %s" % (f,) if isinstance(self._columns[f], fields.binary) and context.get('bin_size', False): return 'length(%s) as "%s"' % (f_qual, f) return f_qual
def convert_field(f): f_qual = "%s.%s" % (self._table, f) # need fully-qualified references in case len(tables) > 1 if f in ('create_date', 'write_date'): return "date_trunc('second', %s) as %s" % (f_qual, f) if f == self.CONCURRENCY_CHECK_FIELD: if self._log_access: return "COALESCE(%s.write_date, %s.create_date, now())::timestamp AS %s" % (self._table, self._table, f,) return "now()::timestamp AS %s" % (f,) if isinstance(self._columns[f], fields.binary) and context.get('bin_size', False): return 'length(%s) as "%s"' % (f_qual, f) return f_qual
469,279
def doc_createXElement(xdoc, tagName): e = xElement(tagName) e.ownerDocument = xdoc return e
def doc_createXElement(xdoc, tagName): e = xElement(tagName) e.ownerDocument = xdoc return e
469,280
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
def_query_get(self,cr,uid,obj='l',context={}):fiscalyear_obj=self.pool.get('account.fiscalyear')fiscalperiod_obj=self.pool.get('account.period')fiscalyear_ids=[]fiscalperiod_ids=[]initial_bal=context.get('initial_bal',False)company_clause=""ifcontext.get('company_id',False):company_clause="AND"+obj+".company_id=%s"%context.get('company_id',False)ifnotcontext.get('fiscalyear',False):fiscalyear_ids=fiscalyear_obj.search(cr,uid,[('state','=','draft')])else:ifinitial_bal:fiscalyear_date_start=fiscalyear_obj.read(cr,uid,context['fiscalyear'],['date_start'])['date_start']fiscalyear_ids=fiscalyear_obj.search(cr,uid,[('date_stop','<',fiscalyear_date_start),('state','=','draft')],context=context)else:fiscalyear_ids=[context['fiscalyear']]
469,281
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
469,282
def check_group(node): if node.get('groups'): groups = node.get('groups').split(',') access_pool = self.pool.get('ir.model.access') can_see = any(access_pool.check_groups(cr, user, group) for group in groups) if not can_see: node.set('invisible', '1') if 'attrs' in node.attrib: del(node.attrib['attrs']) #avoid making field visible later del(node.attrib['groups']) return can_see else: return True
defcheck_group(node):ifnode.get('groups'):groups=node.get('groups').split(',')access_pool=self.pool.get('ir.model.access')can_see=any(access_pool.check_groups(cr,user,group)forgroupingroups)ifnotcan_see:node.set('invisible','1')if'attrs'innode.attrib:del(node.attrib['attrs'])#avoidmakingfieldvisiblelaterdel(node.attrib['groups'])returncan_seeelse:returnTrue
469,283
def check_group(node): if node.get('groups'): groups = node.get('groups').split(',') access_pool = self.pool.get('ir.model.access') can_see = any(access_pool.check_groups(cr, user, group) for group in groups) if not can_see: node.set('invisible', '1') if 'attrs' in node.attrib: del(node.attrib['attrs']) #avoid making field visible later del(node.attrib['groups']) return can_see else: return True
def check_group(node): if node.get('groups'): groups = node.get('groups').split(',') access_pool = self.pool.get('ir.model.access') can_see = any(access_pool.check_groups(cr, user, group) for group in groups) if not can_see: node.set('invisible', '1') if 'attrs' in node.attrib: del(node.attrib['attrs']) #avoid making field visible later del(node.attrib['groups']) return can_see else: return True
469,284
def default_get(self, cr, uid, fields, context=None): res = super(account_move_line_reconcile, self).default_get(cr, uid, fields, context=context) data = self.trans_rec_get(cr, uid, context['active_ids'], context) if 'trans_nbr' in fields: res.update({'trans_nbr':data['trans_nbr']}) if 'credit' in fields: res.update({'trans_nbr':data['credit']}) if 'debit' in fields: res.update({'trans_nbr':data['debit']}) if 'writeoff' in fields: res.update({'trans_nbr':data['writeoff']}) return res
def default_get(self, cr, uid, fields, context=None): res = super(account_move_line_reconcile, self).default_get(cr, uid, fields, context=context) data = self.trans_rec_get(cr, uid, context['active_ids'], context) if 'trans_nbr' in fields: res.update({'trans_nbr':data['trans_nbr']}) if 'credit' in fields: res.update({'credit':data['credit']}) if 'debit' in fields: res.update({'trans_nbr':data['debit']}) if 'writeoff' in fields: res.update({'trans_nbr':data['writeoff']}) return res
469,285
def default_get(self, cr, uid, fields, context=None): res = super(account_move_line_reconcile, self).default_get(cr, uid, fields, context=context) data = self.trans_rec_get(cr, uid, context['active_ids'], context) if 'trans_nbr' in fields: res.update({'trans_nbr':data['trans_nbr']}) if 'credit' in fields: res.update({'trans_nbr':data['credit']}) if 'debit' in fields: res.update({'trans_nbr':data['debit']}) if 'writeoff' in fields: res.update({'trans_nbr':data['writeoff']}) return res
def default_get(self, cr, uid, fields, context=None): res = super(account_move_line_reconcile, self).default_get(cr, uid, fields, context=context) data = self.trans_rec_get(cr, uid, context['active_ids'], context) if 'trans_nbr' in fields: res.update({'trans_nbr':data['trans_nbr']}) if 'credit' in fields: res.update({'trans_nbr':data['credit']}) if 'debit' in fields: res.update({'debit':data['debit']}) if 'writeoff' in fields: res.update({'trans_nbr':data['writeoff']}) return res
469,286
def default_get(self, cr, uid, fields, context=None): res = super(account_move_line_reconcile, self).default_get(cr, uid, fields, context=context) data = self.trans_rec_get(cr, uid, context['active_ids'], context) if 'trans_nbr' in fields: res.update({'trans_nbr':data['trans_nbr']}) if 'credit' in fields: res.update({'trans_nbr':data['credit']}) if 'debit' in fields: res.update({'trans_nbr':data['debit']}) if 'writeoff' in fields: res.update({'trans_nbr':data['writeoff']}) return res
def default_get(self, cr, uid, fields, context=None): res = super(account_move_line_reconcile, self).default_get(cr, uid, fields, context=context) data = self.trans_rec_get(cr, uid, context['active_ids'], context) if 'trans_nbr' in fields: res.update({'trans_nbr':data['trans_nbr']}) if 'credit' in fields: res.update({'trans_nbr':data['credit']}) if 'debit' in fields: res.update({'trans_nbr':data['debit']}) if 'writeoff' in fields: res.update({'writeoff':data['writeoff']}) return res
469,287
def _calculate(self, cr, uid, ids, field_names, arg, context=None): slip_line_obj = self.pool.get('hr.payslip.line') if context is None: context = {} res = {} for rs in self.browse(cr, uid, ids, context=context): allow = 0.0 deduct = 0.0 others = 0.0 obj = {'basic':rs.basic} if rs.igross > 0: obj['gross'] = rs.igross if rs.inet > 0: obj['net'] = rs.inet for line in rs.line_ids: amount = 0.0 if line.amount_type == 'per': try: amount = line.amount * eval(str(line.category_id.base), obj) except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ' % (e))) elif line.amount_type in ('fix', 'func'): amount = line.amount cd = line.category_id.code.lower() obj[cd] = amount contrib = 0.0 if line.type == 'allowance': allow += amount others += contrib amount -= contrib elif line.type == 'deduction': deduct += amount others -= contrib amount += contrib elif line.type == 'advance': others += amount elif line.type == 'loan': others += amount elif line.type == 'otherpay': others += amount slip_line_obj.write(cr, uid, [line.id], {'total':amount}, context=context)
def _calculate(self, cr, uid, ids, field_names, arg, context=None): slip_line_obj = self.pool.get('hr.payslip.line') if context is None: context = {} res = {} for rs in self.browse(cr, uid, ids, context=context): allow = 0.0 deduct = 0.0 others = 0.0 obj = {'basic':rs.basic} if rs.igross > 0: obj['gross'] = rs.igross if rs.inet > 0: obj['net'] = rs.inet for line in rs.line_ids: amount = 0.0 if line.amount_type == 'per': try: amount = line.amount * eval(str(line.category_id.base), obj) except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ' % (e))) elif line.amount_type in ('fix', 'func'): amount = line.amount cd = line.category_id.code.lower() obj[cd] = amount contrib = 0.0 if line.type == 'allowance': allow += amount others += contrib amount -= contrib elif line.type == 'deduction': deduct += amount others -= contrib amount += contrib elif line.type == 'advance': others += amount elif line.type == 'loan': others += amount elif line.type == 'otherpay': others += amount slip_line_obj.write(cr, uid, [line.id], {'total':amount}, context=context)
469,288
def _calculate(self, cr, uid, ids, field_names, arg, context=None): slip_line_obj = self.pool.get('hr.payslip.line') if context is None: context = {} res = {} for rs in self.browse(cr, uid, ids, context=context): allow = 0.0 deduct = 0.0 others = 0.0 obj = {'basic':rs.basic} if rs.igross > 0: obj['gross'] = rs.igross if rs.inet > 0: obj['net'] = rs.inet for line in rs.line_ids: amount = 0.0 if line.amount_type == 'per': try: amount = line.amount * eval(str(line.category_id.base), obj) except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ' % (e))) elif line.amount_type in ('fix', 'func'): amount = line.amount cd = line.category_id.code.lower() obj[cd] = amount contrib = 0.0 if line.type == 'allowance': allow += amount others += contrib amount -= contrib elif line.type == 'deduction': deduct += amount others -= contrib amount += contrib elif line.type == 'advance': others += amount elif line.type == 'loan': others += amount elif line.type == 'otherpay': others += amount slip_line_obj.write(cr, uid, [line.id], {'total':amount}, context=context)
def _calculate(self, cr, uid, ids, field_names, arg, context=None): slip_line_obj = self.pool.get('hr.payslip.line') if context is None: context = {} res = {} for rs in self.browse(cr, uid, ids, context=context): allow = 0.0 deduct = 0.0 others = 0.0 obj = {'basic':rs.basic} if rs.igross > 0: obj['gross'] = rs.igross if rs.inet > 0: obj['net'] = rs.inet for line in rs.line_ids: amount = 0.0 if line.amount_type == 'per': try: amount = line.amount * eval(str(line.category_id.base), obj) except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ' % (e))) elif line.amount_type in ('fix', 'func'): amount = line.amount cd = line.category_id.code.lower() obj[cd] = amount contrib = 0.0 if line.type == 'allowance': allow += amount others += contrib amount -= contrib elif line.type == 'deduction': deduct += amount others -= contrib amount += contrib elif line.type == 'advance': others += amount elif line.type == 'loan': others += amount elif line.type == 'otherpay': others += amount slip_line_obj.write(cr, uid, [line.id], {'total':amount}, context=context)
469,289
def _calculate(self, cr, uid, ids, field_names, arg, context=None): slip_line_obj = self.pool.get('hr.payslip.line') if context is None: context = {} res = {} for rs in self.browse(cr, uid, ids, context=context): allow = 0.0 deduct = 0.0 others = 0.0 obj = {'basic':rs.basic} if rs.igross > 0: obj['gross'] = rs.igross if rs.inet > 0: obj['net'] = rs.inet for line in rs.line_ids: amount = 0.0 if line.amount_type == 'per': try: amount = line.amount * eval(str(line.category_id.base), obj) except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ' % (e))) elif line.amount_type in ('fix', 'func'): amount = line.amount cd = line.category_id.code.lower() obj[cd] = amount contrib = 0.0 if line.type == 'allowance': allow += amount others += contrib amount -= contrib elif line.type == 'deduction': deduct += amount others -= contrib amount += contrib elif line.type == 'advance': others += amount elif line.type == 'loan': others += amount elif line.type == 'otherpay': others += amount slip_line_obj.write(cr, uid, [line.id], {'total':amount}, context=context)
def _calculate(self, cr, uid, ids, field_names, arg, context=None): slip_line_obj = self.pool.get('hr.payslip.line') if context is None: context = {} res = {} for rs in self.browse(cr, uid, ids, context=context): allow = 0.0 deduct = 0.0 others = 0.0 obj = {'basic':rs.basic} if rs.igross > 0: obj['gross'] = rs.igross if rs.inet > 0: obj['net'] = rs.inet for line in rs.line_ids: amount = 0.0 if line.amount_type == 'per': try: amount = line.amount * eval(str(line.category_id.base), obj) except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ' % (e))) elif line.amount_type in ('fix', 'func'): amount = line.amount cd = line.category_id.code.lower() obj[cd] = amount contrib = 0.0 if line.type == 'allowance': allow += amount others += contrib amount -= contrib elif line.type == 'deduction': deduct += amount others -= contrib amount += contrib elif line.type == 'advance': others += amount elif line.type == 'loan': others += amount elif line.type == 'otherpay': others += amount slip_line_obj.write(cr, uid, [line.id], {'total':amount}, context=context)
469,290
def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}}
def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}}
469,291
def _get_group(self,cr, uid, context=None): dataobj = self.pool.get('ir.model.data') data_id = dataobj._get_id(cr, 1, 'base', 'group_user') return data_id and [data_id] or False
def _get_group(self,cr, uid, context=None): data_pool = self.pool.get('ir.model.data') res = data_pool.get_object_reference(cr, 1, 'base', 'group_user') data_id = res and res[1] or False return data_id and [data_id] or False
469,292
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id IN %s \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context)
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id IN %s \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context)
469,293
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \
469,294
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None): res = {} res2 = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) # Warning # This computation doesn't take care of pricelist ! # Just consider list_price if parent_ids: cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ * hr.factor)),0.0) as somme from account_analytic_line \ left join account_analytic_journal \ on (account_analytic_line.journal_id = account_analytic_journal.id) \ join product_product pp \ on (account_analytic_line.product_id = pp.id) \ join product_template pt \ on (pp.product_tmpl_id = pt.id) \ join account_analytic_account a \ on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ where account_analytic_line.account_id IN %s \ and a.to_invoice IS NOT NULL \ and account_analytic_journal.type IN ('purchase','general') GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) res2.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) res[obj_id] += res2.get(child_id, 0.0) # sum both result on account_id for id in ids: res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) return res
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None): res = {} res2 = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) # Warning # This computation doesn't take care of pricelist ! # Just consider list_price if parent_ids: cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ * hr.factor)),0.0) as somme from account_analytic_line \ left join account_analytic_journal \ on (account_analytic_line.journal_id = account_analytic_journal.id) \ join product_product pp \ on (account_analytic_line.product_id = pp.id) \ join product_template pt \ on (pp.product_tmpl_id = pt.id) \ join account_analytic_account a \ on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ where account_analytic_line.account_id IN %s \ and a.to_invoice IS NOT NULL \ and account_analytic_journal.type IN ('purchase','general') GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) res2.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) res[obj_id] += res2.get(child_id, 0.0) # sum both result on account_id for id in ids: res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) return res
469,295
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None): res = {} res2 = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) # Warning # This computation doesn't take care of pricelist ! # Just consider list_price if parent_ids: cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ * hr.factor)),0.0) as somme from account_analytic_line \ left join account_analytic_journal \ on (account_analytic_line.journal_id = account_analytic_journal.id) \ join product_product pp \ on (account_analytic_line.product_id = pp.id) \ join product_template pt \ on (pp.product_tmpl_id = pt.id) \ join account_analytic_account a \ on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ where account_analytic_line.account_id IN %s \ and a.to_invoice IS NOT NULL \ and account_analytic_journal.type IN ('purchase','general') GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) res2.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) res[obj_id] += res2.get(child_id, 0.0) # sum both result on account_id for id in ids: res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) return res
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None): res = {} res2 = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) # Warning # This computation doesn't take care of pricelist ! # Just consider list_price if parent_ids: cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ * hr.factor)),0.0) as somme from account_analytic_line \ left join account_analytic_journal \ on (account_analytic_line.journal_id = account_analytic_journal.id) \ join product_product pp \ on (account_analytic_line.product_id = pp.id) \ join product_template pt \ on (pp.product_tmpl_id = pt.id) \ join account_analytic_account a \ on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ where account_analytic_line.account_id IN %s \ and a.to_invoice IS NOT NULL \ and account_analytic_journal.type IN ('purchase','general') GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) res2.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) res[obj_id] += res2.get(child_id, 0.0) # sum both result on account_id for id in ids: res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) return res
469,296
def _user(self, cr, uid, ids, name, arg, context=None): res = {} cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] for id in ids: parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,)) res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()] else: res[id] = [] return res
def _user(self, cr, uid, ids, name, arg, context=None): res = {} cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] for id in ids: parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,)) res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()] else: res[id] = [] return res
469,297
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
469,298
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, tuple(user_ids),)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
469,299