rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def onchange_days(self, cr, uid, ids, project, context=None): result = {} for id in ids: project_id = self.browse(cr, uid, id, context=context) newdate = datetime.strptime(project_id.date_start, '%Y-%m-%d') + relativedelta(days=project_id.duration or 0.0) result['date_end'] = newdate.strftime('%Y-%m-%d') return {'value': result}
def onchange_days(self, cr, uid, ids, project, context=None): result = {} for id in ids: project_id = self.browse(cr, uid, id, context=context) newdate = datetime.strptime(project_id.date_start, '%Y-%m-%d') + relativedelta(days=project_id.duration or 0.0) result['date_end'] = newdate.strftime('%Y-%m-%d') return {'value': result}
74287c78938cd17d1f2c79063450b879d2989ef5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/74287c78938cd17d1f2c79063450b879d2989ef5/project_long_term.py
'date_start': time.strftime('%Y-01-01'), 'date_stop': time.strftime('%Y-12-31'),
'date_start': lambda *a: time.strftime('%Y-01-01'), 'date_stop': lambda *a: time.strftime('%Y-12-31'),
def _get_default_charts(self, cr, uid, context=None): module_name = False company_id = self._default_company(cr, uid, context=context) company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) address_id = self.pool.get('res.partner').address_get(cr, uid, [company.partner_id.id]) if address_id['default']: address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default'], context=context) code = address.country_id.code module_name = (code and 'l10n_' + code.lower()) or False if module_name: module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)], context=context) if module_id: return module_name return 'configurable'
945a1d16d8c0bff6689c18f0b4544bdbd6bf0269 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/945a1d16d8c0bff6689c18f0b4544bdbd6bf0269/installer.py
def modules_to_install(self, cr, uid, ids, context=None): modules = super(account_installer, self).modules_to_install( cr, uid, ids, context=context) chart = self.read(cr, uid, ids, ['charts'], context=context)[0]['charts'] self.logger.notifyChannel( 'installer', netsvc.LOG_DEBUG, 'Installing chart of accounts %s'%chart) return modules | set([chart])
945a1d16d8c0bff6689c18f0b4544bdbd6bf0269 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/945a1d16d8c0bff6689c18f0b4544bdbd6bf0269/installer.py
def get(self, cr, obj, ids, name, user=None, context=None, values=None): context = context or {} values = values or {}
8b28a3cb5e88d8a859ac2fa74f5a60ddbe3fc359 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8b28a3cb5e88d8a859ac2fa74f5a60ddbe3fc359/fields.py
if id in records: res[id] = (id, records[id])
if res[id] in records: res[id] = (res[id], records[res[id]])
def get(self, cr, obj, ids, name, user=None, context=None, values=None): context = context or {} values = values or {}
8b28a3cb5e88d8a859ac2fa74f5a60ddbe3fc359 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8b28a3cb5e88d8a859ac2fa74f5a60ddbe3fc359/fields.py
def __init__(self, cr, uid, name, context=None): self.date_lst = [] self.date_lst_string = '' super(third_party_ledger, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, 'sum_credit_partner': self._sum_credit_partner, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me,
def __init__(self, cr, uid, name, context=None): self.date_lst = [] self.date_lst_string = '' super(third_party_ledger, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, 'sum_credit_partner': self._sum_credit_partner, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me,
def __init__(self, cr, uid, name, context=None): self.date_lst = [] self.date_lst_string = '' super(third_party_ledger, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, 'sum_credit_partner': self._sum_credit_partner, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self._get_account, 'get_filter': self._get_filter, 'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_fiscalyear': self._get_fiscalyear, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_journal': self._get_journal,
35085e84992f87b57198ecd1a74da6ef671c2bfd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/35085e84992f87b57198ecd1a74da6ef671c2bfd/third_party_ledger.py
'get_journal': self._get_journal, }) def date_range(self, start, end): if not start or not end: return [] start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d"))) full_str_date = [] r = (end+datetime.timedelta(days=1)-start).days date_array = [start+datetime.timedelta(days=i) for i in range(r)] for date in date_array: full_str_date.append(str(date)) return full_str_date def transform_period_into_date_array(self, data): if not data['form']['periods']: periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) else: periods_id = data['form']['periods'] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) self.date_lst = date_array self.date_lst.sort() def transform_date_into_date_array(self, data): return_array = self.date_range(data['form']['date_from'], data['form']['date_to']) self.date_lst = return_array self.date_lst.sort() def transform_none_into_date_array(self, data): sql = "SELECT min(date) as start_date from account_move_line" self.cr.execute(sql) start_date = self.cr.fetchone()[0] sql = "SELECT max(date) as start_date from account_move_line" self.cr.execute(sql) stop_date = self.cr.fetchone()[0] array= [] array = array + self.date_range(start_date, stop_date) self.date_lst = array self.date_lst.sort() def comma_me(self, amount): if type(amount) is float : amount = str('%.2f'%amount) else : amount = str(amount) if (amount == '0'): return ' ' orig = amount new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount) if orig == new: return new else: return self.comma_me(new) def special_map(self): string_map = '' for date_string in self.date_lst: string_map = date_string + ',' return string_map def set_context(self, objects, data, ids, report_type = None): PARTNER_REQUEST = '' if (data['model'] == 'res.partner'): if ids: PARTNER_REQUEST = "AND line.partner_id IN %s",(tuple(ids),) if data['form']['filter'] == 'filter_no': self.transform_none_into_date_array(data) elif data['form']['filter'] == 'filter_date': self.transform_date_into_date_array(data) elif data['form']['filter'] == 'filter_period': self.transform_period_into_date_array(data) self.date_lst_string = '' if self.date_lst: self.date_lst_string = '\'' + '\',\''.join(map(str, self.date_lst)) + '\'' if data['form']['result_selection'] == 'supplier': self.ACCOUNT_TYPE = ['payable'] elif data['form']['result_selection'] == 'customer': self.ACCOUNT_TYPE = ['receivable'] else: self.ACCOUNT_TYPE = ['payable','receivable'] self.cr.execute( "SELECT a.id " \ "FROM account_account a " \ "LEFT JOIN account_account_type t " \ "ON (a.type=t.code) " \ 'WHERE a.type IN %s' \ "AND a.active", (tuple(self.ACCOUNT_TYPE), )) self.account_ids = [a for (a,) in self.cr.fetchall()] partner_to_use = [] if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT DISTINCT line.partner_id " \ "FROM account_move_line AS line, account_account AS account " \ "WHERE line.partner_id IS NOT NULL " \ "AND line.account_id = account.id " \ "AND line.date >= %s " \ "AND line.date <= %s " \ "AND line.reconcile_id IS NULL " \ "AND line.account_id IN %s" \ " " + PARTNER_REQUEST + " " \ "AND account.active " , (self.date_lst[0],self.date_lst[len(self.date_lst)-1],tuple(self.account_ids),)) res = self.cr.dictfetchall() for res_line in res: partner_to_use.append(res_line['partner_id']) new_ids = partner_to_use self.partner_ids = new_ids objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids) super(third_party_ledger, self).set_context(objects, data, new_ids, report_type) def lines(self, partner,data): full_account = [] if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND l.reconcile_id IS NULL" if self.date_lst_string: self.cr.execute( "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \ "FROM account_move_line l " \ "LEFT JOIN account_journal j " \ "ON (l.journal_id = j.id) " \ "WHERE l.partner_id = %s " \ "AND l.account_id IN %s"\ "AND l.date IN (" + self.date_lst_string + ")" " " + RECONCILE_TAG + " "\ "ORDER BY l.id", (partner.id, tuple(self.account_ids),)) res = self.cr.dictfetchall() sum = 0.0 for r in res: sum = r['debit'] - r['credit'] r['progress'] = sum full_account.append(r) return full_account def _sum_debit_partner(self, partner, data): result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (partner.id, tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 if self.date_lst_string: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")" , (partner.id,tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 return result_tmp def _sum_credit_partner(self, partner, data): result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (partner.id, tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")", (partner.id, tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 return result_tmp def _sum_debit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 if self.date_lst_string: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 return result_tmp def _sum_credit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 return result_tmp def _get_currency(self, form): return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field else: currency_total = self.tot_currency = 0.0 return currency_total
'get_journal': self._get_journal, }) def date_range(self, start, end): if not start or not end: return [] start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d"))) full_str_date = [] r = (end+datetime.timedelta(days=1)-start).days date_array = [start+datetime.timedelta(days=i) for i in range(r)] for date in date_array: full_str_date.append(str(date)) return full_str_date def transform_period_into_date_array(self, data): if not data['form']['periods']: periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) else: periods_id = data['form']['periods'] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) self.date_lst = date_array self.date_lst.sort() def transform_date_into_date_array(self, data): return_array = self.date_range(data['form']['date_from'], data['form']['date_to']) self.date_lst = return_array self.date_lst.sort() def transform_none_into_date_array(self, data): sql = "SELECT min(date) as start_date from account_move_line" self.cr.execute(sql) start_date = self.cr.fetchone()[0] sql = "SELECT max(date) as start_date from account_move_line" self.cr.execute(sql) stop_date = self.cr.fetchone()[0] array= [] array = array + self.date_range(start_date, stop_date) self.date_lst = array self.date_lst.sort() def comma_me(self, amount): if type(amount) is float : amount = str('%.2f'%amount) else : amount = str(amount) if (amount == '0'): return ' ' orig = amount new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount) if orig == new: return new else: return self.comma_me(new) def special_map(self): string_map = '' for date_string in self.date_lst: string_map = date_string + ',' return string_map def set_context(self, objects, data, ids, report_type=None): PARTNER_REQUEST = '' if (data['model'] == 'res.partner'): if ids: PARTNER_REQUEST = "AND line.partner_id IN %s",(tuple(ids),) if data['form']['filter'] == 'filter_no': self.transform_none_into_date_array(data) elif data['form']['filter'] == 'filter_date': self.transform_date_into_date_array(data) elif data['form']['filter'] == 'filter_period': self.transform_period_into_date_array(data) self.date_lst_string = '' if self.date_lst: self.date_lst_string = '\'' + '\',\''.join(map(str, self.date_lst)) + '\'' if data['form']['result_selection'] == 'supplier': self.ACCOUNT_TYPE = ['payable'] elif data['form']['result_selection'] == 'customer': self.ACCOUNT_TYPE = ['receivable'] else: self.ACCOUNT_TYPE = ['payable','receivable'] self.cr.execute( "SELECT a.id " \ "FROM account_account a " \ "LEFT JOIN account_account_type t " \ "ON (a.type=t.code) " \ 'WHERE a.type IN %s' \ "AND a.active", (tuple(self.ACCOUNT_TYPE), )) self.account_ids = [a for (a,) in self.cr.fetchall()] partner_to_use = [] if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT DISTINCT line.partner_id " \ "FROM account_move_line AS line, account_account AS account " \ "WHERE line.partner_id IS NOT NULL " \ "AND line.account_id = account.id " \ "AND line.date >= %s " \ "AND line.date <= %s " \ "AND line.reconcile_id IS NULL " \ "AND line.account_id IN %s" \ " " + PARTNER_REQUEST + " " \ "AND account.active " , (self.date_lst[0],self.date_lst[len(self.date_lst)-1],tuple(self.account_ids),)) res = self.cr.dictfetchall() for res_line in res: partner_to_use.append(res_line['partner_id']) new_ids = partner_to_use self.partner_ids = new_ids objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids) super(third_party_ledger, self).set_context(objects, data, new_ids, report_type) def lines(self, partner,data): full_account = [] if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND l.reconcile_id IS NULL" if self.date_lst_string: self.cr.execute( "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \ "FROM account_move_line l " \ "LEFT JOIN account_journal j " \ "ON (l.journal_id = j.id) " \ "WHERE l.partner_id = %s " \ "AND l.account_id IN %s"\ "AND l.date IN (" + self.date_lst_string + ")" " " + RECONCILE_TAG + " "\ "ORDER BY l.id", (partner.id, tuple(self.account_ids),)) res = self.cr.dictfetchall() sum = 0.0 for r in res: sum = r['debit'] - r['credit'] r['progress'] = sum full_account.append(r) return full_account def _sum_debit_partner(self, partner, data): result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (partner.id, tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 if self.date_lst_string: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")" , (partner.id,tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 return result_tmp def _sum_credit_partner(self, partner, data): result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (partner.id, tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")", (partner.id, tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 return result_tmp def _sum_debit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 if self.date_lst_string: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 return result_tmp def _sum_credit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['soldeinit'] : self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 return result_tmp def _get_currency(self, form): return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field else: currency_total = self.tot_currency = 0.0 return currency_total
def __init__(self, cr, uid, name, context=None): self.date_lst = [] self.date_lst_string = '' super(third_party_ledger, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, 'sum_credit_partner': self._sum_credit_partner, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self._get_account, 'get_filter': self._get_filter, 'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_fiscalyear': self._get_fiscalyear, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_journal': self._get_journal,
35085e84992f87b57198ecd1a74da6ef671c2bfd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/35085e84992f87b57198ecd1a74da6ef671c2bfd/third_party_ledger.py
'addons/account/report/third_party_ledger.rml',parser=third_party_ledger, header=False)
'addons/account/report/third_party_ledger.rml',parser=third_party_ledger, header=False)
def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field else: currency_total = self.tot_currency = 0.0 return currency_total
35085e84992f87b57198ecd1a74da6ef671c2bfd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/35085e84992f87b57198ecd1a74da6ef671c2bfd/third_party_ledger.py
'addons/account/report/third_party_ledger_other.rml',parser=third_party_ledger, header=False)
'addons/account/report/third_party_ledger_other.rml',parser=third_party_ledger, header=False)
def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field else: currency_total = self.tot_currency = 0.0 return currency_total
35085e84992f87b57198ecd1a74da6ef671c2bfd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/35085e84992f87b57198ecd1a74da6ef671c2bfd/third_party_ledger.py
' WHERE name in (%s)' % (','.join(['%s'] * len(self))), additional_data.keys()
' WHERE name in %s',(tuple(additional_data),)
def update_from_db(self, cr): # update the graph with values from the database (if exist) ## First, we set the default values for each package in graph additional_data = dict.fromkeys(self.keys(), {'id': 0, 'state': 'uninstalled', 'dbdemo': False, 'installed_version': None}) ## Then we get the values from the database cr.execute('SELECT name, id, state, demo AS dbdemo, latest_version AS installed_version' ' FROM ir_module_module' ' WHERE name in (%s)' % (','.join(['%s'] * len(self))), additional_data.keys() )
f33171198680a04a1dc6a2802531abf41f054884 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f33171198680a04a1dc6a2802531abf41f054884/__init__.py
cr.execute("SELECT name from ir_module_module WHERE state in (%s)" % ','.join(['%s']*len(STATES_TO_LOAD)), STATES_TO_LOAD)
cr.execute("SELECT name from ir_module_module WHERE state in %s" ,(tuple(STATES_TO_LOAD),))
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))
f33171198680a04a1dc6a2802531abf41f054884 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f33171198680a04a1dc6a2802531abf41f054884/__init__.py
'department_id': fields.related('employee_id','department_id', string="Department", readonly=True),
'department_id': fields.related('employee_id','department_id', type='many2one', relation='hr.department', string="Department", readonly=True),
def _get_latest_contract(self, cr, uid, ids, field_name, args, context=None): res = {} obj_contract = self.pool.get('hr.contract') for emp in self.browse(cr, uid, ids, context=context): contract_ids = obj_contract.search(cr, uid, [('employee_id','=',emp.id),], order='date_start', context=context) if contract_ids: res[emp.id] = contract_ids[-1:][0] else: res[emp.id] = False return res
35c76a73c6f4f7d4d44ce02a9f5716738a1bc530 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/35c76a73c6f4f7d4d44ce02a9f5716738a1bc530/hr_contract.py
vals = {}
vals = []
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = 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['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
4009482974533250261bd1f0321a448fb21804ca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4009482974533250261bd1f0321a448fb21804ca/base_calendar.py
vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))}
ref = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))}
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = 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['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
4009482974533250261bd1f0321a448fb21804ca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4009482974533250261bd1f0321a448fb21804ca/base_calendar.py
vals.update({'user_id': user_id, 'email': user.address_id.email})
res = { 'user_id': user_id, 'email': user.address_id.email } res.update(ref) vals.append(res)
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = 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['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
4009482974533250261bd1f0321a448fb21804ca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4009482974533250261bd1f0321a448fb21804ca/base_calendar.py
vals.update({'email': datas['email']})
vals.append({'email': datas['email']})
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = 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['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
4009482974533250261bd1f0321a448fb21804ca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4009482974533250261bd1f0321a448fb21804ca/base_calendar.py
vals.update({ 'partner_address_id': contact.id, 'email': contact.email})
res = { 'partner_address_id': contact.id, 'email': contact.email } res.update(ref) vals.append(res)
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = 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['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
4009482974533250261bd1f0321a448fb21804ca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4009482974533250261bd1f0321a448fb21804ca/base_calendar.py
att_obj._send_mail(cr, uid, [att_id], mail_to, \
att_obj._send_mail(cr, uid, attendees, mail_to, \
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = 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['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
4009482974533250261bd1f0321a448fb21804ca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4009482974533250261bd1f0321a448fb21804ca/base_calendar.py
att_id = att_obj.create(cr, uid, vals) if model_field: obj.write(cr, uid, res_obj.id, {model_field: [(4, att_id)]})
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = 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['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
4009482974533250261bd1f0321a448fb21804ca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4009482974533250261bd1f0321a448fb21804ca/base_calendar.py
value = {}
def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, context={}): if not start_date: return {} start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S") value = {} if end_date and not duration: end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S") diff = end - start duration = float(diff.days)* 24 + (float(diff.seconds) / 3600) value['duration'] = round(duration, 2) elif not end_date: end = start + timedelta(hours=duration) value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S") return {'value': value}
4009482974533250261bd1f0321a448fb21804ca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4009482974533250261bd1f0321a448fb21804ca/base_calendar.py
loc_ids = location_obj.search(cr, uid,[('usage','=','internal')])
def do_change_standard_price(self, cr, uid, ids, datas, context={}): """ Changes the Standard Price of Product and creates an account move accordingly. @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal @param context: A standard dictionary @return: """ location_obj = self.pool.get('stock.location') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line')
8dfe66803b5d77156e76672674a251162c4650c5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8dfe66803b5d77156e76672674a251162c4650c5/product.py
'location_id': fields.dummy(string='Location', relation='stock.location', type='many2one', domain=[('usage','=','internal')]),
'location_id': fields.dummy(string='Location', relation='stock.location', type='many2one'),
def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}): """ Finds the incoming and outgoing quantity of product. @return: Dictionary of values """ if not field_names: field_names = [] res = {} for id in ids: res[id] = {}.fromkeys(field_names, 0.0) for f in field_names: c = context.copy() if f == 'qty_available': c.update({ 'states': ('done',), 'what': ('in', 'out') }) if f == 'virtual_available': c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out') }) if f == 'incoming_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('in',) }) if f == 'outgoing_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('out',) }) stock = self.get_product_available(cr, uid, ids, context=c) for id in ids: res[id][f] = stock.get(id, 0.0) return res
8dfe66803b5d77156e76672674a251162c4650c5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8dfe66803b5d77156e76672674a251162c4650c5/product.py
def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {}
def onchange_planned(self, cr, uid, ids, planned = 0.0, effective = 0.0): return {'value':{'remaining_hours': planned - effective}}
06c40ea9526e34a170d209dd4d8ce575d4e76ac0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/06c40ea9526e34a170d209dd4d8ce575d4e76ac0/project.py
'name': product.partner_ref,
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False, address_id=False): if not prod_id: return {} lang = False if address_id: addr_rec = self.pool.get('res.partner.address').browse(cr, uid, address_id) if addr_rec: lang = addr_rec.partner_id and addr_rec.partner_id.lang or False ctx = {'lang': lang}
f3ebef015c99452d4c34de38fad31a4354bb6b76 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f3ebef015c99452d4c34de38fad31a4354bb6b76/stock.py
if not ids: result['name'] = product.partner_ref
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False, address_id=False): if not prod_id: return {} lang = False if address_id: addr_rec = self.pool.get('res.partner.address').browse(cr, uid, address_id) if addr_rec: lang = addr_rec.partner_id and addr_rec.partner_id.lang or False ctx = {'lang': lang}
f3ebef015c99452d4c34de38fad31a4354bb6b76 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f3ebef015c99452d4c34de38fad31a4354bb6b76/stock.py
wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.id, context)
wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.warehouse_id.id, context)
def make_procurement(self, cr, uid, ids, context=None): '''Create procurement''' for proc in self.browse(cr, uid, ids): wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.id, context) user = self.pool.get('res.users').browse(cr, uid, uid, context) procure_id = self.pool.get('mrp.procurement').create(cr, uid, { 'name':'INT:'+str(user.login), 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.qty, 'product_uom': proc.uom_id.id, 'location_id': wh.lot_stock_id.id, 'procure_method':'make_to_order', }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr) data_obj = self.pool.get('ir.model.data') id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view') id3 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_form_view') 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': 'mrp.procurement', 'res_id' : procure_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window', }
27c588415eef0583c6a82e49f268006c511ae01a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/27c588415eef0583c6a82e49f268006c511ae01a/make_procurement_product.py
'bank': fields.many2one('res.bank', 'Bank'),
'bank': fields.many2one('res.bank', 'Bank', required=True),
def _default_value(self, cursor, user, field, context=None): if field in ('country_id', 'state_id'): value = False else: value = '' if not context.get('address', False): return value for ham, spam, address in context['address']: if address.get('type', False) == 'default': return address.get(field, value) elif not address.get('type', False): value = address.get(field, value) return value
05c30d29f42de9bf5fd27ba9beb576c419135a4a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/05c30d29f42de9bf5fd27ba9beb576c419135a4a/partner.py
a = repair.partner_id.property_account_receivable.id
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
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 ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, '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})
123cb46c6c36bc22eea1bbce33dc5fdf41dfa579 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/123cb46c6c36bc22eea1bbce33dc5fdf41dfa579/mrp_repair.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 ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, '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})
123cb46c6c36bc22eea1bbce33dc5fdf41dfa579 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/123cb46c6c36bc22eea1bbce33dc5fdf41dfa579/mrp_repair.py
'account_id': operation.product_id and operation.product_id.property_account_income and operation.product_id.property_account_income.id,
'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 ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, '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})
123cb46c6c36bc22eea1bbce33dc5fdf41dfa579 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/123cb46c6c36bc22eea1bbce33dc5fdf41dfa579/mrp_repair.py
check = int(10 - math.ceil(total % 10.0))
check = int(10 - math.ceil(total % 10.0)) %10
def check_ean(eancode): if not eancode: return True if len(eancode) <> 13: return False try: int(eancode) except: return False oddsum=0 evensum=0 total=0 eanvalue=eancode reversevalue = eanvalue[::-1] finalean=reversevalue[1:] for i in range(len(finalean)): if is_pair(i): oddsum += int(finalean[i]) else: evensum += int(finalean[i]) total=(oddsum * 3) + evensum check = int(10 - math.ceil(total % 10.0)) if check != int(eancode[-1]): return False return True
2646ac2706cd3dbd62968c52b7fb933978a786a4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2646ac2706cd3dbd62968c52b7fb933978a786a4/product.py
'id': product.id, 'name': s.product_name or product.name, 'default_code': s.product_code or product.default_code,
'id': product.id, 'name': s.product_name or product.name, 'default_code': s.product_code or product.default_code,
def _name_get(d): name = d.get('name','') code = d.get('default_code',False) if code: name = '[%s] %s' % (code,name) if d.get('variants'): name = name + ' - %s' % (d['variants'],) return (d['id'], name)
2646ac2706cd3dbd62968c52b7fb933978a786a4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2646ac2706cd3dbd62968c52b7fb933978a786a4/product.py
def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res
7406420996dd681d6caa3a8ae0c3c42e5a7d6619 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7406420996dd681d6caa3a8ae0c3c42e5a7d6619/hr_payroll.py
'base':fields.char('Based on', size=64, required=True, readonly=False, help='This will use to computer the % fields values, in general its on basic, but You can use all heads code field in small letter as a variable name i.e. hra, ma, lta, etc...., also you can use, static varible basic'),
'base': fields.text('Based on', required=True, readonly=False, help='This will use to computer the % fields values, in general its on basic, but You can use all heads code field in small letter as a variable name i.e. hra, ma, lta, etc...., also you can use, static varible basic'),
def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res
7406420996dd681d6caa3a8ae0c3c42e5a7d6619 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7406420996dd681d6caa3a8ae0c3c42e5a7d6619/hr_payroll.py
if line.category_id.register_id: ctr = { 'register_id':line.category_id.register_id.id, 'name':line.name, 'code':line.code, 'employee_id':slip.employee_id.id, 'period_id':period_id, 'emp_deduction':amount, } if line.category_id.contribute: ctr['comp_deduction'] = amount company = 0.0 employee = 0.0 if line.category_id.contribute and line.category_id.include_in_salary and line.category_id.amount_type == 'per': new_amount = (amount * (line.category_id.contribute_per / (1+line.category_id.contribute_per))) company = new_amount employee = amount - company elif line.category_id.contribute and line.category_id.include_in_salary and line.category_id.amount_type == 'fix': company = line.category_id.contribute_per employee = amount - company elif line.category_id.contribute and line.category_id.include_in_salary and line.category_id.amount_type == 'func': company = self.pool.get('hr.allounce.deduction.categoty').execute_function(cr, uid, line.category_id.id, line.slip_id.basic, context) employee = amount elif line.category_id.contribute and not line.category_id.include_in_salary and line.category_id.amount_type == 'per': company = amount * line.category_id.contribute_per employee = amount elif line.category_id.contribute and not line.category_id.include_in_salary and line.category_id.amount_type == 'fix': company = line.category_id.contribute_per employee = amount elif line.category_id.contribute and not line.category_id.include_in_salary and line.category_id.amount_type == 'func': company = self.pool.get('hr.allounce.deduction.categoty').execute_function(cr, uid, line.category_id.id, line.slip_id.basic, context) employee = amount ctr['emp_deduction'] = employee ctr['comp_deduction'] = company self.pool.get('hr.contibution.register.line').create(cr, uid, ctr)
def verify_sheet(self, cr, uid, ids, context={}): move_pool = self.pool.get('account.move') movel_pool = self.pool.get('account.move.line') exp_pool = self.pool.get('hr.expense.expense') for slip in self.browse(cr,uid,ids): total_deduct = 0.0 line_ids = [] partner = False partner_id = False if not slip.employee_id.address_home_id: raise osv.except_osv(_('Integrity Error !'), _('Please defined the Employee Home Address Along with Partners !!')) if not slip.employee_id.address_home_id.partner_id: raise osv.except_osv(_('Integrity Error !'), _('Please defined the Partner in Home Address !!')) partner = slip.employee_id.address_home_id.partner_id partner_id = slip.employee_id.address_home_id.partner_id.id period_id = False if slip.period_id: period_id = slip.period_id.id else: fiscal_year_ids = self.pool.get('account.fiscalyear').search(cr, uid, []) if not fiscal_year_ids: raise osv.except_osv(_('Warning !'), _('Please define fiscal year for perticular contract')) fiscal_year_objs = self.pool.get('account.fiscalyear').read(cr, uid, fiscal_year_ids, ['date_start','date_stop']) year_exist = False for fiscal_year in fiscal_year_objs: if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)): year_exist = True if not year_exist: raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s'%slip.date)) search_period = self.pool.get('account.period').search(cr,uid,[('date_start','<=',slip.date),('date_stop','>=',slip.date)]) if not search_period: raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s'%slip.date)) period_id = search_period[0] move = { #'name': slip.name, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'date': slip.date, 'ref':slip.number, 'narration': slip.name } move_id = move_pool.create(cr, uid, move) self.create_voucher(cr, uid, [slip.id], slip.name, move_id) line = { 'move_id':move_id, 'name': "By Basic Salary / " + slip.employee_id.name, 'date': slip.date, 'account_id': slip.employee_id.salary_account.id, 'debit': slip.basic, 'credit': 0.0, 'quantity':slip.working_days, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'analytic_account_id': False, 'ref':slip.number } #Setting Analysis Account for Basic Salary if slip.employee_id.analytic_account: line['analytic_account_id'] = slip.employee_id.analytic_account.id move_line_id = movel_pool.create(cr, uid, line) line_ids += [move_line_id] line = { 'move_id':move_id, 'name': "To Basic Paysble Salary / " + slip.employee_id.name, 'partner_id': partner_id, 'date': slip.date, 'account_id': slip.employee_id.employee_account.id, 'debit': 0.0, 'quantity':slip.working_days, 'credit': slip.basic, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, line)] for line in slip.line_ids: name = "[%s] - %s / %s" % (line.code, line.name, slip.employee_id.name) amount = line.total if line.type == 'leaves': continue rec = { 'move_id':move_id, 'name': name, 'date': slip.date, 'account_id': line.account_id.id, 'debit': 0.0, 'credit' : 0.0, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'analytic_account_id':False, 'ref':slip.number, 'quantity':1 } #Setting Analysis Account for Salary Slip Lines if line.analytic_account_id: rec['analytic_account_id'] = line.analytic_account_id.id else: rec['analytic_account_id'] = slip.deg_id.account_id.id if line.type == 'allounce' or line.type == 'otherpay': rec['debit'] = amount if not partner.property_account_payable: raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Payable Account!!')) ded_rec = { 'move_id':move_id, 'name': name, 'partner_id': partner_id, 'date': slip.date, 'account_id': partner.property_account_payable.id, 'debit': 0.0, 'quantity':1, 'credit' : amount, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, ded_rec)] elif line.type == 'deduction' or line.type == 'otherdeduct': if not partner.property_account_receivable: raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Receivable Account!!')) rec['credit'] = amount total_deduct += amount ded_rec = { 'move_id':move_id, 'name': name, 'partner_id': partner_id, 'date': slip.date, 'quantity':1, 'account_id': partner.property_account_receivable.id, 'debit': amount, 'credit' : 0.0, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, ded_rec)] line_ids += [movel_pool.create(cr, uid, rec)] if line.company_contrib > 0: company_contrib = line.company_contrib
7406420996dd681d6caa3a8ae0c3c42e5a7d6619 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7406420996dd681d6caa3a8ae0c3c42e5a7d6619/hr_payroll.py
def _get_leaves(self, cr, user, slip, employee, context={}): """ Compute leaves for an employee @param cr: cursor to database @param user: id of current user @param slip: object of the hr.payroll.slip model @param employee: object of the hr.employee model @param context: context arguments, like lang, time zone @return: return a result """ result = []
7406420996dd681d6caa3a8ae0c3c42e5a7d6619 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7406420996dd681d6caa3a8ae0c3c42e5a7d6619/hr_payroll.py
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
7406420996dd681d6caa3a8ae0c3c42e5a7d6619 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7406420996dd681d6caa3a8ae0c3c42e5a7d6619/hr_payroll.py
for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
7406420996dd681d6caa3a8ae0c3c42e5a7d6619 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7406420996dd681d6caa3a8ae0c3c42e5a7d6619/hr_payroll.py
if line.amount_type in ('fix', 'per'): value = line.amount elif line.amount_type == 'func':
if line.amount_type == 'func':
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
7406420996dd681d6caa3a8ae0c3c42e5a7d6619 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7406420996dd681d6caa3a8ae0c3c42e5a7d6619/hr_payroll.py
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
7406420996dd681d6caa3a8ae0c3c42e5a7d6619 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7406420996dd681d6caa3a8ae0c3c42e5a7d6619/hr_payroll.py
def check_duplicate(self, cr, uid, ids):
e55bd7051cdfcc53b81f73e0797722510c9ccc01 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e55bd7051cdfcc53b81f73e0797722510c9ccc01/fetchmail.py
count = 0
def button_confirm_login(self, cr, uid, ids, context={}): for server in self.browse(cr, uid, ids, context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) count = 0 try: if server.type == 'imap': imap_server = None if server.is_ssl: imap_server = IMAP4_SSL(server.server, int(server.port)) else: imap_server = IMAP4(server.server, int(server.port))
e55bd7051cdfcc53b81f73e0797722510c9ccc01 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e55bd7051cdfcc53b81f73e0797722510c9ccc01/fetchmail.py
"http://calendarserver.org/ns/" : ('getctag',),
"DAV:": ('principal-collection-set'), "http://cal.me.com/_namespace/" : ('user-state'), "http://calendarserver.org/ns/" : ( 'dropbox-home-URL', 'notification-URL', 'getctag',),
def _get_dav_getctag(self, cr): result = self.get_etag(cr) return str(result)
e067fa17a8ef9c2c74072f59edea4f78e688ae35 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e067fa17a8ef9c2c74072f59edea4f78e688ae35/caldav_node.py
def _get_caldav_calendar_data(self, cr): return self.get_data(cr) def _get_caldav_calendar_description(self, cr): uid = self.context.uid calendar_obj = self.context._dirobj.pool.get('basic.calendar') ctx = self.context.context.copy() ctx.update(self.dctx) calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx) return calendar.description def _get_caldav_calendar_home_set(self, cr): import xml.dom.minidom import urllib uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) calendar_obj = self.context._dirobj.pool.get('basic.calendar') calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx) huri = doc.createTextNode(urllib.quote('/%s/%s' % (cr.dbname, calendar.collection_id.name))) href = doc.documentElement href.tagName = 'D:href' href.appendChild(huri) return href def _get_caldav_calendar_user_address_set(self, cr): import xml.dom.minidom dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) user_obj = self.context._dirobj.pool.get('res.users') user = user_obj.browse(cr, uid, uid, context=ctx) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) href = doc.documentElement href.tagName = 'D:href' huri = doc.createTextNode('MAILTO:' + user.email) href.appendChild(huri) return href def _get_caldav_schedule_inbox_URL(self, cr): import xml.dom.minidom import urllib uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) calendar_obj = self.context._dirobj.pool.get('basic.calendar') calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx) res = '%s/%s' %(calendar.name, calendar.collection_id.name) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) href = doc.documentElement href.tagName = 'D:href' huri = doc.createTextNode(urllib.quote('/%s/%s' % (cr.dbname, res))) href.appendChild(huri) return href
def _get_ttag(self,cr): res = False if self.model and self.res_id: res = '%s_%d' % (self.model, self.res_id) elif self.calendar_id: res = '%d' % (self.calendar_id) return res
e067fa17a8ef9c2c74072f59edea4f78e688ae35 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e067fa17a8ef9c2c74072f59edea4f78e688ae35/caldav_node.py
def _get_caldav_schedule_outbox_URL(self, cr): return self._get_caldav_schedule_inbox_URL(cr)
def _get_caldav_schedule_outbox_URL(self, cr): return self._get_caldav_schedule_inbox_URL(cr)
e067fa17a8ef9c2c74072f59edea4f78e688ae35 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e067fa17a8ef9c2c74072f59edea4f78e688ae35/caldav_node.py
order_obj = self.pool.get('payment.order')
def search_entries(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line') mod_obj = self.pool.get('ir.model.data') if context is None: context = {} data = self.read(cr, uid, ids, [], context=context)[0] search_due_date = data['duedate']
3de826e235d514fd83aaf67fb7785922f1a34de9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3de826e235d514fd83aaf67fb7785922f1a34de9/account_payment_order.py
self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context)
self.create_move_from_st_line(cr, uid, st_line, company_currency_id, st_line_number, context)
def button_confirm_bank(self, cr, uid, ids, context=None): done = [] obj_seq = self.pool.get('ir.sequence') if context is None: context = {}
e87753d2e9f4f526e292610f3469b5e9db18ec34 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e87753d2e9f4f526e292610f3469b5e9db18ec34/account_bank_statement.py
p.sale_id,sum(m.product_qty), m.state
p.sale_id,sum(m.product_qty), mp.state as mp_state
def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res
7a2cc710fef49fdec6ec3a9f0a896f563619db8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7a2cc710fef49fdec6ec3a9f0a896f563619db8f/sale.py
p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel':
p.sale_id = ANY(%s) GROUP BY mp.state, p.sale_id''') for oid, nbr, mp_state in cr.fetchall(): if mp_state == 'cancel':
def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res
7a2cc710fef49fdec6ec3a9f0a896f563619db8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7a2cc710fef49fdec6ec3a9f0a896f563619db8f/sale.py
if state == 'done':
if mp_state == 'done':
def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res
7a2cc710fef49fdec6ec3a9f0a896f563619db8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7a2cc710fef49fdec6ec3a9f0a896f563619db8f/sale.py
'user_id':fields.many2one('res.users', 'Responsible', readonly=True),
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_report') cr.execute(""" create or replace view purchase_report as ( select min(l.id) as id, s.date_order as date, to_char(s.date_order, 'YYYY') as name, to_char(s.date_order, 'MM') as month, s.state, s.warehouse_id as warehouse_id, s.partner_id as partner_id, s.fiscal_position, s.create_uid as user_id, s.company_id as company_id, s.invoice_method, l.product_id, s.location_id as location_id, sum(l.product_qty*u.factor) as quantity, count(*) as nbr, sum(l.product_qty*l.price_unit) as price_total, (sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average from purchase_order s left join purchase_order_line l on (s.id=l.order_id) left join product_uom u on (u.id=l.product_uom) where l.product_id is not null group by s.company_id, s.create_uid, s.partner_id, s.location_id, l.product_id, s.date_order, to_char(s.date_order, 'YYYY'), to_char(s.date_order, 'MM'), s.state, s.warehouse_id, s.fiscal_position, s.invoice_method ) """)
9da45d3b15595e5a0b0fa6b9a76f8c8f7c0b8e1f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9da45d3b15595e5a0b0fa6b9a76f8c8f7c0b8e1f/purchase_report.py
create_uid as user_id,
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_order_qty_amount') cr.execute(""" create or replace view purchase_order_qty_amount as ( select min(id) as id, to_char(create_date, 'MM') as month, sum(product_qty) as total_qty, create_uid as user_id, sum(price_unit*product_qty) as total_amount from purchase_order_line where to_char(create_date,'YYYY') = to_char(current_date,'YYYY') group by to_char(create_date, 'MM'), create_uid
9da45d3b15595e5a0b0fa6b9a76f8c8f7c0b8e1f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9da45d3b15595e5a0b0fa6b9a76f8c8f7c0b8e1f/purchase_report.py
to_char(create_date, 'MM'), create_uid
to_char(create_date, 'MM')
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_order_qty_amount') cr.execute(""" create or replace view purchase_order_qty_amount as ( select min(id) as id, to_char(create_date, 'MM') as month, sum(product_qty) as total_qty, create_uid as user_id, sum(price_unit*product_qty) as total_amount from purchase_order_line where to_char(create_date,'YYYY') = to_char(current_date,'YYYY') group by to_char(create_date, 'MM'), create_uid
9da45d3b15595e5a0b0fa6b9a76f8c8f7c0b8e1f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9da45d3b15595e5a0b0fa6b9a76f8c8f7c0b8e1f/purchase_report.py
for slip in self.browse(cr, uid, ids, context=context):
for slip in self.browse(cr, uid, ids, context=context):
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
9860aa21c1fe5c45980f9f219fe454f393bf69ed /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9860aa21c1fe5c45980f9f219fe454f393bf69ed/hr_payroll.py
if not slip.employee_id.contract_id:
update = {} ttyme = datetime.fromtimestamp(time.mktime(time.strptime(slip.date,"%Y-%m-%d"))) contracts = self.get_contract(cr, uid, slip.employee_id, date, context) if contracts.get('id', False) == False: update.update({ 'basic': round(0.0), 'basic_before_leaves': round(0.0), 'name':'Salary Slip of %s for %s' % (slip.employee_id.name, ttyme.strftime('%B-%Y')), 'state':'draft', 'contract_id':False, 'company_id':slip.employee_id.company_id.id }) self.write(cr, uid, [slip.id], update, context=context)
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
9860aa21c1fe5c45980f9f219fe454f393bf69ed /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9860aa21c1fe5c45980f9f219fe454f393bf69ed/hr_payroll.py
update = {}
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
9860aa21c1fe5c45980f9f219fe454f393bf69ed /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9860aa21c1fe5c45980f9f219fe454f393bf69ed/hr_payroll.py
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
9860aa21c1fe5c45980f9f219fe454f393bf69ed /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9860aa21c1fe5c45980f9f219fe454f393bf69ed/hr_payroll.py
ttyme = datetime.fromtimestamp(time.mktime(time.strptime(slip.date,"%Y-%m-%d")))
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
9860aa21c1fe5c45980f9f219fe454f393bf69ed /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9860aa21c1fe5c45980f9f219fe454f393bf69ed/hr_payroll.py
if not slip.employee_id.contract_id:
if not slip.contract_id:
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
9860aa21c1fe5c45980f9f219fe454f393bf69ed /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9860aa21c1fe5c45980f9f219fe454f393bf69ed/hr_payroll.py
sql = [ """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2""", """WHERE l2.account_id = l1.account_id""", """AND""", """l1.id <= l2.id""", """AND""", """l2.id IN %s""", """AND""", self._query_get(cr, uid, obj='l1', context=c), """ GROUP BY l2.id""", ] cr.execute('\n'.join(sql), [tuple(ids)])
sql = """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2 WHERE l2.account_id = l1.account_id AND l1.id <= l2.id AND l2.id IN %%s AND """ + \ self._query_get(cr, uid, obj='l1', context=c) + \ " GROUP BY l2.id" cr.execute(sql, [tuple(ids)])
def _balance(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} c = context.copy() c['initital_bal'] = True sql = [ """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2""", """WHERE l2.account_id = l1.account_id""", """AND""", """l1.id <= l2.id""", """AND""", """l2.id IN %s""", """AND""", self._query_get(cr, uid, obj='l1', context=c), """ GROUP BY l2.id""", ]
bffc2487968be0e77241d5d40d353901e4ce3aed /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bffc2487968be0e77241d5d40d353901e4ce3aed/account_move_line.py
import pdb pdb.set_trace()
def get_memory(self, cr, obj, ids, name, user=None, context=None, values=None): if not context: context = {} if not values: values = [] res = {} for i in ids: val = None for v in values: if v['id'] == i: val = v[name] break
53d3e74d66dfdcbe7706b83d0cf65098ac369f64 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/53d3e74d66dfdcbe7706b83d0cf65098ac369f64/fields.py
def _eval_xml(self, node, pool, cr, uid, idref, context=None): if context is None: context = {} if node.tag in ('field','value'): t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res elif node.tag == "getitem": for n in node: res=_eval_xml(self,n,pool,cr,uid,idref) if not res: raise LookupError elif node.get('type') in ("int", "list"): return res[int(node.get('index'))] else: return res[node.get('index','').encode("utf8")] elif node.tag == "function": args = [] a_eval = node.get('eval','') if a_eval: idref['ref'] = lambda x: self.id_get(cr, False, x) args = unsafe_eval(a_eval, idref) for n in node: return_val = _eval_xml(self,n, pool, cr, uid, idref, context) if return_val is not None: args.append(return_val) model = pool.get(node.get('model','')) method = node.get('name','') res = getattr(model, method)(cr, uid, *args) return res elif node.tag == "test": return node.text
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
return unsafe_eval(a_eval, idref2)
return unsafe_eval(a_eval, idref2)
def _eval_xml(self, node, pool, cr, uid, idref, context=None): if context is None: context = {} if node.tag in ('field','value'): t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res elif node.tag == "getitem": for n in node: res=_eval_xml(self,n,pool,cr,uid,idref) if not res: raise LookupError elif node.get('type') in ("int", "list"): return res[int(node.get('index'))] else: return res[node.get('index','').encode("utf8")] elif node.tag == "function": args = [] a_eval = node.get('eval','') if a_eval: idref['ref'] = lambda x: self.id_get(cr, False, x) args = unsafe_eval(a_eval, idref) for n in node: return_val = _eval_xml(self,n, pool, cr, uid, idref, context) if return_val is not None: args.append(return_val) model = pool.get(node.get('model','')) method = node.get('name','') res = getattr(model, method)(cr, uid, *args) return res elif node.tag == "test": return node.text
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return ""
logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return ""
def _eval_xml(self, node, pool, cr, uid, idref, context=None): if context is None: context = {} if node.tag in ('field','value'): t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res elif node.tag == "getitem": for n in node: res=_eval_xml(self,n,pool,cr,uid,idref) if not res: raise LookupError elif node.get('type') in ("int", "list"): return res[int(node.get('index'))] else: return res[node.get('index','').encode("utf8")] elif node.tag == "function": args = [] a_eval = node.get('eval','') if a_eval: idref['ref'] = lambda x: self.id_get(cr, False, x) args = unsafe_eval(a_eval, idref) for n in node: return_val = _eval_xml(self,n, pool, cr, uid, idref, context) if return_val is not None: args.append(return_val) model = pool.get(node.get('model','')) method = node.get('name','') res = getattr(model, method)(cr, uid, *args) return res elif node.tag == "test": return node.text
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
if data_node_context: context = unsafe_eval(data_node_context, eval_dict) else: context = {}
def get_context(self, data_node, node, eval_dict): data_node_context = (len(data_node) and data_node.get('context','').encode('utf8')) if data_node_context: context = unsafe_eval(data_node_context, eval_dict) else: context = {}
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
if node_context: context.update(unsafe_eval(node_context, eval_dict))
context = {} for ctx in (data_node_context, node_context): if ctx: try: ctx_res = unsafe_eval(ctx, eval_dict) if isinstance(context, dict): context.update(ctx_res) else: context = ctx_res except NameError: context = ctx logging.getLogger("init").debug('Context value (%s) for element with id "%s" or its data node does not parse '\ 'at server-side, keeping original string, in case it\'s meant for client side only', ctx, node.get('id','n/a'), exc_info=True)
def get_context(self, data_node, node, eval_dict): data_node_context = (len(data_node) and data_node.get('context','').encode('utf8')) if data_node_context: context = unsafe_eval(data_node_context, eval_dict) else: context = {}
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
context = rec.get('context','').encode('utf-8') or '{}'
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form'
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form'
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form'
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
context = unsafe_eval(context)
eval_context = { 'name': name, 'xml_id': xml_id, 'type': type, 'view_id': view_id, 'domain': domain, 'res_model': res_model, 'src_model': src_model, 'view_type': view_type, 'view_mode': view_mode, 'usage': usage, 'limit': limit, 'auto_refresh': auto_refresh, 'uid' : uid, 'active_id': active_id, 'ref' : ref, } context = self.get_context(data_node, rec, eval_context) try: domain = unsafe_eval(domain, eval_context) except NameError: logging.getLogger("init").debug('Domain value (%s) for element with id "%s" does not parse '\ 'at server-side, keeping original string, in case it\'s meant for client side only', domain, xml_id or 'n/a', exc_info=True)
def ref(str_id): return self.id_get(cr, None, str_id)
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
f_ref = field.get("ref",'').encode('ascii')
f_ref = field.get("ref",'').encode('utf-8')
def _tag_record(self, cr, rec, data_node=None): rec_model = rec.get("model").encode('ascii') model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.get("id",'').encode('ascii') rec_context = rec.get("context", None) if rec_context: rec_context = unsafe_eval(rec_context) self._test_xml_id(rec_id) if self.isnoupdate(data_node) and self.mode != 'init': # check if the xml record has an id string if rec_id: if '.' in rec_id: module,rec_id2 = rec_id.split('.') else: module = self.module rec_id2 = rec_id id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2) # check if the resource already existed at the last update if id: # if it existed, we don't update the data, but we need to # know the id of the existing record anyway self.idref[rec_id] = int(id) return None else: # if the resource didn't exist if not self.nodeattr2bool(rec, 'forcecreate', True): # we don't want to create it, so we skip it return None # else, we let the record to be created
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
f_model = field.get("model",'').encode('ascii')
f_model = field.get("model",'').encode('utf-8')
def _tag_record(self, cr, rec, data_node=None): rec_model = rec.get("model").encode('ascii') model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.get("id",'').encode('ascii') rec_context = rec.get("context", None) if rec_context: rec_context = unsafe_eval(rec_context) self._test_xml_id(rec_id) if self.isnoupdate(data_node) and self.mode != 'init': # check if the xml record has an id string if rec_id: if '.' in rec_id: module,rec_id2 = rec_id.split('.') else: module = self.module rec_id2 = rec_id id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2) # check if the resource already existed at the last update if id: # if it existed, we don't update the data, but we need to # know the id of the existing record anyway self.idref[rec_id] = int(id) return None else: # if the resource didn't exist if not self.nodeattr2bool(rec, 'forcecreate', True): # we don't want to create it, so we skip it return None # else, we let the record to be created
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
f_use = field.get("use",'').encode('ascii') or 'id'
f_use = field.get("use",'').encode('utf-8') or 'id'
def _tag_record(self, cr, rec, data_node=None): rec_model = rec.get("model").encode('ascii') model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.get("id",'').encode('ascii') rec_context = rec.get("context", None) if rec_context: rec_context = unsafe_eval(rec_context) self._test_xml_id(rec_id) if self.isnoupdate(data_node) and self.mode != 'init': # check if the xml record has an id string if rec_id: if '.' in rec_id: module,rec_id2 = rec_id.split('.') else: module = self.module rec_id2 = rec_id id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2) # check if the resource already existed at the last update if id: # if it existed, we don't update the data, but we need to # know the id of the existing record anyway self.idref[rec_id] = int(id) return None else: # if the resource didn't exist if not self.nodeattr2bool(rec, 'forcecreate', True): # we don't want to create it, so we skip it return None # else, we let the record to be created
fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fdabe0f0dbaca61e1dcb395b5df9ce609b1cc6e2/convert.py
'title': fields.many2one('res.partner.title','Title'),
'title': fields.many2one('res.partner.title','Legal Status'),
def _lang_get(self, cr, uid, context={}): obj = self.pool.get('res.lang') ids = obj.search(cr, uid, [], context=context) res = obj.read(cr, uid, ids, ['code', 'name'], context) return [(r['code'], r['name']) for r in res] + [('','')]
487c36486ca1f5a47369933920e0ceeaff82ac29 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/487c36486ca1f5a47369933920e0ceeaff82ac29/partner.py
help="Check this box if you want to print all entries when printing the General Ledger, "\ "otherwise it will only print its balance."),
def _get_level(self, cr, uid, ids, field_name, arg, context={}): res={} accounts = self.browse(cr, uid, ids) for account in accounts: level = 0 if account.parent_id : obj = self.browse(cr, uid, account.parent_id.id) level = obj.level + 1 res[account.id] = level return res
ca13e53e506133164be6f12f46785a6fb44e3920 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ca13e53e506133164be6f12f46785a6fb44e3920/account.py
raise except_orm(_('Error'), _("You can not remove the field '%s' !") %(field.name,))
raise except_orm(_('Error'), _("You cannot remove the field '%s' !") %(field.name,))
def unlink(self, cr, user, ids, context=None): for field in self.browse(cr, user, ids, context): if field.state <> 'manual': raise except_orm(_('Error'), _("You can not remove the field '%s' !") %(field.name,)) # # MAY BE ADD A ALTER TABLE DROP ? # return super(ir_model_fields, self).unlink(cr, user, ids, context)
abc44a50cbffdab7372e598f4a2f1fcf71b5e4f1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/abc44a50cbffdab7372e598f4a2f1fcf71b5e4f1/ir_model.py
'name': reg.invoice_label + '-' + reg.name,
'name': reg.invoice_label + '-' + c_name,
def _makeInvoices(self, cr, uid, context={}): invoices = {} invoice_ids = [] create_ids=[] tax_ids=[] inv_create = 0 inv_reject = 0 inv_rej_reason = "" list_inv = [] obj_event_reg = self.pool.get('event.registration') obj_lines = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') data_event_reg = obj_event_reg.browse(cr,uid, context['active_ids'], context=context)
3a1c5f23a48563fde0caf761db91b27c4c7d222b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3a1c5f23a48563fde0caf761db91b27c4c7d222b/event_make_invoice.py
acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 0.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=context) amount_unit = obj_timesheet.on_change_unit_amount(cr, uid, timeline_id, prod_id, amount, False, unit, context=context) if amount_unit and 'amount' in amount_unit.get('value',{}): updv = { 'amount': amount_unit['value']['amount'] } obj_timesheet.write(cr, uid, [timeline_id], updv, context=context) vals['hr_analytic_timesheet_id'] = timeline_id
acc_id = obj_task.project_id and obj_task.project_id.analytic_account_id.id or False if acc_id: vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 0.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=context) amount_unit = obj_timesheet.on_change_unit_amount(cr, uid, timeline_id, prod_id, amount, False, unit, context=context) if amount_unit and 'amount' in amount_unit.get('value',{}): updv = { 'amount': amount_unit['value']['amount'] } obj_timesheet.write(cr, uid, [timeline_id], updv, context=context) vals['hr_analytic_timesheet_id'] = timeline_id
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') project_obj = self.pool.get('project.project') task_obj = self.pool.get('project.task') uom_obj = self.pool.get('product.uom') vals_line = {} context = kwargs.get('context', {}) #TOFIX: after loading project_timesheet module, it's fail yml of other project* modules. #Temporary: pass context['withoutemployee'] = True in all yml. if 'withoutemployee' in context and context['withoutemployee']: return super(project_work,self).create(cr, uid, vals, context=context) obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] #calculate quantity based on employee's product's uom vals_line['unit_amount'] = vals['hours'] user_uom, default_uom = project_obj._get_user_and_default_uom_ids(cr, uid) if result['product_uom_id'] != default_uom: vals_line['unit_amount'] = uom_obj._compute_qty(cr, uid, default_uom, vals['hours'], result['product_uom_id']) acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 0.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=context)
467edb6094f68da432d982a5660ff190c4e43538 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/467edb6094f68da432d982a5660ff190c4e43538/project_timesheet.py
WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id2.id, f.warehouse_id2.id))
WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id.id, f.warehouse_id.id))
def create_planning(self,cr, uid, ids, context=None): if context is None: context = {} product_obj = self.pool.get('product.product') planning_obj = self.pool.get('stock.planning') mod_obj = self.pool.get('ir.model.data') prod_categ_obj = self.pool.get('product.category') template_obj = self.pool.get('product.template') planning_lines = [] for f in self.browse(cr, uid, ids, context=context): if f.forecasted_products: cr.execute("SELECT product_id \ FROM stock_sale_forecast \ WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id2.id, f.warehouse_id2.id)) products_id1 = [x for x, in cr.fetchall()] else: categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or [] prod_categ_ids = prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)]) templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)]) products_id1 = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)]) if len(products_id1)==0: raise osv.except_osv(_('Error !'), _('No forecasts for selected period or no products in selected category !'))
ee06bf43d117c2cb365f4af7d9e63b7c8696a094 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ee06bf43d117c2cb365f4af7d9e63b7c8696a094/stock_planning_createlines.py
def _amount_all(self, cr, uid, ids, field_name, arg, context):
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
18d91e942da0a835a4d6b528115c091175aaaaaa /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/18d91e942da0a835a4d6b528115c091175aaaaaa/purchase.py
}
}
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
18d91e942da0a835a4d6b528115c091175aaaaaa /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/18d91e942da0a835a4d6b528115c091175aaaaaa/purchase.py
cur=order.pricelist_id.currency_id
cur = order.pricelist_id.currency_id
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
18d91e942da0a835a4d6b528115c091175aaaaaa /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/18d91e942da0a835a4d6b528115c091175aaaaaa/purchase.py
val+= c['amount'] val1 += line.price_subtotal
val += c['amount']
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
18d91e942da0a835a4d6b528115c091175aaaaaa /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/18d91e942da0a835a4d6b528115c091175aaaaaa/purchase.py
refs = msg.get('references') references = refs.split()
refs = msg.get('references',False) references = False if refs: references = refs.split()
def search_message(self, cr, uid, message, context=None): #@param message: string of mail which is read from EML File #@return model,res_id references = [] dictcreate = dict(message) msg = dictcreate.get('message') msg = self.pool.get('email.server.tools').parse_message(msg) message_id = msg.get('message-id') refs = msg.get('references') references = refs.split() msg_pool = self.pool.get('mailgate.message') model = '' res_id = 0 if message_id: msg_ids = msg_pool.search(cr, uid, [('message_id','=',message_id)]) if msg_ids and len(msg_ids): msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id else: if references : msg_ids = msg_pool.search(cr, uid, [('message_id','in',references)]) msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id return (model,res_id)
c1b6bb712dbb5a9e60f1d928f22a7b797b098a48 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c1b6bb712dbb5a9e60f1d928f22a7b797b098a48/partner.py
msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id
if msg_ids and len(msg_ids): msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id
def search_message(self, cr, uid, message, context=None): #@param message: string of mail which is read from EML File #@return model,res_id references = [] dictcreate = dict(message) msg = dictcreate.get('message') msg = self.pool.get('email.server.tools').parse_message(msg) message_id = msg.get('message-id') refs = msg.get('references') references = refs.split() msg_pool = self.pool.get('mailgate.message') model = '' res_id = 0 if message_id: msg_ids = msg_pool.search(cr, uid, [('message_id','=',message_id)]) if msg_ids and len(msg_ids): msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id else: if references : msg_ids = msg_pool.search(cr, uid, [('message_id','in',references)]) msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id return (model,res_id)
c1b6bb712dbb5a9e60f1d928f22a7b797b098a48 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c1b6bb712dbb5a9e60f1d928f22a7b797b098a48/partner.py
CASE WHEN l.amount > 0 THEN l.amount ELSE 0.0 END ) as debit, sum( CASE WHEN l.amount < 0 THEN -l.amount ELSE 0.0 END ) as credit,
CASE WHEN l.amount > 0 THEN l.amount ELSE 0.0 END ) as debit, sum( CASE WHEN l.amount < 0 THEN -l.amount ELSE 0.0 END ) as credit,
def _debit_credit_bal_qtty(self, cr, uid, ids, name, arg, context=None): res = {} if context is None: context = {} child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) for i in child_ids: res[i] = {} for n in name: res[i][n] = 0.0
5a377aaa6fb102d846891b9e87e14ac4ba687b52 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5a377aaa6fb102d846891b9e87e14ac4ba687b52/analytic.py
bname,ext = os.path.splitext(filename)
try: bname,ext = os.path.splitext(filename or 'test.tmp') except Exception: bname, ext = filename, 'tmp'
def doIndex(self, content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None if content_type and self.mimes.has_key(content_type): mime = content_type fobj = self.mimes[content_type] elif filename: bname,ext = os.path.splitext(filename) if self.exts.has_key(ext): fobj = self.exts[ext] mime = fobj._getDefMime(ext) if content_type and not fobj: mime,fobj = mime_match(content_type, self.mimes) if not fobj: try: if realfname : fname = realfname else: bname,ext = os.path.splitext(filename) fd, fname = tempfile.mkstemp(suffix=ext) os.write(fd, content) os.close(fd) fp = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE).stdout result = fp.read() fp.close() mime2 = result.split(';')[0] self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. mime,fobj = mime_match(mime2, self.mimes) if not mime: mime = mime2 except Exception: self.__logger.exception('Cannot determine mime type') try: if fobj: res = (mime, fobj.indexContent(content,filename,fname or realfname) ) else: self.__logger.debug("Have no object, return (%s, None)", mime) res = (mime, None ) except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname) res = None # If we created a tmp file, unlink it now if not realfname and fname: try: os.unlink(fname) except Exception: self.__logger.exception("Could not unlink %s", fname) return res
6d64f88d5536ae14026556729433ea27b5eece61 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6d64f88d5536ae14026556729433ea27b5eece61/content_index.py
can_compute = True for child in current.child_id: if child.id not in sums: can_compute = False try: brs.insert(0, brs.pop(brs.index(child))) except ValueError: brs.insert(0, child) if can_compute: brs.pop(0) for fn in field_names: sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0) if current.child_id: sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id)
brs.pop(0) for fn in field_names: sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0) if current.child_id: sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id)
def __compute(self, cr, uid, ids, field_names, arg=None, context=None, query='', query_params=()): """ compute the balance, debit and/or credit for the provided account ids Arguments: `ids`: account ids `field_names`: the fields to compute (a list of any of 'balance', 'debit' and 'credit') `arg`: unused fields.function stuff `query`: additional query filter (as a string) `query_params`: parameters for the provided query string (__compute will handle their escaping) as a tuple """ mapping = { 'balance': "COALESCE(SUM(l.debit),0) " \ "- COALESCE(SUM(l.credit), 0) as balance", 'debit': "COALESCE(SUM(l.debit), 0) as debit", 'credit': "COALESCE(SUM(l.credit), 0) as credit" } #get all the necessary accounts children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context) #compute for each account the balance/debit/credit from the move lines accounts = {} if children_and_consolidated: aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
0846b6491e09f04b63f730f270a0f5d207f3b3b1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0846b6491e09f04b63f730f270a0f5d207f3b3b1/account.py
"sale_tax": fields.many2one("account.tax.template", "Sale Tax"), "purchase_tax": fields.many2one("account.tax.template", "Purchase Tax"),
"sale_tax": fields.many2one("account.tax.template", "Default Sale Tax"), "purchase_tax": fields.many2one("account.tax.template", "Default Purchase Tax"),
def _default_company(self, cr, uid, context={}): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) if user.company_id: return user.company_id.id return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
199387f4c6ac4b8f45974104acb7984471964ccc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/199387f4c6ac4b8f45974104acb7984471964ccc/account.py
ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" , "=", chart_template_id)], order="sequence") if len(ids) > 0: id=ids[0] res['value']["sale_tax"] = id res['value']["purchase_tax"] = id
sale_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" , "=", chart_template_id), ('type_tax_use', 'in', ('sale','all'))], order="sequence") purchase_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" , "=", chart_template_id), ('type_tax_use', 'in', ('purchase','all'))], order="sequence") res['value']["sale_tax"] = sale_tax_ids and sale_tax_ids[0] or False res['value']["purchase_tax"] = purchase_tax_ids and purchase_tax_ids[0] or False
def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None): res = {} res['value'] = {} res['value']["sale_tax"] = False res['value']["purchase_tax"] = False if chart_template_id: ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" , "=", chart_template_id)], order="sequence") if len(ids) > 0: id=ids[0] res['value']["sale_tax"] = id res['value']["purchase_tax"] = id return res
199387f4c6ac4b8f45974104acb7984471964ccc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/199387f4c6ac4b8f45974104acb7984471964ccc/account.py
return sequence + str(self.checksum(sequence))
try: return sequence + str(self.checksum(sequence)) except Exception, e: return sequence
def make_sscc(self, cr, uid, context=None): sequence = self.pool.get('ir.sequence').get(cr, uid, 'stock.lot.tracking') return sequence + str(self.checksum(sequence))
89c06b09feff4e0b779370a03925fec729a11b32 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/89c06b09feff4e0b779370a03925fec729a11b32/stock.py
method=True, store=True, type='datetime', string='Expected Date', select=1, help="Expected date for the picking to be processed. Will be set to date of actual processing if not specified."),
method=True, store=True, type='datetime', string='Expected Date', select=1, help="Expected date for the picking to be processed"),
def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) new_id = super(stock_picking, self).create(cr, user, vals, context) return new_id
9f6c10ca2a1258aae7d418c26f5083177e38b1a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f6c10ca2a1258aae7d418c26f5083177e38b1a6/stock.py
users_obj = self.pool.get('res.users')
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
9f6c10ca2a1258aae7d418c26f5083177e38b1a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f6c10ca2a1258aae7d418c26f5083177e38b1a6/stock.py
prodlot_id = partial_data.get('prodlot_id',False)
prodlot_id = partial_data.get('prodlot_id') prodlot_ids[move.id] = prodlot_id
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
9f6c10ca2a1258aae7d418c26f5083177e38b1a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f6c10ca2a1258aae7d418c26f5083177e38b1a6/stock.py
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
9f6c10ca2a1258aae7d418c26f5083177e38b1a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f6c10ca2a1258aae7d418c26f5083177e38b1a6/stock.py
user = users_obj.browse(cr, uid, uid)
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
9f6c10ca2a1258aae7d418c26f5083177e38b1a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f6c10ca2a1258aae7d418c26f5083177e38b1a6/stock.py
pricetype ='standard_price' if pricetype and qty > 0:
if qty > 0:
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
9f6c10ca2a1258aae7d418c26f5083177e38b1a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f6c10ca2a1258aae7d418c26f5083177e38b1a6/stock.py
amount_unit = product.price_get(pricetype, context)[product.id]
amount_unit = product.price_get('standard_price', context)[product.id]
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
9f6c10ca2a1258aae7d418c26f5083177e38b1a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f6c10ca2a1258aae7d418c26f5083177e38b1a6/stock.py
product_obj.write(cr, uid, [product.id], {pricetype.field: new_std_price})
product_obj.write(cr, uid, [product.id], {'standard_price': new_std_price})
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
9f6c10ca2a1258aae7d418c26f5083177e38b1a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f6c10ca2a1258aae7d418c26f5083177e38b1a6/stock.py
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
9f6c10ca2a1258aae7d418c26f5083177e38b1a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f6c10ca2a1258aae7d418c26f5083177e38b1a6/stock.py