rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
message = type_list.get(pick.type, _('Document')) + " '" + pick.name + "' "+ _("is ready to be processed.")
message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or 'n/a') + "' "+ _("is ready to be processed.")
def action_assign_wkf(self, cr, uid, ids, context=None): for pick in self.browse(cr, uid, ids, context=context): type_list = { 'out':'Packing List', 'in':'Reception', 'internal': 'Internal picking', 'delivery': 'Delivery order' } message = type_list.get(pick.type, _('Document')) + " '" + pick.name + "' "+ _("is ready to be processed.") self.log(cr, uid, id, message) self.write(cr, uid, ids, {'state': 'assigned'}) return True
04479073567222206d120f3c501672dc33a16512 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/04479073567222206d120f3c501672dc33a16512/stock.py
html = soup.__str__()
html = unicode(soup)
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <[email protected]> ## download here: http://www.peterbe.com/plog/html2plaintext """ from an HTML text, convert the HTML to plain text. If @body_id is provided then this is the tag where the body (not necessarily <body>) starts. """ try: from BeautifulSoup import BeautifulSoup, SoupStrainer, Comment except: return html urls = [] if body_id is not None: strainer = SoupStrainer(id=body_id) else: strainer = SoupStrainer('body') soup = BeautifulSoup(html, parseOnlyThese=strainer, fromEncoding=encoding) for link in soup.findAll('a'): title = link.renderContents() for url in [x[1] for x in link.attrs if x[0]=='href']: urls.append(dict(url=url, tag=str(link), title=title)) html = soup.__str__() url_index = [] i = 0 for d in urls: if d['title'] == d['url'] or 'http://'+d['title'] == d['url']: html = html.replace(d['tag'], d['url']) else: i += 1 html = html.replace(d['tag'], '%s [%s]' % (d['title'], i)) url_index.append(d['url']) html = html.replace('<strong>', '*').replace('</strong>', '*') html = html.replace('<b>', '*').replace('</b>', '*') html = html.replace('<h3>', '*').replace('</h3>', '*') html = html.replace('<h2>', '**').replace('</h2>', '**') html = html.replace('<h1>', '**').replace('</h1>', '**') html = html.replace('<em>', '/').replace('</em>', '/') # the only line breaks we respect is those of ending tags and # breaks html = html.replace('\n', ' ') html = html.replace('<br>', '\n') html = html.replace('<tr>', '\n') html = html.replace('</p>', '\n\n') html = re.sub('<br\s*/>', '\n', html) html = html.replace(' ' * 2, ' ') # for all other tags we failed to clean up, just remove then and # complain about them on the stderr def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' ' html = re.sub('<.*?>', desperate_fixer, html) # lstrip all lines html = '\n'.join([x.lstrip() for x in html.splitlines()]) for i, url in enumerate(url_index): if i == 0: html += '\n\n' html += '[%s] %s\n' % (i+1, url) return html
10a317d824e73de703eaf65990d0743a584f12a5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/10a317d824e73de703eaf65990d0743a584f12a5/openerp_mailgate.py
"SELECT '1' as type, '' as ref, '' as account_id, '' as account_name, '' as code, '' as name, sum(debit) as debit, sum(credit) as credit, " \
"SELECT '1' as type, '' as ref, l.account_id as account_id, '' as account_name, '' as code, '' as name, sum(debit) as debit, sum(credit) as credit, " \
def lines(self, data): full_account = [] result_tmp = 0.0 if self.date_lst: self.cr.execute( "SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \ "CASE WHEN sum(debit) > sum(credit) " \ "THEN sum(debit) - sum(credit) " \ "ELSE 0 " \ "END AS sdebit, " \ "CASE WHEN sum(debit) < sum(credit) " \ "THEN sum(credit) - sum(debit) " \ "ELSE 0 " \ "END AS scredit, " \ "(SELECT sum(debit-credit) " \ "FROM account_move_line l " \ "WHERE partner_id = p.id " \ "AND l.date IN %s " \ "AND blocked = TRUE " \ ") AS enlitige " \ "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \ "JOIN account_account ac ON (l.account_id = ac.id)" \ "WHERE ac.type IN %s " \ "AND l.date IN %s " \
31836de9aacb8ff0fec4c6076860cce7ec3ed4c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/31836de9aacb8ff0fec4c6076860cce7ec3ed4c3/partner_balance.py
debit += r['debit'] credit += r['credit'] res_init['credit'] = credit res_init['debit'] = debit res_init['type'] = 3 res_init['ref'] = '' res_init['code'] = '' res_init['name'] = 'Initial Balance' res_init['balance'] = debit - credit res_init['enlitige'] = 0.0
if final_init.get(r['account_id'], False): res_init = final_init[r['account_id']] debit += final_init[r['account_id']]['debit'] credit += final_init[r['account_id']]['credit'] res_init['credit'] = credit res_init['debit'] = debit res_init['type'] = 3 res_init['ref'] = '' res_init['code'] = '' res_init['name'] = 'Initial Balance' res_init['balance'] = debit - credit res_init['enlitige'] = 0.0 res_init['account_id'] = final_init[r['account_id']]['account_id'] else: res_init = {} debit = r['debit'] credit = r['credit'] res_init['credit'] = credit res_init['debit'] = debit res_init['type'] = 3 res_init['ref'] = '' res_init['code'] = '' res_init['name'] = 'Initial Balance' res_init['balance'] = debit - credit res_init['enlitige'] = 0.0 res_init['account_id'] = r['account_id'] final_init[r['account_id']] = res_init
def lines(self, data): full_account = [] result_tmp = 0.0 if self.date_lst: self.cr.execute( "SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \ "CASE WHEN sum(debit) > sum(credit) " \ "THEN sum(debit) - sum(credit) " \ "ELSE 0 " \ "END AS sdebit, " \ "CASE WHEN sum(debit) < sum(credit) " \ "THEN sum(credit) - sum(debit) " \ "ELSE 0 " \ "END AS scredit, " \ "(SELECT sum(debit-credit) " \ "FROM account_move_line l " \ "WHERE partner_id = p.id " \ "AND l.date IN %s " \ "AND blocked = TRUE " \ ") AS enlitige " \ "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \ "JOIN account_account ac ON (l.account_id = ac.id)" \ "WHERE ac.type IN %s " \ "AND l.date IN %s " \
31836de9aacb8ff0fec4c6076860cce7ec3ed4c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/31836de9aacb8ff0fec4c6076860cce7ec3ed4c3/partner_balance.py
if self.soldeinit: subtotal_row.insert(0, res_init) return subtotal_row
if not self.soldeinit: return subtotal_row subtotal = copy.deepcopy(subtotal_row) init_acnt = [] for row in subtotal_row: if final_init and row.get('account_id', False) and not row['account_id'] in init_acnt: subtotal.insert(subtotal.index(row), final_init[row['account_id']]) init_acnt.append(row['account_id']) return subtotal
def lines(self, data): full_account = [] result_tmp = 0.0 if self.date_lst: self.cr.execute( "SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \ "CASE WHEN sum(debit) > sum(credit) " \ "THEN sum(debit) - sum(credit) " \ "ELSE 0 " \ "END AS sdebit, " \ "CASE WHEN sum(debit) < sum(credit) " \ "THEN sum(credit) - sum(debit) " \ "ELSE 0 " \ "END AS scredit, " \ "(SELECT sum(debit-credit) " \ "FROM account_move_line l " \ "WHERE partner_id = p.id " \ "AND l.date IN %s " \ "AND blocked = TRUE " \ ") AS enlitige " \ "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \ "JOIN account_account ac ON (l.account_id = ac.id)" \ "WHERE ac.type IN %s " \ "AND l.date IN %s " \
31836de9aacb8ff0fec4c6076860cce7ec3ed4c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/31836de9aacb8ff0fec4c6076860cce7ec3ed4c3/partner_balance.py
if self.soldeinit: date_init = (datetime.datetime.strptime(self.date_lst[0], "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date < %s", (tuple(self.account_ids), date_init,)) temp_res += float(self.cr.fetchone()[0] or 0.0)
def _sum_debit(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst))) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.soldeinit: date_init = (datetime.datetime.strptime(self.date_lst[0], "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date < %s", (tuple(self.account_ids), date_init,)) temp_res += float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp
31836de9aacb8ff0fec4c6076860cce7ec3ed4c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/31836de9aacb8ff0fec4c6076860cce7ec3ed4c3/partner_balance.py
if self.soldeinit: date_init = (datetime.datetime.strptime(self.date_lst[0], "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date < %s", (tuple(self.account_ids), date_init,)) temp_res += float(self.cr.fetchone()[0] or 0.0)
def _sum_credit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.soldeinit: date_init = (datetime.datetime.strptime(self.date_lst[0], "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date < %s", (tuple(self.account_ids), date_init,)) temp_res += float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp
31836de9aacb8ff0fec4c6076860cce7ec3ed4c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/31836de9aacb8ff0fec4c6076860cce7ec3ed4c3/partner_balance.py
if self.soldeinit: date_init = (datetime.datetime.strptime(self.date_lst[0], "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date < %s", (tuple(self.account_ids), date_init,)) temp_res += float(self.cr.fetchone()[0] or 0.0)
def _sum_litige(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s " \ "AND l.blocked=TRUE ", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.soldeinit: date_init = (datetime.datetime.strptime(self.date_lst[0], "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date < %s", (tuple(self.account_ids), date_init,)) temp_res += float(self.cr.fetchone()[0] or 0.0) return result_tmp + temp_res
31836de9aacb8ff0fec4c6076860cce7ec3ed4c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/31836de9aacb8ff0fec4c6076860cce7ec3ed4c3/partner_balance.py
'type_id': fields.many2one ('project.task.type', 'Resolution', domain="[('object_id.model', '=', 'project.issue')]"),
'type_id': fields.many2one ('project.task.type', 'Resolution'),
def _compute_day(self, cr, uid, ids, fields, args, context=None): if context is None: context = {} """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Openday’s IDs @return: difference between current date and log date @param context: A standard dictionary for contextual values """ cal_obj = self.pool.get('resource.calendar') res_obj = self.pool.get('resource.resource')
56249a5de31f1c725c1ea0c9caf6c13df9d1c0e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/56249a5de31f1c725c1ea0c9caf6c13df9d1c0e9/project_issue.py
'account_collected_id': acc_template_ref[value['account_collected_id']], 'account_paid_id': acc_template_ref[value['account_paid_id']],
'account_collected_id': acc_template_ref.get(value['account_collected_id'], False), 'account_paid_id': acc_template_ref.get(value['account_paid_id'], False),
def execute(self, cr, uid, ids, context=None): obj_multi = self.browse(cr, uid, ids[0]) obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id company_id = obj_multi.company_id.id
516084383be8708a61735a8517eed3455b114b64 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/516084383be8708a61735a8517eed3455b114b64/account.py
domain = domain + ['|',('date_maturity','<',search_due_date),('date_maturity','=',False)]
domain = domain + ['|',('date_maturity','<=',search_due_date),('date_maturity','=',False)]
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')
f2d4f864a27333254bd2847214aa359943e20ece /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f2d4f864a27333254bd2847214aa359943e20ece/account_payment_order.py
def _lang_data_get(self, cr, uid, lang_id):
def _lang_data_get(self, cr, uid, lang_id, monetary=False):
def _lang_data_get(self, cr, uid, lang_id): conv = localeconv() lang_obj=self.browse(cr,uid,lang_id) thousands_sep = lang_obj.thousands_sep or conv[monetary and 'mon_thousands_sep' or 'thousands_sep'] decimal_point = lang_obj.decimal_point grouping = lang_obj.grouping return (grouping, thousands_sep, decimal_point)
8e15fd52b369bc2f16739423d4db485bd6963653 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8e15fd52b369bc2f16739423d4db485bd6963653/res_lang.py
lang_grouping, thousands_sep, decimal_point = self._lang_data_get(cr, uid, ids[0])
lang_grouping, thousands_sep, decimal_point = self._lang_data_get(cr, uid, ids[0], monetary)
def format(self, cr, uid, ids, percent, value, grouping=False, monetary=False): """ Format() will return the language-specific output for float values"""
8e15fd52b369bc2f16739423d4db485bd6963653 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8e15fd52b369bc2f16739423d4db485bd6963653/res_lang.py
class MultiHTTPHandler(FixSendError,BaseHTTPRequestHandler):
class HttpOptions: _HTTP_OPTIONS = 'OPTIONS' def do_OPTIONS(self): """return the list of capabilities """ self.send_response(200) self.send_header("Content-Length", 0) self.send_header('Allow', self._HTTP_OPTIONS) self.end_headers() class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler):
def send_error(self, code, message=None): #overriden from BaseHTTPRequestHandler, we also send the content-length try: short, long = self.responses[code] except KeyError: short, long = '???', '???' if message is None: message = short explain = long self.log_error("code %d, message %s", code, message) # using _quote_html to prevent Cross Site Scripting attacks (see bug #1100201) content = (self.error_message_format % {'code': code, 'message': _quote_html(message), 'explain': explain}) self.send_response(code, message) self.send_header("Content-Type", self.error_content_type) self.send_header('Connection', 'close') self.send_header('Content-Length', len(content) or 0) self.end_headers() if hasattr(self, '_flush'): self._flush() if self.command != 'HEAD' and code >= 200 and code not in (204, 304): self.wfile.write(content)
4e36352f5ebb7a2bbdddd3a249cc5b2f4a428a96 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4e36352f5ebb7a2bbdddd3a249cc5b2f4a428a96/websrv_lib.py
dbname = getattr(threading.currentThread(), 'dbname')
def _get_db(self): # find current DB based on thread/worker db name (see netsvc) db_name = getattr(threading.currentThread(), 'dbname', None) if db_name: dbname = getattr(threading.currentThread(), 'dbname') return pooler.get_db_only(dbname)
e5ecadeda7f46968ab776d502fde466e9f4168cd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e5ecadeda7f46968ab776d502fde466e9f4168cd/translate.py
class mail_server(osv.osv):
class email_server(osv.osv):
def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' '
b98126cb41a8da1a0bfba7c4406a35b3d9e8ae5c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b98126cb41a8da1a0bfba7c4406a35b3d9e8ae5c/fetchmail.py
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)) imap_server.login(server.user, server.password) imap_server.select() result, data = imap_server.search(None, '(UNSEEN)') for num in data[0].split(): result, data = imap_server.fetch(num, '(RFC822)') if self._process_email(cr, uid, server, data[0][1], context): imap_server.store(num, '+FLAGS', '\\Seen') count += 1 logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name)) imap_server.close() imap_server.logout() elif server.type == 'pop': pop_server = None if server.is_ssl: pop_server = POP3_SSL(server.server, int(server.port)) else: pop_server = POP3(server.server, int(server.port)) pop_server.user(server.user) pop_server.pass_(server.password) pop_server.list() (numMsgs, totalSize) = pop_server.stat() for num in range(1, numMsgs + 1): (header, msges, octets) = pop_server.retr(num) msg = '\n'.join(msges) self._process_email(cr, uid, server, msg, context) pop_server.dele(num) pop_server.quit() logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (numMsgs, server.name))
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)) imap_server.login(server.user, server.password) imap_server.select() result, data = imap_server.search(None, '(UNSEEN)') for num in data[0].split(): result, data = imap_server.fetch(num, '(RFC822)') if self._process_email(cr, uid, server, data[0][1], context): imap_server.store(num, '+FLAGS', '\\Seen') count += 1 logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name)) imap_server.close() imap_server.logout() elif server.type == 'pop': pop_server = None if server.is_ssl: pop_server = POP3_SSL(server.server, int(server.port)) else: pop_server = POP3(server.server, int(server.port)) pop_server.user(server.user) pop_server.pass_(server.password) pop_server.list() (numMsgs, totalSize) = pop_server.stat() for num in range(1, numMsgs + 1): (header, msges, octets) = pop_server.retr(num) msg = '\n'.join(msges) self._process_email(cr, uid, server, msg, context) pop_server.dele(num) pop_server.quit() logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (numMsgs, server.name)) except Exception, e: logger.notifyChannel('IMAP', netsvc.LOG_WARNING, '%s' % (e))
def fetch_mail(self, cr, uid, ids, context={}): fp = os.popen('ping www.google.com -c 1 -w 5',"r") if not fp.read(): logger.notifyChannel('imap', netsvc.LOG_WARNING, 'No address associated with hostname !')
b98126cb41a8da1a0bfba7c4406a35b3d9e8ae5c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b98126cb41a8da1a0bfba7c4406a35b3d9e8ae5c/fetchmail.py
mail_server()
email_server()
def fetch_mail(self, cr, uid, ids, context={}): fp = os.popen('ping www.google.com -c 1 -w 5',"r") if not fp.read(): logger.notifyChannel('imap', netsvc.LOG_WARNING, 'No address associated with hostname !')
b98126cb41a8da1a0bfba7c4406a35b3d9e8ae5c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b98126cb41a8da1a0bfba7c4406a35b3d9e8ae5c/fetchmail.py
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu) if view_type != 'tree': return result fld = [] fields = {} flds = [] title = self.view_header_get(cr, uid, view_id, view_type, context) xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="on_create_write">\n\t''' % (title) journal_pool = self.pool.get('account.journal') ids = journal_pool.search(cr, uid, []) journals = journal_pool.browse(cr, uid, ids) all_journal = [] for journal in journals: all_journal.append(journal.id) for field in journal.view_id.columns_id: if not field.field in fields: fields[field.field] = [journal.id] fld.append((field.field, field.sequence)) flds.append(field.field) else: fields.get(field.field).append(journal.id) fld.append(('period_id', 3)) fld.append(('journal_id', 10)) flds.append('period_id') flds.append('journal_id') fields['period_id'] = all_journal fields['journal_id'] = all_journal from operator import itemgetter fld = sorted(fld, key=itemgetter(1))
f63415abba53ca9e70a36da7085e258b2d83b830 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f63415abba53ca9e70a36da7085e258b2d83b830/account_move_line.py
all_journal = []
all_journal = [None]
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu) if view_type != 'tree': return result fld = [] fields = {} flds = [] title = self.view_header_get(cr, uid, view_id, view_type, context) xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="on_create_write">\n\t''' % (title) journal_pool = self.pool.get('account.journal') ids = journal_pool.search(cr, uid, []) journals = journal_pool.browse(cr, uid, ids) all_journal = [] for journal in journals: all_journal.append(journal.id) for field in journal.view_id.columns_id: if not field.field in fields: fields[field.field] = [journal.id] fld.append((field.field, field.sequence)) flds.append(field.field) else: fields.get(field.field).append(journal.id) fld.append(('period_id', 3)) fld.append(('journal_id', 10)) flds.append('period_id') flds.append('journal_id') fields['period_id'] = all_journal fields['journal_id'] = all_journal from operator import itemgetter fld = sorted(fld, key=itemgetter(1))
f63415abba53ca9e70a36da7085e258b2d83b830 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f63415abba53ca9e70a36da7085e258b2d83b830/account_move_line.py
fields[field.field] = [journal.id]
fields[field.field] = [None, journal.id]
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu) if view_type != 'tree': return result fld = [] fields = {} flds = [] title = self.view_header_get(cr, uid, view_id, view_type, context) xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="on_create_write">\n\t''' % (title) journal_pool = self.pool.get('account.journal') ids = journal_pool.search(cr, uid, []) journals = journal_pool.browse(cr, uid, ids) all_journal = [] for journal in journals: all_journal.append(journal.id) for field in journal.view_id.columns_id: if not field.field in fields: fields[field.field] = [journal.id] fld.append((field.field, field.sequence)) flds.append(field.field) else: fields.get(field.field).append(journal.id) fld.append(('period_id', 3)) fld.append(('journal_id', 10)) flds.append('period_id') flds.append('journal_id') fields['period_id'] = all_journal fields['journal_id'] = all_journal from operator import itemgetter fld = sorted(fld, key=itemgetter(1))
f63415abba53ca9e70a36da7085e258b2d83b830 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f63415abba53ca9e70a36da7085e258b2d83b830/account_move_line.py
if 'date_deadline' in val and 'duration' not in val:
if val.get('date_deadline', False) and 'duration' not in val:
def check_import(self, cr, uid, vals, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param vals: Get Values @param context: A standard dictionary for contextual values """ if not context: context = {} ids = [] model_obj = self.pool.get(context.get('model')) recur_pool = {} try: for val in vals: # Compute value of duration if 'date_deadline' in val and 'duration' not in val: start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S') end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S') diff = end - start val['duration'] = (diff.seconds/float(86400) + diff.days) * 24 exists, r_id = calendar.uid2openobjectid(cr, val['id'], context.get('model'), \ val.get('recurrent_id')) if val.has_key('create_date'): val.pop('create_date') u_id = val.get('id', None) val.pop('id') if exists and r_id: val.update({'recurrent_uid': exists}) model_obj.write(cr, uid, [r_id], val) ids.append(r_id) elif exists: model_obj.write(cr, uid, [exists], val) ids.append(exists) else: if u_id in recur_pool and val.get('recurrent_id'): val.update({'recurrent_uid': recur_pool[u_id]}) revent_id = model_obj.create(cr, uid, val) ids.append(revent_id) else: __rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$') wematch = __rege.match(u_id.encode('utf8')) if wematch: model, recur_id, dbname = wematch.groups() val.update({'recurrent_uid': recur_id}) event_id = model_obj.create(cr, uid, val) recur_pool[u_id] = event_id ids.append(event_id) except Exception: raise return ids
ef59ed0203296335f16a1e2cc698f19ce1d021c1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ef59ed0203296335f16a1e2cc698f19ce1d021c1/crm_caldav.py
'directory': fields.char('Directory',size=64,readonly=True), 'change_date': fields.datetime('Modified Date', readonly=True), 'file_size': fields.integer('File Size', readonly=True),
def init(self, cr): tools.drop_view_if_exists(cr, 'report_document_user') cr.execute(""" CREATE OR REPLACE VIEW report_document_user as ( SELECT min(f.id) as id, to_char(f.create_date, 'YYYY') as name, to_char(f.create_date, 'MM') as month, f.user_id as user_id, u.name as user, count(*) as nbr, d.name as directory, f.create_date as create_date, f.file_size as file_size, min(d.type) as type, f.write_date as change_date FROM ir_attachment f left join document_directory d on (f.parent_id=d.id and d.name<>'') inner join res_users u on (f.user_id=u.id) group by to_char(f.create_date, 'YYYY'), to_char(f.create_date, 'MM'),d.name,f.parent_id,d.type,f.create_date,f.user_id,f.file_size,u.name,d.type,f.write_date ) """)
08a8e64ca90f709a4b39e6b9f89bd2cd3a7daa90 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/08a8e64ca90f709a4b39e6b9f89bd2cd3a7daa90/document_report.py
'type':fields.char('Directory Type',size=64,readonly=True),
def init(self, cr): tools.drop_view_if_exists(cr, 'report_document_user') cr.execute(""" CREATE OR REPLACE VIEW report_document_user as ( SELECT min(f.id) as id, to_char(f.create_date, 'YYYY') as name, to_char(f.create_date, 'MM') as month, f.user_id as user_id, u.name as user, count(*) as nbr, d.name as directory, f.create_date as create_date, f.file_size as file_size, min(d.type) as type, f.write_date as change_date FROM ir_attachment f left join document_directory d on (f.parent_id=d.id and d.name<>'') inner join res_users u on (f.user_id=u.id) group by to_char(f.create_date, 'YYYY'), to_char(f.create_date, 'MM'),d.name,f.parent_id,d.type,f.create_date,f.user_id,f.file_size,u.name,d.type,f.write_date ) """)
08a8e64ca90f709a4b39e6b9f89bd2cd3a7daa90 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/08a8e64ca90f709a4b39e6b9f89bd2cd3a7daa90/document_report.py
'ean13': fields.char('EAN13', size=13),
'ean13': fields.char('EAN13', size=14),
def _product_partner_ref(self, cr, uid, ids, name, arg, context={}): res = {} for p in self.browse(cr, uid, ids, context): data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context) if not data['variants']: data['variants'] = p.variants if not data['code']: data['code'] = p.code if not data['name']: data['name'] = p.name res[p.id] = (data['code'] and ('['+data['code']+'] ') or '') + \ (data['name'] or '') + (data['variants'] and (' - '+data['variants']) or '') return res
5b647eb30c82b1f3eed3a549ecc08069f0858647 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5b647eb30c82b1f3eed3a549ecc08069f0858647/product.py
if len(partner.ean13) <> 13:
if len(partner.ean13) not in [13,14,8]:
def _check_ean_key(self, cr, uid, ids): for partner in self.browse(cr, uid, ids): if not partner.ean13: continue if len(partner.ean13) <> 13: return False try: int(partner.ean13) except: return False sum=0 for i in range(12): if is_pair(i): sum += int(partner.ean13[i]) else: sum += 3 * int(partner.ean13[i]) check = int(math.ceil(sum / 10.0) * 10 - sum) if check != int(partner.ean13[12]): return False return True
5b647eb30c82b1f3eed3a549ecc08069f0858647 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5b647eb30c82b1f3eed3a549ecc08069f0858647/product.py
sum=0 for i in range(12):
oddsum=0 evensum=0 total=0 eanvalue=partner.ean13 reversevalue = eanvalue[::-1] finalean=reversevalue[1:] for i in range(len(finalean)):
def _check_ean_key(self, cr, uid, ids): for partner in self.browse(cr, uid, ids): if not partner.ean13: continue if len(partner.ean13) <> 13: return False try: int(partner.ean13) except: return False sum=0 for i in range(12): if is_pair(i): sum += int(partner.ean13[i]) else: sum += 3 * int(partner.ean13[i]) check = int(math.ceil(sum / 10.0) * 10 - sum) if check != int(partner.ean13[12]): return False return True
5b647eb30c82b1f3eed3a549ecc08069f0858647 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5b647eb30c82b1f3eed3a549ecc08069f0858647/product.py
sum += int(partner.ean13[i])
oddsum += int(finalean[i])
def _check_ean_key(self, cr, uid, ids): for partner in self.browse(cr, uid, ids): if not partner.ean13: continue if len(partner.ean13) <> 13: return False try: int(partner.ean13) except: return False sum=0 for i in range(12): if is_pair(i): sum += int(partner.ean13[i]) else: sum += 3 * int(partner.ean13[i]) check = int(math.ceil(sum / 10.0) * 10 - sum) if check != int(partner.ean13[12]): return False return True
5b647eb30c82b1f3eed3a549ecc08069f0858647 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5b647eb30c82b1f3eed3a549ecc08069f0858647/product.py
sum += 3 * int(partner.ean13[i]) check = int(math.ceil(sum / 10.0) * 10 - sum) if check != int(partner.ean13[12]):
evensum += int(finalean[i]) total=(oddsum * 3) + evensum check = int(10 - math.ceil(total % 10.0)) if check != int(partner.ean13[-1]):
def _check_ean_key(self, cr, uid, ids): for partner in self.browse(cr, uid, ids): if not partner.ean13: continue if len(partner.ean13) <> 13: return False try: int(partner.ean13) except: return False sum=0 for i in range(12): if is_pair(i): sum += int(partner.ean13[i]) else: sum += 3 * int(partner.ean13[i]) check = int(math.ceil(sum / 10.0) * 10 - sum) if check != int(partner.ean13[12]): return False return True
5b647eb30c82b1f3eed3a549ecc08069f0858647 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5b647eb30c82b1f3eed3a549ecc08069f0858647/product.py
try: file_data = _to_unicode(fp.read()) finally: fp.close() return file_data
return _to_unicode(fp.read())
def _doIndexFile(self,fname): fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout try: file_data = _to_unicode(fp.read()) finally: fp.close() return file_data
1ee15503f4e1ef038d9b4028a6ea9a1beff298c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1ee15503f4e1ef038d9b4028a6ea9a1beff298c0/std_index.py
try: file_data = _to_unicode( fp.read()) finally: fp.close() return file_data
return _to_unicode( fp.read())
def _doIndexFile(self,fname): fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout try: file_data = _to_unicode( fp.read()) finally: fp.close() return file_data
1ee15503f4e1ef038d9b4028a6ea9a1beff298c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1ee15503f4e1ef038d9b4028a6ea9a1beff298c0/std_index.py
rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False acc_id = False bank_id = False fiscal_position = False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)])
rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)])
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False acc_id = False bank_id = False fiscal_position = False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id'])
pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value','res_id'])
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False acc_id = False bank_id = False fiscal_position = False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
rec_obj_acc=self.pool.get('account.account').browse(cr, uid, [rec_res_id]) pay_obj_acc=self.pool.get('account.account').browse(cr, uid, [pay_res_id])
account_obj = self.pool.get('account.account') rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id]) pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id])
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False acc_id = False bank_id = False fiscal_position = False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id and type: if type in ('out_invoice', 'out_refund'): journal_type = 'sale' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, [])
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)])
rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)])
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id and type: if type in ('out_invoice', 'out_refund'): journal_type = 'sale' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, [])
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id'])
pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id'])
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id and type: if type in ('out_invoice', 'out_refund'): journal_type = 'sale' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, [])
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
if not rec_res_id and not rec_res_id:
if not rec_res_id and not pay_res_id:
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id and type: if type in ('out_invoice', 'out_refund'): journal_type = 'sale' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, [])
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)])
result_id = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)])
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id and type: if type in ('out_invoice', 'out_refund'): journal_type = 'sale' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, [])
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id'])
obj_l = account_obj.browse(cr, uid, inv_line[2]['account_id'])
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id and type: if type in ('out_invoice', 'out_refund'): journal_type = 'sale' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, [])
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
fpos_obj = self.pool.get('account.fiscal.position') fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id) or False
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
property_obj = self.pool.get('ir.property') account_obj = self.pool.get('account.account') in_pro_id = property_obj.search(cr, uid, [('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)]) exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
in_pro_id = property_obj.search(cr, uid, [('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)]) exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
app_acc_in = self.pool.get('account.account').browse(cr, uid, in_pro_id)[0]
app_acc_in = account_obj.browse(cr, uid, in_pro_id)[0]
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
app_acc_exp = self.pool.get('account.account').browse(cr, uid, exp_pro_id)[0]
app_acc_exp = account_obj.browse(cr, uid, exp_pro_id)[0]
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
in_res_id=self.pool.get('account.account').search(cr, uid, [('name','=',app_acc_in.name),('company_id','=',company_id)]) exp_res_id=self.pool.get('account.account').search(cr, uid, [('name','=',app_acc_exp.name),('company_id','=',company_id)])
in_res_id = account_obj.search(cr, uid, [('name','=',app_acc_in.name),('company_id','=',company_id)]) exp_res_id = account_obj.search(cr, uid, [('name','=',app_acc_exp.name),('company_id','=',company_id)])
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
in_obj_acc=self.pool.get('account.account').browse(cr, uid, in_res_id) exp_obj_acc=self.pool.get('account.account').browse(cr, uid, exp_res_id)
in_obj_acc = account_obj.browse(cr, uid, in_res_id) exp_obj_acc = account_obj.browse(cr, uid, exp_res_id)
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
a = res.product_tmpl_id.property_account_income.id
a = res.product_tmpl_id.property_account_income.id
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
a = res.product_tmpl_id.property_account_expense.id
a = res.product_tmpl_id.property_account_expense.id
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, a)
a = fpos_obj.map_account(cr, uid, fpos, a)
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
taxep=None
taxep = None
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
prod_pool=self.pool.get('product.product')
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
if not company_id and not currency_id:
if not company_id or not currency_id:
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
9d3752728703af0f57a66468fda2058d9e5cfcdc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d3752728703af0f57a66468fda2058d9e5cfcdc/invoice.py
if hasattr(res, 'section'):
if hasattr(res, 'section_id'):
def email_forward(self, cr, uid, model, res_ids, msg, email_error=False, context=None): """Sends an email to all people following the thread @param res_id: Id of the record of OpenObject model created from the email message @param msg: email.message.Message to forward @param email_error: Default Email address in case of any Problem """ model_pool = self.pool.get(model)
ff0e181c263e871d5c1c3ae10c06c6a7a3f7da7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ff0e181c263e871d5c1c3ae10c06c6a7a3f7da7b/mail_gateway.py
msg['reply-to'] = res.section.email_from if not tools.misc._email_send(msg, openobject_id=res.id) and email_error:
msg['reply-to'] = res.section_id.reply_to smtp_from = self.to_email(msg['from']) if not tools.misc._email_send(smtp_from, message_forward, msg, openobject_id=res.id) and email_error:
def email_forward(self, cr, uid, model, res_ids, msg, email_error=False, context=None): """Sends an email to all people following the thread @param res_id: Id of the record of OpenObject model created from the email message @param msg: email.message.Message to forward @param email_error: Default Email address in case of any Problem """ model_pool = self.pool.get(model)
ff0e181c263e871d5c1c3ae10c06c6a7a3f7da7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ff0e181c263e871d5c1c3ae10c06c6a7a3f7da7b/mail_gateway.py
tools.misc._email_send(msg, openobject_id=res.id)
tools.misc._email_send(smtp_from, self.to_email(email_error), msg, openobject_id=res.id)
def email_forward(self, cr, uid, model, res_ids, msg, email_error=False, context=None): """Sends an email to all people following the thread @param res_id: Id of the record of OpenObject model created from the email message @param msg: email.message.Message to forward @param email_error: Default Email address in case of any Problem """ model_pool = self.pool.get(model)
ff0e181c263e871d5c1c3ae10c06c6a7a3f7da7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ff0e181c263e871d5c1c3ae10c06c6a7a3f7da7b/mail_gateway.py
"""This function Processes email and create record for given OpenERP model
"""This function Processes email and create record for given OpenERP model
def process_email(self, cr, uid, model, message, attach=True, context=None): """This function Processes email and create record for given OpenERP model @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param model: OpenObject Model @param message: Email details @param attach: Email attachments @param context: A standard dictionary for contextual values""" model_pool = self.pool.get(model) if not context: context = {} res_id = False # Create New Record into particular model def create_record(msg): if hasattr(model_pool, 'message_new'): res_id = model_pool.message_new(cr, uid, msg, context) else: data = { 'name': msg.get('subject'), 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'user_id': False, 'description': msg.get('body'), 'state' : 'draft', } data.update(self.get_partner(cr, uid, msg.get('from'), context=context)) res_id = model_pool.create(cr, uid, data, context=context)
ff0e181c263e871d5c1c3ae10c06c6a7a3f7da7b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ff0e181c263e871d5c1c3ae10c06c6a7a3f7da7b/mail_gateway.py
if self.logo and (rml_head.find('company.logo')<0 or rml_head.find('<image')<0) and rml_head.find('<!--image')<0: rml_head = rml_head.replace('<pageGraphics>','''<pageGraphics> <image x="10" y="26cm" height="70" width="90" >[[company.logo]] </image> ''') if not self.logo and rml_head.find('company.logo')>=0: rml_head = rml_head.replace('<image','<!--image') rml_head = rml_head.replace('</image>','</image-->')
def _add_header(self, rml_dom, header=1): if header==2: rml_head = self.rml_header2 else: rml_head = self.rml_header if self.logo and (rml_head.find('company.logo')<0 or rml_head.find('<image')<0) and rml_head.find('<!--image')<0: rml_head = rml_head.replace('<pageGraphics>','''<pageGraphics> <image x="10" y="26cm" height="70" width="90" >[[company.logo]] </image> ''') if not self.logo and rml_head.find('company.logo')>=0: rml_head = rml_head.replace('<image','<!--image') rml_head = rml_head.replace('</image>','</image-->') head_dom = etree.XML(rml_head) for tag in head_dom: found = rml_dom.find('.//'+tag.tag) if found is not None and len(found): if tag.get('position'): found.append(tag) else : found.getparent().replace(found,tag) return True
13a43dfdc36b751cb9ed6c55169e76b48094b829 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/13a43dfdc36b751cb9ed6c55169e76b48094b829/report_sxw.py
processed_rml = self.preprocess_rml(etree.XML(rml),report_xml.report_type)
processed_rml = etree.XML(rml)
def create_single_pdf(self, cr, uid, ids, data, report_xml, context=None): if not context: context={} logo = None context = context.copy() title = report_xml.name rml = report_xml.report_rml_content # if no rml file is found if not rml: return False rml_parser = self.parser(cr, uid, self.name2, context=context) objs = self.getObjects(cr, uid, ids, context) rml_parser.set_context(objs, data, ids, report_xml.report_type) processed_rml = self.preprocess_rml(etree.XML(rml),report_xml.report_type) if report_xml.header: rml_parser._add_header(processed_rml) if rml_parser.logo: logo = base64.decodestring(rml_parser.logo) create_doc = self.generators[report_xml.report_type] pdf = create_doc(etree.tostring(processed_rml),rml_parser.localcontext,logo,title.encode('utf8')) return (pdf, report_xml.report_type)
13a43dfdc36b751cb9ed6c55169e76b48094b829 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/13a43dfdc36b751cb9ed6c55169e76b48094b829/report_sxw.py
rml_parser.set_context(objs, data, ids,report_xml.report_type)
rml_parser.set_context(objs, data, ids, mime_type)
def create_single_odt(self, cr, uid, ids, data, report_xml, context=None): if not context: context={} context = context.copy() report_type = report_xml.report_type context['parents'] = sxw_parents sxw_io = StringIO.StringIO(report_xml.report_sxw_content) sxw_z = zipfile.ZipFile(sxw_io, mode='r') rml = sxw_z.read('content.xml') meta = sxw_z.read('meta.xml') sxw_z.close()
13a43dfdc36b751cb9ed6c55169e76b48094b829 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/13a43dfdc36b751cb9ed6c55169e76b48094b829/report_sxw.py
if report_type == 'odt':
if mime_type == 'odt':
def create_single_odt(self, cr, uid, ids, data, report_xml, context=None): if not context: context={} context = context.copy() report_type = report_xml.report_type context['parents'] = sxw_parents sxw_io = StringIO.StringIO(report_xml.report_sxw_content) sxw_z = zipfile.ZipFile(sxw_io, mode='r') rml = sxw_z.read('content.xml') meta = sxw_z.read('meta.xml') sxw_z.close()
13a43dfdc36b751cb9ed6c55169e76b48094b829 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/13a43dfdc36b751cb9ed6c55169e76b48094b829/report_sxw.py
rml_dom = self.preprocess_rml(rml_dom,report_type) create_doc = self.generators[report_type]
rml_dom = self.preprocess_rml(rml_dom, mime_type) create_doc = self.generators[mime_type]
def create_single_odt(self, cr, uid, ids, data, report_xml, context=None): if not context: context={} context = context.copy() report_type = report_xml.report_type context['parents'] = sxw_parents sxw_io = StringIO.StringIO(report_xml.report_sxw_content) sxw_z = zipfile.ZipFile(sxw_io, mode='r') rml = sxw_z.read('content.xml') meta = sxw_z.read('meta.xml') sxw_z.close()
13a43dfdc36b751cb9ed6c55169e76b48094b829 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/13a43dfdc36b751cb9ed6c55169e76b48094b829/report_sxw.py
return (final_op, report_type)
return (final_op, mime_type)
def create_single_odt(self, cr, uid, ids, data, report_xml, context=None): if not context: context={} context = context.copy() report_type = report_xml.report_type context['parents'] = sxw_parents sxw_io = StringIO.StringIO(report_xml.report_sxw_content) sxw_z = zipfile.ZipFile(sxw_io, mode='r') rml = sxw_z.read('content.xml') meta = sxw_z.read('meta.xml') sxw_z.close()
13a43dfdc36b751cb9ed6c55169e76b48094b829 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/13a43dfdc36b751cb9ed6c55169e76b48094b829/report_sxw.py
def graph_get(cr, graph, wkf_id, nested=False, workitem={}):
def graph_get(cr, graph, wkf_ids, nested=False, workitem={}):
def graph_get(cr, graph, wkf_id, nested=False, workitem={}): import pydot cr.execute('select * from wkf_activity where wkf_id=%s', (wkf_id,)) nodes = cr.dictfetchall() activities = {} actfrom = {} actto = {} for n in nodes: activities[n['id']] = n if n['subflow_id'] and nested: cr.execute('select * from wkf where id=%s', (n['subflow_id'],)) wkfinfo = cr.dictfetchone() graph2 = pydot.Cluster('subflow'+str(n['subflow_id']), fontsize='12', label = """\"Subflow: %s\\nOSV: %s\"""" % ( n['name'], wkfinfo['osv']) ) (s1,s2) = graph_get(cr, graph2, n['subflow_id'], nested,workitem) graph.add_subgraph(graph2) actfrom[n['id']] = s2 actto[n['id']] = s1 else: args = {} if n['flow_start'] or n['flow_stop']: args['style']='filled' args['color']='lightgrey' args['label']=n['name'] if n['subflow_id']: args['shape'] = 'box' if n['id'] in workitem: args['label']+='\\nx '+str(workitem[n['id']]) args['color'] = "red" graph.add_node(pydot.Node(n['id'], **args)) actfrom[n['id']] = (n['id'],{}) actto[n['id']] = (n['id'],{}) cr.execute('select * from wkf_transition where act_from in ('+','.join(map(lambda x: str(x['id']),nodes))+')') transitions = cr.dictfetchall() for t in transitions: args = {} args['label'] = str(t['condition']).replace(' or ', '\\nor ').replace(' and ', '\\nand ') if t['signal']: args['label'] += '\\n'+str(t['signal']) args['style'] = 'bold' if activities[t['act_from']]['split_mode']=='AND': args['arrowtail']='box' elif str(activities[t['act_from']]['split_mode'])=='OR ': args['arrowtail']='inv' if activities[t['act_to']]['join_mode']=='AND': args['arrowhead']='crow' activity_from = actfrom[t['act_from']][1].get(t['signal'], actfrom[t['act_from']][0]) activity_to = actto[t['act_to']][1].get(t['signal'], actto[t['act_to']][0]) graph.add_edge(pydot.Edge( str(activity_from) ,str(activity_to), fontsize='10', **args)) nodes = cr.dictfetchall() cr.execute('select id from wkf_activity where flow_start=True and wkf_id=%s limit 1', (wkf_id,)) start = cr.fetchone()[0] cr.execute("select 'subflow.'||name,id from wkf_activity where flow_stop=True and wkf_id=%s", (wkf_id,)) stop = cr.fetchall() if (stop): stop = (stop[0][1], dict(stop)) else: stop = ("stop",{}) return ((start,{}),stop)
a01b658d8de67b50f93e68ea81bbf08e57f4079d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a01b658d8de67b50f93e68ea81bbf08e57f4079d/print_instance.py
cr.execute('select * from wkf_activity where wkf_id=%s', (wkf_id,))
cr.execute('select * from wkf_activity where wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
def graph_get(cr, graph, wkf_id, nested=False, workitem={}): import pydot cr.execute('select * from wkf_activity where wkf_id=%s', (wkf_id,)) nodes = cr.dictfetchall() activities = {} actfrom = {} actto = {} for n in nodes: activities[n['id']] = n if n['subflow_id'] and nested: cr.execute('select * from wkf where id=%s', (n['subflow_id'],)) wkfinfo = cr.dictfetchone() graph2 = pydot.Cluster('subflow'+str(n['subflow_id']), fontsize='12', label = """\"Subflow: %s\\nOSV: %s\"""" % ( n['name'], wkfinfo['osv']) ) (s1,s2) = graph_get(cr, graph2, n['subflow_id'], nested,workitem) graph.add_subgraph(graph2) actfrom[n['id']] = s2 actto[n['id']] = s1 else: args = {} if n['flow_start'] or n['flow_stop']: args['style']='filled' args['color']='lightgrey' args['label']=n['name'] if n['subflow_id']: args['shape'] = 'box' if n['id'] in workitem: args['label']+='\\nx '+str(workitem[n['id']]) args['color'] = "red" graph.add_node(pydot.Node(n['id'], **args)) actfrom[n['id']] = (n['id'],{}) actto[n['id']] = (n['id'],{}) cr.execute('select * from wkf_transition where act_from in ('+','.join(map(lambda x: str(x['id']),nodes))+')') transitions = cr.dictfetchall() for t in transitions: args = {} args['label'] = str(t['condition']).replace(' or ', '\\nor ').replace(' and ', '\\nand ') if t['signal']: args['label'] += '\\n'+str(t['signal']) args['style'] = 'bold' if activities[t['act_from']]['split_mode']=='AND': args['arrowtail']='box' elif str(activities[t['act_from']]['split_mode'])=='OR ': args['arrowtail']='inv' if activities[t['act_to']]['join_mode']=='AND': args['arrowhead']='crow' activity_from = actfrom[t['act_from']][1].get(t['signal'], actfrom[t['act_from']][0]) activity_to = actto[t['act_to']][1].get(t['signal'], actto[t['act_to']][0]) graph.add_edge(pydot.Edge( str(activity_from) ,str(activity_to), fontsize='10', **args)) nodes = cr.dictfetchall() cr.execute('select id from wkf_activity where flow_start=True and wkf_id=%s limit 1', (wkf_id,)) start = cr.fetchone()[0] cr.execute("select 'subflow.'||name,id from wkf_activity where flow_stop=True and wkf_id=%s", (wkf_id,)) stop = cr.fetchall() if (stop): stop = (stop[0][1], dict(stop)) else: stop = ("stop",{}) return ((start,{}),stop)
a01b658d8de67b50f93e68ea81bbf08e57f4079d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a01b658d8de67b50f93e68ea81bbf08e57f4079d/print_instance.py
cr.execute('select id from wkf_activity where flow_start=True and wkf_id=%s limit 1', (wkf_id,))
cr.execute('select * from wkf_activity where flow_start=True and wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
def graph_get(cr, graph, wkf_id, nested=False, workitem={}): import pydot cr.execute('select * from wkf_activity where wkf_id=%s', (wkf_id,)) nodes = cr.dictfetchall() activities = {} actfrom = {} actto = {} for n in nodes: activities[n['id']] = n if n['subflow_id'] and nested: cr.execute('select * from wkf where id=%s', (n['subflow_id'],)) wkfinfo = cr.dictfetchone() graph2 = pydot.Cluster('subflow'+str(n['subflow_id']), fontsize='12', label = """\"Subflow: %s\\nOSV: %s\"""" % ( n['name'], wkfinfo['osv']) ) (s1,s2) = graph_get(cr, graph2, n['subflow_id'], nested,workitem) graph.add_subgraph(graph2) actfrom[n['id']] = s2 actto[n['id']] = s1 else: args = {} if n['flow_start'] or n['flow_stop']: args['style']='filled' args['color']='lightgrey' args['label']=n['name'] if n['subflow_id']: args['shape'] = 'box' if n['id'] in workitem: args['label']+='\\nx '+str(workitem[n['id']]) args['color'] = "red" graph.add_node(pydot.Node(n['id'], **args)) actfrom[n['id']] = (n['id'],{}) actto[n['id']] = (n['id'],{}) cr.execute('select * from wkf_transition where act_from in ('+','.join(map(lambda x: str(x['id']),nodes))+')') transitions = cr.dictfetchall() for t in transitions: args = {} args['label'] = str(t['condition']).replace(' or ', '\\nor ').replace(' and ', '\\nand ') if t['signal']: args['label'] += '\\n'+str(t['signal']) args['style'] = 'bold' if activities[t['act_from']]['split_mode']=='AND': args['arrowtail']='box' elif str(activities[t['act_from']]['split_mode'])=='OR ': args['arrowtail']='inv' if activities[t['act_to']]['join_mode']=='AND': args['arrowhead']='crow' activity_from = actfrom[t['act_from']][1].get(t['signal'], actfrom[t['act_from']][0]) activity_to = actto[t['act_to']][1].get(t['signal'], actto[t['act_to']][0]) graph.add_edge(pydot.Edge( str(activity_from) ,str(activity_to), fontsize='10', **args)) nodes = cr.dictfetchall() cr.execute('select id from wkf_activity where flow_start=True and wkf_id=%s limit 1', (wkf_id,)) start = cr.fetchone()[0] cr.execute("select 'subflow.'||name,id from wkf_activity where flow_stop=True and wkf_id=%s", (wkf_id,)) stop = cr.fetchall() if (stop): stop = (stop[0][1], dict(stop)) else: stop = ("stop",{}) return ((start,{}),stop)
a01b658d8de67b50f93e68ea81bbf08e57f4079d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a01b658d8de67b50f93e68ea81bbf08e57f4079d/print_instance.py
cr.execute("select 'subflow.'||name,id from wkf_activity where flow_stop=True and wkf_id=%s", (wkf_id,))
cr.execute("select 'subflow.'||name,id from wkf_activity where flow_stop=True and wkf_id in ("+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
def graph_get(cr, graph, wkf_id, nested=False, workitem={}): import pydot cr.execute('select * from wkf_activity where wkf_id=%s', (wkf_id,)) nodes = cr.dictfetchall() activities = {} actfrom = {} actto = {} for n in nodes: activities[n['id']] = n if n['subflow_id'] and nested: cr.execute('select * from wkf where id=%s', (n['subflow_id'],)) wkfinfo = cr.dictfetchone() graph2 = pydot.Cluster('subflow'+str(n['subflow_id']), fontsize='12', label = """\"Subflow: %s\\nOSV: %s\"""" % ( n['name'], wkfinfo['osv']) ) (s1,s2) = graph_get(cr, graph2, n['subflow_id'], nested,workitem) graph.add_subgraph(graph2) actfrom[n['id']] = s2 actto[n['id']] = s1 else: args = {} if n['flow_start'] or n['flow_stop']: args['style']='filled' args['color']='lightgrey' args['label']=n['name'] if n['subflow_id']: args['shape'] = 'box' if n['id'] in workitem: args['label']+='\\nx '+str(workitem[n['id']]) args['color'] = "red" graph.add_node(pydot.Node(n['id'], **args)) actfrom[n['id']] = (n['id'],{}) actto[n['id']] = (n['id'],{}) cr.execute('select * from wkf_transition where act_from in ('+','.join(map(lambda x: str(x['id']),nodes))+')') transitions = cr.dictfetchall() for t in transitions: args = {} args['label'] = str(t['condition']).replace(' or ', '\\nor ').replace(' and ', '\\nand ') if t['signal']: args['label'] += '\\n'+str(t['signal']) args['style'] = 'bold' if activities[t['act_from']]['split_mode']=='AND': args['arrowtail']='box' elif str(activities[t['act_from']]['split_mode'])=='OR ': args['arrowtail']='inv' if activities[t['act_to']]['join_mode']=='AND': args['arrowhead']='crow' activity_from = actfrom[t['act_from']][1].get(t['signal'], actfrom[t['act_from']][0]) activity_to = actto[t['act_to']][1].get(t['signal'], actto[t['act_to']][0]) graph.add_edge(pydot.Edge( str(activity_from) ,str(activity_to), fontsize='10', **args)) nodes = cr.dictfetchall() cr.execute('select id from wkf_activity where flow_start=True and wkf_id=%s limit 1', (wkf_id,)) start = cr.fetchone()[0] cr.execute("select 'subflow.'||name,id from wkf_activity where flow_stop=True and wkf_id=%s", (wkf_id,)) stop = cr.fetchall() if (stop): stop = (stop[0][1], dict(stop)) else: stop = ("stop",{}) return ((start,{}),stop)
a01b658d8de67b50f93e68ea81bbf08e57f4079d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a01b658d8de67b50f93e68ea81bbf08e57f4079d/print_instance.py
cr.execute('select * from wkf_instance where id=%s', (inst_id,)) inst = cr.dictfetchone()
cr.execute('select wkf_id from wkf_instance where id=%s', (inst_id,)) inst = cr.fetchall()
def graph_instance_get(cr, graph, inst_id, nested=False): workitems = {} cr.execute('select * from wkf_instance where id=%s', (inst_id,)) inst = cr.dictfetchone() def workitem_get(instance): cr.execute('select act_id,count(*) from wkf_workitem where inst_id=%s group by act_id', (instance,)) workitems = dict(cr.fetchall()) cr.execute('select subflow_id from wkf_workitem where inst_id=%s', (instance,)) for (subflow_id,) in cr.fetchall(): workitems.update(workitem_get(subflow_id)) return workitems graph_get(cr, graph, inst['wkf_id'], nested, workitem_get(inst_id))
a01b658d8de67b50f93e68ea81bbf08e57f4079d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a01b658d8de67b50f93e68ea81bbf08e57f4079d/print_instance.py
graph_get(cr, graph, inst['wkf_id'], nested, workitem_get(inst_id))
graph_get(cr, graph, [x[0] for x in inst], nested, workitem_get(inst_id))
def workitem_get(instance): cr.execute('select act_id,count(*) from wkf_workitem where inst_id=%s group by act_id', (instance,)) workitems = dict(cr.fetchall())
a01b658d8de67b50f93e68ea81bbf08e57f4079d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a01b658d8de67b50f93e68ea81bbf08e57f4079d/print_instance.py
cr.execute('SELECT id FROM wkf_instance \ WHERE res_id=%s AND wkf_id=%s \ ORDER BY state LIMIT 1', (data['id'], wkfinfo['id'])) inst_id = cr.fetchone() if not inst_id:
cr.execute('select i.id from wkf_instance i left join wkf w on (i.wkf_id=w.id) where res_id=%s and osv=%s',(data['id'],data['model'])) inst_ids = cr.fetchall() if not inst_ids:
def __init__(self, cr, uid, ids, data): logger = netsvc.Logger() try: import pydot except Exception,e: logger.notifyChannel('workflow', netsvc.LOG_WARNING, 'Import Error for pydot, you will not be able to render workflows\n' 'Consider Installing PyDot or dependencies: http://dkbza.org/pydot.html') raise e self.done = False
a01b658d8de67b50f93e68ea81bbf08e57f4079d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a01b658d8de67b50f93e68ea81bbf08e57f4079d/print_instance.py
inst_id = inst_id[0] graph = pydot.Dot(fontsize='16', label="""\\\n\\nWorkflow: %s\\n OSV: %s""" % (wkfinfo['name'],wkfinfo['osv']), size='7.3, 10.1', center='1', ratio='auto', rotate='0', rankdir='TB', ) graph_instance_get(cr, graph, inst_id, data.get('nested', False))
graph = pydot.Dot( fontsize='16', label="""\\\n\\nWorkflow: %s\\n OSV: %s""" % (wkfinfo['name'],wkfinfo['osv']), size='7.3, 10.1', center='1', ratio='auto', rotate='0', rankdir='TB', ) for inst_id in inst_ids: inst_id = inst_id[0] graph_instance_get(cr, graph, inst_id, data.get('nested', False))
def __init__(self, cr, uid, ids, data): logger = netsvc.Logger() try: import pydot except Exception,e: logger.notifyChannel('workflow', netsvc.LOG_WARNING, 'Import Error for pydot, you will not be able to render workflows\n' 'Consider Installing PyDot or dependencies: http://dkbza.org/pydot.html') raise e self.done = False
a01b658d8de67b50f93e68ea81bbf08e57f4079d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a01b658d8de67b50f93e68ea81bbf08e57f4079d/print_instance.py
obj.datas[act[1]] = id
obj.datas[act[1]][self._fields_id] = id
def set_memory(self, cr, obj, id, field, values, user=None, context=None): if not context: context = {} if self._context: context = context.copy() context.update(self._context) if not values: return obj = obj.pool.get(self._obj) for act in values: if act[0] == 0: act[2][self._fields_id] = id obj.create(cr, user, act[2], context=context) elif act[0] == 1: obj.write(cr, user, [act[1]], act[2], context=context) elif act[0] == 2: obj.unlink(cr, user, [act[1]], context=context) elif act[0] == 3: obj.datas[act[1]][self._fields_id] = False elif act[0] == 4: obj.datas[act[1]] = id elif act[0] == 5: for o in obj.datas.values(): if o[self._fields_id] == id: o[self._fields_id] = False elif act[0] == 6: for id2 in (act[2] or []): obj.datas[id2][self._fields_id] = id
44f3c893c51cc29ece6ae6e90ec1136f38960625 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/44f3c893c51cc29ece6ae6e90ec1136f38960625/fields.py
if len(str(result_line['id']).split('-')) > 1:
if not isinstance(result_line['id'], (int, long)) and len(str(result_line['id']).split('-')) > 1:
def __getitem__(self, name): if name == 'id': return self._id
17a9b8f502bc67e6540da1a0fb74bd5110f8d8e2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/17a9b8f502bc67e6540da1a0fb74bd5110f8d8e2/orm.py
if journal_id and company_id: company = self.pool.get('res.company').browse(cr, uid, company_id) journal_id = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal_id.currency:
if journal_id: journal = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal.currency:
def onchange_journal_id(self, cr, uid, ids, journal_id, company_id): result = {} if journal_id and company_id: company = self.pool.get('res.company').browse(cr, uid, company_id) journal_id = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal_id.currency: result = {'value': { 'currency_id': journal_id.currency.id } } else: result = {'value': { 'currency_id': company.currency_id.id } } return result
aed6c48ade90c500b77b8b8d3b039006e110fddc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/aed6c48ade90c500b77b8b8d3b039006e110fddc/invoice.py
'currency_id': journal_id.currency.id
'currency_id': journal.currency.id
def onchange_journal_id(self, cr, uid, ids, journal_id, company_id): result = {} if journal_id and company_id: company = self.pool.get('res.company').browse(cr, uid, company_id) journal_id = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal_id.currency: result = {'value': { 'currency_id': journal_id.currency.id } } else: result = {'value': { 'currency_id': company.currency_id.id } } return result
aed6c48ade90c500b77b8b8d3b039006e110fddc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/aed6c48ade90c500b77b8b8d3b039006e110fddc/invoice.py
else: result = {'value': { 'currency_id': company.currency_id.id
return result if company_id: company = self.pool.get('res.company').browse(cr, uid, company_id) result = {'value': { 'currency_id': company.currency_id.id
def onchange_journal_id(self, cr, uid, ids, journal_id, company_id): result = {} if journal_id and company_id: company = self.pool.get('res.company').browse(cr, uid, company_id) journal_id = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal_id.currency: result = {'value': { 'currency_id': journal_id.currency.id } } else: result = {'value': { 'currency_id': company.currency_id.id } } return result
aed6c48ade90c500b77b8b8d3b039006e110fddc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/aed6c48ade90c500b77b8b8d3b039006e110fddc/invoice.py
def onchange_journal_id(self, cr, uid, ids, journal_id, company_id): result = {} if journal_id and company_id: company = self.pool.get('res.company').browse(cr, uid, company_id) journal_id = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal_id.currency: result = {'value': { 'currency_id': journal_id.currency.id } } else: result = {'value': { 'currency_id': company.currency_id.id } } return result
aed6c48ade90c500b77b8b8d3b039006e110fddc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/aed6c48ade90c500b77b8b8d3b039006e110fddc/invoice.py
logging.getLogger('report').exception(e)
logging.getLogger('report').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True)
def _child_get(node, self=None, tagname=None): for n in node: if self and self.localcontext and n.get('rml_loop'): for ctx in eval(n.get('rml_loop'),{}, self.localcontext): self.localcontext.update(ctx) if (tagname is None) or (n.tag==tagname): if n.get('rml_except', False): try: eval(n.get('rml_except'), {}, self.localcontext) except GeneratorExit: continue except Exception, e: logging.getLogger('report').exception(e) continue if n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) n2 = copy.deepcopy(n) n2.tag = tag n2.attrib.update(attr) yield n2 except GeneratorExit: yield n except Exception, e: logging.getLogger('report').exception(e) yield n else: yield n continue if self and self.localcontext and n.get('rml_except'): try: eval(n.get('rml_except'), {}, self.localcontext) except GeneratorExit: continue except Exception, e: logging.getLogger('report').exception(e) continue if self and self.localcontext and n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) n2 = copy.deepcopy(n) n2.tag = tag n2.attrib.update(attr or {}) yield n2 tagname = '' except GeneratorExit: pass except Exception, e: logging.getLogger('report').exception(e) pass if (tagname is None) or (n.tag==tagname): yield n
2f2ed1d13809310f25bd258146fa5a7b1f04081f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2f2ed1d13809310f25bd258146fa5a7b1f04081f/utils.py
logging.getLogger('report').exception(e)
logging.getLogger('report').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True)
def _child_get(node, self=None, tagname=None): for n in node: if self and self.localcontext and n.get('rml_loop'): for ctx in eval(n.get('rml_loop'),{}, self.localcontext): self.localcontext.update(ctx) if (tagname is None) or (n.tag==tagname): if n.get('rml_except', False): try: eval(n.get('rml_except'), {}, self.localcontext) except GeneratorExit: continue except Exception, e: logging.getLogger('report').exception(e) continue if n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) n2 = copy.deepcopy(n) n2.tag = tag n2.attrib.update(attr) yield n2 except GeneratorExit: yield n except Exception, e: logging.getLogger('report').exception(e) yield n else: yield n continue if self and self.localcontext and n.get('rml_except'): try: eval(n.get('rml_except'), {}, self.localcontext) except GeneratorExit: continue except Exception, e: logging.getLogger('report').exception(e) continue if self and self.localcontext and n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) n2 = copy.deepcopy(n) n2.tag = tag n2.attrib.update(attr or {}) yield n2 tagname = '' except GeneratorExit: pass except Exception, e: logging.getLogger('report').exception(e) pass if (tagname is None) or (n.tag==tagname): yield n
2f2ed1d13809310f25bd258146fa5a7b1f04081f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2f2ed1d13809310f25bd258146fa5a7b1f04081f/utils.py
logging.getLogger('report').exception(e)
logging.getLogger('report').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True)
def _child_get(node, self=None, tagname=None): for n in node: if self and self.localcontext and n.get('rml_loop'): for ctx in eval(n.get('rml_loop'),{}, self.localcontext): self.localcontext.update(ctx) if (tagname is None) or (n.tag==tagname): if n.get('rml_except', False): try: eval(n.get('rml_except'), {}, self.localcontext) except GeneratorExit: continue except Exception, e: logging.getLogger('report').exception(e) continue if n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) n2 = copy.deepcopy(n) n2.tag = tag n2.attrib.update(attr) yield n2 except GeneratorExit: yield n except Exception, e: logging.getLogger('report').exception(e) yield n else: yield n continue if self and self.localcontext and n.get('rml_except'): try: eval(n.get('rml_except'), {}, self.localcontext) except GeneratorExit: continue except Exception, e: logging.getLogger('report').exception(e) continue if self and self.localcontext and n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) n2 = copy.deepcopy(n) n2.tag = tag n2.attrib.update(attr or {}) yield n2 tagname = '' except GeneratorExit: pass except Exception, e: logging.getLogger('report').exception(e) pass if (tagname is None) or (n.tag==tagname): yield n
2f2ed1d13809310f25bd258146fa5a7b1f04081f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2f2ed1d13809310f25bd258146fa5a7b1f04081f/utils.py
logging.getLogger('report').exception(e)
logging.getLogger('report').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True)
def _child_get(node, self=None, tagname=None): for n in node: if self and self.localcontext and n.get('rml_loop'): for ctx in eval(n.get('rml_loop'),{}, self.localcontext): self.localcontext.update(ctx) if (tagname is None) or (n.tag==tagname): if n.get('rml_except', False): try: eval(n.get('rml_except'), {}, self.localcontext) except GeneratorExit: continue except Exception, e: logging.getLogger('report').exception(e) continue if n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) n2 = copy.deepcopy(n) n2.tag = tag n2.attrib.update(attr) yield n2 except GeneratorExit: yield n except Exception, e: logging.getLogger('report').exception(e) yield n else: yield n continue if self and self.localcontext and n.get('rml_except'): try: eval(n.get('rml_except'), {}, self.localcontext) except GeneratorExit: continue except Exception, e: logging.getLogger('report').exception(e) continue if self and self.localcontext and n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) n2 = copy.deepcopy(n) n2.tag = tag n2.attrib.update(attr or {}) yield n2 tagname = '' except GeneratorExit: pass except Exception, e: logging.getLogger('report').exception(e) pass if (tagname is None) or (n.tag==tagname): yield n
2f2ed1d13809310f25bd258146fa5a7b1f04081f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2f2ed1d13809310f25bd258146fa5a7b1f04081f/utils.py
p.sale_id = ANY(%s) GROUP BY mp.state, p.sale_id''')
p.sale_id = ANY(%s) GROUP BY mp.state, p.sale_id''',(ids,))
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), mp.state as mp_state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) LEFT JOIN mrp_procurement mp on (mp.move_id=m.id) WHERE p.sale_id = ANY(%s) GROUP BY mp.state, p.sale_id''') for oid, nbr, mp_state in cr.fetchall(): if mp_state == 'cancel': continue if mp_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
0a2641b0df245ce8ce72113af93f760d7234526b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a2641b0df245ce8ce72113af93f760d7234526b/sale.py
if isinstance(right, basestring):
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {}
def _rec_convert(ids): if field_obj == table: return ids return self.__execute_recursive_in(cr, field._id1, field._rel, field._id2, ids, operator, field._type)
4ab96967d08049b60156a136841f49426255bb5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4ab96967d08049b60156a136841f49426255bb5b/expression.py
self.__exp[i] = ('id','=',0)
return ('id','=',0)
def _rec_convert(ids): if field_obj == table: return ids return self.__execute_recursive_in(cr, field._id1, field._rel, field._id2, ids, operator, field._type)
4ab96967d08049b60156a136841f49426255bb5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4ab96967d08049b60156a136841f49426255bb5b/expression.py
self.__exp[i] = (left, 'in', right)
return (left, 'in', right) m2o_str = False if isinstance(right, basestring): m2o_str = True elif isinstance(right, list) or isinstance(right, tuple): m2o_str = True for ele in right: if not isinstance(ele, basestring): m2o_str = False break if m2o_str: self.__exp[i] = _get_expression(field_obj,cr, uid, left, right, operator, context=context)
def _rec_convert(ids): if field_obj == table: return ids return self.__execute_recursive_in(cr, field._id1, field._rel, field._id2, ids, operator, field._type)
4ab96967d08049b60156a136841f49426255bb5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4ab96967d08049b60156a136841f49426255bb5b/expression.py
def _try_function(self, funct, args, opname='run function', cr=None, default_exc=DAV_Forbidden):
def _try_function(self, funct, args, opname='run function', cr=None, default_exc=DAV_Forbidden):
def _try_function(self, funct, args, opname='run function', cr=None, default_exc=DAV_Forbidden): """ Try to run a function, and properly convert exceptions to DAV ones. @objname the name of the operation being performed @param cr if given, the cursor to close at exceptions """ try: funct(*args) except DAV_Error: if cr: cr.close() raise except NotImplementedError, e: if cr: cr.close() import traceback self.parent.log_error("Cannot %s: %s", opname, str(e)) self.parent.log_message("Exc: %s",traceback.format_exc()) raise DAV_Error(405, str(e) or 'Not supported at this path') except EnvironmentError, err: if cr: cr.close() import traceback self.parent.log_error("Cannot %s: %s", opname, e.strerror) self.parent.log_message("Exc: %s",traceback.format_exc()) raise default_exc(err.strerror) except Exception,e: import traceback self.parent.log_error("Cannot create %s: %s", opname, str(e)) self.parent.log_message("Exc: %s",traceback.format_exc()) raise default_exc("Operation failed")
403a71fbaab7a8b607934347ccf6e7309f875f1a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/403a71fbaab7a8b607934347ccf6e7309f875f1a/dav_fs.py
raise DAV_Error(405, str(e) or 'Not supported at this path')
raise DAV_Error(403, str(e) or 'Not supported at this path')
def _try_function(self, funct, args, opname='run function', cr=None, default_exc=DAV_Forbidden): """ Try to run a function, and properly convert exceptions to DAV ones. @objname the name of the operation being performed @param cr if given, the cursor to close at exceptions """ try: funct(*args) except DAV_Error: if cr: cr.close() raise except NotImplementedError, e: if cr: cr.close() import traceback self.parent.log_error("Cannot %s: %s", opname, str(e)) self.parent.log_message("Exc: %s",traceback.format_exc()) raise DAV_Error(405, str(e) or 'Not supported at this path') except EnvironmentError, err: if cr: cr.close() import traceback self.parent.log_error("Cannot %s: %s", opname, e.strerror) self.parent.log_message("Exc: %s",traceback.format_exc()) raise default_exc(err.strerror) except Exception,e: import traceback self.parent.log_error("Cannot create %s: %s", opname, str(e)) self.parent.log_message("Exc: %s",traceback.format_exc()) raise default_exc("Operation failed")
403a71fbaab7a8b607934347ccf6e7309f875f1a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/403a71fbaab7a8b607934347ccf6e7309f875f1a/dav_fs.py
import traceback self.parent.log_error("GET typeError: %s", str(e)) self.parent.log_message("Exc: %s",traceback.format_exc()) raise DAV_Forbidden
return ''
def get_data(self,uri, rrange=None): self.parent.log_message('GET: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri) try: if not dbname: raise DAV_Error, 409 node = self.uri2object(cr, uid, pool, uri2) if not node: raise DAV_NotFound2(uri2) try: if rrange: self.parent.log_error("Doc get_data cannot use range") raise DAV_Error(409) datas = node.get_data(cr) except TypeError,e: import traceback self.parent.log_error("GET typeError: %s", str(e)) self.parent.log_message("Exc: %s",traceback.format_exc()) raise DAV_Forbidden except IndexError,e : self.parent.log_error("GET IndexError: %s", str(e)) raise DAV_NotFound2(uri2) except Exception,e: import traceback self.parent.log_error("GET exception: %s",str(e)) self.parent.log_message("Exc: %s", traceback.format_exc()) raise DAV_Error, 409 return str(datas) # FIXME! finally: if cr: cr.close()
403a71fbaab7a8b607934347ccf6e7309f875f1a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/403a71fbaab7a8b607934347ccf6e7309f875f1a/dav_fs.py
self._try_function(node.create_child_collection, (cr, uri2[-1]), "create col %s" % uri2[-1], cr=cr)
self._try_function(node.create_child_collection, (cr, uri2[-1]), "create col %s" % uri2[-1], cr=cr)
def mkcol(self,uri): """ create a new collection see par. 9.3 of rfc4918 """ self.parent.log_message('MKCOL: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri) if not uri2[-1]: cr.close() raise DAV_Error(409, "Cannot create nameless collection") if not dbname: cr.close() raise DAV_Error, 409 node = self.uri2object(cr,uid,pool, uri2[:-1]) if not node: cr.close() raise DAV_Error(409, "Parent path %s does not exist" % uri2[:-1]) nc = node.child(cr, uri2[-1]) if nc: cr.close() raise DAV_Error(405, "Path already exists") self._try_function(node.create_child_collection, (cr, uri2[-1]), "create col %s" % uri2[-1], cr=cr) cr.commit() cr.close() return True
403a71fbaab7a8b607934347ccf6e7309f875f1a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/403a71fbaab7a8b607934347ccf6e7309f875f1a/dav_fs.py
sql =""" select rp.name from account_bank_statement_line as absl,res_partner as rp where absl.partner_id = rp.id and absl.pos_statement_id = %d"""%(statement['pos_statement_id']) self.cr.execute(sql) res = self.cr.dictfetchall() if res : return res[0]['name']
if statement['pos_statement_id']: sql =""" select rp.name from account_bank_statement_line as absl,res_partner as rp where absl.partner_id = rp.id and absl.pos_statement_id = %d"""%(statement['pos_statement_id']) self.cr.execute(sql) res = self.cr.dictfetchall() or {} return res and res[0]['name']
def _get_partner(self,statement): res = {} sql =""" select rp.name from account_bank_statement_line as absl,res_partner as rp where absl.partner_id = rp.id and absl.pos_statement_id = %d"""%(statement['pos_statement_id']) self.cr.execute(sql) res = self.cr.dictfetchall() if res : return res[0]['name'] else : return 0.00
9f88bde3ce7b031a0902d8dad009d8246f3af984 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9f88bde3ce7b031a0902d8dad009d8246f3af984/all_closed_cashbox_of_the_day.py
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if context is None: context = {} if not ids: return []
7efb90b28ea9596df97767fb65962e96654b4c59 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7efb90b28ea9596df97767fb65962e96654b4c59/account_analytic_analysis.py
elif path is None:
elif self.path is None:
def full_path(self): """ Return the components of the full path for some node. The returned list only contains the names of nodes. """ if self.parent: s = self.parent.full_path() else: s = [] if isinstance(self.path,list): s+=self.path elif path is None: s.append('') else: s.append(self.path) return s #map(lambda x: '/' +x, s)
d6f1e1f29f8110c363d8a413da8dcf17284cc205 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d6f1e1f29f8110c363d8a413da8dcf17284cc205/nodes.py
result[meeting_id] = {}
result[meeting_id] = {}
def _get_data(self, cr, uid, ids, name, arg, context): result = {} attendee_obj = self.pool.get('calendar.attendee') alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] for meeting_id in ids: result[meeting_id] = {} if "attendees" in name: attendee_ids = attendee_obj.search(cr, uid, [('ref','=','%s,%d'%(self._name, meeting_id))]) result[meeting_id]["attendees"] = attendee_obj.export_cal(cr, uid, attendee_ids) if "alarms" in name: alarm_ids = alarm_obj.search(cr, uid, [('model_id','=',model_id), ('res_id','=',meeting_id)]) result[meeting_id]["alarms"] = alarm_obj.export_cal(cr, uid, alarm_ids) return result
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
if "alarms" in name:
if "alarms" in name:
def _get_data(self, cr, uid, ids, name, arg, context): result = {} attendee_obj = self.pool.get('calendar.attendee') alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] for meeting_id in ids: result[meeting_id] = {} if "attendees" in name: attendee_ids = attendee_obj.search(cr, uid, [('ref','=','%s,%d'%(self._name, meeting_id))]) result[meeting_id]["attendees"] = attendee_obj.export_cal(cr, uid, attendee_ids) if "alarms" in name: alarm_ids = alarm_obj.search(cr, uid, [('model_id','=',model_id), ('res_id','=',meeting_id)]) result[meeting_id]["alarms"] = alarm_obj.export_cal(cr, uid, alarm_ids) return result
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py
result[meeting_id]["alarms"] = alarm_obj.export_cal(cr, uid, alarm_ids)
result[meeting_id]["alarms"] = alarm_obj.export_cal(cr, uid, alarm_ids)
def _get_data(self, cr, uid, ids, name, arg, context): result = {} attendee_obj = self.pool.get('calendar.attendee') alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] for meeting_id in ids: result[meeting_id] = {} if "attendees" in name: attendee_ids = attendee_obj.search(cr, uid, [('ref','=','%s,%d'%(self._name, meeting_id))]) result[meeting_id]["attendees"] = attendee_obj.export_cal(cr, uid, attendee_ids) if "alarms" in name: alarm_ids = alarm_obj.search(cr, uid, [('model_id','=',model_id), ('res_id','=',meeting_id)]) result[meeting_id]["alarms"] = alarm_obj.export_cal(cr, uid, alarm_ids) return result
75258015cae6ae0d493e7eb6204a16eafed73cd9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75258015cae6ae0d493e7eb6204a16eafed73cd9/crm_meeting.py