rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
(newrow, pos, w2, data_res_id2) = res2
(newrow, pos, w2, data_res_id2, xml_id2) = res2
def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0, skip=0): line = datas[position] row = {} warning = [] data_res_id = False nbrmax = position+1
21b9caa46b03594f484dc2233bc0a5c93c706cf5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21b9caa46b03594f484dc2233bc0a5c93c706cf5/orm.py
result = (row, nbrmax, warning, data_res_id)
result = (row, nbrmax, warning, data_res_id, xml_id)
def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0, skip=0): line = datas[position] row = {} warning = [] data_res_id = False nbrmax = position+1
21b9caa46b03594f484dc2233bc0a5c93c706cf5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21b9caa46b03594f484dc2233bc0a5c93c706cf5/orm.py
(res, position, warning, res_id) = \
(res, position, warning, res_id, xml_id) = \
fields_def = self.fields_get(cr, uid, context=context)
21b9caa46b03594f484dc2233bc0a5c93c706cf5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21b9caa46b03594f484dc2233bc0a5c93c706cf5/orm.py
current_module, res, mode=mode,
current_module, res, mode=mode, xml_id=xml_id,
fields_def = self.fields_get(cr, uid, context=context)
21b9caa46b03594f484dc2233bc0a5c93c706cf5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21b9caa46b03594f484dc2233bc0a5c93c706cf5/orm.py
AND name=%s"""
AND name=%s""",
def _get_source(self, cr, uid, name, types, lang, source=None): """ Returns the translation for the given combination of name, type, language and source. All values passed to this method should be unicode (not byte strings), especially ``source``.
96075073d1e871f6ea27e9bf189a95e15071f710 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/96075073d1e871f6ea27e9bf189a95e15071f710/ir_translation.py
data = super(ir_model, self).read(cr, uid, ids, fields=fields, \
data = super(ir_model, self).read(cr, uid, new_ids, fields=fields, \
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'): """ Overrides orm read method. @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of IR Model’s IDs. @param context: A standard dictionary for contextual values """ if not context: context = {} data = super(ir_model, self).read(cr, uid, ids, fields=fields, \ context=context, load=load) if data: for val in data: val['id'] = base_calendar_id2real_id(val['id']) return isinstance(ids, (str, int, long)) and data[0] or data
60ac84f9b9c8f7aae87cb69044ce8a5d8e120863 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60ac84f9b9c8f7aae87cb69044ce8a5d8e120863/base_calendar.py
sql =""" select sum(pieces*number) as bal from singer_statement where starting_id = %d """%(data['id'])
sql =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d """%(data['id'])
def _get_bal(self,data): res = {} sql =""" select sum(pieces*number) as bal from singer_statement where starting_id = %d """%(data['id']) self.cr.execute(sql) res = self.cr.dictfetchall() if res : return res[0]['bal'] else : return False
9a1ccd6f6a0be405b5f5142244a3a71d2a48d17d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9a1ccd6f6a0be405b5f5142244a3a71d2a48d17d/all_closed_cashbox_of_the_day.py
sql1 =""" select sum(pieces*number) as bal from singer_statement where starting_id = %d"""%(r['id'])
sql1 =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d"""%(r['id'])
def _get_net_total_starting(self,user): lst = [] res={} total_ending_bal = 0.0 total_starting_bal = 0.0 sql = """ SELECT abs.id,abs.balance_end_real as net_total FROM account_bank_statement as abs WHERE to_char(date_trunc('day',abs.date),'YYYY-MM-DD')::date = current_date and abs.state IN ('confirm','open') and abs.user_id = %d"""%(user.id) self.cr.execute(sql) res = self.cr.dictfetchall() for r in res : total_ending_bal += (r['net_total'] or 0.0) sql1 =""" select sum(pieces*number) as bal from singer_statement where starting_id = %d"""%(r['id']) self.cr.execute(sql1) data = self.cr.dictfetchall() if data[0]['bal']: total_starting_bal += data[0]['bal'] lst.append(total_ending_bal) lst.append(total_starting_bal) return lst
9a1ccd6f6a0be405b5f5142244a3a71d2a48d17d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9a1ccd6f6a0be405b5f5142244a3a71d2a48d17d/all_closed_cashbox_of_the_day.py
partner_id = self.pool.get('account.move.line').read(cr, uid, context['active_id'], ['partner_id'])['partner_id'][0] self.pool.get('res.partner').write(cr, uid, partner_id, {'last_reconciliation_date': time.strftime('%Y-%m-%d')}, context)
partner_id = self.pool.get('account.move.line').read(cr, uid, context['active_id'], ['partner_id'])['partner_id'] if partner_id: self.pool.get('res.partner').write(cr, uid, partner_id[0], {'last_reconciliation_date': time.strftime('%Y-%m-%d')}, context)
def next_partner(self, cr, uid, ids, context=None): partner_id = self.pool.get('account.move.line').read(cr, uid, context['active_id'], ['partner_id'])['partner_id'][0] self.pool.get('res.partner').write(cr, uid, partner_id, {'last_reconciliation_date': time.strftime('%Y-%m-%d')}, context) #TODO: we have to find a way to update the context of the current tab (we could open a new tab with the context but it's not really handy) #TODO: remove that comments when the client side dev is done return {}
fb2ad5e31d1c43eecff6672baaa8830d7d73c4fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fb2ad5e31d1c43eecff6672baaa8830d7d73c4fe/account_reconcile_partner_process.py
res = res and res[0] or None
res = res and res[0] or 0.0
def __pos_payment_user__total__(self, form): res=[] ids = form['user_id'] self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \ "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \ "and po.state='paid' and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date " \ "and po.user_id IN %s",(tuple(ids),)) res=self.cr.fetchone() res = res and res[0] or None
30ec71647b3e2c01b48c1efb1b36a5913371d3b4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/30ec71647b3e2c01b48c1efb1b36a5913371d3b4/pos_payment_report_user.py
journal_id, period_id = cr.fetchone() result['domain'] = str([('journal_id', '=', journal_id), ('period_id', '=', period_id)]) result['context'] = str({'journal_id': journal_id, 'period_id': period_id})
res = cr.fetchone() if res: journal_id, period_id = res result['domain'] = str([('journal_id', '=', journal_id), ('period_id', '=', period_id)]) result['context'] = str({'journal_id': journal_id, 'period_id': period_id})
def action_open_window(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') if context is None: context = {}
5c6daf7faf5cdf831d0f9230ac4df44ae8306a96 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5c6daf7faf5cdf831d0f9230ac4df44ae8306a96/account_journal_select.py
current_period = self.pool.get('account.period').find(cr, uid)[0]
current_period = period_obj.find(cr, uid)[0]
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): for arg in args: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = self.pool.get('account.period').find(cr, uid)[0] args.append(['period_id','in',[current_period]]) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] args.append(['period_id','in',ids]) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in args: args.remove(a) return super(account_entries_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order, context=context, count=count)
cfac8a4d9dffdd6591b868464063b68e7ca4a1cb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cfac8a4d9dffdd6591b868464063b68e7ca4a1cb/account_entries_report.py
current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
current_year = fiscalyear_obj.find(cr, uid) ids = fiscalyear_obj.read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): for arg in args: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = self.pool.get('account.period').find(cr, uid)[0] args.append(['period_id','in',[current_period]]) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] args.append(['period_id','in',ids]) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in args: args.remove(a) return super(account_entries_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order, context=context, count=count)
cfac8a4d9dffdd6591b868464063b68e7ca4a1cb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cfac8a4d9dffdd6591b868464063b68e7ca4a1cb/account_entries_report.py
current_period = self.pool.get('account.period').find(cr, uid)[0]
current_period = period_obj.find(cr, uid)[0]
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): todel=[] for arg in domain: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = self.pool.get('account.period').find(cr, uid)[0] domain.append(['period_id','in',[current_period]]) todel.append(arg) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] domain.append(['period_id','in',ids]) todel.append(arg) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in domain: domain.remove(a) return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context)
cfac8a4d9dffdd6591b868464063b68e7ca4a1cb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cfac8a4d9dffdd6591b868464063b68e7ca4a1cb/account_entries_report.py
current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
current_year = fiscalyear_obj.find(cr, uid) ids = fiscalyear_obj.read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): todel=[] for arg in domain: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = self.pool.get('account.period').find(cr, uid)[0] domain.append(['period_id','in',[current_period]]) todel.append(arg) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] domain.append(['period_id','in',ids]) todel.append(arg) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in domain: domain.remove(a) return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context)
cfac8a4d9dffdd6591b868464063b68e7ca4a1cb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cfac8a4d9dffdd6591b868464063b68e7ca4a1cb/account_entries_report.py
print child_ids
def read_group(self, cr, user, ids, fields, groupby, context=None): context = context or {} result = [] if not ids:return
d904c93dd70aa3d67b69cd404932845e8d952e20 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d904c93dd70aa3d67b69cd404932845e8d952e20/orm.py
parent_val_dict = {'id':x[0],groupby:(x[0],groupby_name[x[0]]),'group_child':child_ids_dict[x[0]]}
parent_val_dict = {'id':None,groupby:(x[0],groupby_name[x[0]]),'group_child':child_ids_dict[x[0]]}
def read_group(self, cr, user, ids, fields, groupby, context=None): context = context or {} result = [] if not ids:return
d904c93dd70aa3d67b69cd404932845e8d952e20 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d904c93dd70aa3d67b69cd404932845e8d952e20/orm.py
rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False
rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value_reference','res_id']) pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value_reference','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False acc_id = False bank_id = False fiscal_position = False
c74f49b3fa62f07da6b58929800e0159ae57fcc4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c74f49b3fa62f07da6b58929800e0159ae57fcc4/invoice.py
rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False
rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value_reference','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value_reference','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not pay_res_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} account_obj = self.pool.get('account.account') if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = account_obj.browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configuration Error !'), _('Invoice line account company does not match with invoice company.')) else: continue if company_id and type: if type in ('out_invoice'): journal_type = 'sale' elif type in ('out_refund'): journal_type = 'sale_refund' elif type in ('in_refund'): journal_type = 'purchase_refund' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configuration Error !'), _('Can\'t find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Financial Accounting\Accounts\Journals.' % (journal_type))) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, [])
c74f49b3fa62f07da6b58929800e0159ae57fcc4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c74f49b3fa62f07da6b58929800e0159ae57fcc4/invoice.py
'state':'draft', 'number':False, 'move_id':False,
'state':'draft', 'number':False, 'move_id':False,
def copy(self, cr, uid, id, default={}, context=None): default.update({ 'state':'draft', 'number':False, 'move_id':False, 'move_name':False, 'internal_number': False, }) if 'date_invoice' not in default: default.update({ 'date_invoice':False }) if 'date_due' not in default: default.update({ 'date_due':False }) return super(account_invoice, self).copy(cr, uid, id, default, context)
b1f39a97fe0954ca02c49c6dd87a213a26911247 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b1f39a97fe0954ca02c49c6dd87a213a26911247/invoice.py
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference or ''
b1f39a97fe0954ca02c49c6dd87a213a26911247 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b1f39a97fe0954ca02c49c6dd87a213a26911247/invoice.py
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference or ''
b1f39a97fe0954ca02c49c6dd87a213a26911247 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b1f39a97fe0954ca02c49c6dd87a213a26911247/invoice.py
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference or ''
b1f39a97fe0954ca02c49c6dd87a213a26911247 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b1f39a97fe0954ca02c49c6dd87a213a26911247/invoice.py
if not name: result['name'] = res.partner_ref
result['name'] = res.partner_ref
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos_obj = self.pool.get('account.fiscal.position') fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id) or False
b1f39a97fe0954ca02c49c6dd87a213a26911247 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b1f39a97fe0954ca02c49c6dd87a213a26911247/invoice.py
"""
"""
def _child_compute(self, cr, uid, ids, name, arg, context={}): """ @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID of mrp.production object @param name: @param arg:
e3cd823031c382369be6fdc654dc96aea91a478c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e3cd823031c382369be6fdc654dc96aea91a478c/mrp.py
result[bom.id] += map(lambda x: x.id, bom2.bom_lines) print "name",name print "arg",arg print "result",result
result[bom.id] += map(lambda x: x.id, bom2.bom_lines)
def _child_compute(self, cr, uid, ids, name, arg, context={}): """ @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID of mrp.production object @param name: @param arg:
e3cd823031c382369be6fdc654dc96aea91a478c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e3cd823031c382369be6fdc654dc96aea91a478c/mrp.py
'readonly': True,
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) pick_obj = self.pool.get('stock.picking') picking_ids = context.get('active_ids', False) _moves_arch_lst = """<form string="Deliver Products"> <separator colspan="4" string="Delivery Information"/> <group colspan="4" col="4"> <field name="date"/> </group> <separator colspan="4" string="Move Detail"/> """ _moves_fields = result['fields'] if picking_ids and view_type in ['form']: for pick in pick_obj.browse(cr, uid, picking_ids, context): for m in pick.move_lines: if m.state in ('done', 'cancel'): continue _moves_fields.update({ 'move%s_product_id'%(m.id) : { 'string': _('Product'), 'type' : 'many2one', 'relation': 'product.product', 'required' : True, 'readonly' : True, }, 'move%s_product_qty'%(m.id) : { 'string': _('Quantity'), 'type' : 'float', 'required': True, }, 'move%s_product_uom'%(m.id) : { 'string': _('Product UOM'), 'type' : 'many2one', 'relation': 'product.uom', 'required' : True, 'readonly' : True, }, 'move%s_prodlot_id'%(m.id): { 'string': _('Production Lot'), 'type': 'many2one', 'relation': 'stock.production.lot', 'readonly': True, } })
5fc0c4695709a2a7350b43a111186664eefcd7fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5fc0c4695709a2a7350b43a111186664eefcd7fe/stock_partial_picking.py
cr.execute("update ir_module_module set state=%s where name=%s", ('uninstallable', module)) continue
raise osv.osv.except_osv('Error!',"Module '%s' was not found" % (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, '__terp__.py') if not mod_path or not terp_file: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable' % (module)) cr.execute("update ir_module_module set state=%s where name=%s", ('uninstallable', module)) continue 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
740101d9263ea4483c2426f2f67282589a5039af /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/740101d9263ea4483c2426f2f67282589a5039af/__init__.py
def load_modules(db, force_demo=False, status=None, update_module=False): if not status: status = {} cr = db.cursor() if cr: cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='ir_module_module'") if len(cr.fetchall())==0: logger.notifyChannel("init", netsvc.LOG_INFO, "init db") tools.init_db(cr)
740101d9263ea4483c2426f2f67282589a5039af /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/740101d9263ea4483c2426f2f67282589a5039af/__init__.py
if not_loaded: return
def load_modules(db, force_demo=False, status=None, update_module=False): if not status: status = {} cr = db.cursor() if cr: cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='ir_module_module'") if len(cr.fetchall())==0: logger.notifyChannel("init", netsvc.LOG_INFO, "init db") tools.init_db(cr)
740101d9263ea4483c2426f2f67282589a5039af /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/740101d9263ea4483c2426f2f67282589a5039af/__init__.py
raise _('The search method is not implemented on this object !')
raise NotImplementedError(_('The search method is not implemented on this object !'))
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): raise _('The search method is not implemented on this object !')
b04e81c95e848f773e3ccac2679c017630f59651 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b04e81c95e848f773e3ccac2679c017630f59651/orm.py
raise _('The name_get method is not implemented on this object !')
raise NotImplementedError(_('The name_get method is not implemented on this object !'))
def name_get(self, cr, user, ids, context=None): raise _('The name_get method is not implemented on this object !')
b04e81c95e848f773e3ccac2679c017630f59651 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b04e81c95e848f773e3ccac2679c017630f59651/orm.py
raise _('The name_search method is not implemented on this object !')
raise NotImplementedError(_('The name_search method is not implemented on this object !'))
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): raise _('The name_search method is not implemented on this object !')
b04e81c95e848f773e3ccac2679c017630f59651 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b04e81c95e848f773e3ccac2679c017630f59651/orm.py
raise _('The copy method is not implemented on this object !')
raise NotImplementedError(_('The copy method is not implemented on this object !'))
def copy(self, cr, uid, id, default=None, context=None): raise _('The copy method is not implemented on this object !')
b04e81c95e848f773e3ccac2679c017630f59651 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b04e81c95e848f773e3ccac2679c017630f59651/orm.py
raise _('The exists method is not implemented on this object !')
raise NotImplementedError(_('The exists method is not implemented on this object !'))
def exists(self, cr, uid, id, context=None): raise _('The exists method is not implemented on this object !')
b04e81c95e848f773e3ccac2679c017630f59651 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b04e81c95e848f773e3ccac2679c017630f59651/orm.py
to_char(s.create_date, 'MM'),h.user_id,h.state, h.category_id, h.department_id
to_char(s.create_date, 'MM'), to_char(s.create_date, 'YYYY-MM-DD'), h.user_id,h.state, h.category_id, h.department_id
def init(self, cr): tools.drop_view_if_exists(cr, 'available_holidays_report') cr.execute(""" create or replace view available_holidays_report as ( select min(h.id) as id, date_trunc('day',h.create_date) as date, to_char(s.create_date, 'YYYY') as year, to_char(s.create_date, 'MM') as month, to_char(s.create_date, 'YYYY-MM-DD') as day, h.employee_id as employee_id, h.category_id as category_id, h.user_id as user_id, h.department_id, h.state as state, h.holiday_status_id as holiday_status_id, sum(number_of_days) as remaining_leave, (select sum(number_of_days_temp) from hr_holidays where type='remove' and employee_id=h.employee_id and holiday_status_id=h.holiday_status_id and state='validate') as taken_leaves, (select sum(number_of_days_temp) from hr_holidays where type='add' and employee_id=h.employee_id and holiday_status_id=h.holiday_status_id and state='validate') as max_leave from hr_holidays h left join hr_holidays_status s on (s.id = h.holiday_status_id) where h.state='validate' and s.active <> 'f' group by h.holiday_status_id, h.employee_id, date_trunc('day',h.create_date),to_char(s.create_date, 'YYYY'), to_char(s.create_date, 'MM'),h.user_id,h.state, h.category_id, h.department_id
95ee96a179b2500151022825d8a8549c8c635302 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/95ee96a179b2500151022825d8a8549c8c635302/available_holidays.py
srctz = pytz.timezone('GMT') date_gmt = date_1.replace(tzinfo=srctz).astimezone(desttz).strftime('%Y-%m-%d %H:%M:%S')
date_gmt = date_1.replace(tzinfo=pytz.utc).astimezone(desttz).strftime('%Y-%m-%d %H:%M:%S')
def create_ics(self, cr, uid, datas, name, ical, context=None): """ create calendaring and scheduling information @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """
bd76d0a66a42c534bfa21fa9e408b13c13e60ae3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bd76d0a66a42c534bfa21fa9e408b13c13e60ae3/calendar.py
return "Click 'Continue' to configure the next addon..." return "Your database is now fully configured.\n\n"\ "Click 'Continue' and enjoy your OpenERP experience..."
return _("Click 'Continue' to configure the next addon...") return _("Your database is now fully configured.\n\n"\ "Click 'Continue' and enjoy your OpenERP experience...")
def _next_action_note(self, cr, uid, ids, context=None): next = self._next_action(cr, uid) if next: # if the next one is also an old-style extension, you never know... if next.note: return next.note return "Click 'Continue' to configure the next addon..." return "Your database is now fully configured.\n\n"\ "Click 'Continue' and enjoy your OpenERP experience..."
a86a432edf0382fa33b8333024b0924c69fa0546 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a86a432edf0382fa33b8333024b0924c69fa0546/res_config.py
def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) msg = {} if not message_id: return False fields = msg_txt.keys() msg['id'] = message_id msg['message-id'] = message_id if 'Subject' in fields: msg['subject'] = msg_txt.get('Subject') if 'Content-Type' in fields: msg['content-type'] = msg_txt.get('Content-Type') if 'From' in fields: msg['from'] = msg_txt.get('From') if 'Delivered-To' in fields: msg['to'] = msg_txt.get('Delivered-To') if 'Cc' in fields: msg['cc'] = msg_txt.get('Cc') if 'Reply-To' in fields: msg['reply'] = msg_txt.get('Reply-To') if 'Date' in fields: msg['date'] = msg_txt.get('Date') if 'Content-Transfer-Encoding' in fields: msg['encoding'] = msg_txt.get('Content-Transfer-Encoding') if 'References' in fields: msg['references'] = msg_txt.get('References')
9697f8b04341af6e76937c14d38255813219660b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9697f8b04341af6e76937c14d38255813219660b/fetchmail.py
msg['subject'] = msg_txt.get('Subject')
msg['subject'] = ' '.join(map(lambda (x, y): unicode(x, y or 'ascii'), decode_header(msg_txt.get('Subject'))))
def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) msg = {} if not message_id: return False fields = msg_txt.keys() msg['id'] = message_id msg['message-id'] = message_id if 'Subject' in fields: msg['subject'] = msg_txt.get('Subject') if 'Content-Type' in fields: msg['content-type'] = msg_txt.get('Content-Type') if 'From' in fields: msg['from'] = msg_txt.get('From') if 'Delivered-To' in fields: msg['to'] = msg_txt.get('Delivered-To') if 'Cc' in fields: msg['cc'] = msg_txt.get('Cc') if 'Reply-To' in fields: msg['reply'] = msg_txt.get('Reply-To') if 'Date' in fields: msg['date'] = msg_txt.get('Date') if 'Content-Transfer-Encoding' in fields: msg['encoding'] = msg_txt.get('Content-Transfer-Encoding') if 'References' in fields: msg['references'] = msg_txt.get('References')
9697f8b04341af6e76937c14d38255813219660b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9697f8b04341af6e76937c14d38255813219660b/fetchmail.py
print 'avant', result
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
d716dd6bb6ed3586cc83747e569c654cfc6d0f08 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d716dd6bb6ed3586cc83747e569c654cfc6d0f08/ir_values.py
print 'avant', res2
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
d716dd6bb6ed3586cc83747e569c654cfc6d0f08 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d716dd6bb6ed3586cc83747e569c654cfc6d0f08/ir_values.py
print 'apres', res2
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
d716dd6bb6ed3586cc83747e569c654cfc6d0f08 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d716dd6bb6ed3586cc83747e569c654cfc6d0f08/ir_values.py
query = "SELECT id FROM account_fiscalyear WHERE date_stop < '" + str(new_fyear.date_start) + "'" cr.execute(query) result = cr.dictfetchall() fy_ids = ','.join([str(x['id']) for x in result])
def _data_save(self, cr, uid, data, context): if not data['form']['sure']: raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year cancelled, please check the box !')) pool = pooler.get_pool(cr.dbname) fy_id = data['form']['fy_id'] period_ids = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', fy_id)]) fy_period_set = ','.join(map(str, period_ids)) periods_fy2 = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fy2_id'])]) fy2_period_set = ','.join(map(str, periods_fy2)) period = pool.get('account.period').browse(cr, uid, data['form']['period_id'], context=context) new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'], context=context) old_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy_id'], context=context) new_journal = data['form']['journal_id'] new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context) if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id: raise wizard.except_wizard(_('UserError'), _('The journal must have default credit and debit account')) if not new_journal.centralisation: raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart')) move_ids = pool.get('account.move.line').search(cr, uid, [ ('journal_id','=',new_journal.id),('period_id.fiscalyear_id','=',new_fyear.id)]) if move_ids: raise wizard.except_wizard(_('UserError'), _('The opening journal must not have any entry in the new fiscal year !')) query_line = pool.get('account.move.line')._query_get(cr, uid, obj='account_move_line', context={'fiscalyear': fy_id}) cr.execute('select id from account_account WHERE active') ids = map(lambda x: x[0], cr.fetchall()) for account in pool.get('account.account').browse(cr, uid, ids, context={'fiscalyear': fy_id}): accnt_type_data = account.user_type if not accnt_type_data: continue if accnt_type_data.close_method=='none' or account.type == 'view': continue if accnt_type_data.close_method=='balance': if abs(account.balance)>0.0001: pool.get('account.move.line').create(cr, uid, { 'debit': account.balance>0 and account.balance, 'credit': account.balance<0 and -account.balance, 'name': data['form']['report_name'], 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, 'account_id': account.id }, {'journal_id': new_journal.id, 'period_id':period.id}) if accnt_type_data.close_method == 'unreconciled': offset = 0 limit = 100 while True: cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'AND reconcile_id is NULL ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, 'period_id': period.id, }) offset += limit #We have also to consider all move_lines that were reconciled #on another fiscal year, and report them too offset = 0 limit = 100 while True: #TODO: this query could be improved in order to work if there is more than 2 open FY # a.period_id IN ('+fy2_period_set+') is the problematic clause cr.execute('SELECT b.id, b.name, b.quantity, b.debit, b.credit, b.account_id, b.ref, ' \ 'b.amount_currency, b.currency_id, b.blocked, b.partner_id, ' \ 'b.date_maturity, b.date_created ' \ 'FROM account_move_line a, account_move_line b ' \ 'WHERE b.account_id = %s ' \ 'AND b.reconcile_id is NOT NULL ' \ 'AND a.reconcile_id = b.reconcile_id ' \ 'AND b.period_id IN ('+fy_period_set+') ' \ 'AND a.period_id IN ('+fy2_period_set+') ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, 'period_id': period.id, }) offset += limit if accnt_type_data.close_method=='detail': offset = 0 limit = 100 while True: cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move) offset += limit ids = pool.get('account.move.line').search(cr, uid, [('journal_id','=',new_journal.id), ('period_id.fiscalyear_id','=',new_fyear.id)]) context['fy_closing'] = True if ids: pool.get('account.move.line').reconcile(cr, uid, ids, context=context) new_period = data['form']['period_id'] ids = pool.get('account.journal.period').search(cr, uid, [('journal_id','=',new_journal.id),('period_id','=',new_period)]) if not ids: ids = [pool.get('account.journal.period').create(cr, uid, { 'name': (new_journal.name or '')+':'+(period.code or ''), 'journal_id': new_journal.id, 'period_id': period.id })] cr.execute('UPDATE account_fiscalyear ' \ 'SET end_journal_period_id = %s ' \ 'WHERE id = %s', (ids[0], old_fyear.id)) return {}
9683d25c9b17a7db402b29375e37ebe27e677100 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9683d25c9b17a7db402b29375e37ebe27e677100/wizard_fiscalyear_close.py
obj='account_move_line', context={'fiscalyear': fy_id})
obj='account_move_line', context={'fiscalyear': fy_ids})
def _data_save(self, cr, uid, data, context): if not data['form']['sure']: raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year cancelled, please check the box !')) pool = pooler.get_pool(cr.dbname) fy_id = data['form']['fy_id'] period_ids = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', fy_id)]) fy_period_set = ','.join(map(str, period_ids)) periods_fy2 = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fy2_id'])]) fy2_period_set = ','.join(map(str, periods_fy2)) period = pool.get('account.period').browse(cr, uid, data['form']['period_id'], context=context) new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'], context=context) old_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy_id'], context=context) new_journal = data['form']['journal_id'] new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context) if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id: raise wizard.except_wizard(_('UserError'), _('The journal must have default credit and debit account')) if not new_journal.centralisation: raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart')) move_ids = pool.get('account.move.line').search(cr, uid, [ ('journal_id','=',new_journal.id),('period_id.fiscalyear_id','=',new_fyear.id)]) if move_ids: raise wizard.except_wizard(_('UserError'), _('The opening journal must not have any entry in the new fiscal year !')) query_line = pool.get('account.move.line')._query_get(cr, uid, obj='account_move_line', context={'fiscalyear': fy_id}) cr.execute('select id from account_account WHERE active') ids = map(lambda x: x[0], cr.fetchall()) for account in pool.get('account.account').browse(cr, uid, ids, context={'fiscalyear': fy_id}): accnt_type_data = account.user_type if not accnt_type_data: continue if accnt_type_data.close_method=='none' or account.type == 'view': continue if accnt_type_data.close_method=='balance': if abs(account.balance)>0.0001: pool.get('account.move.line').create(cr, uid, { 'debit': account.balance>0 and account.balance, 'credit': account.balance<0 and -account.balance, 'name': data['form']['report_name'], 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, 'account_id': account.id }, {'journal_id': new_journal.id, 'period_id':period.id}) if accnt_type_data.close_method == 'unreconciled': offset = 0 limit = 100 while True: cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'AND reconcile_id is NULL ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, 'period_id': period.id, }) offset += limit #We have also to consider all move_lines that were reconciled #on another fiscal year, and report them too offset = 0 limit = 100 while True: #TODO: this query could be improved in order to work if there is more than 2 open FY # a.period_id IN ('+fy2_period_set+') is the problematic clause cr.execute('SELECT b.id, b.name, b.quantity, b.debit, b.credit, b.account_id, b.ref, ' \ 'b.amount_currency, b.currency_id, b.blocked, b.partner_id, ' \ 'b.date_maturity, b.date_created ' \ 'FROM account_move_line a, account_move_line b ' \ 'WHERE b.account_id = %s ' \ 'AND b.reconcile_id is NOT NULL ' \ 'AND a.reconcile_id = b.reconcile_id ' \ 'AND b.period_id IN ('+fy_period_set+') ' \ 'AND a.period_id IN ('+fy2_period_set+') ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, 'period_id': period.id, }) offset += limit if accnt_type_data.close_method=='detail': offset = 0 limit = 100 while True: cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move) offset += limit ids = pool.get('account.move.line').search(cr, uid, [('journal_id','=',new_journal.id), ('period_id.fiscalyear_id','=',new_fyear.id)]) context['fy_closing'] = True if ids: pool.get('account.move.line').reconcile(cr, uid, ids, context=context) new_period = data['form']['period_id'] ids = pool.get('account.journal.period').search(cr, uid, [('journal_id','=',new_journal.id),('period_id','=',new_period)]) if not ids: ids = [pool.get('account.journal.period').create(cr, uid, { 'name': (new_journal.name or '')+':'+(period.code or ''), 'journal_id': new_journal.id, 'period_id': period.id })] cr.execute('UPDATE account_fiscalyear ' \ 'SET end_journal_period_id = %s ' \ 'WHERE id = %s', (ids[0], old_fyear.id)) return {}
9683d25c9b17a7db402b29375e37ebe27e677100 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9683d25c9b17a7db402b29375e37ebe27e677100/wizard_fiscalyear_close.py
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): ids = super(ir_ui_menu, self).search(cr, uid, args, offset=0, limit=None, order=order, context=context, count=False) if not ids: if count: return 0 return []
def _filter_visible_menus(self, cr, uid, ids, context=None): """Filters the give menu ids to only keep the menu items that should be visible in the menu hierarchy of the current user. Uses a cache for speeding up the computation. """
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
498a04ae2d5f9cbb170ea1d2f08e9ab773d9a8a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/498a04ae2d5f9cbb170ea1d2f08e9ab773d9a8a9/ir_ui_menu.py
for menu in self.browse(cr, uid, ids):
for menu in self.browse(cr, uid, ids, context=context):
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
498a04ae2d5f9cbb170ea1d2f08e9ab773d9a8a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/498a04ae2d5f9cbb170ea1d2f08e9ab773d9a8a9/ir_ui_menu.py
'project_id':_get_project,
'project_id':_get_project, 'probability':lambda *a:0.0, 'planned_cost':lambda *a:0.0, 'planned_revenue':lambda *a:0.0,
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}): if not stage_id: return {'value':{}} stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context) if not stage.on_change: return {'value':{}} return {'value':{'probability':stage.probability}}
69fb27723d372d51924c3288665abe4c0aee3b44 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/69fb27723d372d51924c3288665abe4c0aee3b44/crm_project_bug.py
for datas in self.read(cr, uid, ids):
for datas in self.read(cr, uid, ids, context=context):
def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Get rule string. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False elif datas.get('rrule_type') == 'custom': rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context)
45256557dc1239459c984a2a994a7cb3fb7c5eb0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/45256557dc1239459c984a2a994a7cb3fb7c5eb0/base_calendar.py
result[event] = False
result[datas['id']] = False
def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Get rule string. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False elif datas.get('rrule_type') == 'custom': rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context)
45256557dc1239459c984a2a994a7cb3fb7c5eb0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/45256557dc1239459c984a2a994a7cb3fb7c5eb0/base_calendar.py
rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom
rrule_custom = self.compute_rule_string(cr, uid, datas,\ context=context) result[datas['id']] = rrule_custom
def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Get rule string. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False elif datas.get('rrule_type') == 'custom': rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context)
45256557dc1239459c984a2a994a7cb3fb7c5eb0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/45256557dc1239459c984a2a994a7cb3fb7c5eb0/base_calendar.py
result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context)
result[datas['id']] = self.compute_rule_string(cr, uid, {'freq': datas.get('rrule_type').upper(), 'interval': 1}, context=context)
def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Get rule string. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False elif datas.get('rrule_type') == 'custom': rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context)
45256557dc1239459c984a2a994a7cb3fb7c5eb0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/45256557dc1239459c984a2a994a7cb3fb7c5eb0/base_calendar.py
res[pick]['min_date'] = dt1 res[pick]['max_date'] = dt2
res[pick]['min_date'] = dt1 res[pick]['max_date'] = dt2
def get_min_max_date(self, cr, uid, ids, field_name, arg, context=None): """ Finds minimum and maximum dates for picking. @return: Dictionary of values """ res = {} for id in ids: res[id] = {'min_date': False, 'max_date': False} if not ids: return res cr.execute("""select picking_id, min(date_expected), max(date_expected) from stock_move where picking_id IN %s group by picking_id""",(tuple(ids),)) for pick, dt1, dt2 in cr.fetchall(): res[pick]['min_date'] = dt1 res[pick]['max_date'] = dt2 return res
2626459b5fc8494406d885663ad7bd06396998c1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2626459b5fc8494406d885663ad7bd06396998c1/stock.py
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']]
fiscalyear_ids = [context['fiscalyear']]
def _query_get(self, cr, uid, obj='l', context=None): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') account_obj = self.pool.get('account.account') fiscalyear_ids = [] if context is None: context = {} 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']]
d3f5955317583a2e0d11a9d815e37949a9880806 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d3f5955317583a2e0d11a9d815e37949a9880806/account_move_line.py
def create(self, cr, uid, vals, context=None, check=True): account_obj = self.pool.get('account.account') tax_obj = self.pool.get('account.tax') move_obj = self.pool.get('account.move') cur_obj = self.pool.get('res.currency') journal_obj = self.pool.get('account.journal') if context is None: context = {} if vals.get('move_id', False): company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False) if company_id: vals['company_id'] = company_id[0] self._check_date(cr, uid, vals, context, check) if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals: context['journal_id'] = vals['journal_id'] if 'period_id' in vals: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = move_obj.browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
d3f5955317583a2e0d11a9d815e37949a9880806 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d3f5955317583a2e0d11a9d815e37949a9880806/account_move_line.py
'arch':view
'arch': view
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Returns views and fields for current model where view will depend on {view_type}. @param cr: A database cursor @param user: ID of the user currently logged in @param view_id: list of fields, which required to read signatures @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx) @param context: context arguments, like lang, time zone @param toolbar: contains a list of reports, wizards, and links related to current model
e0c99e20f61553d68861fb44121d7e4ed46ff739 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e0c99e20f61553d68861fb44121d7e4ed46ff739/account_move_journal.py
[res['base_pricelist_id']], prod_id,
[res['base_pricelist_id']], product_id,
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
58d8d88e28c480347effe9b5bb6565b78fe34542 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58d8d88e28c480347effe9b5bb6565b78fe34542/pricelist.py
[res['base_pricelist_id']], prod_id,
[res['base_pricelist_id']], product_id,
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
58d8d88e28c480347effe9b5bb6565b78fe34542 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58d8d88e28c480347effe9b5bb6565b78fe34542/pricelist.py
product.id, qty or 1.0, partner_id, {'uom': uom,'date': date_order })[pricelist]
product.id, qty or 1.0, partner_id, {'uom': uom,'date': date_order })
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True,date_order=False,packaging=False,fiscal_position=False, flag=False):
93a68feaf7e020921cf2f46332790f1f9c41c44d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/93a68feaf7e020921cf2f46332790f1f9c41c44d/product.py
pricelists=pricelist_obj.read(cr,uid,[pricelist],['visible_discount'])
pricelists = pricelist_obj.read(cr,uid,[pricelist],['visible_discount'])
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True,date_order=False,packaging=False,fiscal_position=False, flag=False):
93a68feaf7e020921cf2f46332790f1f9c41c44d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/93a68feaf7e020921cf2f46332790f1f9c41c44d/product.py
new_list_price = product_uom_obj._compute_price(cr, uid, old_uom.id, list_price, uom) if(len(pricelists)>0 and pricelists[0]['visible_discount'] and list_price != 0): discount=(new_list_price-price) / new_list_price * 100
new_list_price = get_real_price(list_price, product.id, pricelist) if(len(pricelists)>0 and pricelists[0]['visible_discount'] and list_price[pricelist] != 0): discount = (new_list_price - price) / new_list_price * 100
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True,date_order=False,packaging=False,fiscal_position=False, flag=False):
93a68feaf7e020921cf2f46332790f1f9c41c44d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/93a68feaf7e020921cf2f46332790f1f9c41c44d/product.py
_inherit = "project.projesct"
_inherit = "project.project"
def write(self, cr, uid, ids,vals,context=None): if context is None: context = {} if vals.get('project_id',False) or vals.get('name',False): vals_line = {} hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet') task_obj_l = self.browse(cr, uid, ids, context) if vals.get('project_id',False): project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id']) acc_id = project_obj.analytic_account_id.id
0e56e3702941a77ae16537be0d76e03481242239 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0e56e3702941a77ae16537be0d76e03481242239/project_timesheet.py
'name':fields.char('Description', size=256, required=True),
'name':fields.char('Memo', size=256, required=True),
def copy(self, cr, uid, id, default={}, context=None): res = { 'state':'draft', 'number':False, 'move_id':False, 'payment_ids':False } default.update(res) if 'date' not in default: default['date'] = time.strftime('%Y-%m-%d') return super(account_voucher, self).copy(cr, uid, id, default, context)
5d9a7b0404631fa29f5715bd6102136c3cd496f0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5d9a7b0404631fa29f5715bd6102136c3cd496f0/voucher.py
att_val.update({ 'parent_ids': [(4, att.id)], 'ref': att.ref._name + ',' + str(att.ref.id) })
if ref: att_val.update({ 'parent_ids': [(4, att.id)], 'ref': att.ref._name + ',' +str(att.ref.id) })
def do_invite(self, cr, uid, ids, context={}): """ Invite attendee for meeting.. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of base calendar invite attendee’s IDs. @param context: A standard dictionary for contextual values @return: Dictionary of {}. """ for datas in self.read(cr, uid, ids): model = False model_field = False context_id = context and context.get('active_id', False) or False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context_id) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = [] mail_to = [] attendees = [] ref = {}
38470a93d2e1441f80272a2f303583489beb4fab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/38470a93d2e1441f80272a2f303583489beb4fab/base_calendar.py
def do_invite(self, cr, uid, ids, context={}): """ Invite attendee for meeting.. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of base calendar invite attendee’s IDs. @param context: A standard dictionary for contextual values @return: Dictionary of {}. """ for datas in self.read(cr, uid, ids): model = False model_field = False context_id = context and context.get('active_id', False) or False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context_id) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = [] mail_to = [] attendees = [] ref = {}
38470a93d2e1441f80272a2f303583489beb4fab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/38470a93d2e1441f80272a2f303583489beb4fab/base_calendar.py
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context={}): """ send mail. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of calendar attendee’s IDs. @param context: A standard dictionary for contextual values @return: True """ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.name for att in self.browse(cr, uid, ids, context=context): sign = att.sent_by_uid and att.sent_by_uid.signature or '' sign = '<br>'.join(sign and sign.split('\n') or []) res_obj = att.ref if res_obj and len(res_obj): res_obj = res_obj[0] sub = '[%s Invitation][%d] %s' % (company, att.id, res_obj.name) att_infos = [] other_invitaion_ids = self.search(cr, uid, [('ref', '=', att.ref)]) for att2 in self.browse(cr, uid, other_invitaion_ids): att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ att2.email) + ' - Status: ' + att2.state.title()) body_vals = {'name': res_obj.name, 'start_date': res_obj.date, 'end_date': res_obj.date_deadline or False, 'description': res_obj.description or '-', 'location': res_obj.location or '-', 'attendees': '<br>'.join(att_infos), 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', 'sign': sign, 'company': company } body = html_invitation % body_vals if mail_to and email_from: tools.email_send( email_from, mail_to, sub, body, subtype='html', reply_to=email_from ) return True
38470a93d2e1441f80272a2f303583489beb4fab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/38470a93d2e1441f80272a2f303583489beb4fab/base_calendar.py
'product_id': fields.many2one('product.product', 'Product', required=True),
'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type', '<>', 'service')]),
def _stock_search(self, cr, uid, obj, name, args, context=None): """ Searches Ids of products @return: Ids of locations """ locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')]) cr.execute('''select prodlot_id, sum(qty) from stock_report_prodlots where location_id IN %s group by prodlot_id having sum(qty) '''+ str(args[0][1]) + str(args[0][2]),(tuple(locations),)) res = cr.fetchall() ids = [('id', 'in', map(lambda x: x[0], res))] return ids
0705b7bad719a3e87758346cd02b1bb1575faa5a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0705b7bad719a3e87758346cd02b1bb1575faa5a/stock.py
users = self.pool.get('res.users') users.write(cr, uid, users.search(cr, uid, [('action_id','=','Setup')], context=context), {'action_id': menu.id}, context=context) users.write(cr, uid, users.search(cr, uid, [('menu_id','=','Setup')], context=context), {'menu_id': menu.id}, context=context)
user = self.pool.get('res.users')\ .browse(cr, uid, uid, context=context) user.write({'action_id': menu.id, 'menu_id': menu.id})
def set_default_menu(self, cr, uid, menu, context=None): users = self.pool.get('res.users') users.write(cr, uid, users.search(cr, uid, [('action_id','=','Setup')], context=context), {'action_id': menu.id}, context=context) users.write(cr, uid, users.search(cr, uid, [('menu_id','=','Setup')], context=context), {'menu_id': menu.id}, context=context)
bedf69d3f01304c66ca07bda475fe77f5dfbb9bb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bedf69d3f01304c66ca07bda475fe77f5dfbb9bb/__init__.py
'A given user should only have menu item'
'A given user should only have one menu item'
def get_default_menu(self, cr, uid, context=None): actions = self.pool.get('ir.actions.act_window')
bedf69d3f01304c66ca07bda475fe77f5dfbb9bb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bedf69d3f01304c66ca07bda475fe77f5dfbb9bb/__init__.py
print p print p.property_account_receivable, p.property_account_receivable.company_id, p.property_account_payable, p.property_account_payable.company_id
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False acc_id = False bank_id = False fiscal_position = False
be8fcf14fbb2567db1179c6c36b63f23534330e1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/be8fcf14fbb2567db1179c6c36b63f23534330e1/invoice.py
print '** la'
def move_line_id_payment_get(self, cr, uid, ids, *args): print '** la' if not ids: return [] result = self.move_line_id_payment_gets(cr, uid, ids, *args) return result.get(ids[0], [])
be8fcf14fbb2567db1179c6c36b63f23534330e1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/be8fcf14fbb2567db1179c6c36b63f23534330e1/invoice.py
print '** ICI'
def move_line_id_payment_gets(self, cr, uid, ids, *args): print '** ICI' res = {} if not ids: return res cr.execute('SELECT i.id, l.id '\ 'FROM account_move_line l '\ 'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\ 'WHERE i.id IN %s '\ 'AND l.account_id=i.account_id', (tuple(ids),)) for r in cr.fetchall(): res.setdefault(r[0], []) res[r[0]].append( r[1] ) return res
be8fcf14fbb2567db1179c6c36b63f23534330e1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/be8fcf14fbb2567db1179c6c36b63f23534330e1/invoice.py
operator = operator.lower()
def rg(ids, table, parent): if not ids: return [] ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context) return ids + rg(ids2, table, parent)
4e5ab1870b81011f3490d6625f2f085231c408a4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4e5ab1870b81011f3490d6625f2f085231c408a4/expression.py
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {}
if isinstance(right, basestring):
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
4e5ab1870b81011f3490d6625f2f085231c408a4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4e5ab1870b81011f3490d6625f2f085231c408a4/expression.py
dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator]
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
4e5ab1870b81011f3490d6625f2f085231c408a4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4e5ab1870b81011f3490d6625f2f085231c408a4/expression.py
return ('id','=',0)
self.__exp[i] = ('id','=',0)
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
4e5ab1870b81011f3490d6625f2f085231c408a4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4e5ab1870b81011f3490d6625f2f085231c408a4/expression.py
return (left, 'in', right) m2o_str = False if isinstance(right, basestring): m2o_str = True elif isinstance(right, list) or isinstance(right, tuple): m2o_str = True for ele in right: if not isinstance(ele, basestring): m2o_str = False break if m2o_str: self.__exp[i] = _get_expression(field_obj,cr, uid, left, right, operator, context=context)
self.__exp[i] = (left, 'in', right)
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
4e5ab1870b81011f3490d6625f2f085231c408a4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4e5ab1870b81011f3490d6625f2f085231c408a4/expression.py
'name': fields.char('Description',size=64,required=True),
'name': fields.char('Description', size=1024, required=True),
def _get_log_ids(self, cr, uid, ids, field_names, arg, context={}): result = {} history_obj = False model_obj = self.pool.get('ir.model') if 'history_line' in field_names: history_obj = self.pool.get('crm.case.history') name = 'history_line' if 'log_ids' in field_names: history_obj = self.pool.get('crm.case.log') name = 'log_ids' if not history_obj: return result for case in self.browse(cr, uid, ids, context): model_ids = model_obj.search(cr, uid, [('model','=',case._name)]) history_ids = history_obj.search(cr, uid, [('model_id','=',model_ids[0]),('res_id','=',case.id)]) if history_ids: result[case.id] = {name:history_ids} else: result[case.id] = {name:[]} return result
57125a1002f15acdc61a9882a94156e371ef2767 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/57125a1002f15acdc61a9882a94156e371ef2767/crm.py
ids = obj.search(cr, uid, [])
ids = obj.search(cr, uid, [('translatable','=',True)])
def _lang_get(self, cr, uid, context={}): obj = self.pool.get('res.lang') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['code', 'name'], context) res = [(r['code'], r['name']) for r in res] return res
e2ec26683e61ce68cd930f6c41f05c8626f968a0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e2ec26683e61ce68cd930f6c41f05c8626f968a0/res_user.py
for lots in lots_obj.browse(cr, uid, record_ids): if lots.ach_uid: res['arch'] = """ <form title="Mapping Result"> <group col="2" colspan="2"> <label string="All objects are assigned to buyers !"/> <newline/> <button icon='gtk-cancel' special="cancel" string="Done" /> </group> </form> """
try: for lots in lots_obj.browse(cr, uid, record_ids): if lots.ach_uid: res['arch'] = """ <form title="Mapping Result"> <group col="2" colspan="2"> <label string="All objects are assigned to buyers !"/> <newline/> <button icon='gtk-cancel' special="cancel" string="Done" /> </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_ids = context and context.get('active_ids', False) or False res = super(wiz_auc_lots_buyer_map, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) lots_obj = self.pool.get('auction.lots') if record_ids: for lots in lots_obj.browse(cr, uid, record_ids): if lots.ach_uid: res['arch'] = """ <form title="Mapping Result"> <group col="2" colspan="2"> <label string="All objects are assigned to buyers !"/> <newline/> <button icon='gtk-cancel' special="cancel" string="Done" /> </group> </form> """ return res
c4b7a902cb789875b4547635c9307d72145c407e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c4b7a902cb789875b4547635c9307d72145c407e/auction_lots_buyer_map.py
if line.move_id.state <> 'draft':
if line.move_id.state <> 'draft' and (not line.journal_id.entry_posted):
def _update_check(self, cr, uid, ids, context={}): done = {} for line in self.browse(cr, uid, ids, context): if line.move_id.state <> 'draft': raise osv.except_osv(_('Error !'), _('You can not do this modification on a confirmed entry ! Please note that you can just change some non important fields !')) if line.reconcile_id: raise osv.except_osv(_('Error !'), _('You can not do this modification on a reconciled entry ! Please note that you can just change some non important fields !')) t = (line.journal_id.id, line.period_id.id) if t not in done: self._update_journal_check(cr, uid, line.journal_id.id, line.period_id.id, context) done[t] = True return True
4e95e42233a6728401d58359d71f791f79aea703 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4e95e42233a6728401d58359d71f791f79aea703/account_move_line.py
user = self.pool.get('res.users').browse(cr, uid, uid2, context)
user = self.pool.get('res.users').browse(cr, uid, uid2, context)
def _get_company(self,cr, uid, context={}, uid2=False): if not uid2: uid2 = uid user = self.pool.get('res.users').browse(cr, uid, uid2, context) return user.company_id.id
0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313/res_user.py
res = getattr(user,k)
res = getattr(user,k) or False
def context_get(self, cr, uid, context=None): user = self.browse(cr, uid, uid, context) result = {} for k in self._columns.keys(): if k.startswith('context_'): res = getattr(user,k) if isinstance(res, browse_record): res = res.id result[k[8:]] = res return result
0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313/res_user.py
res = res.id result[k[8:]] = res
res = res.id result[k[8:]] = res
def context_get(self, cr, uid, context=None): user = self.browse(cr, uid, uid, context) result = {} for k in self._columns.keys(): if k.startswith('context_'): res = getattr(user,k) if isinstance(res, browse_record): res = res.id result[k[8:]] = res return result
0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313/res_user.py
def context_get(self, cr, uid, context=None): user = self.browse(cr, uid, uid, context) result = {} for k in self._columns.keys(): if k.startswith('context_'): res = getattr(user,k) if isinstance(res, browse_record): res = res.id result[k[8:]] = res return result
0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313/res_user.py
cr = pooler.get_db(db).cursor()
cr = pooler.get_db(db).cursor()
def login(self, db, login, password): if not password: return False cr = pooler.get_db(db).cursor() cr.execute('select id from res_users where login=%s and password=%s and active', (tools.ustr(login), tools.ustr(password))) res = cr.fetchone() cr.close() if res: return res[0] else: return False
0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313/res_user.py
cr = pooler.get_db(db).cursor() cr.execute('select count(1) from res_users where id=%s and password=%s and active=%s', (int(uid), passwd, True))
cr = pooler.get_db(db).cursor() cr.execute('select count(1) from res_users where id=%s and password=%s and active=%s', (int(uid), passwd, True))
def check(self, db, uid, passwd): if not passwd: return False cached_pass = self._uid_cache.get(db, {}).get(uid) if (cached_pass is not None) and cached_pass == passwd: return True cr = pooler.get_db(db).cursor() cr.execute('select count(1) from res_users where id=%s and password=%s and active=%s', (int(uid), passwd, True)) res = cr.fetchone()[0] cr.close() if not bool(res): raise security.ExceptionNoTb('AccessDenied') if res: if self._uid_cache.has_key(db): ulist = self._uid_cache[db] ulist[uid] = passwd else: self._uid_cache[db] = {uid:passwd} return bool(res)
0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313/res_user.py
cr = pooler.get_db(db).cursor()
cr = pooler.get_db(db).cursor()
def access(self, db, uid, passwd, sec_level, ids): if not passwd: return False cr = pooler.get_db(db).cursor() cr.execute('select id from res_users where id=%s and password=%s', (uid, passwd)) res = cr.fetchone() cr.close() if not res: raise security.ExceptionNoTb('Bad username or password') return res[0]
0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313/res_user.py
def access(self, db, uid, passwd, sec_level, ids): if not passwd: return False cr = pooler.get_db(db).cursor() cr.execute('select id from res_users where id=%s and password=%s', (uid, passwd)) res = cr.fetchone() cr.close() if not res: raise security.ExceptionNoTb('Bad username or password') return res[0]
0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a5f82bd3b22aa2fc8fe3a0baa53c7020b314313/res_user.py
self.parent = self.context.get_dir_node(cr, dbro.parent_id.id)
self.parent = self.context.get_dir_node(cr, dbro.parent_id)
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): """ Move directory. This operation is simple, since the present node is only used for static, simple directories. Note /may/ be called with ndir_node = None, to rename the document root. """ if ndir_node and (ndir_node.context != self.context): raise NotImplementedError("Cannot move directories between contexts")
9dec9c2863bb41a997510b7eedab1945412a6cb0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9dec9c2863bb41a997510b7eedab1945412a6cb0/nodes.py
if ndir_node.context != self.context:
if ndir_node and ndir_node.context != self.context:
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): if ndir_node.context != self.context: raise NotImplementedError("Cannot move files between contexts")
9dec9c2863bb41a997510b7eedab1945412a6cb0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9dec9c2863bb41a997510b7eedab1945412a6cb0/nodes.py
self.parent = self.context.get_dir_node(cr, dbro.parent_id.id)
self.parent = self.context.get_dir_node(cr, dbro.parent_id)
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): if ndir_node.context != self.context: raise NotImplementedError("Cannot move files between contexts")
9dec9c2863bb41a997510b7eedab1945412a6cb0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9dec9c2863bb41a997510b7eedab1945412a6cb0/nodes.py
if self.parent != ndir_node:
if ndir_node and self.parent != ndir_node:
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): if ndir_node.context != self.context: raise NotImplementedError("Cannot move files between contexts")
9dec9c2863bb41a997510b7eedab1945412a6cb0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9dec9c2863bb41a997510b7eedab1945412a6cb0/nodes.py
'active': fields.boolean('Active', help="If the active field is set to\ true, it will allow you to hide the case without removing it."),
'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the case without removing it."),
def _get_log_ids(self, cr, uid, ids, field_names, arg, context=None): """Gets id for case log from history of particular case @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Case IDs @param context: A standard dictionary for contextual values """ if not context: context = {}
9f92862f80e4fff53514e7f5421a547e867678d7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f92862f80e4fff53514e7f5421a547e867678d7/crm.py
return all(procurement.move_id.state != 'cancel' for procurement in self.browse(cr, uid, ids))
return all(procurement.move_id.state == 'cancel' for procurement in self.browse(cr, uid, ids))
def check_move_cancel(self, cr, uid, ids, context={}): """ Checks if move is cancelled or not. @return: True or False. """ return all(procurement.move_id.state != 'cancel' for procurement in self.browse(cr, uid, ids))
6a4845aee0a0c50b50d813993b7c513ad0898564 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6a4845aee0a0c50b50d813993b7c513ad0898564/procurement.py
scrpaed_location_ids = location_obj.search(cr, uid, [('scraped','=',True)])
scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)])
def default_get(self, cr, uid, fields, context=None): """ Get default values @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for default value @param context: A standard dictionary @return: default values of fields """ res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context) move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) location_obj = self.pool.get('stock.location') scrpaed_location_ids = location_obj.search(cr, uid, [('scraped','=',True)]) if 'product_id' in fields: res.update({'product_id': move.product_id.id}) if 'product_uom' in fields: res.update({'product_uom': move.product_uom.id}) if 'product_qty' in fields: res.update({'product_qty': move.product_qty}) if 'location_id' in fields: if scrpaed_location_ids: res.update({'location_id': scrpaed_location_ids[0]}) else: res.update({'location_id': False}) return res
27e1daebc0b9336057290f9e5a446219b00563c6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/27e1daebc0b9336057290f9e5a446219b00563c6/stock_move.py
def _compute(self, cr, uid, ids, context=None):
def _compute(self, cr, uid, ids,field_name, arg, context=None):
def _compute(self, cr, uid, ids, context=None): res = {} if not ids: return res for phase in self.browse(cr, uid, ids, context=context): tot = 0.0 for task in phase.task_ids: tot += task.planned_hours res[phase.id] = { 'total_hours' : tot } return res
622e39465b006df40574f02cf70d9e7008d10ac7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/622e39465b006df40574f02cf70d9e7008d10ac7/project_long_term.py
res[phase.id] = { 'total_hours' : tot }
res[phase.id] = tot
def _compute(self, cr, uid, ids, context=None): res = {} if not ids: return res for phase in self.browse(cr, uid, ids, context=context): tot = 0.0 for task in phase.task_ids: tot += task.planned_hours res[phase.id] = { 'total_hours' : tot } return res
622e39465b006df40574f02cf70d9e7008d10ac7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/622e39465b006df40574f02cf70d9e7008d10ac7/project_long_term.py
re = model.read_group(cr, uid, [], fields_order, context.get('group_by',False),0,None,context)
re = model.read_group(cr, uid, [('id','in',ids)], fields_order, context.get('group_by',False),0,None,context)
def create(self, cr, uid, ids, datas, context=None): if not context: context={} self.context = context pool = pooler.get_pool(cr.dbname) model = pool.get(datas['model']) model_id = pool.get('ir.model').search(cr, uid, [('model','=',model._name)]) if model_id: model_desc = pool.get('ir.model').browse(cr, uid, model_id[0], context).name self.title = model_desc else: model_desc = model._description self.title = model_desc
f5914d0033c22b167f837374a409d76e033b8f39 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f5914d0033c22b167f837374a409d76e033b8f39/ps_list.py
obj = self.pool.get('ir.model.data').read(self.cr, self.uid, ir_id, ['res_id'])
obj = self.pool.get('ir.model.data').read(self.cr, self.uid, ir_id, ['res_id']) or {}
def get_id(self, xml_id): if not xml_id: raise YamlImportException("The xml_id should be a non empty string.") if isinstance(xml_id, types.IntType): id = xml_id elif xml_id in self.id_map: id = self.id_map[xml_id] else: if '.' in xml_id: module, checked_xml_id = xml_id.split('.', 1) else: module = self.module checked_xml_id = xml_id ir_id = self.pool.get('ir.model.data')._get_id(self.cr, self.uid, module, checked_xml_id) obj = self.pool.get('ir.model.data').read(self.cr, self.uid, ir_id, ['res_id']) id = int(obj['res_id']) self.id_map[xml_id] = id return id
04c05faf9b5469afdbc0d446246a39d860fc5345 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/04c05faf9b5469afdbc0d446246a39d860fc5345/yaml_import.py