bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
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
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 or 'n/a') + "' "+ _("is ready to be processed.") self.log(cr, uid, id, message) self.write(cr, uid, ids, {'state': 'assigned'}) return True
470,200
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <peter@fry-it.com> ## 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
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <peter@fry-it.com> ## 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 = unicode(soup) 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
470,201
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 " \
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 " \
470,202
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 " \
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 " \
470,203
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 " \
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 " \
470,204
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
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) result_tmp = result_tmp + temp_res return result_tmp
470,205
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
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) result_tmp = result_tmp + temp_res return result_tmp
470,206
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
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) return result_tmp + temp_res
470,207
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')
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')
470,208
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
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
470,209
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')
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')
470,210
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)
def _lang_data_get(self, cr, uid, lang_id, monetary=False): 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)
470,211
def format(self, cr, uid, ids, percent, value, grouping=False, monetary=False): """ Format() will return the language-specific output for float values"""
def format(self, cr, uid, ids, percent, value, grouping=False, monetary=False): """ Format() will return the language-specific output for float values"""
470,212
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)
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)
470,213
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)
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: return pooler.get_db_only(dbname)
470,214
def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' '
def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' '
470,215
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 !')
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 !')
470,216
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 !')
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 !')
470,217
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))
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))
470,218
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))
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 = [None] 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))
470,219
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))
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] = [None, 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))
470,220
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
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 val.get('date_deadline', False) 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
470,221
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 ) """)
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 ) """)
470,222
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 ) """)
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 ) """)
470,223
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
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
470,224
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
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) not in [13,14,8]: 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
470,225
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
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 oddsum=0 evensum=0 total=0 eanvalue=partner.ean13 reversevalue = eanvalue[::-1] finalean=reversevalue[1:] for i in range(len(finalean)): 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
470,226
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
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): oddsum += int(finalean[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
470,227
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
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: evensum += int(finalean[i]) total=(oddsum * 3) + evensum check = int(10 - math.ceil(total % 10.0)) if check != int(partner.ean13[-1]): return False return True
470,228
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
def _doIndexFile(self,fname): fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout return _to_unicode(fp.read())
470,229
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
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
470,230
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
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
470,231
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
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
470,232
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
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
470,233
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
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
470,234
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, [])
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = 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, [])
470,235
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, [])
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 = property_obj.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, [])
470,236
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, [])
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 = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not 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, [])
470,237
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, [])
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 pay_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, [])
470,238
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, [])
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 = account_obj.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, [])
470,239
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, [])
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 = account_obj.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, [])
470,240
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
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
470,241
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
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
470,242
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
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
470,243
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
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
470,244
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
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
470,245
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
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
470,246
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
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
470,247
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
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
470,248
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
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
470,249
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
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
470,250
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
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
470,251
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
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
470,252
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
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
470,253
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
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
470,254
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
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
470,255
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
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
470,256
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
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
470,257
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)
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)
470,258
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)
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)
470,259
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)
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)
470,260
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)
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)
470,261
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
def _add_header(self, rml_dom, header=1): if header==2: rml_head = self.rml_header2 else: rml_head = self.rml_header 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
470,262
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)
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 = etree.XML(rml) 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)
470,263
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()
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()
470,264
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()
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()
470,265
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()
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()
470,266
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()
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()
470,267
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)
def graph_get(cr, graph, wkf_ids, 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)
470,268
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)
def graph_get(cr, graph, wkf_id, nested=False, workitem={}): import pydot cr.execute('select * from wkf_activity where wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids) 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)
470,269
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)
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 * from wkf_activity where flow_start=True and wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids) 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)
470,270
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)
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 in ("+','.join(['%s']*len(wkf_ids))+')', wkf_ids) stop = cr.fetchall() if (stop): stop = (stop[0][1], dict(stop)) else: stop = ("stop",{}) return ((start,{}),stop)
470,271
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))
def graph_instance_get(cr, graph, inst_id, nested=False): workitems = {} cr.execute('select wkf_id from wkf_instance where id=%s', (inst_id,)) inst = cr.fetchall() 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))
470,272
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())
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())
470,273
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
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
470,274
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
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
470,275
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
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]][self._fields_id] = 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
470,276
def __getitem__(self, name): if name == 'id': return self._id
def __getitem__(self, name): if name == 'id': return self._id
470,277
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
def onchange_journal_id(self, cr, uid, ids, journal_id, company_id): result = {} if journal_id: journal = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal.currency: result = {'value': { 'currency_id': journal_id.currency.id } } else: result = {'value': { 'currency_id': company.currency_id.id } } return result
470,278
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
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.currency.id } } else: result = {'value': { 'currency_id': company.currency_id.id } } return result
470,279
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
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 } } return result if company_id: company = self.pool.get('res.company').browse(cr, uid, company_id) result = {'value': { 'currency_id': company.currency_id.id } } return result
470,280
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
defonchange_journal_id(self,cr,uid,ids,journal_id,company_id):result={}ifjournal_idandcompany_id:company=self.pool.get('res.company').browse(cr,uid,company_id)journal_id=self.pool.get('account.journal').browse(cr,uid,journal_id)ifjournal_id.currency:result={'value':{'currency_id':journal_id.currency.id}}else:result={'value':{'currency_id':company.currency_id.id}}returnresult
470,281
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
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').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True) 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').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True) 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').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True) 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').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True) pass if (tagname is None) or (n.tag==tagname): yield n
470,282
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
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').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True) 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').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True) 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').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True) 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').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True) pass if (tagname is None) or (n.tag==tagname): yield n
470,283
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
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').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True) 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').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True) 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').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True) 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').warning('rml_except: "%s"',n.get('rml_except',''), exc_info=True) pass if (tagname is None) or (n.tag==tagname): yield n
470,284
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
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').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True) 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').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True) 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').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True) 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').warning('rml_tag: "%s"',n.get('rml_tag',''), exc_info=True) pass if (tagname is None) or (n.tag==tagname): yield n
470,285
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
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''',(ids,)) 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
470,286
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)
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)
470,287
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)
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)
470,288
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)
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)
470,289
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")
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")
470,290
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")
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(403, 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")
470,291
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()
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: return '' 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()
470,292
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
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
470,293
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
def _get_partner(self,statement): res = {} 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'] else : return 0.00
470,294
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if context is None: context = {} if not ids: return []
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if context is None: context = {} if not ids: return []
470,295
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)
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 self.path is None: s.append('') else: s.append(self.path) return s #map(lambda x: '/' +x, s)
470,296
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
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
470,297
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
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
470,298
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
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
470,299