bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={} if 'date' in context: date=context['date'] else: date=time.strftime('%Y-%m-%d') date= date or time.strftime('%Y-%m-%d') for id in ids: cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date)) if cr.rowcount: id, rate=cr.fetchall()[0] res[id]=rate else: res[id]=0 return res
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={} if 'date' in context: date = context['date'] else: date=time.strftime('%Y-%m-%d') date= date or time.strftime('%Y-%m-%d') for id in ids: cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date)) if cr.rowcount: id, rate=cr.fetchall()[0] res[id]=rate else: res[id]=0 return res
468,500
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={} if 'date' in context: date=context['date'] else: date=time.strftime('%Y-%m-%d') date= date or time.strftime('%Y-%m-%d') for id in ids: cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date)) if cr.rowcount: id, rate=cr.fetchall()[0] res[id]=rate else: res[id]=0 return res
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={} if 'date' in context: date=context['date'] else: date = time.strftime('%Y-%m-%d') date = date or time.strftime('%Y-%m-%d') for id in ids: cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date)) if cr.rowcount: id, rate=cr.fetchall()[0] res[id]=rate else: res[id]=0 return res
468,501
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={} if 'date' in context: date=context['date'] else: date=time.strftime('%Y-%m-%d') date= date or time.strftime('%Y-%m-%d') for id in ids: cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date)) if cr.rowcount: id, rate=cr.fetchall()[0] res[id]=rate else: res[id]=0 return res
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={} if 'date' in context: date=context['date'] else: date=time.strftime('%Y-%m-%d') date= date or time.strftime('%Y-%m-%d') for id in ids: cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date)) if cr.rowcount: id, rate = cr.fetchall()[0] res[id] = rate else: res[id]=0 return res
468,502
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={} if 'date' in context: date=context['date'] else: date=time.strftime('%Y-%m-%d') date= date or time.strftime('%Y-%m-%d') for id in ids: cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date)) if cr.rowcount: id, rate=cr.fetchall()[0] res[id]=rate else: res[id]=0 return res
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={} if 'date' in context: date=context['date'] else: date=time.strftime('%Y-%m-%d') date= date or time.strftime('%Y-%m-%d') for id in ids: cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date)) if cr.rowcount: id, rate=cr.fetchall()[0] res[id]=rate else: res[id] = 0 return res
468,503
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): res=super(osv.osv, self).read(cr, user, ids, fields, context, load) for r in res: if r.__contains__('rate_ids'): rates=r['rate_ids'] if rates: currency_rate_obj=self.pool.get('res.currency.rate') currency_date=currency_rate_obj.read(cr,user,rates[0],['name'])['name'] r['date']=currency_date return res
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): res=super(osv.osv, self).read(cr, user, ids, fields, context, load) for r in res: if r.__contains__('rate_ids'): rates=r['rate_ids'] if rates: currency_rate_obj= self.pool.get('res.currency.rate') currency_date = currency_rate_obj.read(cr,user,rates[0],['name'])['name'] r['date'] = currency_date return res
468,504
def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount, round=True, context={}, account=None, account_invert=False): if not from_currency_id: from_currency_id = to_currency_id if not to_currency_id: to_currency_id = from_currency_id xc = self.browse(cr, uid, [from_currency_id,to_currency_id], context=context) from_currency = (xc[0].id == from_currency_id and xc[0]) or xc[1] to_currency = (xc[0].id == to_currency_id and xc[0]) or xc[1] if from_currency['rate'] == 0 or to_currency['rate'] == 0: date = context.get('date', time.strftime('%Y-%m-%d')) if from_currency['rate'] == 0: code = from_currency.code else: code = to_currency.code raise osv.except_osv(_('Error'), _('No rate found \n' \ 'for the currency: %s \n' \ 'at the date: %s') % (code, date)) rate = to_currency.rate/from_currency.rate if account and (account.currency_mode=='average') and account.currency_id: q = self.pool.get('account.move.line')._query_get(cr, uid, context=context) cr.execute('select sum(debit-credit),sum(amount_currency) from account_move_line l ' \ 'where l.currency_id=%s and l.account_id=%s and '+q, (account.currency_id.id,account.id,)) tot1,tot2 = cr.fetchone() if tot2 and not account_invert: rate = float(tot1)/float(tot2) elif tot1 and account_invert: rate = float(tot2)/float(tot1) if to_currency_id==from_currency_id: if round: return self.round(cr, uid, to_currency, from_amount) else: return from_amount else: if round: return self.round(cr, uid, to_currency, from_amount * rate) else: return (from_amount * rate)
def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount, round=True, context=None, account=None, account_invert=False): if context is None: context = {} if not from_currency_id: from_currency_id = to_currency_id if not to_currency_id: to_currency_id = from_currency_id xc = self.browse(cr, uid, [from_currency_id,to_currency_id], context=context) from_currency = (xc[0].id == from_currency_id and xc[0]) or xc[1] to_currency = (xc[0].id == to_currency_id and xc[0]) or xc[1] if from_currency['rate'] == 0 or to_currency['rate'] == 0: date = context.get('date', time.strftime('%Y-%m-%d')) if from_currency['rate'] == 0: code = from_currency.code else: code = to_currency.code raise osv.except_osv(_('Error'), _('No rate found \n' \ 'for the currency: %s \n' \ 'at the date: %s') % (code, date)) rate = to_currency.rate/from_currency.rate if account and (account.currency_mode=='average') and account.currency_id: q = self.pool.get('account.move.line')._query_get(cr, uid, context=context) cr.execute('select sum(debit-credit),sum(amount_currency) from account_move_line l ' \ 'where l.currency_id=%s and l.account_id=%s and '+q, (account.currency_id.id,account.id,)) tot1,tot2 = cr.fetchone() if tot2 and not account_invert: rate = float(tot1)/float(tot2) elif tot1 and account_invert: rate = float(tot2)/float(tot1) if to_currency_id==from_currency_id: if round: return self.round(cr, uid, to_currency, from_amount) else: return from_amount else: if round: return self.round(cr, uid, to_currency, from_amount * rate) else: return (from_amount * rate)
468,505
def name_get(self, cr, uid, ids, context=None): return dict([(a["id"], "%s (%s)" % (a['email_id'], a['name'])) for a in self.read(cr, uid, ids, ['name', 'email_id'], context=context)])
def name_get(self, cr, uid, ids, context=None): return dict([(a["id"], "%s (%s)" % (a['email_id'], a['name'])) for a in self.read(cr, uid, ids, ['name', 'email_id'], context=context)])
468,506
def history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \ email_from=False, message_id=False, references=None, attach=None, email_cc=None, \ email_bcc=None, email_date=None, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param cases: a browse record list @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used @param history: Value True/False, If True it makes entry in case History otherwise in Case Log @param email: Email-To / Recipient address @param email_from: Email From / Sender address if any @param email_cc: Comma-Separated list of Carbon Copy Emails To addresse if any @param email_bcc: Comma-Separated list of Blind Carbon Copy Emails To addresses if any @param email_date: Email Date string if different from now, in server Timezone @param details: Description, Ddtails of case history if any @param atach: Attachment sent in email @param context: A standard dictionary for contextual values""" if context is None: context = {} if attach is None: attach = []
def history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \ email_from=False, message_id=False, references=None, attach=None, email_cc=None, \ email_bcc=None, email_date=None, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param cases: a browse record list @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used @param history: Value True/False, If True it makes entry in case History otherwise in Case Log @param email: Email-To / Recipient address @param email_from: Email From / Sender address if any @param email_cc: Comma-Separated list of Carbon Copy Emails To addresse if any @param email_bcc: Comma-Separated list of Blind Carbon Copy Emails To addresses if any @param email_date: Email Date string if different from now, in server Timezone @param details: Description, Details of case history if any @param atach: Attachment sent in email @param context: A standard dictionary for contextual values""" if context is None: context = {} if attach is None: attach = []
468,507
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
468,508
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): journal_obj = self.pool.get('account.journal') if context.get('active_model','') in ['res.partner']: partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0] if not view_type: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.tree')])[0] view_type = 'tree' if view_type == 'form': if partner['supplier'] and not partner['customer']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.supplier.form')])[0] else: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.form')])[0] res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) type = context.get('journal_type', 'sale') for field in res['fields']: if field == 'journal_id': journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) res['fields'][field]['selection'] = journal_select
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): journal_obj = self.pool.get('account.journal') if context is None: context = {} if context.get('active_model', '') in ['res.partner'] and context.get('active_ids', False) and context['active_ids']: partner = self.pool.get(context['active_model']).read(cr, uid, context['active_ids'], ['supplier','customer'])[0] if not view_type: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.tree')])[0] view_type = 'tree' if view_type == 'form': if partner['supplier'] and not partner['customer']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.supplier.form')])[0] else: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.form')])[0] res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) type = context.get('journal_type', 'sale') for field in res['fields']: if field == 'journal_id': journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) res['fields'][field]['selection'] = journal_select
468,509
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): journal_obj = self.pool.get('account.journal') if context.get('active_model','') in ['res.partner']: partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0] if not view_type: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.tree')])[0] view_type = 'tree' if view_type == 'form': if partner['supplier'] and not partner['customer']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.supplier.form')])[0] else: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.form')])[0] res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) type = context.get('journal_type', 'sale') for field in res['fields']: if field == 'journal_id': journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) res['fields'][field]['selection'] = journal_select
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): journal_obj = self.pool.get('account.journal') if context.get('active_model','') in ['res.partner']: partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0] if not view_type: view_id = self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'account.invoice.tree')])[0] view_type = 'tree' if view_type == 'form': if partner['supplier'] and not partner['customer']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.supplier.form')])[0] else: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.form')])[0] res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) type = context.get('journal_type', 'sale') for field in res['fields']: if field == 'journal_id': journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) res['fields'][field]['selection'] = journal_select
468,510
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): journal_obj = self.pool.get('account.journal') if context.get('active_model','') in ['res.partner']: partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0] if not view_type: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.tree')])[0] view_type = 'tree' if view_type == 'form': if partner['supplier'] and not partner['customer']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.supplier.form')])[0] else: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.form')])[0] res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) type = context.get('journal_type', 'sale') for field in res['fields']: if field == 'journal_id': journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) res['fields'][field]['selection'] = journal_select
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): journal_obj = self.pool.get('account.journal') if context.get('active_model','') in ['res.partner']: partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0] if not view_type: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.tree')])[0] view_type = 'tree' if view_type == 'form': if partner['supplier'] and not partner['customer']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.supplier.form')])[0] else: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.form')])[0] res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) type = context.get('journal_type', 'sale') for field in res['fields']: if field == 'journal_id': journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) res['fields'][field]['selection'] = journal_select
468,511
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): journal_obj = self.pool.get('account.journal') if context.get('active_model','') in ['res.partner']: partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0] if not view_type: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.tree')])[0] view_type = 'tree' if view_type == 'form': if partner['supplier'] and not partner['customer']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.supplier.form')])[0] else: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.form')])[0] res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) type = context.get('journal_type', 'sale') for field in res['fields']: if field == 'journal_id': journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) res['fields'][field]['selection'] = journal_select
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): journal_obj = self.pool.get('account.journal') if context.get('active_model','') in ['res.partner']: partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0] if not view_type: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.tree')])[0] view_type = 'tree' if view_type == 'form': if partner['supplier'] and not partner['customer']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.supplier.form')])[0] else: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.form')])[0] res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) type = context.get('journal_type', 'sale') for field in res['fields']: if field == 'journal_id': journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) res['fields'][field]['selection'] = journal_select
468,512
def msg_new(self, msg): message = self.msg_body_get(msg) data = { 'name': self._decode_header(msg['Subject']), 'email_from': self._decode_header(msg['From']), 'email_cc': self._decode_header(msg['Cc'] or ''), 'canal_id': self.canal_id, 'user_id': False, 'description': message['body'], } data.update(self.partner_get(self._decode_header(msg['From'])))
def msg_new(self, msg): message = self.msg_body_get(msg) data = { 'name': self._decode_header(msg['Subject']), 'email_from': self._decode_header(msg['From']), 'email_cc': self._decode_header(msg['Cc'] or ''), 'canal_id': self.canal_id, 'user_id': False, 'description': message['body'], } data.update(self.partner_get(self._decode_header(msg['From'])))
468,513
def replace(match): return ''
def replace(match): return ''
468,514
def msg_user(self, msg, id): body = self.msg_body_get(msg)
def msg_user(self, msg, id): body = self.msg_body_get(msg)
468,515
def msg_user(self, msg, id): body = self.msg_body_get(msg)
def msg_user(self, msg, id): body = self.msg_body_get(msg)
468,516
def msg_partner(self, msg, id): message = self.msg_body_get(msg) body = message['body'] act = 'case_open' self.rpc(self.model, act, [id]) body2 = '\n'.join(map(lambda l: '> '+l, (body or '').split('\n'))) data = { 'description':body, } self.rpc(self.model, 'write', [id], data) self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], message['body']) return id
def msg_partner(self, msg, id): message = self.msg_body_get(msg) body = message['body'] act = 'case_open' self.rpc(self.model, act, [id]) self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], message['body']) return id
468,517
def parse(self, msg): case_str = reference_re.search(msg.get('References', '')) if case_str: case_str = case_str.group(1) else: case_str = case_re.search(msg.get('Subject', '')) if case_str: case_str = case_str.group(1) (case_id, emails) = self.msg_test(msg, case_str) if case_id: if emails[0] and self.email_get(emails[0])==self.email_get(self._decode_header(msg['From'])): self.msg_user(msg, case_id) else: self.msg_partner(msg, case_id) else: case_id = self.msg_new(msg) subject = self._decode_header(msg['subject']) if msg.get('Subject', ''): del msg['Subject'] msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
def parse(self, msg): case_str = reference_re.search(msg.get('References', '')) if case_str: case_str = case_str.group(1) else: case_str = case_re.search(msg.get('Subject', '')) if case_str: case_str = case_str.group(1) (case_id, emails) = self.msg_test(msg, case_str) if case_id: if emails[0] and self.email_get(emails[0])==self.email_get(self._decode_header(msg['From'])): self.msg_user(msg, case_id) else: self.msg_partner(msg, case_id) else: case_id = self.msg_new(msg) subject = self._decode_header(msg['subject']) if msg.get('Subject', ''): del msg['Subject'] msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
468,518
def check(self, db, uid, passwd): try: return super(users,self).check(db, uid, passwd) except ExceptionNoTb: # AccessDenied pass cr = pooler.get_db(db).cursor() user = self.browse(cr, 1, uid) logger = logging.getLogger('orm.ldap') if user and user.company_id.ldaps: for res_company_ldap in user.company_id.ldaps: try: l = ldap.open(res_company_ldap.ldap_server, res_company_ldap.ldap_server_port) if l.simple_bind_s(res_company_ldap.ldap_binddn, res_company_ldap.ldap_password): base = res_company_ldap.ldap_base scope = ldap.SCOPE_SUBTREE filter = filter_format(res_company_ldap.ldap_filter, (user.login,)) retrieve_attributes = None result_id = l.search(base, scope, filter, retrieve_attributes) timeout = 60 result_type, result_data = l.result(result_id, timeout) if result_data and result_type == ldap.RES_SEARCH_RESULT and len(result_data) == 1: dn = result_data[0][0] if l.bind_s(dn, passwd): l.unbind() self._uid_cache.setdefault(db, {})[uid] = passwd cr.close() return True l.unbind() except Exception, e: logger.warning('cannot check', exc_info=True) pass cr.close() raise security.ExceptionNoTb('AccessDenied')
def check(self, db, uid, passwd): try: return super(users,self).check(db, uid, passwd) except security.ExceptionNoTb: # AccessDenied pass cr = pooler.get_db(db).cursor() user = self.browse(cr, 1, uid) logger = logging.getLogger('orm.ldap') if user and user.company_id.ldaps: for res_company_ldap in user.company_id.ldaps: try: l = ldap.open(res_company_ldap.ldap_server, res_company_ldap.ldap_server_port) if l.simple_bind_s(res_company_ldap.ldap_binddn, res_company_ldap.ldap_password): base = res_company_ldap.ldap_base scope = ldap.SCOPE_SUBTREE filter = filter_format(res_company_ldap.ldap_filter, (user.login,)) retrieve_attributes = None result_id = l.search(base, scope, filter, retrieve_attributes) timeout = 60 result_type, result_data = l.result(result_id, timeout) if result_data and result_type == ldap.RES_SEARCH_RESULT and len(result_data) == 1: dn = result_data[0][0] if l.bind_s(dn, passwd): l.unbind() self._uid_cache.setdefault(db, {})[uid] = passwd cr.close() return True l.unbind() except Exception, e: logger.warning('cannot check', exc_info=True) pass cr.close() raise security.ExceptionNoTb('AccessDenied')
468,519
def _get_titles(self,form): lst = [] vals = {} qtys = 1
def _get_titles(self,form): lst = [] vals = {} qtys = 1
468,520
def _set_quantity(self,form): for i in range(1,6): q = 'qty%d'%i if form[q] >0 and form[q] not in self.quantity: self.quantity.append(form[q])
def _set_quantity(self,form): for i in range(1,6): q = 'qty%d'%i if form[q] >0 and form[q] not in self.quantity: self.quantity.append(form[q])
468,521
def _get_categories(self, products,form): cat_ids=[] res=[] self.pricelist = form['price_list'] self._set_quantity(form) pool = pooler.get_pool(self.cr.dbname) pro_ids=[] for product in products: pro_ids.append(product.id) if product.categ_id.id not in cat_ids: cat_ids.append(product.categ_id.id) cats = pool.get('product.category').read(self.cr, self.uid, cat_ids, ['name']) for cat in cats: product_ids=pool.get('product.product').search(self.cr, self.uid, [('id','in',pro_ids),('categ_id','=',cat['id'])]) products = [] for product in pool.get('product.product').read(self.cr, self.uid, product_ids, ['name','code']): val={ 'id':product['id'], 'name':product['name'], 'code':product['code'] } i = 1 for qty in self.quantity: if qty == 0: val['qty'+str(i)] = "" else: val['qty'+str(i)]=self._get_price(self.pricelist, product['id'], qty) i += 1 products.append(val) res.append({'name':cat['name'],'products':products}) return res
def _get_categories(self, products,form): cat_ids=[] res=[] self.pricelist = form['price_list'] self._set_quantity(form) pool = pooler.get_pool(self.cr.dbname) pro_ids=[] for product in products: pro_ids.append(product.id) if product.categ_id.id not in cat_ids: cat_ids.append(product.categ_id.id) cats = pool.get('product.category').read(self.cr, self.uid, cat_ids, ['name']) for cat in cats: product_ids=pool.get('product.product').search(self.cr, self.uid, [('id','in',pro_ids),('categ_id','=',cat['id'])]) products = [] for product in pool.get('product.product').read(self.cr, self.uid, product_ids, ['name','code']): val={ 'id':product['id'], 'name':product['name'], 'code':product['code'] } i = 1 for qty in self.quantity: if qty == 0: val['qty'+str(i)] = 0.0 else: val['qty'+str(i)]=self._get_price(self.pricelist, product['id'], qty) i += 1 products.append(val) res.append({'name':cat['name'],'products':products}) return res
468,522
def _get_categories(self, products,form): cat_ids=[] res=[] self.pricelist = form['price_list'] self._set_quantity(form) pool = pooler.get_pool(self.cr.dbname) pro_ids=[] for product in products: pro_ids.append(product.id) if product.categ_id.id not in cat_ids: cat_ids.append(product.categ_id.id) cats = pool.get('product.category').read(self.cr, self.uid, cat_ids, ['name']) for cat in cats: product_ids=pool.get('product.product').search(self.cr, self.uid, [('id','in',pro_ids),('categ_id','=',cat['id'])]) products = [] for product in pool.get('product.product').read(self.cr, self.uid, product_ids, ['name','code']): val={ 'id':product['id'], 'name':product['name'], 'code':product['code'] } i = 1 for qty in self.quantity: if qty == 0: val['qty'+str(i)] = "" else: val['qty'+str(i)]=self._get_price(self.pricelist, product['id'], qty) i += 1 products.append(val) res.append({'name':cat['name'],'products':products}) return res
def _get_categories(self, products,form): cat_ids=[] res=[] self.pricelist = form['price_list'] self._set_quantity(form) pool = pooler.get_pool(self.cr.dbname) pro_ids=[] for product in products: pro_ids.append(product.id) if product.categ_id.id not in cat_ids: cat_ids.append(product.categ_id.id) cats = pool.get('product.category').read(self.cr, self.uid, cat_ids, ['name']) for cat in cats: product_ids=pool.get('product.product').search(self.cr, self.uid, [('id','in',pro_ids),('categ_id','=',cat['id'])]) products = [] for product in pool.get('product.product').read(self.cr, self.uid, product_ids, ['name','code']): val={ 'id':product['id'], 'name':product['name'], 'code':product['code'] } i = 1 for qty in self.quantity: if qty == 0: val['qty'+str(i)] = "" else: val['qty'+str(i)]=self._get_price(self.pricelist, product['id'], qty) i += 1 products.append(val) res.append({'name':cat['name'],'products':products}) return res
468,523
def _get_categories(self, products,form): cat_ids=[] res=[] self.pricelist = form['price_list'] self._set_quantity(form) pool = pooler.get_pool(self.cr.dbname) pro_ids=[] for product in products: pro_ids.append(product.id) if product.categ_id.id not in cat_ids: cat_ids.append(product.categ_id.id) cats = pool.get('product.category').read(self.cr, self.uid, cat_ids, ['name']) for cat in cats: product_ids=pool.get('product.product').search(self.cr, self.uid, [('id','in',pro_ids),('categ_id','=',cat['id'])]) products = [] for product in pool.get('product.product').read(self.cr, self.uid, product_ids, ['name','code']): val={ 'id':product['id'], 'name':product['name'], 'code':product['code'] } i = 1 for qty in self.quantity: if qty == 0: val['qty'+str(i)] = "" else: val['qty'+str(i)]=self._get_price(self.pricelist, product['id'], qty) i += 1 products.append(val) res.append({'name':cat['name'],'products':products}) return res
def _get_categories(self, products,form): cat_ids=[] res=[] self.pricelist = form['price_list'] self._set_quantity(form) pool = pooler.get_pool(self.cr.dbname) pro_ids=[] for product in products: pro_ids.append(product.id) if product.categ_id.id not in cat_ids: cat_ids.append(product.categ_id.id) cats = pool.get('product.category').read(self.cr, self.uid, cat_ids, ['name']) for cat in cats: product_ids=pool.get('product.product').search(self.cr, self.uid, [('id','in',pro_ids),('categ_id','=',cat['id'])]) products = [] for product in pool.get('product.product').read(self.cr, self.uid, product_ids, ['name','code']): val={ 'id':product['id'], 'name':product['name'], 'code':product['code'] } i = 1 for qty in self.quantity: if qty == 0: val['qty'+str(i)] = "" else: val['qty'+str(i)]=self._get_price(self.pricelist, product['id'], qty) i += 1 products.append(val) res.append({'name':cat['name'],'products': products}) return res
468,524
def compute_tax(self, cr, uid, ids, context={}): tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') position_pool = self.pool.get('account.fiscal.position') voucher_line_pool = self.pool.get('account.voucher.line') voucher_pool = self.pool.get('account.voucher') for voucher in voucher_pool.browse(cr, uid, ids, context): voucher_amount = 0.0 for line in voucher.line_ids: voucher_amount += line.untax_amount or line.amount line.amount = line.untax_amount or line.amount voucher_line_pool.write(cr, uid, [line.id], {'amount':line.amount, 'untax_amount':line.untax_amount}) if not voucher.tax_id: continue tax = [tax_pool.browse(cr, uid, voucher.tax_id.id)] partner = partner_pool.browse(cr, uid, voucher.partner_id.id) or False taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax) tax = tax_pool.browse(cr, uid, taxes) total = voucher_amount total_tax = 0.0 if not tax[0].price_include: for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_amount, 1).get('taxes'): total_tax += tax_line.get('amount') total += total_tax else: line_ids2 = [] for line in voucher.line_ids: line_total = 0.0 line_tax = 0.0 for tax_line in tax_pool.compute_all(cr, uid, tax, line.untax_amount or line.amount, 1).get('taxes'): line_tax += tax_line.get('amount') line_total += tax_line.get('price_unit') total_tax += line_tax untax_amount = line.untax_amount or line.amount voucher_line_pool.write(cr, uid, [line.id], {'amount':line_total, 'untax_amount':untax_amount}) self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax}) return True
def compute_tax(self, cr, uid, ids, context={}): tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') position_pool = self.pool.get('account.fiscal.position') voucher_line_pool = self.pool.get('account.voucher.line') voucher_pool = self.pool.get('account.voucher') for voucher in voucher_pool.browse(cr, uid, ids, context): voucher_amount = 0.0 for line in voucher.line_ids: voucher_amount += line.untax_amount or line.amount line.amount = line.untax_amount or line.amount voucher_line_pool.write(cr, uid, [line.id], {'amount':line.amount, 'untax_amount':line.untax_amount}) if not voucher.tax_id: continue tax = [tax_pool.browse(cr, uid, voucher.tax_id.id)] partner = partner_pool.browse(cr, uid, voucher.partner_id.id) or False taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax) tax = tax_pool.browse(cr, uid, taxes) total = voucher_amount total_tax = 0.0 if not tax[0].price_include: for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_amount, 1).get('taxes'): total_tax += tax_line.get('amount') total += total_tax else: line_ids2 = [] for line in voucher.line_ids: line_total = 0.0 line_tax = 0.0 for tax_line in tax_pool.compute_all(cr, uid, tax, line.untax_amount or line.amount, 1).get('taxes'): line_tax += tax_line.get('amount') line_total += tax_line.get('price_unit') total_tax += line_tax untax_amount = line.untax_amount or line.amount voucher_line_pool.write(cr, uid, [line.id], {'amount':line_total, 'untax_amount':untax_amount}) self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax}) return True
468,525
def _build_context(self, cr, uid, ids, data, context = None): result = {} result['fiscalyear'] = data['form']['fiscalyear_id'] and data['form']['fiscalyear_id'] or False if data['form']['filter'] == 'filter_date': result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] elif data['form']['filter'] == 'filter_period': period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])[0]['date_start'] period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])[0]['date_stop'] cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) result['periods'] = lambda x: x[0], cr.fetchall() return result
def _build_context(self, cr, uid, ids, data, context = None): result = {} result['fiscalyear'] = data['form']['fiscalyear_id'] and data['form']['fiscalyear_id'] or False if data['form']['filter'] == 'filter_date': result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] elif data['form']['filter'] == 'filter_period': period_obj = self.pool.get('account.period') period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start'] period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop'] cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) result['periods'] = lambda x: x[0], cr.fetchall() return result
468,526
def check_report(self, cr, uid, ids, context=None): obj_acc_move_line = self.pool.get('account.move.line') data = {} data['ids'] = context.get('active_ids',[]) data['model'] = context.get('active_model', 'ir.ui.menu') data['form'] = self.read(cr, uid, ids, ['date_from', 'date_to', 'fiscalyear_id', 'journal_ids', 'period_from', 'period_to', 'filter', 'chart_account_id'])[0] used_context = self._build_context(cr, uid, ids, data, context) query_line = obj_acc_move_line._query_get(cr, uid, obj='l', context=used_context) return self._print_report(cr, uid, ids, data, query_line, context)
def check_report(self, cr, uid, ids, context=None): obj_acc_move_line = self.pool.get('account.move.line') data = {} data['ids'] = context.get('active_ids',[]) data['model'] = context.get('active_model', 'ir.ui.menu') data['form'] = self.read(cr, uid, ids, ['date_from', 'date_to', 'fiscalyear_id', 'journal_ids', 'period_from', 'period_to', 'filter', 'chart_account_id'])[0] used_context = self._build_context(cr, uid, ids, data, context) query_line = obj_acc_move_line._query_get(cr, uid, obj='l', context=used_context) return self._print_report(cr, uid, ids, data, query_line, context)
468,527
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ Search for record/s with or without domain
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ Search for record/s with or without domain
468,528
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ Search for record/s with or without domain
defsearch(self,cr,user,args,offset=0,limit=None,order=None,context=None,count=False):"""Searchforrecord/swithorwithoutdomain
468,529
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ Search for record/s with or without domain
def if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) search(self, if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) cr, if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) user, if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) args, if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) offset=0, if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) limit=None, if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) order=None, if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) context=None, if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) count=False): if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) """ if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) Search if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) for if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) record/s if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) with if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) or if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) without if len(qu1_join): qu1 = qu1 + ' and ' qu1 += ' and '.join(qu1_join) domain
468,530
def _name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100, name_get_uid=None): if not args: args = [] if not context: context = {} args = args[:] if name: args += [(self._rec_name, operator, name)] ids = self.search(cr, user, args, limit=limit, context=context) res = self.name_get(cr, name_get_uid or user, ids, context) return res
def _name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100, name_get_uid=None): if args is None: args = [] if not context: context = {} args = args[:] if name: args += [(self._rec_name, operator, name)] ids = self.search(cr, user, args, limit=limit, context=context) res = self.name_get(cr, name_get_uid or user, ids, context) return res
468,531
def _name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100, name_get_uid=None): if not args: args = [] if not context: context = {} args = args[:] if name: args += [(self._rec_name, operator, name)] ids = self.search(cr, user, args, limit=limit, context=context) res = self.name_get(cr, name_get_uid or user, ids, context) return res
def _name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100, name_get_uid=None): if not args: args = [] if context is None: context = {} args = args[:] if name: args += [(self._rec_name, operator, name)] ids = self.search(cr, user, args, limit=limit, context=context) res = self.name_get(cr, name_get_uid or user, ids, context) return res
468,532
def copy_data(self, cr, uid, id, default=None, context=None): """ Copy given record's data with all its fields values
def copy_data(self, cr, uid, id, default=None, context=None): """ Copy given record's data with all its fields values
468,533
def default_get(self, cr, uid, fields, context=None): """ Get default values @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for default value @param context: A standard dictionary @return: default values of fields """ res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context) move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) if 'product_id' in fields: res.update({'product_id': move.product_id.id}) if 'product_uom' in fields: res.update({'product_uom': move.product_uom.id}) if 'product_qty' in fields: res.update({'product_qty': move.product_qty.id}) if 'location_id' in fields: res.update({'location_id': move.location_id.id}) return res
def default_get(self, cr, uid, fields, context=None): """ Get default values @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for default value @param context: A standard dictionary @return: default values of fields """ res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context) move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) if 'product_id' in fields: res.update({'product_id': move.product_id.id}) if 'product_uom' in fields: res.update({'product_uom': move.product_uom.id}) if 'product_qty' in fields: res.update({'product_qty': move.product_qty}) if 'location_id' in fields: res.update({'location_id': move.location_id.id}) return res
468,534
def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False, attach=None, openobject_id=False, ssl=False, debug=False, subtype='plain', x_headers=None, priority='3'): """Send an email. Arguments: `email_from`: A string used to fill the `From` header, if falsy, config['email_from'] is used instead. Also used for the `Reply-To` header if `reply_to` is not provided `email_to`: a sequence of addresses to send the mail to. """ import smtplib from email.MIMEText import MIMEText from email.MIMEBase import MIMEBase from email.MIMEMultipart import MIMEMultipart from email.Header import Header from email.Utils import formatdate, COMMASPACE from email.Utils import formatdate, COMMASPACE from email import Encoders import netsvc if x_headers is None: x_headers = {} if not ssl: ssl = config.get('smtp_ssl', False) if not (email_from or config['email_from']): raise ValueError("Sending an email requires either providing a sender " "address or having configured one") if not email_from: email_from = config.get('email_from', False) if not email_cc: email_cc = [] if not email_bcc: email_bcc = [] if not body: body = u'' try: email_body = body.encode('utf-8') except (UnicodeEncodeError, UnicodeDecodeError): email_body = body email_text = MIMEText(email_body, _subtype=subtype, _charset='utf-8') if attach: msg = MIMEMultipart() else: msg = email_text msg['Subject'] = Header(ustr(subject), 'utf-8') msg['From'] = email_from del msg['Reply-To'] if reply_to: msg['Reply-To'] = reply_to else: msg['Reply-To'] = msg['From'] msg['To'] = COMMASPACE.join(email_to) if email_cc: msg['Cc'] = COMMASPACE.join(email_cc) if email_bcc: msg['Bcc'] = COMMASPACE.join(email_bcc) msg['Date'] = formatdate(localtime=True) # Add OpenERP Server information msg['X-Generated-By'] = 'OpenERP (http://www.openerp.com)' msg['X-OpenERP-Server-Host'] = socket.gethostname() msg['X-OpenERP-Server-Version'] = release.version msg['X-Priority'] = priorities.get(priority, '3 (Normal)') # Add dynamic X Header for key, value in x_headers.iteritems(): msg['X-OpenERP-%s' % key] = str(value) if openobject_id: msg['Message-Id'] = "<%s-openobject-%s@%s>" % (time.time(), openobject_id, socket.gethostname()) if attach: msg.attach(email_text) for (fname,fcontent) in attach: part = MIMEBase('application', "octet-stream") part.set_payload( fcontent ) Encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"' % (fname,)) msg.attach(part) class WriteToLogger(object): def __init__(self): self.logger = netsvc.Logger() def write(self, s): self.logger.notifyChannel('email_send', netsvc.LOG_DEBUG, s) smtp_server = config['smtp_server'] if smtp_server.startswith('maildir:/'): from mailbox import Maildir maildir_path = smtp_server[8:] try: mdir = Maildir(maildir_path,factory=None, create = True) mdir.add(msg.as_string(True)) return True except Exception,e: netsvc.Logger().notifyChannel('email_send (maildir)', netsvc.LOG_ERROR, e) return False try: oldstderr = smtplib.stderr s = smtplib.SMTP() try: # in case of debug, the messages are printed to stderr. if debug: smtplib.stderr = WriteToLogger() s.set_debuglevel(int(bool(debug))) # 0 or 1 s.connect(smtp_server, config['smtp_port']) if ssl: s.ehlo() s.starttls() s.ehlo() if config['smtp_user'] or config['smtp_password']: s.login(config['smtp_user'], config['smtp_password']) s.sendmail(email_from, flatten([email_to, email_cc, email_bcc]), msg.as_string() ) finally: s.quit() if debug: smtplib.stderr = oldstderr except Exception, e: netsvc.Logger().notifyChannel('email_send', netsvc.LOG_ERROR, e) return False return True
def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False, attach=None, openobject_id=False, ssl=False, debug=False, subtype='plain', x_headers=None, priority='3'): """Send an email. Arguments: `email_from`: A string used to fill the `From` header, if falsy, config['email_from'] is used instead. Also used for the `Reply-To` header if `reply_to` is not provided `email_to`: a sequence of addresses to send the mail to. """ import smtplib from email.MIMEText import MIMEText from email.MIMEBase import MIMEBase from email.MIMEMultipart import MIMEMultipart from email.Header import Header from email.Utils import formatdate, COMMASPACE from email.Utils import formatdate, COMMASPACE from email import Encoders import netsvc if x_headers is None: x_headers = {} if not ssl: ssl = config.get('smtp_ssl', False) if not (email_from or config['email_from']): raise ValueError("Sending an email requires either providing a sender " "address or having configured one") if not email_from: email_from = config.get('email_from', False) if not email_cc: email_cc = [] if not email_bcc: email_bcc = [] if not body: body = u'' try: email_body = body.encode('utf-8') except (UnicodeEncodeError, UnicodeDecodeError): email_body = body try: email_text = MIMEText(email_body.encode('utf8') or '',_subtype=subtype,_charset='utf-8') except: email_text = MIMEText(email_body or '',_subtype=subtype,_charset='utf-8') if attach: msg = MIMEMultipart() else: msg = email_text msg['Subject'] = Header(ustr(subject), 'utf-8') msg['From'] = email_from del msg['Reply-To'] if reply_to: msg['Reply-To'] = reply_to else: msg['Reply-To'] = msg['From'] msg['To'] = COMMASPACE.join(email_to) if email_cc: msg['Cc'] = COMMASPACE.join(email_cc) if email_bcc: msg['Bcc'] = COMMASPACE.join(email_bcc) msg['Date'] = formatdate(localtime=True) # Add OpenERP Server information msg['X-Generated-By'] = 'OpenERP (http://www.openerp.com)' msg['X-OpenERP-Server-Host'] = socket.gethostname() msg['X-OpenERP-Server-Version'] = release.version msg['X-Priority'] = priorities.get(priority, '3 (Normal)') # Add dynamic X Header for key, value in x_headers.iteritems(): msg['X-OpenERP-%s' % key] = str(value) if openobject_id: msg['Message-Id'] = "<%s-openobject-%s@%s>" % (time.time(), openobject_id, socket.gethostname()) if attach: msg.attach(email_text) for (fname,fcontent) in attach: part = MIMEBase('application', "octet-stream") part.set_payload( fcontent ) Encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"' % (fname,)) msg.attach(part) class WriteToLogger(object): def __init__(self): self.logger = netsvc.Logger() def write(self, s): self.logger.notifyChannel('email_send', netsvc.LOG_DEBUG, s) smtp_server = config['smtp_server'] if smtp_server.startswith('maildir:/'): from mailbox import Maildir maildir_path = smtp_server[8:] try: mdir = Maildir(maildir_path,factory=None, create = True) mdir.add(msg.as_string(True)) return True except Exception,e: netsvc.Logger().notifyChannel('email_send (maildir)', netsvc.LOG_ERROR, e) return False try: oldstderr = smtplib.stderr s = smtplib.SMTP() try: # in case of debug, the messages are printed to stderr. if debug: smtplib.stderr = WriteToLogger() s.set_debuglevel(int(bool(debug))) # 0 or 1 s.connect(smtp_server, config['smtp_port']) if ssl: s.ehlo() s.starttls() s.ehlo() if config['smtp_user'] or config['smtp_password']: s.login(config['smtp_user'], config['smtp_password']) s.sendmail(email_from, flatten([email_to, email_cc, email_bcc]), msg.as_string() ) finally: s.quit() if debug: smtplib.stderr = oldstderr except Exception, e: netsvc.Logger().notifyChannel('email_send', netsvc.LOG_ERROR, e) return False return True
468,535
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos_obj = self.pool.get('account.fiscal.position') fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id) or False
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos_obj = self.pool.get('account.fiscal.position') fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id) or False
468,536
def run(self): # import select try: self.running = True while self.running: (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: netsvc.Logger().notifyChannel("web-services", netsvc.LOG_WARNING, "Netrpc: closing because of exception %s" % str(e)) self.socket.close() return False
def run(self): # import select try: self.running = True while self.running: (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
468,537
def _auto_init(self, cursor, context=None): res = super(stock_move, self)._auto_init(cursor, context=contexts) cursor.execute('SELECT indexname \ FROM pg_indexes \ WHERE indexname = \'stock_move_location_id_location_dest_id_product_id_state\'') if not cursor.fetchone(): cursor.execute('CREATE INDEX stock_move_location_id_location_dest_id_product_id_state \ ON stock_move (location_id, location_dest_id, product_id, state)') cursor.commit() return res
def _auto_init(self, cursor, context=None): res = super(stock_move, self)._auto_init(cursor, context=context) cursor.execute('SELECT indexname \ FROM pg_indexes \ WHERE indexname = \'stock_move_location_id_location_dest_id_product_id_state\'') if not cursor.fetchone(): cursor.execute('CREATE INDEX stock_move_location_id_location_dest_id_product_id_state \ ON stock_move (location_id, location_dest_id, product_id, state)') cursor.commit() return res
468,538
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
468,539
def button_install(self, cr, uid, ids, context={}): return self.write(cr, uid, ids, {'state': 'installed'}, context)
def button_install(self, cr, uid, ids, context={}): res = self.write(cr, uid, ids, {'state': 'installed'}, context) if res: return "Installed"
468,540
def button_uninstall(self, cr, uid, ids, context={}): return self.write(cr, uid, ids, {'state': 'uninstalled'}, context)
def button_uninstall(self, cr, uid, ids, context={}): res = self.write(cr, uid, ids, {'state': 'uninstalled'}, context) if res: return "Uninstalled"
468,541
def historise(self, cr, uid, ids, message='', context=None): for id in ids: history = self.read(cr, uid, id, ['history'], context).get('history', '') self.write(cr, uid, id, {'history':history or '' + "\n" + time.strftime("%Y-%m-%d %H:%M:%S") + ": " + tools.ustr(message)}, context)
def historise(self, cr, uid, ids, message='', context=None): for id in ids: history = self.read(cr, uid, id, ['history'], context).get('history', '') self.write(cr, uid, id, {'history': (history or '' )+ "\n" + time.strftime("%Y-%m-%d %H:%M:%S") + ": " + tools.ustr(message)}, context)
468,542
def _makeOrder(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) case_obj = pool.get('crm.case') sale_obj = pool.get('sale.order') partner_obj = pool.get('res.partner') sale_line_obj = pool.get('sale.order.line')
def _makeOrder(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) case_obj = pool.get('crm.case') sale_obj = pool.get('sale.order') partner_obj = pool.get('res.partner') sale_line_obj = pool.get('sale.order.line')
468,543
def set_done(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'done'}, context=context) return True
def set_done(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'close'}, context=context) return True
468,544
def copy(self, cr, uid, id, default={},context={}): proj = self.browse(cr, uid, id, context=context) default = default or {} context['active_test'] = False default['state'] = 'open' if not default.get('name', False): default['name'] = proj.name+_(' (copy)') res = super(project, self).copy(cr, uid, id, default, context) ids = self.search(cr, uid, [('parent_id','child_of', [res])]) cr.execute('update project_task set active=True where project_id in ('+','.join(map(str, ids))+')') return res
def copy(self, cr, uid, id, default={},context={}): proj = self.browse(cr, uid, id, context=context) default = default or {} context['active_test'] = False default['state'] = 'open' if not default.get('name', False): default['name'] = proj.name+_(' (copy)') res = super(project, self).copy(cr, uid, id, default, context) ids = self.search(cr, uid, [('parent_id','child_of', [res])]) if ids: cr.execute('update project_task set active=True where project_id in ('+','.join(map(str, ids))+')') return res
468,545
def duplicate_template(self, cr, uid, ids,context={}): for proj in self.browse(cr, uid, ids): parent_id=context.get('parent_id',False) new_id=self.pool.get('project.project').copy(cr, uid, proj.id,default={'name':proj.name+_(' (copy)'),'state':'open','parent_id':parent_id}) cr.execute('select id from project_task where project_id=%s', (proj.id,)) res = cr.fetchall() for (tasks_id,) in res: self.pool.get('project.task').copy(cr, uid, tasks_id,default={'project_id':new_id,'active':True}, context=context) cr.execute('select id from project_project where parent_id=%s', (proj.id,)) res = cr.fetchall() project_ids = [x[0] for x in res] for child in project_ids: self.duplicate_template(cr, uid, [child],context={'parent_id':new_id})
def duplicate_template(self, cr, uid, ids,context={}): for proj in self.browse(cr, uid, ids): parent_id=context.get('parent_id',False) new_id=self.pool.get('project.project').copy(cr, uid, proj.id,default={'name':proj.name+_(' (copy)'),'state':'open','parent_id':parent_id}) cr.execute('select id from project_task where project_id=%s', (proj.id,)) res = cr.fetchall() for (tasks_id,) in res: self.pool.get('project.task').copy(cr, uid, tasks_id,default={'project_id':new_id,'active':True}, context=context) cr.execute('select id from project_project where parent_id=%s', (proj.id,)) res = cr.fetchall() project_ids = [x[0] for x in res] for child in project_ids: self.duplicate_template(cr, uid, [child],context={'parent_id':new_id})
468,546
def setActive(self, cr, uid, ids, value=True, context={}): for proj in self.browse(cr, uid, ids, context): self.write(cr, uid, [proj.id], {'state': value and 'open' or 'template'}, context) cr.execute('select id from project_task where project_id=%s', (proj.id,)) tasks_id = [x[0] for x in cr.fetchall()] if tasks_id: self.pool.get('project.task').write(cr, uid, tasks_id, {'active': value}, context) cr.execute('select id from project_project where parent_id=%s', (proj.id,)) project_ids = [x[0] for x in cr.fetchall()] for child in project_ids: self.setActive(cr, uid, [child], value, context) return True
def setActive(self, cr, uid, ids, value=True, context={}): for proj in self.browse(cr, uid, ids, context): self.write(cr, uid, [proj.id], {'state': value and 'open' or 'template'}, context) cr.execute('select id from project_task where project_id=%s', (proj.id,)) tasks_id = [x[0] for x in cr.fetchall()] if tasks_id: self.pool.get('project.task').write(cr, uid, tasks_id, {'active': value}, context) child_ids = self.search(cr, uid, [('parent_id','=', proj.id)]) if child_ids: self.setActive(cr, uid, child_ids, value, context) return True
468,547
def write(self, cr, uid, ids, vals, context=None): res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context) account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') for statement in self.browse(cr, uid, ids, context): seq = 0 for line in statement.line_ids: seq += 1 if not line.sequence: account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context) return res
def write(self, cr, uid, ids, vals, context=None): res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context) account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') for statement in self.browse(cr, uid, ids, context): seq = 0 for line in statement.line_ids: seq += 1 account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context) return res
468,548
def get_next_st_line_number(self, cr, uid, st_number, st_line, context=None): return st_number + ' - ' + str(st_line.sequence)
def get_next_st_line_number(self, cr, uid, st_number, st_line, context=None): return st_number + ' - ' + str(st_line.sequence)
468,549
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
def onchange_type(self, cr, uid, line_id, partner_id, type, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
468,550
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cr, uid, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
468,551
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cr, uid, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
468,552
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
468,553
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
468,554
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
468,555
def create(self, cr, user, vals, context={}): """ Create a new record for a model idea_idea @param cr: A database cursor @param user: ID of the user currently logged in @param vals: provides data for new record @param context: context arguments, like lang, time zone
defcreate(self,cr,user,vals,context={}):"""Createanewrecordforamodelidea_idea@paramcr:Adatabasecursor@paramuser:IDoftheusercurrentlyloggedin@paramvals:providesdatafornewrecord@paramcontext:contextarguments,likelang,timezone
468,556
def create(self, cr, user, vals, context={}): """ Create a new record for a model idea_idea @param cr: A database cursor @param user: ID of the user currently logged in @param vals: provides data for new record @param context: context arguments, like lang, time zone
defcreate(self,cr,user,vals,context={}):"""Createanewrecordforamodelidea_idea@paramcr:Adatabasecursor@paramuser:IDoftheusercurrentlyloggedin@paramvals:providesdatafornewrecord@paramcontext:contextarguments,likelang,timezone
468,557
def write(self, cr, user, ids, vals, context=None): """ Update redord(s) exist in {ids}, with new value provided in {vals}
def visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) write(self, visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) cr, visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) user, visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) ids, visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) vals, visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) context=None): visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) """ visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) Update visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) redord(s) visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) exist visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) in visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) {ids}, visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) with visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) new visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) value visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) provided visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) in visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) {vals}
468,558
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form' usage = rec.get('usage','').encode('utf-8') limit = rec.get('limit','').encode('utf-8') auto_refresh = rec.get('auto_refresh','').encode('utf-8') uid = self.uid # def ref() added because , if context has ref('id') eval wil use this ref
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form' usage = rec.get('usage','').encode('utf-8') limit = rec.get('limit','').encode('utf-8') auto_refresh = rec.get('auto_refresh','').encode('utf-8') uid = self.uid # def ref() added because , if context has ref('id') eval wil use this ref
468,559
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form' usage = rec.get('usage','').encode('utf-8') limit = rec.get('limit','').encode('utf-8') auto_refresh = rec.get('auto_refresh','').encode('utf-8') uid = self.uid # def ref() added because , if context has ref('id') eval wil use this ref
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form' usage = rec.get('usage','').encode('utf-8') limit = rec.get('limit','').encode('utf-8') auto_refresh = rec.get('auto_refresh','').encode('utf-8') uid = self.uid # def ref() added because , if context has ref('id') eval wil use this ref
468,560
def create_ics(self, cr, uid, datas, name, ical, context=None): """ create calendaring and scheduling information @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """
def create_ics(self, cr, uid, datas, name, ical, context=None): """ create calendaring and scheduling information @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """
468,561
def export_cal(self, cr, uid, datas, vobj=None, context=None): """ Export Calendar @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 datas: Get Data's for caldav @param context: A standard dictionary for contextual values """
defexport_cal(self,cr,uid,datas,vobj=None,context=None):"""ExportCalendar@paramself:Theobjectpointer@paramcr:thecurrentrow,fromthedatabasecursor,@paramuid:thecurrentuser’sIDforsecuritychecks,@paramdatas:GetData'sforcaldav@paramcontext:Astandarddictionaryforcontextualvalues"""
468,562
def get_calendar_objects(self, cr, uid, ids, parent=None, domain=None, context=None): if not context: context = {} if not domain: domain = [] res = [] ctx_res_id = context.get('res_id', None) ctx_model = context.get('model', None) for cal in self.browse(cr, uid, ids): for line in cal.line_ids: if ctx_model and ctx_model != line.object_id.model: continue if line.name in ('valarm', 'attendee'): continue line_domain = eval(line.domain or '[]') line_domain += domain if ctx_res_id: line_domain += [('id','=',ctx_res_id)] mod_obj = self.pool.get(line.object_id.model) data_ids = mod_obj.search(cr, uid, line_domain, context=context) for data in mod_obj.browse(cr, uid, data_ids, context): ctx = parent and parent.context or None node = res_node_calendar('%s.ics' %data.id, parent, ctx, data, line.object_id.model, data.id) res.append(node) return res
def get_calendar_objects(self, cr, uid, ids, parent=None, domain=None, context=None): if not context: context = {} if not domain: domain = [] res = [] ctx_res_id = context.get('res_id', None) ctx_model = context.get('model', None) for cal in self.browse(cr, uid, ids): for line in cal.line_ids: if ctx_model and ctx_model != line.object_id.model: continue if line.name in ('valarm', 'attendee'): continue line_domain = eval(line.domain or '[]') line_domain += domain if ctx_res_id: line_domain += [('id','=',ctx_res_id)] mod_obj = self.pool.get(line.object_id.model) data_ids = mod_obj.search(cr, uid, line_domain, order="id", context=context) for data in mod_obj.browse(cr, uid, data_ids, context): ctx = parent and parent.context or None node = res_node_calendar('%s.ics' %data.id, parent, ctx, data, line.object_id.model, data.id) res.append(node) return res
468,563
def export_cal(self, cr, uid, ids, vobj='vevent', context=None): """ Export Calendar @param ids: List of calendar’s IDs @param vobj: the type of object to export @return the ical data. """ if not context: context = {} ctx_model = context.get('model', None) ctx_res_id = context.get('res_id', None) ical = vobject.iCalendar() for cal in self.browse(cr, uid, ids): for line in cal.line_ids: if ctx_model and ctx_model != line.object_id.model: continue if line.name in ('valarm', 'attendee'): continue domain = eval(line.domain or '[]') if ctx_res_id: domain += [('id','=',ctx_res_id)] mod_obj = self.pool.get(line.object_id.model) data_ids = mod_obj.search(cr, uid, domain, context=context) datas = mod_obj.read(cr, uid, data_ids, context=context) context.update({'model': line.object_id.model, 'calendar_id': cal.id }) self.__attribute__ = get_attribute_mapping(cr, uid, line.name, context) self.create_ics(cr, uid, datas, line.name, ical, context=context) return ical.serialize()
defexport_cal(self,cr,uid,ids,vobj='vevent',context=None):"""ExportCalendar@paramids:Listofcalendar’sIDs@paramvobj:thetypeofobjecttoexport@returntheicaldata."""ifnotcontext:context={}ctx_model=context.get('model',None)ctx_res_id=context.get('res_id',None)ical=vobject.iCalendar()forcalinself.browse(cr,uid,ids):forlineincal.line_ids:ifctx_modelandctx_model!=line.object_id.model:continueifline.namein('valarm','attendee'):continuedomain=eval(line.domainor'[]')ifctx_res_id:domain+=[('id','=',ctx_res_id)]mod_obj=self.pool.get(line.object_id.model)data_ids=mod_obj.search(cr,uid,domain,context=context)datas=mod_obj.read(cr,uid,data_ids,context=context)context.update({'model':line.object_id.model,'calendar_id':cal.id})self.__attribute__=get_attribute_mapping(cr,uid,line.name,context)self.create_ics(cr,uid,datas,line.name,ical,context=context)returnical.serialize()
468,564
def import_cal(self, cr, uid, content, data_id=None, context=None): """ Import Calendar @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 data_id: Get Data’s ID or False @param context: A standard dictionary for contextual values """
defimport_cal(self,cr,uid,content,data_id=None,context=None):"""ImportCalendar@paramself:Theobjectpointer@paramcr:thecurrentrow,fromthedatabasecursor,@paramuid:thecurrentuser’sIDforsecuritychecks,@paramdata_id:GetData’sIDorFalse@paramcontext:Astandarddictionaryforcontextualvalues"""
468,565
def get_children(self,uri, filters=None): """ return the child objects as self.baseuris for the given URI """ self.parent.log_message('get children: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri, allow_last=True)
def get_childs(self,uri, filters=None): """ return the child objects as self.baseuris for the given URI """ self.parent.log_message('get children: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri, allow_last=True)
468,566
def doIndex(self,content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None if content_type and self.mimes.has_key(content_type): mime = content_type fobj = self.mimes[content_type] elif filename: bname,ext = os.path.splitext(filename) if self.exts.has_key(ext): fobj = self.exts[ext] mime = fobj._getDefMime(ext) if content_type and not fobj: mime,fobj = mime_match(content_type, self.mimes) if not fobj: try: if realfname : fname = realfname else: bname,ext = os.path.splitext(filename) fd, fname = tempfile.mkstemp(suffix=ext) os.write(fd, content) os.close(fd) #fp = Popen(['file','-b','--mime-type',fname], shell=False, stdout=PIPE).stdout fp = Popen(['file','-b',fname], shell=False, stdout=PIPE).stdout result = fp.read() fp.close() mime2 = result.strip() self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. mime,fobj = mime_match(mime2, self.mimes) if not mime: mime = mime2 except Exception: self.__logger.exception('Cannot determine mime type') try: if fobj: res = (mime, fobj.indexContent(content,filename,fname or realfname) ) else: self.__logger.debug("Have no object, return (%s, None)", mime) res = (mime, None ) except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname) res = None # If we created a tmp file, unlink it now if not realfname and fname: try: os.unlink(fname) except Exception: self.__logger.exception("Could not unlink %s", fname) return res
def doIndex(self,content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None if content_type and self.mimes.has_key(content_type): mime = content_type fobj = self.mimes[content_type] elif filename: bname,ext = os.path.splitext(filename) if self.exts.has_key(ext): fobj = self.exts[ext] mime = fobj._getDefMime(ext) if content_type and not fobj: mime,fobj = mime_match(content_type, self.mimes) if not fobj: try: if realfname : fname = realfname else: bname,ext = os.path.splitext(filename) fd, fname = tempfile.mkstemp(suffix=ext) os.write(fd, content) os.close(fd) #fp = Popen(['file','-b','--mime-type',fname], shell=False, stdout=PIPE).stdoutfp = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE).stdout result = fp.read() fp.close() mime2 = result.strip() self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. mime,fobj = mime_match(mime2, self.mimes) if not mime: mime = mime2 except Exception: self.__logger.exception('Cannot determine mime type') try: if fobj: res = (mime, fobj.indexContent(content,filename,fname or realfname) ) else: self.__logger.debug("Have no object, return (%s, None)", mime) res = (mime, None ) except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname) res = None # If we created a tmp file, unlink it now if not realfname and fname: try: os.unlink(fname) except Exception: self.__logger.exception("Could not unlink %s", fname) return res
468,567
def doIndex(self,content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None if content_type and self.mimes.has_key(content_type): mime = content_type fobj = self.mimes[content_type] elif filename: bname,ext = os.path.splitext(filename) if self.exts.has_key(ext): fobj = self.exts[ext] mime = fobj._getDefMime(ext) if content_type and not fobj: mime,fobj = mime_match(content_type, self.mimes) if not fobj: try: if realfname : fname = realfname else: bname,ext = os.path.splitext(filename) fd, fname = tempfile.mkstemp(suffix=ext) os.write(fd, content) os.close(fd) #fp = Popen(['file','-b','--mime-type',fname], shell=False, stdout=PIPE).stdout fp = Popen(['file','-b',fname], shell=False, stdout=PIPE).stdout result = fp.read() fp.close() mime2 = result.strip() self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. mime,fobj = mime_match(mime2, self.mimes) if not mime: mime = mime2 except Exception: self.__logger.exception('Cannot determine mime type') try: if fobj: res = (mime, fobj.indexContent(content,filename,fname or realfname) ) else: self.__logger.debug("Have no object, return (%s, None)", mime) res = (mime, None ) except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname) res = None # If we created a tmp file, unlink it now if not realfname and fname: try: os.unlink(fname) except Exception: self.__logger.exception("Could not unlink %s", fname) return res
def doIndex(self,content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None if content_type and self.mimes.has_key(content_type): mime = content_type fobj = self.mimes[content_type] elif filename: bname,ext = os.path.splitext(filename) if self.exts.has_key(ext): fobj = self.exts[ext] mime = fobj._getDefMime(ext) if content_type and not fobj: mime,fobj = mime_match(content_type, self.mimes) if not fobj: try: if realfname : fname = realfname else: bname,ext = os.path.splitext(filename) fd, fname = tempfile.mkstemp(suffix=ext) os.write(fd, content) os.close(fd) #fp = Popen(['file','-b','--mime-type',fname], shell=False, stdout=PIPE).stdout fp = Popen(['file','-b',fname], shell=False, stdout=PIPE).stdout result = fp.read() fp.close() mime2 = result.split(';')[0] self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. mime,fobj = mime_match(mime2, self.mimes) if not mime: mime = mime2 except Exception: self.__logger.exception('Cannot determine mime type') try: if fobj: res = (mime, fobj.indexContent(content,filename,fname or realfname) ) else: self.__logger.debug("Have no object, return (%s, None)", mime) res = (mime, None ) except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname) res = None # If we created a tmp file, unlink it now if not realfname and fname: try: os.unlink(fname) except Exception: self.__logger.exception("Could not unlink %s", fname) return res
468,568
def _is_template(self, cr, uid, ids, field_name, arg, context=None): res = {} for task in self.browse(cr, uid, ids, context=context): res[task.id] = True if task.project_id: if task.project_id.active == False or task.project_id.state == 'template': res[task.id] = False return res
def _is_template(self, cr, uid, ids, field_name, arg, context=None): res = {} for task in self.browse(cr, uid, ids, context=context): res[task.id] = True if task.project_id: if task.project_id.active == False or task.project_id.state == 'template': res[task.id] = False return res
468,569
def generate(self, cr, uid, ids, datas={}, context={}): move_ids = [] for model in self.browse(cr, uid, ids, context): period_id = self.pool.get('account.period').find(cr,uid, context=context) if not period_id: raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] move_id = self.pool.get('account.move').create(cr, uid, { 'ref': model.ref, 'period_id': period_id, 'journal_id': model.journal_id.id, }) move_ids.append(move_id) for line in model.lines_id: val = { 'move_id': move_id, 'journal_id': model.journal_id.id, 'period_id': period_id } val.update({ 'name': line.name, 'quantity': line.quantity, 'debit': line.debit, 'credit': line.credit, 'account_id': line.account_id.id, 'move_id': move_id, 'ref': line.ref, 'partner_id': line.partner_id.id, 'date': time.strftime('%Y-%m-%d'), 'date_maturity': time.strftime('%Y-%m-%d') }) c = context.copy() c.update({'journal_id': model.journal_id.id,'period_id': period_id}) self.pool.get('account.move.line').create(cr, uid, val, context=c) return move_ids
def generate(self, cr, uid, ids, datas={}, context={}): move_ids = [] for model in self.browse(cr, uid, ids, context): period_id = self.pool.get('account.period').find(cr,uid, context=context) if not period_id: raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] move_id = self.pool.get('account.move').create(cr, uid, { 'ref': model.ref, 'period_id': period_id, 'journal_id': model.journal_id.id, }) move_ids.append(move_id) for line in model.lines_id: val = { 'move_id': move_id, 'journal_id': model.journal_id.id, 'period_id': period_id } val.update({ 'name': line.name, 'quantity': line.quantity, 'debit': line.debit, 'credit': line.credit, 'account_id': line.account_id.id, 'move_id': move_id, 'ref': line.ref, 'partner_id': line.partner_id.id, 'date': time.strftime('%Y-%m-%d'), 'date_maturity': time.strftime('%Y-%m-%d') }) c = context.copy() c.update({'journal_id': model.journal_id.id,'period_id': period_id}) self.pool.get('account.move.line').create(cr, uid, val, context=c) return move_ids
468,570
def create(self, cr, uid, vals, context=None): if not context: context = {} vals['title'] = vals['name'] vals['parent_id'] = context.get('parent_id', False) or vals.get('parent_id', False) if not vals['parent_id']: vals['parent_id'] = self.pool.get('document.directory')._get_root_directory(cr,uid, context) if not vals.get('res_id', False) and context.get('default_res_id', False): vals['res_id'] = context.get('default_res_id', False) if not vals.get('res_model', False) and context.get('default_res_model', False): vals['res_model'] = context.get('default_res_model', False) if vals.get('res_id', False) and vals.get('res_model', False): obj_model = self.pool.get(vals['res_model']) result = obj_model.read(cr, uid, [vals['res_id']], context=context) if len(result): obj = result[0] if obj.get('name', False): vals['title'] = (obj.get('name', ''))[:60] if obj_model._name == 'res.partner': vals['partner_id'] = obj['id'] elif obj.get('address_id', False): if isinstance(obj['address_id'], tuple) or isinstance(obj['address_id'], list): address_id = obj['address_id'][0] else: address_id = obj['address_id'] address = self.pool.get('res.partner.address').read(cr, uid, [address_id], context=context) if len(address): vals['partner_id'] = address[0]['partner_id'][0] or False elif obj.get('partner_id', False): if isinstance(obj['partner_id'], tuple) or isinstance(obj['partner_id'], list): vals['partner_id'] = obj['partner_id'][0] else: vals['partner_id'] = obj['partner_id']
def create(self, cr, uid, vals, context=None): if not context: context = {} vals['title'] = vals['name'] vals['parent_id'] = context.get('parent_id', False) or vals.get('parent_id', False) if not vals['parent_id']: vals['parent_id'] = self.pool.get('document.directory')._get_root_directory(cr,uid, context) if not vals.get('res_id', False) and context.get('default_res_id', False): vals['res_id'] = context.get('default_res_id', False) if not vals.get('res_model', False) and context.get('default_res_model', False): vals['res_model'] = context.get('default_res_model', False) if vals.get('res_id', False) and vals.get('res_model', False): obj_model = self.pool.get(vals['res_model']) result = obj_model.read(cr, uid, [vals['res_id']], ['name', 'partner_id', 'address_id'], context=context) if len(result): obj = result[0] if obj.get('name', False): vals['title'] = (obj.get('name', ''))[:60] if obj_model._name == 'res.partner': vals['partner_id'] = obj['id'] elif obj.get('address_id', False): if isinstance(obj['address_id'], tuple) or isinstance(obj['address_id'], list): address_id = obj['address_id'][0] else: address_id = obj['address_id'] address = self.pool.get('res.partner.address').read(cr, uid, [address_id], context=context) if len(address): vals['partner_id'] = address[0]['partner_id'][0] or False elif obj.get('partner_id', False): if isinstance(obj['partner_id'], tuple) or isinstance(obj['partner_id'], list): vals['partner_id'] = obj['partner_id'][0] else: vals['partner_id'] = obj['partner_id']
468,571
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default if ttype not in ('payment', 'receipt'): return default if not ids: raise osv.except_osv(_('Invalid !'), _('Please save voucher before selection partner !')) line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) voucher_id = ids[0] ids = move_pool.search(cr, uid, [('reconcile_id','=', False), ('state','=','posted'), ('partner_id','=',partner_id)], context=context) for move in move_pool.browse(cr, uid, ids): rs = { 'ref':move.ref or '/', 'move_id':move.id, 'voucher_id':voucher_id, } if ttype == 'payment': rs.update({ 'account_id':move.partner_id.property_account_payable.id, 'type':'dr', 'amount':move.amount }) elif ttype == 'receipt': rs.update({ 'account_id':move.partner_id.property_account_receivable.id, 'type':'cr', 'amount':move.amount }) line_id = line_pool.create(cr, uid, rs) res += [line_id] return { 'value':{'payment_ids':res}, 'context':context, }
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default if ttype not in ('payment', 'receipt'): return default voucher_id = ids and ids[0] or False ids = move_pool.search(cr, uid, [('reconcile_id','=', False), ('state','=','posted'), ('partner_id','=',partner_id)], context=context) for move in move_pool.browse(cr, uid, ids): rs = { 'ref':move.ref or '/', 'move_id':move.id, 'voucher_id':voucher_id, } if ttype == 'payment': rs.update({ 'account_id':move.partner_id.property_account_payable.id, 'type':'dr', 'amount':move.amount }) elif ttype == 'receipt': rs.update({ 'account_id':move.partner_id.property_account_receivable.id, 'type':'cr', 'amount':move.amount }) line_id = line_pool.create(cr, uid, rs) res += [line_id] return { 'value':{'payment_ids':res}, 'context':context, }
468,572
def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None): ''' context = { 'uom': Unit of Measure (int), 'partner': Partner ID (int), 'date': Date of the pricelist (%Y-%m-%d), } ''' context = context or {} currency_obj = self.pool.get('res.currency') product_obj = self.pool.get('product.product') supplierinfo_obj = self.pool.get('product.supplierinfo') price_type_obj = self.pool.get('product.price.type')
def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None): ''' context = { 'uom': Unit of Measure (int), 'partner': Partner ID (int), 'date': Date of the pricelist (%Y-%m-%d), } ''' context = context or {} currency_obj = self.pool.get('res.currency') product_obj = self.pool.get('product.product') supplierinfo_obj = self.pool.get('product.supplierinfo') price_type_obj = self.pool.get('product.price.type')
468,573
def execute(self, cr, uid, ids, context=None): obj_multi = self.browse(cr, uid, ids[0]) obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id company_id = obj_multi.company_id.id
def execute(self, cr, uid, ids, context=None): obj_multi = self.browse(cr, uid, ids[0]) obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id company_id = obj_multi.company_id.id
468,574
def execute(self, cr, uid, ids, context=None): obj_multi = self.browse(cr, uid, ids[0]) obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id company_id = obj_multi.company_id.id
def execute(self, cr, uid, ids, context=None): obj_multi = self.browse(cr, uid, ids[0]) obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id company_id = obj_multi.company_id.id
468,575
def selection_field(in_field): col_obj = self.pool.get(in_field.keys()[0]) if f[i] in col_obj._columns.keys(): return col_obj._columns[f[i]] elif f[i] in col_obj._inherits.keys(): selection_field(col_obj._inherits) else: return False
def selection_field(in_field): col_obj = self.pool.get(in_field.keys()[0]) if f[i] in col_obj._columns.keys(): return col_obj._columns[f[i]] elif f[i] in col_obj._inherits.keys(): selection_field(col_obj._inherits) else: return False
468,576
def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product based on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = []
defaction_produce(self,cr,uid,production_id,production_qty,production_mode,context=None):"""Toproducefinalproductbasedonproductionmode(consume/consume&produce).IfProductionmodeisconsume,allstockmovelinesofrawmaterialswillbedone/consumed.IfProductionmodeisconsume&produce,allstockmovelinesofrawmaterialswillbedone/consumedandstockmovelinesoffinalproductwillbealsodone/produced.@paramproduction_id:theIDofmrp.productionobject@paramproduction_qty:specifyqtytoproduce@paramproduction_mode:specifyproductionmode(consume/consume&produce).@return:True"""stock_mov_obj=self.pool.get('stock.move')production=self.browse(cr,uid,production_id)raw_product_todo=[]final_product_todo=[]
468,577
def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product based on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = []
def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product based on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = []
468,578
def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product based on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = []
def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product based on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = []
468,579
def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product based on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = []
def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product based on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = []
468,580
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context'])
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 0.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context'])
468,581
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context'])
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context'])
468,582
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context'])
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context'])
468,583
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context)
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context)
468,584
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context)
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context)
468,585
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context)
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) for fld in ('product_id', 'general_account_id', 'journal_id', 'product_uom_id'): if result.get(fld, False): vals_line[fld] = result[fld] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context)
468,586
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context)
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context)
468,587
def unlink(self, cr, uid, ids, *args, **kwargs): pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id']
def unlink(self, cr, uid, ids, *args, **kwargs): pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id']
468,588
def unlink(self, cr, uid, ids, *args, **kwargs): pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id']
def unlink(self, cr, uid, ids, *args, **kwargs): pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id']
468,589
def unlink(self, cr, uid, ids, *args, **kwargs): pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id']
def unlink(self, cr, uid, ids, *args, **kwargs): pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id']
468,590
def _lang_get(self, cr, uid, context={}): """ Get language for language selection field. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values @return: list of dictionary which contain code and name and id. """ obj = self.pool.get('res.lang') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['code', 'name'], context=context) res = [((r['code']).replace('_', '-').lower(), r['name']) for r in res] return res
def _lang_get(self, cr, uid, context=None): """ Get language for language selection field. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values @return: list of dictionary which contain code and name and id. """ obj = self.pool.get('res.lang') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['code', 'name'], context=context) res = [((r['code']).replace('_', '-').lower(), r['name']) for r in res] return res
468,591
def _tz_get(self, cr, uid, context={}): return [(x.lower(), x) for x in pytz.all_timezones]
def _tz_get(self, cr, uid, context=None): return [(x.lower(), x) for x in pytz.all_timezones]
468,592
def onchange_allday(self, cr, uid, ids, allday, context={}): """Sets duration as 24 Hours if event is selcted for all day @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 calendar event’s IDs. @param allday: Value of allday boolean @param context: A standard dictionary for contextual values """ if not allday or not ids: return {} event = self.browse(cr, uid, ids, context=context)[0] value = { 'duration': 24 } return {'value': value}
def onchange_allday(self, cr, uid, ids, allday, context=None): """Sets duration as 24 Hours if event is selcted for all day @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 calendar event’s IDs. @param allday: Value of allday boolean @param context: A standard dictionary for contextual values """ if not allday or not ids: return {} event = self.browse(cr, uid, ids, context=context)[0] value = { 'duration': 24 } return {'value': value}
468,593
def browse(self, cr, uid, ids, context=None, list_class=None, fields_process={}): """ Overrides orm browse method. @param self: the object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm meeting's ids @param context: A standard dictionary for contextual values @return: the object list. """ if isinstance(ids, (str, int, long)): select = [ids] else: select = ids select = map(lambda x: base_calendar_id2real_id(x), select) res = super(calendar_event, self).browse(cr, uid, select, context, \ list_class, fields_process) if isinstance(ids, (str, int, long)): return res and res[0] or False
def browse(self, cr, uid, ids, context=None, list_class=None, fields_process=None): """ Overrides orm browse method. @param self: the object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm meeting's ids @param context: A standard dictionary for contextual values @return: the object list. """ if isinstance(ids, (str, int, long)): select = [ids] else: select = ids select = map(lambda x: base_calendar_id2real_id(x), select) res = super(calendar_event, self).browse(cr, uid, select, context, \ list_class, fields_process) if isinstance(ids, (str, int, long)): return res and res[0] or False
468,594
def _lines_p(self, date1, date2): res = [] acc_obj = self.pool.get('account.account')
def _lines_p(self, date1, date2): res = [] acc_obj = self.pool.get('account.account')
468,595
def _lines_p(self, date1, date2): res = [] acc_obj = self.pool.get('account.account')
def _lines_p(self, date1, date2): res = [] acc_obj = self.pool.get('account.account')
468,596
def log_picking(self, cr, uid, ids, context=None): """ This function will create log messages for picking. @param cr: the database cursor @param uid: the current user's ID for security checks, @param ids: List of Picking Ids @param context: A standard dictionary for contextual values """ for pick in self.browse(cr, uid, ids, context=context): type_list = { 'out':'Picking List', 'in':'Reception', 'internal': 'Internal picking', 'delivery': 'Delivery order' } message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or 'n/a') + "' " state_list = { 'confirmed': "is scheduled for the '" + datetime.strptime(pick.min_date, '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d') + "'.", 'assigned': 'is ready to process.', 'cancel': 'is Cancelled.', 'done': 'is processed.', 'draft':'is draft.', } message += state_list[pick.state] self.log(cr, uid, pick.id, message) return True
def log_picking(self, cr, uid, ids, context=None): """ This function will create log messages for picking. @param cr: the database cursor @param uid: the current user's ID for security checks, @param ids: List of Picking Ids @param context: A standard dictionary for contextual values """ for pick in self.browse(cr, uid, ids, context=context): type_list = { 'out':'Picking List', 'in':'Reception', 'internal': 'Internal picking', 'delivery': 'Delivery order' } message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or 'n/a') + "' " state_list = { 'confirmed': "is scheduled for the '" + msg , 'assigned': 'is ready to process.', 'cancel': 'is Cancelled.', 'done': 'is processed.', 'draft':'is draft.', } message += state_list[pick.state] self.log(cr, uid, pick.id, message) return True
468,597
def __init__(self, nodes, localcontext): self.localcontext = localcontext self.styles = {} self.names = {} self.table_styles = {} for node in nodes: for style in node.findall('blockTableStyle'): self.table_styles[style.get('id')] = self._table_style_get(style) for style in node.findall('paraStyle'): self.styles[style.get('name')] = self._para_style_update(style) for variable in node.findall('initialize'): for name in variable.findall('name'): self.names[ name.get('id')] = name.get('value')
def __init__(self, nodes, localcontext): self.localcontext = localcontext self.styles = {} self.names = {} self.table_styles = {} for node in nodes: for style in node.findall('blockTableStyle'): self.table_styles[style.get('id')] = self._table_style_get(style) for style in node.findall('paraStyle'): sname = style.get('name') self.styles[sname] = self._para_style_update(style) self.styles_obj[sname] = reportlab.lib.styles.ParagraphStyle(sname, self.default_style["Normal"], **self.styles[sname]) for variable in node.findall('initialize'): for name in variable.findall('name'): self.names[ name.get('id')] = name.get('value')
468,598
def para_style_get(self, node): style = False if node.get('style'): if node.get('style') in self.styles: styles = reportlab.lib.styles.getSampleStyleSheet() sname = node.get('style') style = reportlab.lib.styles.ParagraphStyle(sname, styles["Normal"], **self.styles[sname]) else: sys.stderr.write('Warning: style not found, %s - setting default!\n' % (node.get('style'),) ) if not style: styles = reportlab.lib.styles.getSampleStyleSheet() style = styles['Normal'] style.__dict__.update(self._para_style_update(node)) return style
def para_style_get(self, node): style = False sname = node.get('style') if sname: if sname in self.styles_obj: style = self.styles_obj[sname] else: sys.stderr.write('Warning: style not found, %s - setting default!\n' % (node.get('style'),) ) if not style: styles = reportlab.lib.styles.getSampleStyleSheet() style = styles['Normal'] style.__dict__.update(self._para_style_update(node)) return style
468,599