bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
fields_def = self.__view_look_dom(cr, user, node, view_id, context=context)
fields_def = self.__view_look_dom(cr, user, node, view_id, context=context)
468,700
def __get_default_calendar_view(self): """Generate a default calendar view (For internal use only). """
def __get_default_calendar_view(self): """Generate a default calendar view (For internal use only). """
468,701
def __get_default_calendar_view(self): """Generate a default calendar view (For internal use only). """
def __get_default_calendar_view(self): """Generate a default calendar view (For internal use only). """
468,702
def clean(x): x = x[2] for key in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): if key in x: del x[key] return x
def clean(x): x = x[2] for key in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): if key in x: del x[key] return x
468,703
def _add_missing_default_values(self, cr, uid, values, context=None): missing_defaults = [] avoid_tables = [] # avoid overriding inherited values when parent is set for tables, parent_field in self._inherits.items(): if parent_field in values: avoid_tables.append(tables) for field in self._columns.keys(): if not field in values: missing_defaults.append(field) for field in self._inherit_fields.keys(): if (field not in values) and (self._inherit_fields[field][0] not in avoid_tables): missing_defaults.append(field)
def _add_missing_default_values(self, cr, uid, values, context=None): missing_defaults = [] avoid_tables = [] # avoid overriding inherited values when parent is set for tables, parent_field in self._inherits.items(): if parent_field in values: avoid_tables.append(tables) for field in self._columns.keys(): if not field in values: missing_defaults.append(field) for field in self._inherit_fields.keys(): if (field not in values) and (self._inherit_fields[field][0] not in avoid_tables): missing_defaults.append(field)
468,704
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): """ Get the list of records in list view grouped by the given ``groupby`` fields
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): """ Get the list of records in list view grouped by the given ``groupby`` fields
468,705
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): """ Get the list of records in list view grouped by the given ``groupby`` fields
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): """ Get the list of records in list view grouped by the given ``groupby`` fields
468,706
def write(self, cr, user, ids, vals, context=None): """ Update records with given ids with the given field values
def write(self, cr, user, ids, vals, context=None): """ Update records with given ids with the given field values
468,707
def _store_set_values(self, cr, uid, ids, fields, context): if not ids: return True field_flag = False field_dict = {} if self._log_access: cr.execute('select id,write_date from '+self._table+' where id IN %s',(tuple(ids),)) res = cr.fetchall() for r in res: if r[1]: field_dict.setdefault(r[0], []) res_date = time.strptime((r[1])[:19], '%Y-%m-%d %H:%M:%S') write_date = datetime.datetime.fromtimestamp(time.mktime(res_date)) for i in self.pool._store_function.get(self._name, []): if i[5]: up_write_date = write_date + datetime.timedelta(hours=i[5]) if datetime.datetime.now() < up_write_date: if i[1] in fields: field_dict[r[0]].append(i[1]) if not field_flag: field_flag = True todo = {} keys = [] for f in fields: if self._columns[f]._multi not in keys: keys.append(self._columns[f]._multi) todo.setdefault(self._columns[f]._multi, []) todo[self._columns[f]._multi].append(f) for key in keys: val = todo[key] if key: # uid == 1 for accessing objects having rules defined on store fields result = self._columns[val[0]].get(cr, self, ids, val, 1, context=context) for id,value in result.items(): if field_flag: for f in value.keys(): if f in field_dict[id]: value.pop(f) upd0 = [] upd1 = [] for v in value: if v not in val: continue if self._columns[v]._type in ('many2one', 'one2one'): try: value[v] = value[v][0] except: pass upd0.append('"'+v+'"='+self._columns[v]._symbol_set[0]) upd1.append(self._columns[v]._symbol_set[1](value[v])) upd1.append(id) if upd0 and upd1: cr.execute('update "' + self._table + '" set ' + \ string.join(upd0, ',') + ' where id = %s', upd1)
def _store_set_values(self, cr, uid, ids, fields, context): if not ids: return True field_flag = False field_dict = {} if self._log_access: cr.execute('select id,write_date from '+self._table+' where id IN %s',(tuple(ids),)) res = cr.fetchall() for r in res: if r[1]: field_dict.setdefault(r[0], []) res_date = time.strptime((r[1])[:19], '%Y-%m-%d %H:%M:%S') write_date = datetime.datetime.fromtimestamp(time.mktime(res_date)) for i in self.pool._store_function.get(self._name, []): if i[5]: up_write_date = write_date + datetime.timedelta(hours=i[5]) if datetime.datetime.now() < up_write_date: if i[1] in fields: field_dict[r[0]].append(i[1]) if not field_flag: field_flag = True todo = {} keys = [] for f in fields: if self._columns[f]._multi not in keys: keys.append(self._columns[f]._multi) todo.setdefault(self._columns[f]._multi, []) todo[self._columns[f]._multi].append(f) for key in keys: val = todo[key] if key: # uid == 1 for accessing objects having rules defined on store fields result = self._columns[val[0]].get(cr, self, ids, val, 1, context=context) for id,value in result.items(): if field_flag: for f in value.keys(): if f in field_dict[id]: value.pop(f) upd0 = [] upd1 = [] for v in value: if v not in val: continue if self._columns[v]._type in ('many2one', 'one2one'): try: value[v] = value[v][0] except: pass upd0.append('"'+v+'"='+self._columns[v]._symbol_set[0]) upd1.append(self._columns[v]._symbol_set[1](value[v])) upd1.append(id) if upd0 and upd1: cr.execute('update "' + self._table + '" set ' + \ string.join(upd0, ',') + ' where id = %s', upd1)
468,708
def _product_value(self, cr, uid, ids, field_names, arg, context=None): """Computes stock value (real and virtual) for a product, as well as stock qty (real and virtual). @param field_names: Name of field @return: Dictionary of values """ result = dict([(i, {}.fromkeys(field_names, 0.0)) for i in ids])
def_product_value(self,cr,uid,ids,field_names,arg,context=None):"""Computesstockvalue(realandvirtual)foraproduct,aswellasstockqty(realandvirtual).@paramfield_names:Nameoffield@return:Dictionaryofvalues"""result=dict([(i,{}.fromkeys(field_names,0.0))foriinids])
468,709
def _product_value(self, cr, uid, ids, field_names, arg, context=None): """Computes stock value (real and virtual) for a product, as well as stock qty (real and virtual). @param field_names: Name of field @return: Dictionary of values """ result = dict([(i, {}.fromkeys(field_names, 0.0)) for i in ids])
def _product_value(self, cr, uid, ids, field_names, arg, context=None): """Computes stock value (real and virtual) for a product, as well as stock qty (real and virtual). @param field_names: Name of field @return: Dictionary of values """ result = dict([(i, {}.fromkeys(field_names, 0.0)) for i in ids])
468,710
def _models_get(self, cr, uid, context=None): return self._models_field_get(cr, uid, 'model_id.model', 'model_id.name', context)
def _models_get(self, cr, uid, context=None): return self._models_field_get(cr, uid, 'model_id.model', 'model_id.name', context)
468,711
def _search_invoices(obj, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) line_obj = pool.get('account.move.line') statement_obj = pool.get('account.bank.statement') journal_obj = pool.get('account.journal') statement = statement_obj.browse(cr, uid, data['id'], context=context) args_move_line = [] repeated_move_line_ids = [] # Creating a group that is unique for importing move lines(move lines, once imported into statement lines, should not appear again) for st_line in statement.line_ids: args_move_line = [] args_move_line.append(('name','=', st_line.name)) args_move_line.append(('ref','=',st_line.ref)) if st_line.partner_id: args_move_line.append(('partner_id','=',st_line.partner_id.id)) args_move_line.append(('account_id','=',st_line.account_id.id)) move_line_id = line_obj.search(cr, uid, args_move_line,context=context) if move_line_id: repeated_move_line_ids.append(move_line_id) journal_ids = data['form']['journal_id'][0][2] if journal_ids == []: journal_ids = journal_obj.search(cr, uid, [('type', 'in', ('sale','cash','purchase'))], context=context) args = [ ('reconcile_id', '=', False), ('journal_id', 'in', journal_ids), ('account_id.reconcile', '=', True)] if repeated_move_line_ids: args.append(('id','not in',repeated_move_line_ids)) line_ids = line_obj.search(cr, uid, args, #order='date DESC, id DESC', #doesn't work context=context) FORM.string = '''<?xml version="1.0"?>
def _search_invoices(obj, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) line_obj = pool.get('account.move.line') statement_obj = pool.get('account.bank.statement') journal_obj = pool.get('account.journal') statement = statement_obj.browse(cr, uid, data['id'], context=context) args_move_line = [] repeated_move_line_ids = [] # Creating a group that is unique for importing move lines(move lines, once imported into statement lines, should not appear again) for st_line in statement.line_ids: args_move_line = [] args_move_line.append(('name','=', st_line.name)) args_move_line.append(('ref','=',st_line.ref)) if st_line.partner_id: args_move_line.append(('partner_id','=',st_line.partner_id.id)) args_move_line.append(('account_id','=',st_line.account_id.id)) move_line_id = line_obj.search(cr, uid, args_move_line,context=context) if move_line_id: repeated_move_line_ids += move_line_id journal_ids = data['form']['journal_id'][0][2] if journal_ids == []: journal_ids = journal_obj.search(cr, uid, [('type', 'in', ('sale','cash','purchase'))], context=context) args = [ ('reconcile_id', '=', False), ('journal_id', 'in', journal_ids), ('account_id.reconcile', '=', True)] if repeated_move_line_ids: args.append(('id','not in',repeated_move_line_ids)) line_ids = line_obj.search(cr, uid, args, #order='date DESC, id DESC', #doesn't work context=context) FORM.string = '''<?xml version="1.0"?>
468,712
def init(self, cr):
def init(self, cr):
468,713
def init(self, cr):
def init(self, cr):
468,714
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """
468,715
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """
468,716
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """
468,717
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): journal_pool = self.pool.get('account.journal')
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): journal_pool = self.pool.get('account.journal')
468,718
def OpenPartnerForm(txtProcessor,*args): import win32con b = check() if not b: return #Acquiring control of the text box partner_link = txtProcessor.GetControl() #Reading Current Selected Email. ex = txtProcessor.window.manager.outlook.ActiveExplorer() assert ex.Selection.Count == 1 mail = ex.Selection.Item(1) partner_text = "" try: partner_text = ustr(mail.SenderName).encode('iso-8859-1') sender_mail = ustr(mail.SenderEmailAddress).encode('iso-8859-1') except Exception: win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, "< Error in reading email.>") pass vals = NewConn.SearchPartner(sender_mail) if vals == True: win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, "< Their is contact related to "+str(partner_text)+" email address, but no partner is linked to contact>") txtProcessor.init_done=True return if vals == None: win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, "< No Partner found linked to "+str(partner_text)+" email address.>") txtProcessor.init_done=True return global web_server global web_server_port if web_server.strip() == "" or web_server.strip() == "http:\\\\": win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, " <Invalid Server Address>") txtProcessor.init_done=True return try: linktopartner = "http:\\\\"+web_server+":"+str(web_server_port)+"\\openerp\\form\\view?model=res.partner&id="+str(vals) win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, linktopartner) except Exception,e: win32ui.MessageBox("Error While Opening Partner.\n"+str(e),"Open Partner", flag_error) webbrowser.open_new(linktopartner) txtProcessor.init_done=True
def OpenPartnerForm(txtProcessor,*args): import win32con b = check() if not b: return #Acquiring control of the text box partner_link = txtProcessor.GetControl() #Reading Current Selected Email. ex = txtProcessor.window.manager.outlook.ActiveExplorer() assert ex.Selection.Count == 1 mail = ex.Selection.Item(1) partner_text = "" try: partner_text = ustr(mail.SenderName).encode('iso-8859-1') sender_mail = ustr(mail.SenderEmailAddress).encode('iso-8859-1') except Exception: win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, "< Error in reading email.>") pass vals = NewConn.SearchPartner(sender_mail) if vals == True: win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, "< Their is contact related to "+str(partner_text)+" email address, but no partner is linked to contact>") txtProcessor.init_done=True return if vals == None: win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, "< No Partner found linked to "+str(partner_text)+" email address.>") txtProcessor.init_done=True return global web_server global web_server_port if web_server.strip() == "" or web_server.strip() == "http:\\\\": win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, " <Invalid Server Address>") txtProcessor.init_done=True return try: linktopartner = "http://"+web_server+":"+str(web_server_port)+"/openerp/form/view?model=res.partner&id="+str(vals) win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, str(linktopartner)) except Exception,e: win32ui.MessageBox("Error While Opening Partner.\n"+str(e),"Open Partner", flag_error) webbrowser.open_new(linktopartner) txtProcessor.init_done=True
468,719
def get_sys_logs(cr, uid): """ Utility method to send a publisher warranty get logs messages. """ pool = pooler.get_pool(cr.dbname) dbuuid = pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid') db_create_date = pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date') nbr_users = pool.get("res.users").search(cr, uid, [], count=True) contractosv = pool.get('publisher_warranty.contract') contracts = contractosv.browse(cr, uid, contractosv.search(cr, uid, [])) user = pool.get("res.users").browse(cr, uid, uid) msg = { "dbuuid": dbuuid, "nbr_users": nbr_users, "dbname": cr.dbname, "db_create_date": db_create_date, "version": release.version, "contracts": [c.name for c in contracts], "language": user.context_lang, } add_arg = {"timeout":30} if sys.version_info >= (2,6) else {} uo = urllib2.urlopen(config.get("publisher_warranty_url"), urllib.urlencode({'arg0': msg, "action": "update",}), **add_arg) try: submit_result = uo.read() finally: uo.close() result = safe_eval(submit_result) return result
def get_sys_logs(cr, uid): """ Utility method to send a publisher warranty get logs messages. """ pool = pooler.get_pool(cr.dbname) dbuuid = pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid') db_create_date = pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date') nbr_users = pool.get("res.users").search(cr, uid, [], count=True) contractosv = pool.get('publisher_warranty.contract') contracts = contractosv.browse(cr, uid, contractosv.search(cr, uid, [])) user = pool.get("res.users").browse(cr, uid, uid) msg = { "dbuuid": dbuuid, "nbr_users": nbr_users, "dbname": cr.dbname, "db_create_date": db_create_date, "version": release.version, "contracts": [c.name for c in contracts], "language": user.context_lang, } add_arg = {"timeout":30} if sys.version_info >= (2,6) else {} uo = urllib2.urlopen(config.get("publisher_warranty_url"), urllib.urlencode({'arg0': msg, "action": "update",}), **add_arg) try: submit_result = uo.read() finally: uo.close() result = safe_eval(submit_result) if submit_result else {} return result
468,720
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') data_pool = self.pool.get('ir.model.data')
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') data_pool = self.pool.get('ir.model.data')
468,721
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') data_pool = self.pool.get('ir.model.data')
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') data_pool = self.pool.get('ir.model.data')
468,722
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') data_pool = self.pool.get('ir.model.data')
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') data_pool = self.pool.get('ir.model.data')
468,723
def last_day_of_current_month(): import datetime import calendar today = datetime.date.today() last_day = str(calendar.monthrange(today.year, today.month)[1]) return time.strftime('%Y-%m-' + last_day)
def last_day_of_current_month(): today = datetime.date.today() last_day = str(calendar.monthrange(today.year, today.month)[1]) return time.strftime('%Y-%m-' + last_day)
468,724
def __init__(self, cr): super(orm, self).__init__(cr)
def __init__(self, cr): super(orm, self).__init__(cr)
468,725
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') account_analytic_line_obj = self.pool.get('account.analytic.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id.id, context) st = st_line.statement_id
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') account_analytic_line_obj = self.pool.get('account.analytic.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context) st = st_line.statement_id
468,726
def fetch_mail(self, cr, uid, ids, context=None): if not context: context = {} email_tool = self.pool.get('email.server.tools') for server in self.browse(cr, uid, ids, context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) count = 0 try: if server.type == 'imap': imap_server = None if server.is_ssl: imap_server = IMAP4_SSL(server.server, int(server.port)) else: imap_server = IMAP4(server.server, int(server.port))
def fetch_mail(self, cr, uid, ids, context=None): if not context: context = {} email_tool = self.pool.get('email.server.tools') for server in self.browse(cr, uid, ids, context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) count = 0 try: if server.type == 'imap': imap_server = None if server.is_ssl: imap_server = IMAP4_SSL(server.server, int(server.port)) else: imap_server = IMAP4(server.server, int(server.port))
468,727
def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {}
def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {}
468,728
def create_invoices(self, cr, uid, ids, context={}): """ To create invoices.
def create_invoices(self, cr, uid, ids, context={}): """ To create invoices.
468,729
def __init__(self, parent, path, mode): nodes.node_descriptor.__init__(self, parent) self.__file = open(path, mode) if mode in ('w', 'w+', 'r+'): self._need_index = True else: self._need_index = False for attr in ('closed', 'read', 'write', 'seek', 'tell'): setattr(self,attr, getattr(self.__file, attr))
def __init__(self, parent, path, mode): nodes.node_descriptor.__init__(self, parent) self.__file = open(path, mode) if mode.endswith('b'): mode = mode[:-1] self.mode = mode for attr in ('closed', 'read', 'write', 'seek', 'tell'): setattr(self,attr, getattr(self.__file, attr))
468,730
def close(self): # TODO: locking in init, close() fname = self.__file.name self.__file.close() if self._need_index: par = self._get_parent() cr = pooler.get_db(par.context.dbname).cursor() icont = '' mime = '' filename = par.path if isinstance(filename, (tuple, list)): filename = '/'.join(filename) try: mime, icont = cntIndex.doIndex(None, filename=filename, content_type=None, realfname=fname) except Exception: logging.getLogger('document.storage').debug('Cannot index file:', exc_info=True) pass
def close(self): # TODO: locking in init, close() fname = self.__file.name self.__file.close() if self.mode in ('w', 'w+', 'r+'): par = self._get_parent() cr = pooler.get_db(par.context.dbname).cursor() icont = '' mime = '' filename = par.path if isinstance(filename, (tuple, list)): filename = '/'.join(filename) try: mime, icont = cntIndex.doIndex(None, filename=filename, content_type=None, realfname=fname) except Exception: logging.getLogger('document.storage').debug('Cannot index file:', exc_info=True) pass
468,731
def close(self): # TODO: locking in init, close() fname = self.__file.name self.__file.close() if self._need_index: par = self._get_parent() cr = pooler.get_db(par.context.dbname).cursor() icont = '' mime = '' filename = par.path if isinstance(filename, (tuple, list)): filename = '/'.join(filename) try: mime, icont = cntIndex.doIndex(None, filename=filename, content_type=None, realfname=fname) except Exception: logging.getLogger('document.storage').debug('Cannot index file:', exc_info=True) pass
def close(self): # TODO: locking in init, close() fname = self.__file.name self.__file.close() if self._need_index: par = self._get_parent() cr = pooler.get_db(par.context.dbname).cursor() icont = '' mime = '' filename = par.path if isinstance(filename, (tuple, list)): filename = '/'.join(filename) try: mime, icont = cntIndex.doIndex(None, filename=filename, content_type=None, realfname=fname) except Exception: logging.getLogger('document.storage').debug('Cannot index file:', exc_info=True) pass
468,732
def close(self): # TODO: locking in init, close() fname = self.__file.name self.__file.close() if self._need_index: par = self._get_parent() cr = pooler.get_db(par.context.dbname).cursor() icont = '' mime = '' filename = par.path if isinstance(filename, (tuple, list)): filename = '/'.join(filename) try: mime, icont = cntIndex.doIndex(None, filename=filename, content_type=None, realfname=fname) except Exception: logging.getLogger('document.storage').debug('Cannot index file:', exc_info=True) pass
def close(self): # TODO: locking in init, close() fname = self.__file.name self.__file.close() if self._need_index: par = self._get_parent() cr = pooler.get_db(par.context.dbname).cursor() icont = '' mime = '' filename = par.path if isinstance(filename, (tuple, list)): filename = '/'.join(filename) try: mime, icont = cntIndex.doIndex(None, filename=filename, content_type=None, realfname=fname) except Exception: logging.getLogger('document.storage').debug('Cannot index file:', exc_info=True) pass
468,733
def get_file(self, cr, uid, id, file_node, mode, context=None): """ Return a file-like object for the contents of some node """ if context is None: context = {} boo = self.browse(cr, uid, id, context) if not boo.online: raise RuntimeError('media offline') ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context) if boo.type == 'filestore': if not ira.store_fname: # On a migrated db, some files may have the wrong storage type # try to fix their directory. if ira.file_size: self._doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id) raise IOError(errno.ENOENT, 'No file can be located') fpath = os.path.join(boo.path, ira.store_fname) return nodefd_file(file_node, path=fpath, mode=mode)
def get_file(self, cr, uid, id, file_node, mode, context=None): """ Return a file-like object for the contents of some node """ if context is None: context = {} boo = self.browse(cr, uid, id, context) if not boo.online: raise RuntimeError('media offline') ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context) if boo.type == 'filestore': if not ira.store_fname: # On a migrated db, some files may have the wrong storage type # try to fix their directory. if ira.file_size: self._doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id) raise IOError(errno.ENOENT, 'No file can be located') fpath = os.path.join(boo.path, ira.store_fname) return nodefd_file(file_node, path=fpath, mode=mode)
468,734
def get_file(self, cr, uid, id, file_node, mode, context=None): """ Return a file-like object for the contents of some node """ if context is None: context = {} boo = self.browse(cr, uid, id, context) if not boo.online: raise RuntimeError('media offline') ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context) if boo.type == 'filestore': if not ira.store_fname: # On a migrated db, some files may have the wrong storage type # try to fix their directory. if ira.file_size: self._doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id) raise IOError(errno.ENOENT, 'No file can be located') fpath = os.path.join(boo.path, ira.store_fname) return nodefd_file(file_node, path=fpath, mode=mode)
def get_file(self, cr, uid, id, file_node, mode, context=None): """ Return a file-like object for the contents of some node """ if context is None: context = {} boo = self.browse(cr, uid, id, context) if not boo.online: raise RuntimeError('media offline') ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context) if boo.type == 'filestore': if not ira.store_fname: # On a migrated db, some files may have the wrong storage type # try to fix their directory. if ira.file_size: self._doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id) raise IOError(errno.ENOENT, 'No file can be located') fpath = os.path.join(boo.path, ira.store_fname) return nodefd_file(file_node, path=fpath, mode=mode)
468,735
def set_data(self, cr, uid, id, file_node, data, context=None, fil_obj=None): """ store the data. This function MUST be used from an ir.attachment. It wouldn't make sense to store things persistently for other types (dynamic). """ if not context: context = {} boo = self.browse(cr, uid, id, context) if fil_obj: ira = fil_obj else: ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context)
def set_data(self, cr, uid, id, file_node, data, context=None, fil_obj=None): """ store the data. This function MUST be used from an ir.attachment. It wouldn't make sense to store things persistently for other types (dynamic). """ if not context: context = {} boo = self.browse(cr, uid, id, context) if fil_obj: ira = fil_obj else: ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context)
468,736
def set_data(self, cr, uid, id, file_node, data, context=None, fil_obj=None): """ store the data. This function MUST be used from an ir.attachment. It wouldn't make sense to store things persistently for other types (dynamic). """ if not context: context = {} boo = self.browse(cr, uid, id, context) if fil_obj: ira = fil_obj else: ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context)
def set_data(self, cr, uid, id, file_node, data, context=None, fil_obj=None): """ store the data. This function MUST be used from an ir.attachment. It wouldn't make sense to store things persistently for other types (dynamic). """ if not context: context = {} boo = self.browse(cr, uid, id, context) if fil_obj: ira = fil_obj else: ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context)
468,737
def _user_left_days(self, cr, uid, ids, name, args, context={}): return_false = False employee_id = False res = {} for id in ids: res[id] = {}.fromkeys(name, 0) if context and context.has_key('employee_id'): if not context['employee_id']: return_false = True employee_id = context['employee_id'] else: employee_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)]) if employee_ids: employee_id = employee_ids[0] else: return_false = True if employee_id: res = self.get_days(cr, uid, ids, employee_id, return_false, context=context) return res
def _user_left_days(self, cr, uid, ids, name, args, context={}): return_false = False employee_id = False res = {} if context and context.has_key('employee_id'): if not context['employee_id']: return_false = True employee_id = context['employee_id'] else: employee_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)]) if employee_ids: employee_id = employee_ids[0] else: return_false = True if employee_id: res = self.get_days(cr, uid, ids, employee_id, return_false, context=context) return res
468,738
def init(self, cr): drop_view_if_exists(cr, 'report_intrastat') cr.execute(""" create or replace view report_intrastat as ( select to_char(inv.create_date, 'YYYY') as name, to_char(inv.create_date, 'MM') as month, min(inv_line.id) as id, intrastat.id as intrastat_id, upper(inv_country.code) as code, sum(case when inv_line.price_unit is not null then inv_line.price_unit * inv_line.quantity else 0 end) as value, sum( case when uom.category_id != puom.category_id then (pt.weight_net * inv_line.quantity) else (pt.weight_net * inv_line.quantity * uom.factor) end ) as weight, sum( case when uom.category_id != puom.category_id then inv_line.quantity else (inv_line.quantity * uom.factor) end ) as supply_units,
def init(self, cr): drop_view_if_exists(cr, 'report_intrastat') cr.execute(""" create or replace view report_intrastat as ( select to_char(inv.create_date, 'YYYY') as name, to_char(inv.create_date, 'MM') as month, min(inv_line.id) as id, intrastat.id as intrastat_id, upper(inv_country.code) as code, sum(case when inv_line.price_unit is not null then inv_line.price_unit * inv_line.quantity else 0 end) as value, sum( case when uom.category_id != puom.category_id then (pt.weight_net * inv_line.quantity) else (pt.weight_net * inv_line.quantity * uom.factor) end ) as weight, sum( case when uom.category_id != puom.category_id then inv_line.quantity else (inv_line.quantity * uom.factor) end ) as supply_units,
468,739
def execute(self, cr, uid, ids, context=None): assert len(ids) == 1, "We should only get one object from the form" payload = self.browse(cr, uid, ids[0], context=context) if not getattr(payload, 'company_id', None): raise ValueError('Case where no default main company is setup ' 'not handled yet')
def execute(self, cr, uid, ids, context=None): assert len(ids) == 1, "We should only get one object from the form" payload = self.browse(cr, uid, ids[0], context=context) if not getattr(payload, 'company_id', None): raise ValueError('Case where no default main company is setup ' 'not handled yet')
468,740
def action_cancel(self, cr, uid, ids, context={}): if not len(ids): return True pickings = {} for move in self.browse(cr, uid, ids): if move.state in ('confirmed', 'waiting', 'assigned', 'draft'): if move.picking_id: pickings[move.picking_id.id] = True if move.move_dest_id and move.move_dest_id.state == 'waiting': self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) self.write(cr, uid, ids, {'state': 'cancel', 'move_dest_id': False})
def action_cancel(self, cr, uid, ids, context={}): if not len(ids): return True pickings = {} for move in self.browse(cr, uid, ids): if move.state in ('confirmed', 'waiting', 'assigned', 'draft'): if move.picking_id: pickings[move.picking_id.id] = True if move.move_dest_id and move.move_dest_id.state == 'waiting': self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if context.get('call_unlink',False) and move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) self.write(cr, uid, ids, {'state': 'cancel', 'move_dest_id': False})
468,741
def action_cancel(self, cr, uid, ids, context={}): if not len(ids): return True pickings = {} for move in self.browse(cr, uid, ids): if move.state in ('confirmed', 'waiting', 'assigned', 'draft'): if move.picking_id: pickings[move.picking_id.id] = True if move.move_dest_id and move.move_dest_id.state == 'waiting': self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) self.write(cr, uid, ids, {'state': 'cancel', 'move_dest_id': False})
def action_cancel(self, cr, uid, ids, context={}): if not len(ids): return True pickings = {} for move in self.browse(cr, uid, ids): if move.state in ('confirmed', 'waiting', 'assigned', 'draft'): if move.picking_id: pickings[move.picking_id.id] = True if move.move_dest_id and move.move_dest_id.state == 'waiting': self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) self.write(cr, uid, ids, {'state': 'cancel', 'move_dest_id': False})
468,742
def open_wiki_page(self, cr, uid, ids, context):
def open_wiki_page(self, cr, uid, ids, context):
468,743
def create(self, cr, uid, vals, context=None):
def create(self, cr, uid, vals, context=None):
468,744
def createInstance(cls, pool, module, cr): name = getattr(cls, '_name', cls._inherit) parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new name = getattr(cls, '_name', cls._inherit) cls = type(name, (cls, parent_class), nattr)
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new name = getattr(cls, '_name', cls._inherit) cls = type(name, (cls, parent_class), nattr)
468,745
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults', '_inherits', '_constraints', '_sql_constraints'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: if s=='_constraints': for c in cls.__dict__.get(s, []): exist = False for c2 in range(len(new)): if new[c2][2]==c[2]: new[c2] = c exist = True break if not exist: new.append(c) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new name = getattr(cls, '_name', cls._inherit) cls = type(name, (cls, parent_class), nattr) obj = object.__new__(cls) obj.__init__(pool, cr) return obj
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults', '_inherits', '_constraints', '_sql_constraints'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: if s=='_constraints': for c in cls.__dict__.get(s, []): exist = False for c2 in range(len(new)): if new[c2][2]==c[2]: new[c2] = c exist = True break if not exist: new.append(c) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new name = getattr(cls, '_name', cls._inherit) cls = type(name, (cls, parent_class), nattr) obj = object.__new__(cls) obj.__init__(pool, cr) return obj
468,746
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults', '_inherits', '_constraints', '_sql_constraints'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: if s=='_constraints': for c in cls.__dict__.get(s, []): exist = False for c2 in range(len(new)): if new[c2][2]==c[2]: new[c2] = c exist = True break if not exist: new.append(c) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new name = getattr(cls, '_name', cls._inherit) cls = type(name, (cls, parent_class), nattr) obj = object.__new__(cls) obj.__init__(pool, cr) return obj
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]): parent_class = pool.get(parent_name).__class__ assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module) nattr = {} for s in ('_columns', '_defaults', '_inherits', '_constraints', '_sql_constraints'): new = copy.copy(getattr(pool.get(parent_name), s)) if hasattr(new, 'update'): new.update(cls.__dict__.get(s, {})) else: if s=='_constraints': for c in cls.__dict__.get(s, []): exist = False for c2 in range(len(new)): if new[c2][2]==c[2]: new[c2] = c exist = True break if not exist: new.append(c) else: new.extend(cls.__dict__.get(s, [])) nattr[s] = new name = hasattr(cls, '_name') and cls._name or cls._inherit cls = type(name, (cls, parent_class), nattr) obj = object.__new__(cls) obj.__init__(pool, cr) return obj
468,747
def do_PUT(self): dc=self.IFACE_CLASS uri=urlparse.urljoin(self.get_baseuri(dc), self.path) uri=urllib.unquote(uri) # Handle If-Match if self.headers.has_key('If-Match'): test = False etag = None for match in self.headers['If-Match'].split(','): if match == '*': if dc.exists(uri): test = True break else: if dc.match_prop(uri, match, "DAV:", "getetag"): test = True break if not test: self.send_status(412) return
def do_PUT(self): dc=self.IFACE_CLASS uri=urlparse.urljoin(self.get_baseuri(dc), self.path) uri=urllib.unquote(uri) # Handle If-Match if self.headers.has_key('If-Match'): test = False etag = None for match in self.headers['If-Match'].split(','): if match == '*': if dc.exists(uri): test = True break else: if dc.match_prop(uri, match, "DAV:", "getetag"): test = True break if not test: self.send_status(412) return
468,748
def do_PUT(self): dc=self.IFACE_CLASS uri=urlparse.urljoin(self.get_baseuri(dc), self.path) uri=urllib.unquote(uri) # Handle If-Match if self.headers.has_key('If-Match'): test = False etag = None for match in self.headers['If-Match'].split(','): if match == '*': if dc.exists(uri): test = True break else: if dc.match_prop(uri, match, "DAV:", "getetag"): test = True break if not test: self.send_status(412) return
def do_PUT(self): dc=self.IFACE_CLASS uri=urlparse.urljoin(self.get_baseuri(dc), self.path) uri=urllib.unquote(uri) # Handle If-Match if self.headers.has_key('If-Match'): test = False etag = None for match in self.headers['If-Match'].split(','): if match == '*': if dc.exists(uri): test = True break else: if dc.match_prop(uri, match, "DAV:", "getetag"): test = True break if not test: self.send_status(412) return
468,749
def copy(self, cr, uid, ids, *args, **argv): raise osv.except_osv(_('Error !'), _('You can not duplicate a timesheet !'))
def copy(self, cr, uid, ids, *args, **argv): raise osv.except_osv(_('Error !'), _('You can not duplicate a timesheet !'))
468,750
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): res = super(account_coda, self).search(cr, user, args=args, offset=offset, limit=limit, order=order, context=context, count=count) if not res: raise osv.except_osv('Error', _('Coda file not found for bank statement !!')) return res
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): res = super(account_coda, self).search(cr, user, args=args, offset=offset, limit=limit, order=order, context=context, count=count) if context.get('bank_statement', False) and not res: raise osv.except_osv('Error', _('Coda file not found for bank statement !!')) return res
468,751
def _get_image_icon(self, cr, uid, ids, name, args, context=None): res = {} for menu in self.browse(cr, uid, ids, context=context): res[menu.id] = { 'web_icon_data': False, 'web_icon_hover_data': False, } if not menu.parent_id: if menu.web_icon_hover: res[menu.id]['web_icon_hover_data'] = self.read_image(menu.web_icon_hover) if menu.web_icon: res[menu.id]['web_icon_data'] = self.read_image(menu.web_icon) return res
def _get_image_icon(self, cr, uid, ids, name, args, context=None): res = {} for menu in self.browse(cr, uid, ids, context=context): res[menu.id] = { 'web_icon_data': False, 'web_icon_hover_data': False, } if not menu.parent_id: if menu.web_icon_hover: res[menu.id]['web_icon_hover_data'] = self.read_image(menu.web_icon_hover) if menu.web_icon: res[menu.id]['web_icon_data'] = self.read_image(menu.web_icon) return res
468,752
def run(self): self.running = True try: ts = tiny_socket.mysocket(self.sock) except: self.threads.remove(self) self.running = False return False while self.running: try: msg = ts.myreceive() except: self.threads.remove(self) self.running = False return False try: result = self.dispatch(msg[0], msg[1], msg[2:]) ts.mysend(result) except netsvc.OpenERPDispatcherException, e: try: new_e = Exception(tools.exception_to_unicode(e.exception)) # avoid problems of pickeling ts.mysend(new_e, exception=True, traceback=e.traceback) except: self.running = False break except Exception, e: # this code should not be reachable, therefore we warn netsvc.Logger().notifyChannel("net-rpc", netsvc.LOG_WARNING, "exception: %s" % str(e)) break
def run(self): self.running = True try: ts = tiny_socket.mysocket(self.sock) except: self.threads.remove(self) self.running = False return False while self.running: try: msg = ts.myreceive() result = self.dispatch(msg[0], msg[1], msg[2:]) ts.mysend(result) except netsvc.OpenERPDispatcherException, e: try: new_e = Exception(tools.exception_to_unicode(e.exception)) # avoid problems of pickeling ts.mysend(new_e, exception=True, traceback=e.traceback) except: self.running = False break except Exception, e: # this code should not be reachable, therefore we warn netsvc.Logger().notifyChannel("net-rpc", netsvc.LOG_WARNING, "exception: %s" % str(e)) break
468,753
def run(self): self.running = True try: ts = tiny_socket.mysocket(self.sock) except: self.threads.remove(self) self.running = False return False while self.running: try: msg = ts.myreceive() except: self.threads.remove(self) self.running = False return False try: result = self.dispatch(msg[0], msg[1], msg[2:]) ts.mysend(result) except netsvc.OpenERPDispatcherException, e: try: new_e = Exception(tools.exception_to_unicode(e.exception)) # avoid problems of pickeling ts.mysend(new_e, exception=True, traceback=e.traceback) except: self.running = False break except Exception, e: # this code should not be reachable, therefore we warn netsvc.Logger().notifyChannel("net-rpc", netsvc.LOG_WARNING, "exception: %s" % str(e)) break
def run(self): self.running = True try: ts = tiny_socket.mysocket(self.sock) except: self.threads.remove(self) self.running = False return False while self.running: try: msg = ts.myreceive() except: self.threads.remove(self) self.running = False return False try: result = self.dispatch(msg[0], msg[1], msg[2:]) ts.mysend(result) except netsvc.OpenERPDispatcherException, e: try: new_e = Exception(tools.exception_to_unicode(e.exception)) # avoid problems of pickeling ts.mysend(new_e, exception=True, traceback=e.traceback) except Exception: logging.getLogger('web-services').exception("netrpc: cannot deliver exception message to client") break except Exception, e: # this code should not be reachable, therefore we warn netsvc.Logger().notifyChannel("net-rpc", netsvc.LOG_WARNING, "exception: %s" % str(e)) break
468,754
def run(self): self.running = True try: ts = tiny_socket.mysocket(self.sock) except: self.threads.remove(self) self.running = False return False while self.running: try: msg = ts.myreceive() except: self.threads.remove(self) self.running = False return False try: result = self.dispatch(msg[0], msg[1], msg[2:]) ts.mysend(result) except netsvc.OpenERPDispatcherException, e: try: new_e = Exception(tools.exception_to_unicode(e.exception)) # avoid problems of pickeling ts.mysend(new_e, exception=True, traceback=e.traceback) except: self.running = False break except Exception, e: # this code should not be reachable, therefore we warn netsvc.Logger().notifyChannel("net-rpc", netsvc.LOG_WARNING, "exception: %s" % str(e)) break
def run(self): self.running = True try: ts = tiny_socket.mysocket(self.sock) except: self.threads.remove(self) self.running = False return False while self.running: try: msg = ts.myreceive() except: self.threads.remove(self) self.running = False return False try: result = self.dispatch(msg[0], msg[1], msg[2:]) ts.mysend(result) except netsvc.OpenERPDispatcherException, e: try: new_e = Exception(tools.exception_to_unicode(e.exception)) # avoid problems of pickeling ts.mysend(new_e, exception=True, traceback=e.traceback) except: self.running = False break except Exception, e: # this code should not be reachable, therefore we warn netsvc.Logger().notifyChannel("net-rpc", netsvc.LOG_WARNING, "exception: %s" % str(e)) break
468,755
def run(self): try: self.running = True while self.running: timeout = self.socket.gettimeout() fd_sets = select.select([self.socket], [], [], timeout) if not fd_sets[0]: continue (clientsocket, address) = self.socket.accept() ct = TinySocketClientThread(clientsocket, self.threads) clientsocket = None self.threads.append(ct) ct.start() lt = len(self.threads) if (lt > 10) and (lt % 10 == 0): # Not many threads should be serving at the same time, so log # their abuse. netsvc.Logger().notifyChannel("web-services", netsvc.LOG_DEBUG, "Netrpc: %d threads" % len(self.threads)) self.socket.close() except Exception, e: import logging logging.getLogger('web-services').warning("Netrpc: closing because of exception %s" % str(e)) self.socket.close() return False
def run(self): try: self.running = True while self.running: timeout = self.socket.gettimeout() fd_sets = select.select([self.socket], [], [], timeout) if not fd_sets[0]: continue (clientsocket, address) = self.socket.accept() ct = TinySocketClientThread(clientsocket, self.threads) clientsocket = None self.threads.append(ct) ct.start() lt = len(self.threads) if (lt > 10) and (lt % 10 == 0): # Not many threads should be serving at the same time, so log # their abuse. netsvc.Logger().notifyChannel("web-services", netsvc.LOG_DEBUG, "Netrpc: %d threads" % len(self.threads)) self.socket.close() except Exception, e: logging.getLogger('web-services').warning("Netrpc: closing because of exception %s" % str(e)) self.socket.close() return False
468,756
def on_change_parent(self, cr, uid, id, parent_id): if not parent_id: return {} parent = self.read(cr, uid, [parent_id], ['partner_id','code'])[0] childs = self.search(cr, uid, [('parent_id', '=', parent_id), ('active', 'in', [True, False])]) numchild = len(childs) if parent['partner_id']: partner = parent['partner_id'][0] else: partner = False res = {'value' : {'code' : '%s - %03d' % (parent['code'] or '', numchild + 1),}} if partner: res['value']['partner_id'] = partner return res
def on_change_parent(self, cr, uid, id, parent_id): if not parent_id: return {} parent = self.read(cr, uid, [parent_id], ['partner_id','code'])[0] childs = self.search(cr, uid, [('parent_id', '=', parent_id)]) numchild = len(childs) if parent['partner_id']: partner = parent['partner_id'][0] else: partner = False res = {'value' : {'code' : '%s - %03d' % (parent['code'] or '', numchild + 1),}} if partner: res['value']['partner_id'] = partner return res
468,757
def _get_comment_invoice(self, cursor, user, picking): if picking.sale_id and picking.sale_id.note: if picking.note: return picking.note + '\n' + picking.sale_id.note else: return picking.sale_id.note return super(stock_picking, self)._get_comment_invoice(cursor, user, picking)
def _get_comment_invoice(self, cursor, user, picking): if picking.note or (picking.sale_id and picking.sale_id.note): return picking.note or picking.sale_id.note return super(stock_picking, self)._get_comment_invoice(cursor, user, picking)
468,758
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(account_bs_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) doc = etree.XML(res['arch']) nodes = doc.xpath("//field[@name='journal_ids']") for node in nodes: node.set('readonly', '1') node.set('required', '0') res['arch'] = etree.tostring(doc) return res
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(account_bs_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) doc = etree.XML(res['arch']) nodes = doc.xpath("//field[@name='journal_ids']") for node in nodes: node.set('readonly', '1') node.set('required', '0') res['arch'] = etree.tostring(doc) return res
468,759
def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} data = self.pre_print_report(cr, uid, ids, data, context=context) account = self.pool.get('account.account').browse(cr, uid, data['form']['chart_account_id'], context=context) if not account.company_id.property_reserve_and_surplus_account: raise osv.except_osv(_('Warning'),_('Please define the Reserve and Profit/Loss account for current user company !')) data['form']['reserve_account_id'] = account.company_id.property_reserve_and_surplus_account.id data['form'].update(self.read(cr, uid, ids, ['display_type'])[0]) if data['form']['display_type']: return { 'type': 'ir.actions.report.xml', 'report_name': 'account.balancesheet.horizontal', 'datas': data, } else: return { 'type': 'ir.actions.report.xml', 'report_name': 'account.balancesheet', 'datas': data, }
def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} data = self.pre_print_report(cr, uid, ids, data, context=context) if data['form']['display_type']: return { 'type': 'ir.actions.report.xml', 'report_name': 'account.balancesheet.horizontal', 'datas': data, } else: return { 'type': 'ir.actions.report.xml', 'report_name': 'account.balancesheet', 'datas': data, }
468,760
def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} data = self.pre_print_report(cr, uid, ids, data, context=context) account = self.pool.get('account.account').browse(cr, uid, data['form']['chart_account_id'], context=context) if not account.company_id.property_reserve_and_surplus_account: raise osv.except_osv(_('Warning'),_('Please define the Reserve and Profit/Loss account for current user company !')) data['form']['reserve_account_id'] = account.company_id.property_reserve_and_surplus_account.id data['form'].update(self.read(cr, uid, ids, ['display_type'])[0]) if data['form']['display_type']: return { 'type': 'ir.actions.report.xml', 'report_name': 'account.balancesheet.horizontal', 'datas': data, } else: return { 'type': 'ir.actions.report.xml', 'report_name': 'account.balancesheet', 'datas': data, }
def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} data = self.pre_print_report(cr, uid, ids, data, context=context) account = self.pool.get('account.account').browse(cr, uid, data['form']['chart_account_id'], context=context) if not account.company_id.property_reserve_and_surplus_account: raise osv.except_osv(_('Warning'),_('Please define the Reserve and Profit/Loss account for current user company !')) data['form']['reserve_account_id'] = account.company_id.property_reserve_and_surplus_account.id data['form'].update(self.read(cr, uid, ids, ['display_type'])[0]) if data['form']['display_type']: return { 'type': 'ir.actions.report.xml', 'report_name': 'account.balancesheet.horizontal', 'datas': data, } else: return { 'type': 'ir.actions.report.xml', 'report_name': 'account.balancesheet', 'datas': data, }
468,761
def __call__(self, source): is_new_cr = False res = source try: frame = inspect.stack()[1][0] cr, is_new_cr = self._get_cr(frame) lang = self._get_lang(frame) if lang and cr: cr.execute('SELECT value FROM ir_translation WHERE lang=%s AND type IN (%s, %s) AND src=%s', (lang, 'code','sql_constraint', source)) res_trans = cr.fetchone() res = res_trans and res_trans[0] or source except: logger.warn('translation went wrong for string %s', repr(source)) finally: if is_new_cr: cr.close() return res
def __call__(self, source): is_new_cr = False res = source try: frame = inspect.stack()[1][0] cr, is_new_cr = self._get_cr(frame) lang = self._get_lang(frame) if lang and cr: cr.execute('SELECT value FROM ir_translation WHERE lang=%s AND type IN (%s, %s) AND src=%s', (lang, 'code','sql_constraint', source)) res_trans = cr.fetchone() res = res_trans and res_trans[0] or source except Exception: logger.debug('translation went wrong for string %s', repr(source)) finally: if is_new_cr: cr.close() return res
468,762
def __getattr__(self, name): for model, field in self._inherits.iteritems(): if hasattr(self.pool.get(model), name): break else: return super(orm, self).__getattr__(name)
def __getattr__(self, name): for model, field in self._inherits.iteritems(): proxy = self.pool.get(model) if hasattr(proxy, name): attribute = getattr(proxy, name) if not hasattr(attribute, '__call__'): return attribute break else: return super(orm, self).__getattr__(name)
468,763
def _proxy(cr, uid, ids, *args, **kwargs): objects = self.browse(cr, uid, ids, kwargs.get('context', None)) lst = [obj[field].id for obj in objects if obj[field]] proxy = self.pool.get(model) return getattr(proxy, name)(cr, uid, lst, *args, **kwargs)
def _proxy(cr, uid, ids, *args, **kwargs): objects = self.browse(cr, uid, ids, kwargs.get('context', None)) lst = [obj[field].id for obj in objects if obj[field]] return getattr(proxy, name)(cr, uid, lst, *args, **kwargs)
468,764
def _ellipsis(self, orig_str, maxlen=100, ellipsis='...'): maxlen = maxlen - len(ellipsis) if maxlen <= 0: maxlen = 1 new_str = orig_str[:maxlen] return new_str
def _ellipsis(self, orig_str, maxlen=100, ellipsis='...'): maxlen = maxlen - len(ellipsis) if maxlen <= 0: maxlen = 1 new_str = orig_str[:maxlen] return new_str
468,765
def _strip_name(self, name, maxlen=50): return self._ellipsis(name, maxlen, ' ...')
def _strip_name(self, name, maxlen=50): return self._ellipsis(name, maxlen, ' ...')
468,766
def _get_sortby(self, data): if self.sortby == 'sort_date': return 'Date' elif self.sortby == 'sort_journal_partner': return 'Journal & Partner' return 'Date'
def _get_sortby(self, data): if self.sortby == 'sort_date': return 'Date' elif self.sortby == 'sort_journal_partner': return 'Journal & Partner' return 'Date'
468,767
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'): if not partner_id: return {} partner_pool = self.pool.get('res.partner') res = {'account_id':False} if pay_now == 'pay_later': partner = partner_pool.browse(cr, uid, partner_id) if ttype == 'sale': res.update({ 'account_id':partner.property_account_receivable.id, }) elif ttype == 'purchase': res.update({ 'account_id':partner.property_account_payable.id, }) return { 'value':res }
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'): if not partner_id: return res res = {'account_id':False} partner_pool = self.pool.get('res.partner') res = {'account_id':False} if pay_now == 'pay_later': partner = partner_pool.browse(cr, uid, partner_id) if ttype == 'sale': res.update({ 'account_id':partner.property_account_receivable.id, }) elif ttype == 'purchase': res.update({ 'account_id':partner.property_account_payable.id, }) return { 'value':res }
468,768
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'): if not partner_id: return {} partner_pool = self.pool.get('res.partner') res = {'account_id':False} if pay_now == 'pay_later': partner = partner_pool.browse(cr, uid, partner_id) if ttype == 'sale': res.update({ 'account_id':partner.property_account_receivable.id, }) elif ttype == 'purchase': res.update({ 'account_id':partner.property_account_payable.id, }) return { 'value':res }
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'): if not partner_id: return {} partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') if pay_now == 'pay_later': partner = partner_pool.browse(cr, uid, partner_id) if ttype == 'sale': res.update({ 'account_id':partner.property_account_receivable.id, }) elif ttype == 'purchase': res.update({ 'account_id':partner.property_account_payable.id, }) return { 'value':res }
468,769
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'): if not partner_id: return {} partner_pool = self.pool.get('res.partner') res = {'account_id':False} if pay_now == 'pay_later': partner = partner_pool.browse(cr, uid, partner_id) if ttype == 'sale': res.update({ 'account_id':partner.property_account_receivable.id, }) elif ttype == 'purchase': res.update({ 'account_id':partner.property_account_payable.id, }) return { 'value':res }
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'): if not partner_id: return {} partner_pool = self.pool.get('res.partner') res = {'account_id':False} if pay_now == 'pay_later': partner = partner_pool.browse(cr, uid, partner_id) if ttype == 'sale': res.update({ 'account_id':partner.property_account_receivable.id, }) elif ttype == 'purchase': res.update({ 'account_id':partner.property_account_payable.id, }) return { 'value':res }
468,770
def __init__(self, interface, port, handler): threading.Thread.__init__(self) netsvc.Server.__init__(self) self.__port = port self.__interface = interface
def __init__(self, interface, port, handler): threading.Thread.__init__(self) netsvc.Server.__init__(self) self.__port = port self.__interface = interface
468,771
def _check_recursion(self, cr, uid, ids, context=None): level = 100 while len(ids): cr.execute('select distinct parent_id from hr_employee_category where id IN %s', (tuple(ids), )) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False level -= 1 return True
def _check_recursion(self, cr, uid, ids, context=None): level = 100 while len(ids): cr.execute('select distinct parent_id from hr_employee_category where id IN %s', (tuple(ids), )) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False level -= 1 return True
468,772
def on_change_expected_employee(self, cr, uid, ids, expected_employee, context=None): if context is None: context = {} result={} if expected_employee: xx = self.browse(cr, uid, ids, context)[0] result['no_of_recruitment'] = expected_employee - xx['no_of_employee'] return {'value': result}
def on_change_expected_employee(self, cr, uid, ids, expected_employee, no_of_employee, context=None): if context is None: context = {} result={} if expected_employee: xx = self.browse(cr, uid, ids, context)[0] result['no_of_recruitment'] = expected_employee - xx['no_of_employee'] return {'value': result}
468,773
def on_change_expected_employee(self, cr, uid, ids, expected_employee, context=None): if context is None: context = {} result={} if expected_employee: xx = self.browse(cr, uid, ids, context)[0] result['no_of_recruitment'] = expected_employee - xx['no_of_employee'] return {'value': result}
def on_change_expected_employee(self, cr, uid, ids, expected_employee, context=None): if context is None: context = {} result={} if expected_employee: result['no_of_recruitment'] = expected_employee - no_of_employee return {'value': result}
468,774
def _parent_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} result = {} obj_dept = self.pool.get('hr.department') for user_id in ids: ids_dept = obj_dept.search(cr, uid, [('member_ids', 'in', [user_id])], context=context) parent_ids = [] if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['manager_id'], context=context) parent_ids = map(lambda x: x['manager_id'][0], data_dept) result[user_id] = parent_ids return result
def _parent_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} result = {} obj_dept = self.pool.get('hr.department') for user_id in ids: emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)]) cr.execute('SELECT emp.department_id FROM hr_employee AS emp JOIN resource_resource AS res ON res.id = emp.resource_id \ WHERE res.user_id = %s AND emp.department_id IS NOT NULL', (user_id,)) ids_dept = [x[0] for x in cr.fetchall()] parent_ids = [] if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['manager_id'], context=context) parent_ids = map(lambda x: x['manager_id'][0], data_dept) result[user_id] = parent_ids return result
468,775
def _parent_search(self, cr, uid, obj, name, args, context=None): if context is None: context = {} parent = [] for arg in args: if arg[0] == 'parent_id': parent = arg[2] child_ids = self._child_compute(cr, uid, parent, name, args, context=context) if not child_ids: return [('id', 'in', [0])] return [('id', 'in', child_ids.get(uid,[]))]
def _parent_search(self, cr, uid, obj, name, args, context=None): if context is None: context = {} parent = [] for arg in args: if arg[0] == 'parent_id': parent = arg[2] child_ids = self._child_compute(cr, uid, parent, name, args, context=context) if not child_ids: return [('id', 'in', [0])] return [('id', 'in', child_ids.get(uid,[]))]
468,776
def _child_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} obj_dept = self.pool.get('hr.department') obj_user = self.pool.get('res.users') result = {} for manager_id in ids: child_ids = [] mgnt_dept_ids = obj_dept.search(cr, uid, [('manager_id', '=', manager_id)], context=context) ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context) if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context) childs = map(lambda x: x['member_ids'], data_dept) childs = tools.flatten(childs) childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context) if manager_id in childs: childs.remove(manager_id) child_ids.extend(tools.flatten(childs)) set = {} map(set.__setitem__, child_ids, []) child_ids = set.keys() else: child_ids = [] result[manager_id] = child_ids return result
def _child_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} obj_dept = self.pool.get('hr.department') obj_user = self.pool.get('res.users') result = {} for user_id in ids: child_ids = [] mgnt_dept_ids = obj_dept.search(cr, uid, [('manager_id', '=', manager_id)], context=context) ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context) if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context) childs = map(lambda x: x['member_ids'], data_dept) childs = tools.flatten(childs) childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context) if manager_id in childs: childs.remove(manager_id) child_ids.extend(tools.flatten(childs)) set = {} map(set.__setitem__, child_ids, []) child_ids = set.keys() else: child_ids = [] result[manager_id] = child_ids return result
468,777
def _child_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} obj_dept = self.pool.get('hr.department') obj_user = self.pool.get('res.users') result = {} for manager_id in ids: child_ids = [] mgnt_dept_ids = obj_dept.search(cr, uid, [('manager_id', '=', manager_id)], context=context) ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context) if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context) childs = map(lambda x: x['member_ids'], data_dept) childs = tools.flatten(childs) childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context) if manager_id in childs: childs.remove(manager_id) child_ids.extend(tools.flatten(childs)) set = {} map(set.__setitem__, child_ids, []) child_ids = set.keys() else: child_ids = [] result[manager_id] = child_ids return result
def _child_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} obj_dept = self.pool.get('hr.department') obj_user = self.pool.get('res.users') result = {} for manager_id in ids: child_ids = [] cr.execute('SELECT dept.id FROM hr_department AS dept \ LEFT JOIN hr_employee AS emp ON dept.manager_id = emp.id \ WHERE emp.id IN \ (SELECT emp.id FROM hr_employee \ JOIN resource_resource r ON r.id = emp.resource_id WHERE r.user_id=' + str(user_id) + ') ') mgnt_dept_ids = [x[0] for x in cr.fetchall()] ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context) if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context) childs = map(lambda x: x['member_ids'], data_dept) childs = tools.flatten(childs) childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context) if manager_id in childs: childs.remove(manager_id) child_ids.extend(tools.flatten(childs)) set = {} map(set.__setitem__, child_ids, []) child_ids = set.keys() else: child_ids = [] result[manager_id] = child_ids return result
468,778
def _child_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} obj_dept = self.pool.get('hr.department') obj_user = self.pool.get('res.users') result = {} for manager_id in ids: child_ids = [] mgnt_dept_ids = obj_dept.search(cr, uid, [('manager_id', '=', manager_id)], context=context) ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context) if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context) childs = map(lambda x: x['member_ids'], data_dept) childs = tools.flatten(childs) childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context) if manager_id in childs: childs.remove(manager_id) child_ids.extend(tools.flatten(childs)) set = {} map(set.__setitem__, child_ids, []) child_ids = set.keys() else: child_ids = [] result[manager_id] = child_ids return result
def _child_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} obj_dept = self.pool.get('hr.department') obj_user = self.pool.get('res.users') result = {} for manager_id in ids: child_ids = [] mgnt_dept_ids = obj_dept.search(cr, uid, [('manager_id', '=', manager_id)], context=context) ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context) if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context) childs = map(lambda x: x['member_ids'], data_dept) childs = tools.flatten(childs) childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context) if user_id in childs: childs.remove(user_id) child_ids.extend(tools.flatten(childs)) set = {} map(set.__setitem__, child_ids, []) child_ids = set.keys() else: child_ids = [] result[manager_id] = child_ids return result
468,779
def _child_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} obj_dept = self.pool.get('hr.department') obj_user = self.pool.get('res.users') result = {} for manager_id in ids: child_ids = [] mgnt_dept_ids = obj_dept.search(cr, uid, [('manager_id', '=', manager_id)], context=context) ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context) if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context) childs = map(lambda x: x['member_ids'], data_dept) childs = tools.flatten(childs) childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context) if manager_id in childs: childs.remove(manager_id) child_ids.extend(tools.flatten(childs)) set = {} map(set.__setitem__, child_ids, []) child_ids = set.keys() else: child_ids = [] result[manager_id] = child_ids return result
def _child_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} obj_dept = self.pool.get('hr.department') obj_user = self.pool.get('res.users') result = {} for manager_id in ids: child_ids = [] mgnt_dept_ids = obj_dept.search(cr, uid, [('manager_id', '=', manager_id)], context=context) ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context) if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context) childs = map(lambda x: x['member_ids'], data_dept) childs = tools.flatten(childs) childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context) if manager_id in childs: childs.remove(manager_id) child_ids.extend(tools.flatten(childs)) set = {} map(set.__setitem__, child_ids, []) child_ids = set.keys() result[user_id] = child_ids return result
468,780
def _child_search(self, cr, uid, obj, name, args, context=None): if context is None: context = {} parent = [] for arg in args: if arg[0] == 'child_ids': parent = arg[2] child_ids = self._child_compute(cr, uid, parent, name, args, context=context) if not child_ids: return [('id', 'in', [0])] return [('id', 'in', child_ids.get(uid,[]))]
def _child_search(self, cr, uid, obj, name, args, context=None): if context is None: context = {} parent = [] for arg in args: if arg[0] == 'child_ids': parent = arg[2] child_ids = self._child_compute(cr, uid, parent, name, args, context=context) if not child_ids: return [('id', 'in', [0])] return [('id', 'in', child_ids.get(uid,[]))]
468,781
def _child_search(self, cr, uid, obj, name, args, context=None): if context is None: context = {} parent = [] for arg in args: if arg[0] == 'child_ids': parent = arg[2] child_ids = self._child_compute(cr, uid, parent, name, args, context=context) if not child_ids: return [('id', 'in', [0])] return [('id', 'in', child_ids.get(uid,[]))]
def _child_search(self, cr, uid, obj, name, args, context=None): if context is None: context = {} parent = [] for arg in args: if arg[0] == 'child_ids': parent = arg[2] child_ids = self._child_compute(cr, uid, parent, name, args, context=context) if not child_ids: return [('id', 'in', [0])] return [('id', 'in', child_ids.get(uid,[]))]
468,782
def create_child(self, cr, path, data): """ API function to create a child file object and node Return the node_* created """ dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) fil_obj=dirobj.pool.get('ir.attachment') val = { 'name': path, 'datas_fname': path, 'parent_id': self.dir_id, # Datas are not set here }
def create_child(self, cr, path, data): """ API function to create a child file object and node Return the node_* created """ dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) fil_obj=dirobj.pool.get('ir.attachment') val = { 'name': path, 'datas_fname': path, 'parent_id': self.dir_id, # Datas are not set here }
468,783
def __init__(self, cr, uid, name, parents=rml_parents, tag=rml_tag, context=None): if not context: context={} self.cr = cr self.uid = uid self.pool = pooler.get_pool(cr.dbname) user = self.pool.get('res.users').browse(cr, uid, uid, context=context) self.localcontext = { 'user': user, 'company': user.company_id, 'repeatIn': self.repeatIn, 'setLang': self.setLang, 'setTag': self.setTag, 'removeParentNode': self.removeParentNode, 'format': self.format, 'formatLang': self.formatLang, 'logo' : user.company_id.logo, 'lang' : user.company_id.partner_id.lang, 'translate' : self._translate, 'setHtmlImage' : self.set_html_image, 'strip_name' : self._strip_name, 'time' : time } self.localcontext.update(context) self.rml_header = user.company_id.rml_header self.rml_header2 = user.company_id.rml_header2 self.rml_header3 = user.company_id.rml_header3 self.logo = user.company_id.logo self.name = name self._node = None self.parents = parents self.tag = tag self._lang_cache = {} self.lang_dict = {} self.default_lang = {} self.lang_dict_called = False self._transl_regex = re.compile('(\[\[.+?\]\])')
def __init__(self, cr, uid, name, parents=rml_parents, tag=rml_tag, context=None): if not context: context={} self.cr = cr self.uid = uid self.pool = pooler.get_pool(cr.dbname) user = self.pool.get('res.users').browse(cr, uid, uid, context=context) self.localcontext = { 'user': user, 'setCompany': self.setCompany, 'repeatIn': self.repeatIn, 'setLang': self.setLang, 'setTag': self.setTag, 'removeParentNode': self.removeParentNode, 'format': self.format, 'formatLang': self.formatLang, 'logo' : user.company_id.logo, 'lang' : user.company_id.partner_id.lang, 'translate' : self._translate, 'setHtmlImage' : self.set_html_image, 'strip_name' : self._strip_name, 'time' : time } self.localcontext.update(context) self.rml_header = user.company_id.rml_header self.rml_header2 = user.company_id.rml_header2 self.rml_header3 = user.company_id.rml_header3 self.logo = user.company_id.logo self.name = name self._node = None self.parents = parents self.tag = tag self._lang_cache = {} self.lang_dict = {} self.default_lang = {} self.lang_dict_called = False self._transl_regex = re.compile('(\[\[.+?\]\])')
468,784
def __init__(self, cr, uid, name, parents=rml_parents, tag=rml_tag, context=None): if not context: context={} self.cr = cr self.uid = uid self.pool = pooler.get_pool(cr.dbname) user = self.pool.get('res.users').browse(cr, uid, uid, context=context) self.localcontext = { 'user': user, 'company': user.company_id, 'repeatIn': self.repeatIn, 'setLang': self.setLang, 'setTag': self.setTag, 'removeParentNode': self.removeParentNode, 'format': self.format, 'formatLang': self.formatLang, 'logo' : user.company_id.logo, 'lang' : user.company_id.partner_id.lang, 'translate' : self._translate, 'setHtmlImage' : self.set_html_image, 'strip_name' : self._strip_name, 'time' : time } self.localcontext.update(context) self.rml_header = user.company_id.rml_header self.rml_header2 = user.company_id.rml_header2 self.rml_header3 = user.company_id.rml_header3 self.logo = user.company_id.logo self.name = name self._node = None self.parents = parents self.tag = tag self._lang_cache = {} self.lang_dict = {} self.default_lang = {} self.lang_dict_called = False self._transl_regex = re.compile('(\[\[.+?\]\])')
def __init__(self, cr, uid, name, parents=rml_parents, tag=rml_tag, context=None): if not context: context={} self.cr = cr self.uid = uid self.pool = pooler.get_pool(cr.dbname) user = self.pool.get('res.users').browse(cr, uid, uid, context=context) self.localcontext = { 'user': user, 'company': user.company_id, 'repeatIn': self.repeatIn, 'setLang': self.setLang, 'setTag': self.setTag, 'removeParentNode': self.removeParentNode, 'format': self.format, 'formatLang': self.formatLang, 'lang' : user.company_id.partner_id.lang, 'translate' : self._translate, 'setHtmlImage' : self.set_html_image, 'strip_name' : self._strip_name, 'time' : time } self.localcontext.update(context) self.rml_header = user.company_id.rml_header self.rml_header2 = user.company_id.rml_header2 self.rml_header3 = user.company_id.rml_header3 self.logo = user.company_id.logo self.name = name self._node = None self.parents = parents self.tag = tag self._lang_cache = {} self.lang_dict = {} self.default_lang = {} self.lang_dict_called = False self._transl_regex = re.compile('(\[\[.+?\]\])')
468,785
def __init__(self, cr, uid, name, parents=rml_parents, tag=rml_tag, context=None): if not context: context={} self.cr = cr self.uid = uid self.pool = pooler.get_pool(cr.dbname) user = self.pool.get('res.users').browse(cr, uid, uid, context=context) self.localcontext = { 'user': user, 'company': user.company_id, 'repeatIn': self.repeatIn, 'setLang': self.setLang, 'setTag': self.setTag, 'removeParentNode': self.removeParentNode, 'format': self.format, 'formatLang': self.formatLang, 'logo' : user.company_id.logo, 'lang' : user.company_id.partner_id.lang, 'translate' : self._translate, 'setHtmlImage' : self.set_html_image, 'strip_name' : self._strip_name, 'time' : time } self.localcontext.update(context) self.rml_header = user.company_id.rml_header self.rml_header2 = user.company_id.rml_header2 self.rml_header3 = user.company_id.rml_header3 self.logo = user.company_id.logo self.name = name self._node = None self.parents = parents self.tag = tag self._lang_cache = {} self.lang_dict = {} self.default_lang = {} self.lang_dict_called = False self._transl_regex = re.compile('(\[\[.+?\]\])')
def __init__(self, cr, uid, name, parents=rml_parents, tag=rml_tag, context=None): if not context: context={} self.cr = cr self.uid = uid self.pool = pooler.get_pool(cr.dbname) user = self.pool.get('res.users').browse(cr, uid, uid, context=context) self.localcontext = { 'user': user, 'company': user.company_id, 'repeatIn': self.repeatIn, 'setLang': self.setLang, 'setTag': self.setTag, 'removeParentNode': self.removeParentNode, 'format': self.format, 'formatLang': self.formatLang, 'logo' : user.company_id.logo, 'lang' : user.company_id.partner_id.lang, 'translate' : self._translate, 'setHtmlImage' : self.set_html_image, 'strip_name' : self._strip_name, 'time' : time, } self.localcontext.update(context) self.rml_header = user.company_id.rml_header self.rml_header2 = user.company_id.rml_header2 self.rml_header3 = user.company_id.rml_header3 self.logo = user.company_id.logo self.name = name self._node = None self.parents = parents self.tag = tag self._lang_cache = {} self.lang_dict = {} self.default_lang = {} self.lang_dict_called = False self._transl_regex = re.compile('(\[\[.+?\]\])')
468,786
def __init__(self, cr, uid, name, parents=rml_parents, tag=rml_tag, context=None): if not context: context={} self.cr = cr self.uid = uid self.pool = pooler.get_pool(cr.dbname) user = self.pool.get('res.users').browse(cr, uid, uid, context=context) self.localcontext = { 'user': user, 'company': user.company_id, 'repeatIn': self.repeatIn, 'setLang': self.setLang, 'setTag': self.setTag, 'removeParentNode': self.removeParentNode, 'format': self.format, 'formatLang': self.formatLang, 'logo' : user.company_id.logo, 'lang' : user.company_id.partner_id.lang, 'translate' : self._translate, 'setHtmlImage' : self.set_html_image, 'strip_name' : self._strip_name, 'time' : time } self.localcontext.update(context) self.rml_header = user.company_id.rml_header self.rml_header2 = user.company_id.rml_header2 self.rml_header3 = user.company_id.rml_header3 self.logo = user.company_id.logo self.name = name self._node = None self.parents = parents self.tag = tag self._lang_cache = {} self.lang_dict = {} self.default_lang = {} self.lang_dict_called = False self._transl_regex = re.compile('(\[\[.+?\]\])')
def __init__(self, cr, uid, name, parents=rml_parents, tag=rml_tag, context=None): if not context: context={} self.cr = cr self.uid = uid self.pool = pooler.get_pool(cr.dbname) user = self.pool.get('res.users').browse(cr, uid, uid, context=context) self.localcontext = { 'user': user, 'company': user.company_id, 'repeatIn': self.repeatIn, 'setLang': self.setLang, 'setTag': self.setTag, 'removeParentNode': self.removeParentNode, 'format': self.format, 'formatLang': self.formatLang, 'logo' : user.company_id.logo, 'lang' : user.company_id.partner_id.lang, 'translate' : self._translate, 'setHtmlImage' : self.set_html_image, 'strip_name' : self._strip_name, 'time' : time } self.localcontext.update(context) self.name = name self._node = None self.parents = parents self.tag = tag self._lang_cache = {} self.lang_dict = {} self.default_lang = {} self.lang_dict_called = False self._transl_regex = re.compile('(\[\[.+?\]\])')
468,787
def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Gets Recurrence rule string according to value type RECUR of iCalendar from the values given. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids, context=context): event = datas['id'] if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False cr.execute("UPDATE %s set exrule=Null where id=%s" % (self._table, event)) elif datas.get('rrule_type') == 'custom': if datas.get('interval', 0) < 0: raise osv.except_osv('Warning!', 'Interval can not be Negative') if datas.get('count', 0) < 0: raise osv.except_osv('Warning!', 'Count can not be Negative') rrule_custom = self.compute_rule_string(cr, uid, datas, \ context=context) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq': datas.get('rrule_type').upper(), 'interval': 1}, context=context)
def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Gets Recurrence rule string according to value type RECUR of iCalendar from the values given. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids, context=context): event = datas['id'] if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False cr.execute("UPDATE %s set exrule=Null where id=%s" % (self._table, event)) elif datas.get('rrule_type') == 'custom': if datas.get('interval', 0) < 0: raise osv.except_osv('Warning!', 'Interval can not be Negative') if datas.get('count', 0) < 0: raise osv.except_osv('Warning!', 'Count can not be Negative') rrule_custom = self.compute_rule_string(cr, uid, datas, \ context=context) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq': datas.get('rrule_type').upper(), 'interval': 1}, context=context)
468,788
def ref(str_id): return self.id_get(cr, None, str_id)
def ref(str_id): return self.id_get(cr, None, str_id)
468,789
def action_apply(self, cr, uid, ids, context=None): """ This converts lead to opportunity and opens Opportunity view @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Lead to Opportunity IDs @param context: A standard dictionary for contextual values
def action_apply(self, cr, uid, ids, context=None): """ This converts lead to opportunity and opens Opportunity view @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Lead to Opportunity IDs @param context: A standard dictionary for contextual values
468,790
def action_apply(self, cr, uid, ids, context=None): """ This converts lead to opportunity and opens Opportunity view @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Lead to Opportunity IDs @param context: A standard dictionary for contextual values
def action_apply(self, cr, uid, ids, context=None): """ This converts lead to opportunity and opens Opportunity view @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Lead to Opportunity IDs @param context: A standard dictionary for contextual values
468,791
result_def = state_def.get('result', {})
result_def = state_def.get('result', {})
468,792
def update_list(self, cr, uid, context={}): res = [0, 0] # [update, add]
defupdate_list(self,cr,uid,context={}):res=[0,0]#[update,add]
468,793
def update_list(self, cr, uid, context={}): res = [0, 0] # [update, add]
def update_list(self, cr, uid, context={}): res = [0, 0] # [update, add]
468,794
def check(self, cr, uid, ids, context=None): logger = logging.getLogger('init') for mod in self.browse(cr, uid, ids, context=context): if not mod.description: logger.warn('module %s: description is empty !', mod.name)
def check(self, cr, uid, ids, context=None): logger = logging.getLogger('init') for mod in self.browse(cr, uid, ids, context=context): if not mod.description: logger.warn('module %s: description is empty !', mod.name)
468,795
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {} if self._context: context = context.copy() context.update(self._context) if not values: values = {}
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {} if self._context: context = context.copy() context.update(self._context) if not values: values = {}
468,796
def load_information_from_description_file(module): """ :param module: The name of the module (sale, purchase, ...) """ for filename in ['__openerp__.py', '__terp__.py']: description_file = addons.get_module_resource(module, filename) if os.path.isfile(description_file): return eval(tools.file_open(description_file).read()) raise Exception('The module %s does not contain a description file: __openerp__.py or __terp__.py (deprecated)')
def load_information_from_description_file(module): """ :param module: The name of the module (sale, purchase, ...) """ for filename in ['__openerp__.py', '__terp__.py']: description_file = addons.get_module_resource(module, filename) if os.path.isfile(description_file): return eval(tools.file_open(description_file).read()) return
468,797
def _search_amount(self, cr, uid, obj, name, args, context): ids = [] cr.execute('select move_id,sum(debit) from account_move_line group by move_id') result = dict(cr.fetchall())
def _search_amount(self, cr, uid, obj, name, args, context): ids = [] cr.execute('select move_id,sum(debit) from account_move_line group by move_id') result = dict(cr.fetchall())
468,798
def _search_amount(self, cr, uid, obj, name, args, context): ids = [] cr.execute('select move_id,sum(debit) from account_move_line group by move_id') result = dict(cr.fetchall())
def _search_amount(self, cr, uid, obj, name, args, context): ids = [] cr.execute('select move_id,sum(debit) from account_move_line group by move_id') result = dict(cr.fetchall())
468,799