rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
else: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable, skipped' % (module))
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
75d569cc6c5ed18f920052415c23e7b838e3b6a4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75d569cc6c5ed18f920052415c23e7b838e3b6a4/__init__.py
global not_loaded if not_loaded: not_loaded = [] return
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))
75d569cc6c5ed18f920052415c23e7b838e3b6a4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75d569cc6c5ed18f920052415c23e7b838e3b6a4/__init__.py
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
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
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,
d0a6aeebff76728a5f850b59cb87990b97cd3780 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d0a6aeebff76728a5f850b59cb87990b97cd3780/report_intrastat.py
else case when uom.factor_inv_data > 0 then inv_line.quantity * uom.factor_inv_data else inv_line.quantity / uom.factor end end
else (inv_line.quantity * uom.factor) end
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,
d0a6aeebff76728a5f850b59cb87990b97cd3780 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d0a6aeebff76728a5f850b59cb87990b97cd3780/report_intrastat.py
if picking_id: wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
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')
bf00ee7f5cbd05edf189e1e1c7e9743b26a1d6c6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf00ee7f5cbd05edf189e1e1c7e9743b26a1d6c6/sale.py
'account_id': a,
'account_id': account_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})
8ee7af483dc8860e76ca1e7c8fb3e4cbb01f0bed /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8ee7af483dc8860e76ca1e7c8fb3e4cbb01f0bed/mrp_repair.py
for dirname in rl_config.TTFSearchPath: abp = os.path.abspath(dirname) if os.path.isdir(abp): dirpath.append(abp)
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)
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
7c55e521a3b6aa0e45599c67158cf392e57173ea /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7c55e521a3b6aa0e45599c67158cf392e57173ea/customfonts.py
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
7c55e521a3b6aa0e45599c67158cf392e57173ea /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7c55e521a3b6aa0e45599c67158cf392e57173ea/customfonts.py
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})
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)
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
3dec5629c96aab45601f8277e2c1264fcca32d3b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3dec5629c96aab45601f8277e2c1264fcca32d3b/invoice.py
number = obj_seq.get_id(cr, uid, 'account.invoice.%s' % invtype, 'code=%s', context=tmp_context)
number = self.pool.get('ir.sequence').get_id(cr, uid, 'account.invoice.%s' % invtype, 'code', context=tmp_context)
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
3dec5629c96aab45601f8277e2c1264fcca32d3b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3dec5629c96aab45601f8277e2c1264fcca32d3b/invoice.py
data_id = dataobj._get_id(cr, 1, 'base', 'group_user') return data_id and [data_id] or False
dummy,group_id = dataobj.get_object_reference(cr, 1, 'base', 'group_user') return [group_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
55da21f5b634485b520adc10e2f5afc60ce231aa /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/55da21f5b634485b520adc10e2f5afc60ce231aa/res_user.py
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' }
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!'))
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
1b2f939266031a4b013f02cde4e30074531f82d5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1b2f939266031a4b013f02cde4e30074531f82d5/wizard_return.py
'amount': fields.float('Amount', required=True, digits_compute=dp.get_precision('Account'), help="For taxes of type percentage, enter % ratio between 0-1."),
'amount': fields.float('Amount', required=True, digits_compute=get_precision_tax(), help="For taxes of type percentage, enter % ratio between 0-1."),
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)
8e2d576a8b13f18a1bbaeb00e2c058d18dd8aa12 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8e2d576a8b13f18a1bbaeb00e2c058d18dd8aa12/account.py
totalin = totalex = round(price_unit * quantity, precision)
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 }
eca497d46b7159a9ff5fd5fdd6f74368d026c287 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/eca497d46b7159a9ff5fd5fdd6f74368d026c287/account.py
tex = self._compute(cr, uid, tex, price_unit, quantity, address_id=address_id, product=product, partner=partner)
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 }
eca497d46b7159a9ff5fd5fdd6f74368d026c287 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/eca497d46b7159a9ff5fd5fdd6f74368d026c287/account.py
print "Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included"
logger = netsvc.Logger() logger.notifyChannel("warning", netsvc.LOG_WARNING, "Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included")
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)
eca497d46b7159a9ff5fd5fdd6f74368d026c287 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/eca497d46b7159a9ff5fd5fdd6f74368d026c287/account.py
today = (last_month_date- 1).strftime('%Y-%m-%d')
today = (last_month_date- relativedelta(days=1)).strftime('%Y-%m-%d')
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)
7b4cae7e4cbcfe64d3c1c2b48dd21d7c463bc313 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7b4cae7e4cbcfe64d3c1c2b48dd21d7c463bc313/account_report.py
<table width="100%"> <tr> <td width=60% style="padding-right:8px;"> <input id="sidebar_pad_datas" name="pad_name" size="5" /> </td> <td> <button>${_("Ok")}</button> </td> </tr> </table>
<input id="sidebar_pad_datas" name="pad_name" size="5" /> <button>${_("Ok")}</button>
def edit(self, template, template_text): output = super(SidebarTemplateEditor, self).edit(template, template_text)
13c8d859d3506703afe1751d8114f438637a8649 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/13c8d859d3506703afe1751d8114f438637a8649/editors.py
'attendances_ids' : one2many_mod2('hr.attendance', 'sheet_id', 'Attendances', readonly=True, states={'draft':[('readonly',False)],'new':[('readonly',False)]}),
'attendances_ids' : one2many_mod2('hr.attendance', 'sheet_id', 'Attendances', readonly=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
e20452310d64f6c8c07fc3e7830c4ddb88e8d8fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e20452310d64f6c8c07fc3e7830c4ddb88e8d8fd/hr_timesheet_sheet.py
def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] cur_obj = self.pool.get('res.currency')
6bf8e8540e15556d4f6de35150e5b4b6a0e54466 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6bf8e8540e15556d4f6de35150e5b4b6a0e54466/account_analytic_plans.py
if il['analytics_id']:
if il.get('analytics_id', False):
def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] cur_obj = self.pool.get('res.currency')
6bf8e8540e15556d4f6de35150e5b4b6a0e54466 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6bf8e8540e15556d4f6de35150e5b4b6a0e54466/account_analytic_plans.py
il['analytic_lines']=[]
il['analytic_lines'] = []
def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] cur_obj = self.pool.get('res.currency')
6bf8e8540e15556d4f6de35150e5b4b6a0e54466 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6bf8e8540e15556d4f6de35150e5b4b6a0e54466/account_analytic_plans.py
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')
6bf8e8540e15556d4f6de35150e5b4b6a0e54466 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6bf8e8540e15556d4f6de35150e5b4b6a0e54466/account_analytic_plans.py
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> """
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
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
60e601b49a0ccd670ade65dfe13553a978b7dfeb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60e601b49a0ccd670ade65dfe13553a978b7dfeb/cancel_repair.py
journal_id = inv.journal_id.id
journal_id = inv.journal_id.id
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
c38d1e200acb560a320e4195af9387b261388786 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c38d1e200acb560a320e4195af9387b261388786/invoice.py
company_currency=False
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
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}}
c38d1e200acb560a320e4195af9387b261388786 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c38d1e200acb560a320e4195af9387b261388786/invoice.py
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}}
amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*tax_sign, 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}}
c38d1e200acb560a320e4195af9387b261388786 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c38d1e200acb560a320e4195af9387b261388786/invoice.py
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', c),
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c),
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
47a7f86d3162d81e28573378e26d8d92e0961425 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/47a7f86d3162d81e28573378e26d8d92e0961425/project.py
print history_type
def _get_case_history(self, cr, uid, history_type, res_id, context=None): if not res_id: return
80f26e7878e033ff9efe81eb3554203b32c95b48 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/80f26e7878e033ff9efe81eb3554203b32c95b48/crm_forward_to_partner.py
return False if type(self) != type(other):
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
9cdbcbfee1d356ebaab68e17e75aa0bf1eb16b5d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9cdbcbfee1d356ebaab68e17e75aa0bf1eb16b5d/nodes.py
return False if type(self) != type(other):
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
9cdbcbfee1d356ebaab68e17e75aa0bf1eb16b5d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9cdbcbfee1d356ebaab68e17e75aa0bf1eb16b5d/nodes.py
return False if type(self) != type(other):
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
9cdbcbfee1d356ebaab68e17e75aa0bf1eb16b5d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9cdbcbfee1d356ebaab68e17e75aa0bf1eb16b5d/nodes.py
return False if type(self) != type(other):
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
9cdbcbfee1d356ebaab68e17e75aa0bf1eb16b5d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9cdbcbfee1d356ebaab68e17e75aa0bf1eb16b5d/nodes.py
entry_type = 'journal_pur_voucher' if invoice.type == 'in_refund': entry_type = 'cont_voucher'
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')
d7e0e18d7f7499b0129cf7f9c1cd233481fe5ec4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d7e0e18d7f7499b0129cf7f9c1cd233481fe5ec4/invoice.py
entry_type = 'journal_sale_vou' if invoice.type == 'out_refund': entry_type = 'cont_voucher'
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')
d7e0e18d7f7499b0129cf7f9c1cd233481fe5ec4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d7e0e18d7f7499b0129cf7f9c1cd233481fe5ec4/invoice.py
@return: True
@return: True
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)]"
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
_('WARNING: audittrail is not part of the pool'),
_('WARNING: audittrail is not part of the pool'),
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)]"
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
"name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model,
"name": 'View Log', "res_model": 'audittrail.log', "src_model": thisrule.object_id.model,
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)]"
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
id = obj_action.create(cr, uid, val) self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": id})
action_id = obj_action.create(cr, uid, val) self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": action_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)]"
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
value = 'ir.actions.act_window,' + str(id)
value = 'ir.actions.act_window,' + str(action_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)]"
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
@return: True
@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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
"name": fields.char("Name", size=32), "object_id": fields.many2one('ir.model', 'Object'), "user_id": fields.many2one('res.users', 'User'), "method": fields.selection((('read', 'Read'), ('write', 'Write'), ('unlink', 'Delete'), ('create', 'Create')), "Method"), "timestamp": fields.datetime("Date"), "res_id": fields.integer('Resource Id'), "line_ids": fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
"name": fields.char("Resource Name",size=64), "object_id": fields.many2one('ir.model', 'Object'), "user_id": fields.many2one('res.users', 'User'), "method": fields.char("Method", size=64), "timestamp": fields.datetime("Date"), "res_id": fields.integer('Resource Id'), "line_ids": fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
'field_id': fields.many2one('ir.model.fields', 'Fields', required=True), 'log_id': fields.many2one('audittrail.log', 'Log'), 'log': fields.integer("Log ID"), 'old_value': fields.text("Old Value"), 'new_value': fields.text("New Value"), 'old_value_text': fields.text('Old value Text'), 'new_value_text': fields.text('New value Text'), 'field_description': fields.char('Field Description', size=64),
'field_id': fields.many2one('ir.model.fields', 'Fields', required=True), 'log_id': fields.many2one('audittrail.log', 'Log'), 'log': fields.integer("Log ID"), 'old_value': fields.text("Old Value"), 'new_value': fields.text("New Value"), 'old_value_text': fields.text('Old value Text'), 'new_value_text': fields.text('New value Text'), 'field_description': fields.char('Field Description', size=64),
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
def get_value_text(self, cr, uid, field_name, values, object, context=None):
def get_value_text(self, cr, uid, field_name, values, model, context=None):
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
@param field_name: List of fields for text values @param values: Values for field to be converted into textual values @return: values: List of textual values for given fields
@param field_name: List of fields for text values @param values: Values for field to be converted into textual values @return: values: List of textual values for given fields
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', '=', object.id)]) if f_id: field = pool.get('ir.model.fields').read(cr, uid, f_id)[0] model = field['relation'] if field['ttype'] == 'many2one': if values: if type(values) == tuple: values = values[0] val = pool.get(model).read(cr, uid, [values], [pool.get(model)._rec_name]) if val: return val[0][pool.get(model)._rec_name] elif field['ttype'] == 'many2many': value = [] if values: for id in values: val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name]) if val: value.append(val[0][pool.get(model)._rec_name]) return value elif field['ttype'] == 'one2many': if values: value = [] for id in values: val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name]) if val: value.append(val[0][pool.get(model)._rec_name]) return value return values def create_log_line(self, cr, uid, id, object, lines=[]):
field_pool = pool.get('ir.model.fields') model_pool = pool.get('ir.model') obj_pool = pool.get(model.model) if obj_pool._inherits: inherits_ids = model_pool.search(cr, uid, [('model', '=', obj_pool._inherits.keys()[0])]) field_ids = field_pool.search(cr, uid, [('name', '=', field_name), ('model_id', 'in', (model.id, inherits_ids[0]))]) else: field_ids = field_pool.search(cr, uid, [('name', '=', field_name), ('model_id', '=', model.id)]) field_id = field_ids and field_ids[0] or False assert field_id, _("'%s' field is not exits in '%s' model" %(field_name, model.model)) field = field_pool.read(cr, uid, field_id) relation_model = field['relation'] relation_model_pool = relation_model and pool.get(relation_model) or False if field['ttype'] == 'many2one': res = False relation_id = False if values and type(values) == tuple: relation_id = values[0] if relation_id and relation_model_pool: relation_model_object = relation_model_pool.read(cr, uid, relation_id, [relation_model_pool._rec_name]) res = relation_model_object[relation_model_pool._rec_name] return res elif field['ttype'] in ('many2many','one2many'): res = [] for relation_model_object in relation_model_pool.read(cr, uid, values, [relation_model_pool._rec_name]): res.append(relation_model_object[relation_model_pool._rec_name]) return res return values def create_log_line(self, cr, uid, log_id, model, lines=[]):
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
@param object: Object who's values are being changed
@param model: Object who's values are being changed
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
obj = pool.get(object.model)
obj_pool = pool.get(model.model) model_pool = pool.get('ir.model') field_pool = pool.get('ir.model.fields') log_line_pool = pool.get('audittrail.log.line')
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
if obj._inherits: inherits_ids = pool.get('ir.model').search(cr, uid, [('model', '=', obj._inherits.keys()[0])]) f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (object.id, inherits_ids[0]))])
if obj_pool._inherits: inherits_ids = model_pool.search(cr, uid, [('model', '=', obj_pool._inherits.keys()[0])]) field_ids = field_pool.search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (model.id, inherits_ids[0]))])
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', '=', object.id)]) if f_id: fields = pool.get('ir.model.fields').read(cr, uid, f_id) old_value = 'old_value' in line and line['old_value'] or '' new_value = 'new_value' in line and line['new_value'] or '' old_value_text = 'old_value_text' in line and line['old_value_text'] or '' new_value_text = 'new_value_text' in line and line['new_value_text'] or '' if old_value_text == new_value_text: continue if fields[0]['ttype'] == 'many2one': if type(old_value) == tuple: old_value = old_value[0] if type(new_value) == tuple: new_value = new_value[0] vals = { "log_id": id, "field_id": f_id[0], "old_value": old_value, "new_value": new_value, "old_value_text": old_value_text, "new_value_text": new_value_text, "field_description": fields[0]['field_description'] } line_id = pool.get('audittrail.log.line').create(cr, uid, vals) cr.commit()
field_ids = field_pool.search(cr, uid, [('name', '=', line['name']), ('model_id', '=', model.id)]) field_id = field_ids and field_ids[0] or False assert field_id, _("'%s' field is not exits in '%s' model" %(line['name'], model.model)) field = field_pool.read(cr, uid, field_id) old_value = 'old_value' in line and line['old_value'] or '' new_value = 'new_value' in line and line['new_value'] or '' old_value_text = 'old_value_text' in line and line['old_value_text'] or '' new_value_text = 'new_value_text' in line and line['new_value_text'] or '' if old_value_text == new_value_text: continue if field['ttype'] == 'many2one': if type(old_value) == tuple: old_value = old_value[0] if type(new_value) == tuple: new_value = new_value[0] vals = { "log_id": log_id, "field_id": field_id, "old_value": old_value, "new_value": new_value, "old_value_text": old_value_text, "new_value_text": new_value_text, "field_description": field['field_description'] } line_id = log_line_pool.create(cr, uid, vals)
def create_log_line(self, cr, uid, id, object, lines=[]): """ Creates lines for changed fields with its old and new values
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
def log_fct(self, db, uid, object, method, fct_src, *args):
def log_fct(self, db, uid, model, method, fct_src, *args):
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
@param method: method to log: create, read, write, unlink
@param method: method to log: create, read, write, unlink
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
@return: Returns result as per method of Object proxy """ logged_uids = []
@return: Returns result as per method of Object proxy """ res2 = args
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0]
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)
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
res_id = fct_src(db, uid, object, method, *args)
res_id = fct_src(db, uid, model.model, method, *args)
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
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)
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)
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
if method in ('write'): res_ids = args[0] for res_id in res_ids: old_values = pool.get(model_object.model).read(cr, uid, res_id, args[1].keys()) old_values_text = {} for field in args[1].keys(): old_values_text[field] = self.get_value_text(cr, uid, field, old_values[field], model_object) res = fct_src(db, uid, object, method, *args) cr.commit() if res: new_values = pool.get(model_object.model).read(cr, uid, res_ids, args[1].keys())[0] 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 '' id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name}) lines = [] for field in args[1].keys(): if args[1].keys(): line = { 'name': field, 'new_value': field in new_values and new_values[field] or '', 'old_value': field in old_values and old_values[field] or '', 'new_value_text': self.get_value_text(cr, uid, field, new_values[field], model_object), 'old_value_text': old_values_text[field] } lines.append(line) cr.commit() self.create_log_line(cr, uid, id, model_object, lines) cr.close() return res if method in ('read'):
elif method in ('read'):
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
res = fct_src(db, uid, object, method, *args)
res = fct_src(db, uid, model.model, method, *args)
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
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 '' id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name}) lines = [] for field in old_values[res_id]: if old_values[res_id][field]: line = { 'name': field, 'old_value': old_values[res_id][field], 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object) } lines.append(line) cr.commit() self.create_log_line(cr, uid, id, model_object, lines)
vals = { "method": method, "object_id": model.id, "user_id": uid, "res_id": res_id, } log_id = log_pool.create(cr, uid, vals) lines = [] for field in old_values[res_id]: line = { 'name': field, 'old_value': old_values[res_id][field], 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model) } lines.append(line) self.create_log_line(cr, uid, log_id, model, lines)
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
if method in ('unlink'):
elif method in ('unlink'):
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
old_values[res_id] = pool.get(model_object.model).read(cr, uid, res_id, [])
old_values[res_id] = resource_pool.read(cr, uid, 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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
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 '' id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
vals = { "method": method, "object_id": model.id, "user_id": uid, "res_id": res_id, } log_id = log_pool.create(cr, uid, vals) lines = [] for field in old_values[res_id]: if field in ('id'): continue line = { 'name': field, 'old_value': old_values[res_id][field], 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model) } lines.append(line) self.create_log_line(cr, uid, log_id, model, lines) res = fct_src(db, uid, model.model, method, *args) cr.commit() cr.close() return res else: res_ids = args[0] old_values = {} fields = [] if len(args)>1 and type(args[1]) == dict: fields = args[1].keys() if type(res_ids) in (long, int): res_ids = [res_ids] if res_ids: for resource in resource_pool.read(cr, uid, res_ids): resource_id = resource['id'] if 'id' in resource: del resource['id'] old_values_text = {} old_value = {} for field in resource.keys(): old_value[field] = resource[field] old_values_text[field] = self.get_value_text(cr, uid, field, resource[field], model) old_values[resource_id] = {'text':old_values_text, 'value': old_value} res = fct_src(db, uid, model.model, method, *args) cr.commit() if res_ids: for resource in resource_pool.read(cr, uid, res_ids): resource_id = resource['id'] if 'id' in resource: del resource['id'] vals = { "method": method, "object_id": model.id, "user_id": uid, "res_id": resource_id, } log_id = log_pool.create(cr, uid, vals)
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
for field in old_values[res_id]: if old_values[res_id][field]: line = { 'name': field, 'old_value': old_values[res_id][field], 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object) } lines.append(line) cr.commit() self.create_log_line(cr, uid, id, model_object, lines) res = fct_src(db, uid, object, method, *args)
for field in resource.keys(): line = { 'name': field, 'new_value': resource[field], 'old_value': old_values[resource_id]['value'][field], 'new_value_text': self.get_value_text(cr, uid, field, resource[field], model), 'old_value_text': old_values[resource_id]['text'][field] } lines.append(line) self.create_log_line(cr, uid, log_id, model, lines) cr.commit()
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
cr.close() def execute(self, db, uid, object, method, *args, **kw):
return True def execute(self, db, uid, model, method, *args, **kw):
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
@param method: method to log: create, read, write, unlink @return: Returns result as per method of Object proxy """
@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):
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
fct_src = super(audittrail_objects_proxy, self).execute 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) for thisrule in pool.get('audittrail.rule').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 field in ('read', 'write', 'create', 'unlink'): if getattr(thisrule, 'log_' + field): return self.log_fct(db, uid, object, method, fct_src, *args) return fct_src(db, uid, object, method, *args) res = my_fct(db, uid, object, method, *args)
fct_src = super(audittrail_objects_proxy, self).exec_workflow field = method rule = False model_pool = pool.get('ir.model') rule_pool = pool.get('audittrail.rule') model_ids = model_pool.search(cr, uid, [('model', '=', model)]) for obj_name in pool.obj_list(): if obj_name == 'audittrail.rule': rule = True if not rule: cr.close() return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv) if not model_ids: cr.close() return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv) rule_ids = rule_pool.search(cr, uid, [('object_id', 'in', model_ids), ('state', '=', 'subscribed')]) if not rule_ids: cr.close() return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv) 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 thisrule.log_workflow: cr.close() return self.log_fct(db, uid, model, method, fct_src, *args) cr.close() return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv)
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
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
return res
return True
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)
db704adb67985bd6eaad8c1dd3c5eac480aaa2ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/db704adb67985bd6eaad8c1dd3c5eac480aaa2ec/audittrail.py
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
1394a3272fefe6dd7f4fefe67cbedf3a27118ae5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1394a3272fefe6dd7f4fefe67cbedf3a27118ae5/base_vat.py
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
1394a3272fefe6dd7f4fefe67cbedf3a27118ae5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1394a3272fefe6dd7f4fefe67cbedf3a27118ae5/base_vat.py
return source cr = frame.f_locals.get('cr') try: lang = (frame.f_locals.get('context') or {}).get('lang', False) if not (cr and lang): args = frame.f_locals.get('args',False) if args: lang = args[-1].get('lang',False) if frame.f_globals.get('pooler',False): cr = pooler.get_db(frame.f_globals['pooler'].pool_dic.keys()[0]).cursor() if not (lang and cr): return source except: return source cr.execute('select value from ir_translation where lang=%s and type IN (%s,%s) and src=%s', (lang, 'code','sql_constraint', source)) res_trans = cr.fetchone() return res_trans and res_trans[0] or source
logger.warn('translation went wrong for string %s', repr(source)) finally: if is_new_cr: cr.close() return res
def __call__(self, source): try: frame = inspect.stack()[1][0] except: return source
34577af85f3d9b2a4f578e66cf47d86e5de7a3aa /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/34577af85f3d9b2a4f578e66cf47d86e5de7a3aa/translate.py
help="Total of Prospect Registrations"),
help="Total of Prospect Registrati./event/event.py:41:ons"),
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']
54e6589b272a82a0b1d1c2963f27837ff52f3066 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/54e6589b272a82a0b1d1c2963f27837ff52f3066/event.py
(_check_recursion, 'Error ! You cannot create recursive event.', ['parent_id'])
(_check_recursion, 'Error ! You cannot create recursive event.', ['parent_id']), (_check_closing_date, 'Error ! Closing Date cannot be set before Beginning Date.', ['date_end']),
def _check_recursion(self, cr, uid, ids): """ Checks for recursion level for event """ level = 100
54e6589b272a82a0b1d1c2963f27837ff52f3066 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/54e6589b272a82a0b1d1c2963f27837ff52f3066/event.py
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',
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
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 {}
e069d37fb1a47c9278cf9be48d42e11174e93f5a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e069d37fb1a47c9278cf9be48d42e11174e93f5a/stock_change_standard_price.py
return {}
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 {}
e069d37fb1a47c9278cf9be48d42e11174e93f5a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e069d37fb1a47c9278cf9be48d42e11174e93f5a/stock_change_standard_price.py
def draft_validate(self, cr, uid, ids, *args):
def draft_validate(self, cr, uid, ids, context=None):
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)
cff45072e7024a39ec3df798a8103499e8f412c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cff45072e7024a39ec3df798a8103499e8f412c0/stock.py
self.action_move(cr, uid, [pick.id]) wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr) return True
context.update({'active_ids':ids}) return { 'name': 'Make Picking', 'view_type': 'form', 'view_mode': 'form', 'res_model': 'stock.partial.picking', 'type': 'ir.actions.act_window', 'target': 'new', 'nodestroy': True, 'context':context }
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)
cff45072e7024a39ec3df798a8103499e8f412c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cff45072e7024a39ec3df798a8103499e8f412c0/stock.py
WHERE emp.id IN %s', (tuple(parent_ids),)) parent_ids = [x[0] for x in cr.fetchall() if x[0]]
WHERE emp.id IN %s AND res.user_id IS NOT NULL', (tuple(parent_ids),)) parent_ids = [x[0] for x in cr.fetchall()]
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
7d9d5287846fb261b6844229d4bf17cbf87e18b1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7d9d5287846fb261b6844229d4bf17cbf87e18b1/hr_department.py
cols = intersect(self._inherit_fields.keys(), set(fields_to_read) - set(self._columns.keys()))
cols = [x for x in intersect(self._inherit_fields.keys(), fields_to_read) if x not in self._columns.keys()]
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
e15952531b7825b653b7fee6847170446715dab6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e15952531b7825b653b7fee6847170446715dab6/orm.py
class record(yaml.YAMLObject): yaml_tag = u'!record' def __init__(self, model, id=None, attrs={}): self.model = model self.id = id self.attrs=attrs def __repr__(self): return '!record {model: %s, id: %s}:' % (str(self.model,), str(self.id,)) class workflow(yaml.YAMLObject): yaml_tag = u'!workflow' def __init__(self, model, action, ref=None): self.model = model self.ref = ref self.action=action def __repr__(self): return '!workflow {model: %s, action: %s, ref: %s}' % (str(self.model,), str(self.action,), str(self.ref,)) class ref(yaml.YAMLObject): yaml_tag = u'!ref' def __init__(self, expr="False"): self.expr = expr def __repr__(self): return 'ref(%s)' % (str(self.expr,)) class eval(yaml.YAMLObject): yaml_tag = u'!eval' def __init__(self, expr="False"): self.expr = expr def __repr__(self): return 'eval(%s)' % (str(self.expr,)) class function(yaml.YAMLObject): yaml_tag = u'!python' def __init__(self, model, action=None,attrs={}): self.model = model self.action = action self.attrs=attrs def __repr__(self): return '!python {model: %s}: |' % (str(self.model), )
from tools import yaml_tag
def doc_createXElement(xdoc, tagName): e = xElement(tagName) e.ownerDocument = xdoc return e
06b12c0192ce16139fc7f80b193698cffb7b3a8b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/06b12c0192ce16139fc7f80b193698cffb7b3a8b/base_module_record.py
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']]
e235f2a631a9eaa1c957dbbe638c0d85c0e21040 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e235f2a631a9eaa1c957dbbe638c0d85c0e21040/account_move_line.py
ids = ','.join([str(x) for x in context['periods']]) query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids, where_move_state, where_move_lines_by_date)
if initial_bal: query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause, where_move_state, where_move_lines_by_date) period_ids = fiscalperiod_obj.search(cr, uid, [('id', 'in', context['periods'])], order='date_start', limit=1) if period_ids and period_ids[0]: first_period = fiscalperiod_obj.browse(cr, uid, period_ids[0], context=context) periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<', first_period.date_start)]) periods = ','.join([str(x) for x in periods]) if periods: query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) OR id in (%s)) %s %s" % (fiscalyear_clause, periods, where_move_state, where_move_lines_by_date) else: ids = ','.join([str(x) for x in context['periods']]) query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids, where_move_state, where_move_lines_by_date)
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']]
e235f2a631a9eaa1c957dbbe638c0d85c0e21040 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e235f2a631a9eaa1c957dbbe638c0d85c0e21040/account_move_line.py
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
211d9c1d79f825dfa396607c6d05f674e15f5941 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/211d9c1d79f825dfa396607c6d05f674e15f5941/orm.py
attrs['selection'] = relation._name_search(cr, user, '', dom, context=search_context, limit=None, name_get_uid=1)
attrs['selection'] = relation._name_search(cr, 1, '', dom, context=search_context, limit=None, name_get_uid=1)
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
211d9c1d79f825dfa396607c6d05f674e15f5941 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/211d9c1d79f825dfa396607c6d05f674e15f5941/orm.py
res.update({'trans_nbr':data['credit']})
res.update({'credit':data['credit']})
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
2deeca8f09cb50cfb2244c842522ba638a05f5ac /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2deeca8f09cb50cfb2244c842522ba638a05f5ac/account_reconcile.py
res.update({'trans_nbr':data['debit']})
res.update({'debit':data['debit']})
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
2deeca8f09cb50cfb2244c842522ba638a05f5ac /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2deeca8f09cb50cfb2244c842522ba638a05f5ac/account_reconcile.py
res.update({'trans_nbr':data['writeoff']})
res.update({'writeoff':data['writeoff']})
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
2deeca8f09cb50cfb2244c842522ba638a05f5ac /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2deeca8f09cb50cfb2244c842522ba638a05f5ac/account_reconcile.py
'allounce':round(allow), 'deduction':round(deduct), 'grows':round(rs.basic + allow), 'net':round(rs.basic + allow - deduct),
'allounce':allow, 'deduction':deduct, 'grows':rs.basic + allow, 'net':rs.basic + allow - deduct,
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)
e0bd6974e23888d11f0954c282c2f73add98d1f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e0bd6974e23888d11f0954c282c2f73add98d1f2/hr_payroll.py
'total_pay':round(rs.basic + allow - deduct)
'total_pay':rs.basic + allow - deduct
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)
e0bd6974e23888d11f0954c282c2f73add98d1f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e0bd6974e23888d11f0954c282c2f73add98d1f2/hr_payroll.py
'basic_before_leaves': fields.float('Basic Salary', readonly=True, digits=(16, 2)), 'leaves': fields.float('Leave Deductions', readonly=True, digits=(16, 2)), 'basic': fields.float('Net Basic', readonly=True, digits=(16, 2)), 'grows': fields.function(_calculate, method=True, store=True, multi='dc', string='Gross Salary', type='float', digits=(16, 2)), 'net': fields.function(_calculate, method=True, store=True, multi='dc', string='Net Salary', digits=(16, 2)), 'allounce': fields.function(_calculate, method=True, store=True, multi='dc', string='Allowance', digits=(16, 2)), 'deduction': fields.function(_calculate, method=True, store=True, multi='dc', string='Deduction', digits=(16, 2)), 'other_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Others', digits=(16, 2)), 'total_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Total Payment', digits=(16, 2)),
'basic_before_leaves': fields.float('Basic Salary', readonly=True, digits_compute=dp.get_precision('Account')), 'leaves': fields.float('Leave Deductions', readonly=True, digits_compute=dp.get_precision('Account')), 'basic': fields.float('Net Basic', readonly=True, digits_compute=dp.get_precision('Account')), 'grows': fields.function(_calculate, method=True, store=True, multi='dc', string='Gross Salary', digits_compute=dp.get_precision('Account')), 'net': fields.function(_calculate, method=True, store=True, multi='dc', string='Net Salary', digits_compute=dp.get_precision('Account')), 'allounce': fields.function(_calculate, method=True, store=True, multi='dc', string='Allowance', digits_compute=dp.get_precision('Account')), 'deduction': fields.function(_calculate, method=True, store=True, multi='dc', string='Deduction', digits_compute=dp.get_precision('Account')), 'other_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Others', digits_compute=dp.get_precision('Account')), 'total_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Total Payment', digits_compute=dp.get_precision('Account')),
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)
e0bd6974e23888d11f0954c282c2f73add98d1f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e0bd6974e23888d11f0954c282c2f73add98d1f2/hr_payroll.py
'total': fields.float('Sub Total', readonly=True, digits=(16, 4)),
'total': fields.float('Sub Total', readonly=True, digits_compute=dp.get_precision('Account')),
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}}
e0bd6974e23888d11f0954c282c2f73add98d1f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e0bd6974e23888d11f0954c282c2f73add98d1f2/hr_payroll.py
dataobj = self.pool.get('ir.model.data') data_id = dataobj._get_id(cr, 1, 'base', 'group_user')
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
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
b153bdce7088c24acb75ba3de83ad1167ba68a08 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b153bdce7088c24acb75ba3de83ad1167ba68a08/res_user.py
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)
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
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) \
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
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
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
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
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
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
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)]))
parent_ids = tuple(account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)]))
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
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
'AND "user" IN %s',(parent_ids, user_ids,))
'AND "user" IN %s',(parent_ids, tuple(user_ids),))
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
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py