rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
context)['object_name']
context)['object_name'] or False
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: OpenERP Context """ return self.pool.get('email.template').read( cursor, user, context['template_id'], ['object_name'], context)['object_name...
'ref_template': lambda self, cr, uid, ctx:ctx['template_id'],
'ref_template': lambda self, cr, uid, ctx:ctx['template_id'] or False,
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: OpenERP Context """ return self.pool.get('email.template').read( cursor, user, context['template_id'], ['object_name'], context)['object_name...
'name': _("%s Mail Form") % template_obj.name,
'name': template_obj.name,
def create_action(self, cr, uid, ids, context): vals = {} template_obj = self.browse(cr, uid, ids)[0] src_obj = template_obj.object_name.model vals['ref_ir_act_window'] = self.pool.get('ir.actions.act_window').create(cr, uid, { 'name': _("%s Mail Form") % template_obj.name, 'type': 'ir.actions.act_window', 'res_model':...
'amount': fields.float('Amount'),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
def onchange_type(self, cr, uid, line_id, partner_id, type, context=None): 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_pa...
class contentIndex() :
class contentIndex(): __logger = logging.getLogger('addons.document.content_index')
def mime_match(mime, mdict): if mdict.has_key(mime): return (mime, mdict[mime]) if '/' in mime: mpat = mime.split('/')[0]+'/*' if mdict.has_key(mpat): return (mime, mdict[mpat]) return (None, None)
log(netsvc.LOG_DEBUG, "Register content indexer: %r" % obj)
self.__logger.debug('Register content indexer: %s', obj)
def register(self, obj): f = False for mime in obj._getMimeTypes(): self.mimes[mime] = obj f = True for ext in obj._getExtensions(): self.exts[ext] = obj f = True if f: log(netsvc.LOG_DEBUG, "Register content indexer: %r" % obj) if not f: raise Exception("Your indexer should at least suport a mimetype or extension")
log(netsvc.LOG_DEBUG,"File gave us: %s" % mime2)
self.__logger.debug('File gave us: %s', mime2)
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...
except Exception, e: log(netsvc.LOG_WARNING,"Cannot determine mime type: %s" % str(e))
except Exception: self.__logger.exception('Cannot determine mime type')
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...
log(netsvc.LOG_DEBUG,"Have no object, return (%s, None)" % mime)
self.__logger.debug("Have no object, return (%s, None)", mime)
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...
except Exception, e: log(netsvc.LOG_WARNING,"Could not index file, %s" % e)
except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname)
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...
except Exception, e: log(netsvc.LOG_WARNING,"Could not unlink %s, %s" %(fname, e))
except Exception: self.__logger.exception("Could not unlink %s", fname)
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...
'section_id' : case.section_id and case.section_id or False,
'section_id' : case.section_id and case.section_id.id or False,
def _default_values(self, cr, uid, data, context): case_obj = pooler.get_pool(cr.dbname).get('crm.opportunity') categ_id = pooler.get_pool(cr.dbname).get('crm.phonecall.categ').search(cr, uid, [('name','=','Outbound')]) case = case_obj.browse(cr, uid, data['id']) return { 'user_id' : case.user_id and case.user_id.id, '...
date_local = cal_data.value.astimezone(_server_tzinfo) self.ical_set(cal_data.name.lower(), date_local, 'value')
self.ical_set('vtimezone', cal_data.params.get('X-VOBJ-ORIGINAL-TZID'), 'value') date_utc = cal_data.value.astimezone(pytz.utc) self.ical_set(cal_data.name.lower(), date_utc, 'value')
def parse_ics(self, cr, uid, child, cal_children=None, context=None): """ parse 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 ...
self.ids[(rec[3], result)] = id
self.ids[(rec[2], result)] = id
def _generate_object_xml(self, cr, uid, rec, recv, doc, result=None): record_list = [] noupdate = False if rec[4]=='write': for id in rec[5]: id,update = self._get_id(cr, uid, rec[3], id) noupdate = noupdate or update if not id: continue record,update = self._create_record(cr, uid, doc, rec[3], rec[6], id) noupdate = n...
wkf.setAttribute("model", rec[1][3]) wkf.setAttribute("action", rec[1][4])
wkf.setAttribute("model", rec[1][2]) wkf.setAttribute("action", rec[1][3])
def generate_xml(self, cr, uid): # Create the minidom document if len(self.recording_data): self.ids = {} doc = minidom.Document() terp = doc.createElement("openerp") doc.appendChild(terp) for rec in self.recording_data: if rec[0]=='workflow': rec_id,noupdate = self._get_id(cr, uid, rec[1][2], rec[1][4]) if not rec_id:...
yaml_file += str(object) + '''\n'''
yaml_file += str(object) + '''\n\n'''
def generate_yaml(self, cr, uid): self.ids = {} if len(self.recording_data): yaml_file='''\n''' for rec in self.recording_data: if rec[1][3] == 'create': self.mode="create" elif rec[1][3] == 'write': self.mode="write" elif rec[1][3] == 'copy': self.mode="copy" elif rec[0] == 'workflow': self.mode="workflow" else: cont...
line = "- \n" + " " + line
line = "- \n" + " " + line elif line.find('!comment') == 0: line=line.replace('!comment','- \n ')
def generate_yaml(self, cr, uid): self.ids = {} if len(self.recording_data): yaml_file='''\n''' for rec in self.recording_data: if rec[1][3] == 'create': self.mode="create" elif rec[1][3] == 'write': self.mode="write" elif rec[1][3] == 'copy': self.mode="copy" elif rec[0] == 'workflow': self.mode="workflow" else: cont...
amount2 = data['amount']
amount2 = data.get('amount', 0.0)
def _unit_compute(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None, quantity=0): taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner) res = [] cur_price_unit=price_unit for tax in taxes: # we compute the amount for the current tax object and append it to the re...
print 'Error'
def geo_find(addr): import urllib,re regex = '<coordinates>([+-]?[0-9\.]+),([+-]?[0-9\.]+),([+-]?[0-9\.]+)</coordinates>' url = 'http://maps.google.com/maps/geo?q=' + urllib.quote(addr) + '&output=xml&oe=utf8&sensor=false' xml = urllib.urlopen(url).read() if '<error>' in xml: print 'Error' return None result = re.searc...
print 'No Regex', xml
def geo_find(addr): import urllib,re regex = '<coordinates>([+-]?[0-9\.]+),([+-]?[0-9\.]+),([+-]?[0-9\.]+)</coordinates>' url = 'http://maps.google.com/maps/geo?q=' + urllib.quote(addr) + '&output=xml&oe=utf8&sensor=false' xml = urllib.urlopen(url).read() if '<error>' in xml: print 'Error' return None result = re.searc...
}, {'active_id': lead.id, 'active_ids': [lead.id]})
}, context) fobj.action_forward(cr, uid, [forward], context)
def forward_to_partner(self, cr, uid, ids, context=None): fobj = self.pool.get('crm.lead.forward.to.partner') for lead in self.browse(cr, uid, ids, context=context): if lead.partner_assigned_id: email = False if lead.partner_assigned_id.address: email = lead.partner_assigned_id.address[0].email forward = fobj.create(cr...
msg['From'] = tools.ustr(self.server[serverid]['from_email'])
if context.get('email_from', self.server[serverid]['from_email']): msg['From'] = context.get('email_from', self.server[serverid]['from_email']) elif tools.config['email_from']: msg['From'] = tools.config['email_from'] else: raise osv.except_osv(_('Error'), _("Please specify server option --email-from !"))
def test_verify_email(self, cr, uid, ids, toemail, test=False, code=False): serverid = ids[0] self.open_connection(cr, uid, ids, serverid) key = False if test and self.server[serverid]['state'] == 'confirm': body = self.server[serverid]['test_email'] or '' else: body = self.server[serverid]['verify_email'] or '' #ign...
msg['From'] = context.get('email_from', smtp_server.from_email)
print "::context.get('email_from', smtp_server.from_email):::",context.get('email_from', smtp_server.from_email) print "::TOOOLL::",tools.config['email_from'] if context.get('email_from', smtp_server.from_email): msg['From'] = context.get('email_from', smtp_server.from_email) elif tools.config['email_from']: msg['From'...
def createReport(cr, uid, report, ids, name=False): files = [] for id in ids: try: service = netsvc.LocalService(report) (result, format) = service.create(cr, uid, [id], {}, {}) if not name: report_file = '/tmp/reports'+ str(id) + '.pdf' else: report_file = name fp = open(report_file,'wb+') fp.write(result); fp.close(...
template = self.browse(cursor, user, template_id, context=ctx)
template = self.browse(cursor, user, template.id, context=ctx)
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None): """ Generates an email from the template for record record_id of target object @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for ...
self._generate_attach_reports(
self.generate_attach_reports(
def generate_mail(self, cursor, user, template_id, record_ids, context=None): if context is None: context = {} template = self.browse(cursor, user, template_id, context=context) if not template: raise Exception("The requested template could not be loaded") print 'loaded', record_ids result = True for record_id in recor...
acc_variation = accounts['property_stock_variation']
acc_variation = accounts.get('property_stock_variation', False)
def _get_accounting_values(self, cr, uid, move, context=None): product_obj=self.pool.get('product.product') product_uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') accounts = product_obj.get_product_accounts(cr,uid,move.product_id.id,context) acc_src = accounts['stock_account...
"WHERE partner_id = %s " \
"WHERE l.partner_id = %s " \
def _get_intial_balance(self, partner): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted']
"WHERE partner_id = %s" \
"WHERE l.partner_id = %s" \
def _sum_debit_partner(self, partner): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted']
"WHERE partner_id = %s" \
"WHERE l.partner_id = %s" \
def _sum_credit_partner(self, partner): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted']
for inv in inv_obj.browse(cr, uid, context['active_ids'], context=context):
company = self.pool.get('res.users').browse(cr, uid, uid).company_id for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
def compute_refund(self, cr, uid, ids, mode='refund', context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: the account invoice refund’s ID or list of IDs
cr.execute("""SELECT id from account_period where date(%s) between date_start AND date_stop \ and company_id = %s limit 1 """, (date, self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id,))
cr.execute("""select p.id, p.name from account_fiscalyear y, account_period p where y.id=p.fiscalyear_id \ and date(%s) between p.date_start AND p.date_stop and y.company_id = %s limit 1""", (date, company.id,))
def compute_refund(self, cr, uid, ids, mode='refund', context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: the account invoice refund’s ID or list of IDs
return context['move_line'][0][2] and context['move_line'][0][2]['location_dest_id'] or False
return context['move_line'][0][2] and context['move_line'][0][2].get('location_dest_id',False)
def _default_location_destination(self, cr, uid, context=None): """ Gets default address of partner for destination location @return: Address id or False """ if context.get('move_line', []): if context['move_line'][0]: if isinstance(context['move_line'][0], (tuple, list)): return context['move_line'][0][2] and context[...
if not context:
if context is None:
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: args=[] if not context: context={} ids = [] if name: ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit) if not ids: ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) retu...
ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit)
ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit, context=context)
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: args=[] if not context: context={} ids = [] if name: ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit) if not ids: ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) retu...
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit)
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: args=[] if not context: context={} ids = [] if name: ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit) if not ids: ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) retu...
res['fields']['qty_available']['string'] = _('P&L Qty')
if fields.get('qty_available'): res['fields']['qty_available']['string'] = _('P&L Qty')
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(product_product,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) if context == None: context = {} if ('location' in context) and context['location']: l...
if ('name' not in default) or (picking_obj.get('name')=='/'):
if ('name' not in default) or (picking_obj.name=='/'):
def copy(self, cr, uid, id, default=None, context={}): if default is None: default = {} default = default.copy() picking_obj = self.browse(cr, uid, [id], context)[0] if ('name' not in default) or (picking_obj.get('name')=='/'): seq_obj_name = 'stock.picking.' + picking_obj.type default['name'] = self.pool.get('ir.sequ...
new_end_date = date(*time.strptime(vals['date'],'%Y-%m-%d')[:3])
if isinstance(vals['date'], datetime): new_end_date = vals['date'].date() elif isinstance(vals['date'], date): new_end_date = vals['date'] else: new_end_date = date(*time.strptime(vals['date'],'%Y-%m-%d')[:3])
def write(self, cr, uid, ids, vals, *args, **kwargs): if isinstance(ids, (int, long)): ids = [ids] if vals.get('date', False): data_project = self.browse(cr, uid, ids) for prj in data_project: new_end_date = date(*time.strptime(vals['date'],'%Y-%m-%d')[:3]) if prj.date: old_end_date = date(*time.strptime(prj.date,'%Y-%...
res_id = email_tool.process_email(cr, uid, server.object_id.model, data[0][1], attach=server.attach, context=context)
res_id = email_tool.process_email(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context)
def fetch_mail(self, cr, uid, ids, context={}): email_tool = self.pool.get('email.server.tools') action_pool = self.pool.get('ir.actions.server') context.update({'get_server': True}) for server in self.browse(cr, uid, ids, context): count = 0 try: if server.type == 'imap': imap_server = self.button_confirm_login(cr, ui...
res_id = email_tool.process_email(cr, uid, server.object_id.model, msg, attach=server.attach, context=context)
res_id = email_tool.process_email(cr, user, server.object_id.model, msg, attach=server.attach, context=context)
def fetch_mail(self, cr, uid, ids, context={}): email_tool = self.pool.get('email.server.tools') action_pool = self.pool.get('ir.actions.server') context.update({'get_server': True}) for server in self.browse(cr, uid, ids, context): count = 0 try: if server.type == 'imap': imap_server = self.button_confirm_login(cr, ui...
<separator colspan="4">
<separator colspan="4"/>
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): result = super(stock_partial_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) move_obj = self.pool.get('stock.move') move_ids = context.get('active_ids', False) move_ids = mov...
'section_id' : case.section_id and case.section_id.id or False,
def _default_values(self, cr, uid, data, context):
'section_id' : form['section_id'],
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'crm', 'view_crm_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('crm.phonecall') job_case_obj = poo...
def check(db, uid, passwd): if security._uid_cache.has_key( uid ) and (security._uid_cache[uid]==passwd):
def check_creds(db, uid, passwd): if security._uid_cache.get(db, {}).get(uid) and security._uid_cache.get(db, {}).get(uid) == passwd:
def check(db, uid, passwd): if security._uid_cache.has_key( uid ) and (security._uid_cache[uid]==passwd): return True cr = pooler.get_db(db).cursor() if passwd not in _salt_cache: cr.execute( 'select login from res_users where id=%s', (uid,) ) stored_login = cr.fetchone() if stored_login: stored_login = stored_login[0]...
raise Exception('AccessDenied')
raise security.ExceptionNoTb('AccessDenied')
def check(db, uid, passwd): if security._uid_cache.has_key( uid ) and (security._uid_cache[uid]==passwd): return True cr = pooler.get_db(db).cursor() if passwd not in _salt_cache: cr.execute( 'select login from res_users where id=%s', (uid,) ) stored_login = cr.fetchone() if stored_login: stored_login = stored_login[0]...
raise Exception('Bad username or password')
raise security.ExceptionNoTb('Bad username or password')
def access(db, uid, passwd, sec_level, ids): cr = pooler.get_db(db).cursor() salt = _salt_cache[passwd] cr.execute('select id from res_users where id=%s and password=%s', (uid, encrypt_md5( passwd, salt )) ) res = cr.fetchone() cr.close() if not res: raise Exception('Bad username or password') return res[0]
security.check=check
security.check_creds=check_creds
def access(db, uid, passwd, sec_level, ids): cr = pooler.get_db(db).cursor() salt = _salt_cache[passwd] cr.execute('select id from res_users where id=%s and password=%s', (uid, encrypt_md5( passwd, salt )) ) res = cr.fetchone() cr.close() if not res: raise Exception('Bad username or password') return res[0]
self.write(cr, uid, [res_id], {})
def create(self, cr, uid, vals, context=None): sql = [ ('journal_id', '=', vals['journal_id']), ('state', '=', 'open') ] open_jrnl = self.search(cr, uid, sql) if open_jrnl: raise osv.except_osv('Error', _('You can not have two open register for the same journal'))
term_id = False
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, currency_id=False, ttype=False, context={}): """price Returns a dict that contains new values and context @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context argume...
default['value'].update({ 'account_id':account_id, 'term_id':term_id })
default['value']['account_id'] = account_id
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, currency_id=False, ttype=False, context={}): """price Returns a dict that contains new values and context @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context argume...
case_obj = pooler.get_pool(cr.dbname).get('hr.applicant') categ_id=pooler.get_pool(cr.dbname).get('crm.case.categ').search(cr, uid, [('name','=','Outbound')]) case = case_obj.browse(cr, uid, data['id']) return { 'user_id' : case.user_id and case.user_id.id, 'category_id' : categ_id and categ_id[0] or case.categ_id and ...
def _get_note(self, cr, uid, context=None): case_obj = self.pool.get('hr.applicant') case = case_obj.browse(cr, uid, context['active_id']) return case.description or ''
def _default_values(self, cr, uid, data, context):
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter')
_defaults = { 'user_id': _date_user, 'category_id': _date_category, 'note': _get_note } def make_phonecall(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') job_case_obj = self.pool.get('hr.applicant') data_obj = self.pool.get('ir.model.data') phonecall_case_obj = self.pool.get('crm.phonecall...
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.g...
phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.get('hr.applicant')
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.g...
data_obj = pool.get('ir.model.data') id2 = data_obj._get_id(cr, uid, 'hr', 'hr_case_phone_tree_view') id3 = data_obj._get_id(cr, uid, 'hr', 'hr_case_phone_form_view')
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_tree_view') id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_form_view')
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.g...
for job in job_case_obj.browse(cr, uid, data['ids']):
for job in job_case_obj.browse(cr, uid, context['active_ids']):
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.g...
'section_id' : form['section_id'],
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.g...
if not job.case_id: vals.update({'phonecall_id' : new_phonecall.id})
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.g...
'res_model': 'hr.phonecall',
'res_model': 'crm.phonecall',
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.g...
states = { 'init': { 'actions': [_default_values], 'result': {'type': 'form', 'arch': case_form, 'fields': case_fields, 'state' : [('end', 'Cancel','gtk-cancel'),('order', 'Schedule Phone Call','gtk-go-forward')]} }, 'order': { 'actions': [], 'result': {'type': 'action', 'action': _doIt, 'state': 'end'} } }
job2phonecall()
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.g...
job2phonecall('hr.applicant.reschedule_phone_call') class job2meeting(wizard.interface): def _makeMeeting(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) job_case_obj = pool.get('hr.applicant') meeting_case_obj = pool.get('hr.meeting') for job in job_case_obj.browse(cr, uid, data['ids']): new_meeting...
def _doIt(self, cr, uid, data, context): form = data['form'] pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'hr', 'view_hr_case_phonecalls_filter') res = mod_obj.read(cr, uid, result, ['res_id']) phonecall_case_obj = pool.get('hr.phonecall') job_case_obj = pool.g...
assert not groupby or groupby in fields, "Fields in 'groupby' must appear in the list of fields to read (perhaps it's missing in the list view?)"
if groupby: assert not groupby or groupby in fields, "Fields in 'groupby' must appear in the list of fields to read (perhaps it's missing in the list view?)" groupby_def = self._columns.get(groupby) or (self._inherit_fields.get(groupby) and self._inherit_fields.get(groupby)[2]) assert groupby_def and groupby_def._class...
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False): """ Get the list of records in list view grouped by the given ``groupby`` fields
'product_id': fields.many2one('product.product', 'Product', required=True),
'product_id': fields.many2one('product.product', 'Product', required=True, states={'draft':[('readonly',False)]}, readonly=True),
def force_production(self, cr, uid, ids, *args): pick_obj = self.pool.get('stock.picking') pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)]) return True
'location_id': fields.many2one('stock.location', 'Location', required=True),
'location_id': fields.many2one('stock.location', 'Location', required=True, states={'draft':[('readonly',False)]}, readonly=True),
def force_production(self, cr, uid, ids, *args): pick_obj = self.pool.get('stock.picking') pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)]) return True
self.pool.get('purchase.requisition').write(cr, uid, [po.requisition_id.id], {'state':'close','date_end':time.strftime('%Y-%m-%d %H:%M:%S')})
self.pool.get('purchase.requisition').write(cr, uid, [po.requisition_id.id], {'state':'done','date_end':time.strftime('%Y-%m-%d %H:%M:%S')})
def wkf_confirm_order(self, cr, uid, ids, context={}): res = super(purchase_order, self).wkf_confirm_order(cr, uid, ids, context) for po in self.browse(cr, uid, ids, context): if po.requisition_id and (po.requisition_id.exclusive=='exclusive'): for order in po.requisition_id.purchase_ids: if order.id<>po.id: wf_service...
new_header['debit'] = tot_debit new_header['credit'] = tot_credit
new_header['debit'] = r['credit'] new_header['credit'] = r['debit']
def _add_subtotal(self, cleanarray): i = 0 completearray = [] tot_debit = 0.0 tot_credit = 0.0 tot_scredit = 0.0 tot_sdebit = 0.0 tot_enlitige = 0.0 for r in cleanarray: # For the first element we always add the line # type = 1 is the line is the first of the account # type = 2 is an other line of the account if i==0: ...
def action_in_production(self, cr, uid, ids): """ Changes state to In Production and writes starting date. @return: True """ obj = self.browse(cr, uid, ids)[0] workcenter_line_obj = self.pool.get('mrp.production.workcenter.line') for workcenter_line in obj.workcenter_lines: workcenter_line_obj.action_start_working(cr, ...
def action_production_end(self, cr, uid, ids): obj=self.browse(cr,uid,ids)[0] for workcenter_line in obj.workcenter_lines: tmp=self.pool.get('mrp.production.workcenter.line').action_done(cr,uid,[workcenter_line.id]) return super(mrp_production,self).action_production_end(cr,uid,ids)
'name': 'Customer Invoices',
'name': _('Customer Invoices'),
def make_invoice(self, cr, uid, ids, context=None): reg_obj = self.pool.get('event.registration') mod_obj = self.pool.get('ir.model.data') newinv = [] if context is None: context = {}
'location_id': dest,
valdef = { 'picking_id': move.picking_id.id, 'product_id': line['product_id'], 'product_uom': line['product_uom'], 'product_qty': line['product_qty'], 'product_uos': line['product_uos'], 'product_uos_qty': line['product_uos_qty'], 'move_dest_id': move.id, 'state': state, 'name': line['name'], 'location_dest_id': dest, ...
picking_id=super(mrp_production,self).action_confirm(cr, uid, ids) for production in self.browse(cr, uid, ids): source = production.product_id.product_tmpl_id.property_stock_production.id for sub_product in production.bom_id.sub_products: qty1 = sub_product.product_qty qty2 = production.product_uos and production.produ...
picking_id=super(mrp_production,self).action_confirm(cr, uid, ids) for production in self.browse(cr, uid, ids): source = production.product_id.product_tmpl_id.property_stock_production.id if not production.bom_id: continue for sub_product in production.bom_id.sub_products: qty1 = sub_product.product_qty qty2 = producti...
def action_confirm(self, cr, uid, ids): picking_id=super(mrp_production,self).action_confirm(cr, uid, ids) for production in self.browse(cr, uid, ids): source = production.product_id.product_tmpl_id.property_stock_production.id for sub_product in production.bom_id.sub_products: qty1 = sub_product.product_qty qty2 = pro...
self.pool.get('account.voucher').unlink(cr, uid, voucher_ids, context)
def button_cancel(self, cr, uid, ids, context=None): done = [] for st in self.browse(cr, uid, ids, context): voucher_ids = [] for line in st.line_ids: if line.voucher_id: voucher_ids.append(line.voucher_id.id) self.pool.get('account.voucher').cancel_voucher(cr, uid, voucher_ids, context) self.pool.get('account.voucher'...
else: partner_id = partner_obj.create(cr, uid, { 'name': case.partner_name or case.name, 'user_id': case.user_id.id, 'comment': case.description, })
partner_id = partner_obj.create(cr, uid, { 'name': case.partner_name or case.name, 'user_id': case.user_id.id, 'comment': case.description, })
def make_order(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') partner_obj = self.pool.get('res.partner') contact_obj = self.pool.get('res.partner.address') case_obj = self.pool.get('hr.applicant')
case_obj.write(cr, uid, context['active_ids'], { 'partner_id': partner_id, 'partner_address_id': contact_id })
case_obj.write(cr, uid, case.id, { 'partner_id': partner_id, 'partner_address_id': contact_id })
def make_order(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') partner_obj = self.pool.get('res.partner') contact_obj = self.pool.get('res.partner.address') case_obj = self.pool.get('hr.applicant')
pricelist_version_ids = pricelist_ids
plversions_search_ids = pricelist_ids
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
pricelist_version_ids = product_pricelist_version_obj.search(cr, uid, []) pricelist_version_ids = list(set(pricelist_version_ids))
plversions_search_ids = product_pricelist_version_obj.search(cr, uid, []) plversions_search_ids = list(set(plversions_search_ids))
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
('pricelist_id', 'in', pricelist_version_ids),
('pricelist_id', 'in', plversions_search_ids),
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
plversion_ids = product_pricelist_version_obj.search(cr, uid, plversions_search_args) if len(pricelist_version_ids) != len(plversion_ids):
pricelist_version_ids = product_pricelist_version_obj.search(cr, uid, plversions_search_args) if len(plversions_search_ids) != len(pricelist_version_ids):
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
for pricelist_id in pricelist_version_ids:
for pricelist_id in plversions_search_ids:
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
(tmpl_id, product_id, plversion_ids[0], qty))
(tmpl_id, product_id, pricelist_version_ids[0], qty))
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
if new_qty <= 0.0: return {}
def _change_prod_qty(self, cr, uid, ids, new_qty, context={}): move_obj = self.pool.get('stock.move')
move_obj.unlink(cr, uid, moves[product_id][0])
move_obj.unlink(cr, uid, moves[product_id])
def change(product_id, product_qty, qty_vals, qty_vals_done, moves, moves_done, field): if not moves.get(product_id) and moves_done.get(product_id): new_qty = (product_qty - qty_vals_done.get(product_id, 0.0)) new_move = move_obj.copy(cr, uid, moves_done.get(product_id), default={'product_qty': new_qty}) self.write(cr,...
sql = [ """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2""", """WHERE l2.account_id = l1.account_id""", """AND""", """l1.id <= l2.id""", """AND""", """l2.id IN %s""", """AND""", self._query_get(cr, uid, obj='l1', context=c), """ GROUP BY l2.id""", ] cr.execute('\n'.join(sql), [t...
sql = """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2 WHERE l2.account_id = l1.account_id AND l1.id <= l2.id AND l2.id IN %%s AND """ + \ self._query_get(cr, uid, obj='l1', context=c) + \ " GROUP BY l2.id" cr.execute(sql, [tuple(ids)])
def _balance(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} c = context.copy() c['initital_bal'] = True sql = [ """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2""", """WHERE l2.account_id = l1.account_id""", """AND""", """l1.id <= l2.id""", """AND"...
'function_id': fields.related('job_ids','function_id',type='many2one', \ relation='res.partner.function', string='Main Function'),
'function': fields.related('job_ids', 'function', type='char', \ string='Main Function'),
def _main_job(self, cr, uid, ids, fields, arg, 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 ids: List of partner contact’s IDs @fields: Get Fields @param context: A standard dictionary for contextua...
funct = r.function_id and (", " + r.function_id.name) or ""
funct = r.function and (", " + r.function) or ""
def name_get(self, cr, uid, ids, context={}): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param user: the current user, @param ids: List of partner address’s IDs @param context: A standard dictionary for contextual values """
'function_id': fields.many2one('res.partner.function','Partner Function', \ help="Function of this contact with this partner"),
'function': fields.char('Partner Function', size=34, help="Function of this contact with this partner"),
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ search parnter job @param self: The object pointer @param cr: the current row, from the database cursor, @param user: the current user @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @...
for tax in tax_obj.compute(cr, uid, [tax_id], total, 1.00):
for tax in tax_obj.compute_all(cr, uid, [tax_id], total, 1.00).get('taxes'):
def create(self, cr, uid, vals, context=None, check=True): account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') if context is None: context = {} self._check_date(cr, uid, vals, context, check) if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['act...
if type(ids) == int:
if isinstance(ids, (int, long)):
def write(self, cr, uid, ids, vals, context=None): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') uom_obj = self.pool.get('product.uom') if context is None: context = {} if context.get('scheduler',False): return super(project_phase, self).write(cr, uid, ids,...
if tasks2[i][0][:10]<=current_date:
if tasks2[i][0] and tasks2[i][0][:10]<=current_date:
def compute_burndown(cr, uid, tasks_id, date_start, date_stop): latest = False if len(tasks_id): cr.execute('select id,create_date,state,planned_hours from project_task where id = ANY(%s) order by create_date',(tasks_id,)) tasks = cr.fetchall() cr.execute('select w.date,w.hours from project_task_work w left join proje...
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.model', context=c),
def compute_inv(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): """ Compute tax values for given PRICE_UNIT, QUANTITY and a buyer/seller ADDRESS_ID. Price Unit is a VAT included price
raise RuntimeError('media offline')
raise IOError(errno.EREMOTE, 'medium offline') if boo.readonly and mode not in ('r', 'rb'): raise IOError(errno.EPERM, "Readonly medium")
def get_file(self, cr, uid, id, file_node, mode, context=None): """ Return a file-like object for the contents of some node """ if context is None: context = {} boo = self.browse(cr, uid, id, context) if not boo.online: raise RuntimeError('media offline') ira = self.pool.get('ir.attachment').browse(cr, uid, file_node....
if not boo.online: raise RuntimeError('media offline')
def __get_data_3(self, cr, uid, boo, ira, context): if not boo.online: raise RuntimeError('media offline') if boo.type == 'filestore': if not ira.store_fname: # On a migrated db, some files may have the wrong storage type # try to fix their directory. if ira.file_size: self._doclog.warning( "ir.attachment #%d does not ...
raise IOError("File not found: %s" % fpath)
raise IOError(errno.ENOENT, "File not found: %s" % fpath)
def __get_data_3(self, cr, uid, boo, ira, context): if not boo.online: raise RuntimeError('media offline') if boo.type == 'filestore': if not ira.store_fname: # On a migrated db, some files may have the wrong storage type # try to fix their directory. if ira.file_size: self._doclog.warning( "ir.attachment #%d does not ...
raise RuntimeError('media offline')
raise IOError(errno.EREMOTE, 'medium offline') if boo.readonly: raise IOError(errno.EPERM, "Readonly medium")
def set_data(self, cr, uid, id, file_node, data, context=None, fil_obj=None): """ store the data. This function MUST be used from an ir.attachment. It wouldn't make sense to store things persistently for other types (dynamic). """ if not context: context = {} boo = self.browse(cr, uid, id, context) if fil_obj: ira = fi...
raise RuntimeError('media offline')
raise IOError(errno.EREMOTE, 'medium offline') if storage_bo.readonly: raise IOError(errno.EPERM, "Readonly medium")
def prepare_unlink(self, cr, uid, storage_bo, fil_bo): """ Before we unlink a file (fil_boo), prepare the list of real files that have to be removed, too. """
if not sbro.online: raise IOError(errno.EREMOTE, 'medium offline') if sbro.readonly: raise IOError(errno.EPERM, "Readonly medium")
def simple_rename(self, cr, uid, file_node, new_name, context=None): """ A preparation for a file rename. It will not affect the database, but merely check and perhaps rename the realstore file. @return the dict of values that can safely be be stored in the db. """ sbro = self.browse(cr, uid, file_node.storage_id, con...
result.append((sur.id, sur.title))
res = True break
def _get_survey(self, cr, uid, context=None): """ Set the value In survey_id field.
result.append((sur.id, sur.title))
res = True break if res: result.append((sur.id, sur.title))
def _get_survey(self, cr, uid, context=None): """ Set the value In survey_id field.
if context is None: context = {} id = self.search(cr, uid, [('user_id', '=', context.get('user_id', uid))], context=context) if id: journal = self.browse(cr, uid, id[0], context=context) if journal.journal_id: return journal.journal_id.id
md = self.pool.get('ir.model.data') try: result = md.get_object_reference(cr, uid, 'hr_timesheet', 'analytic_journal') return result[1] except ValueError, e: pass
def _getAnalyticJournal(self, cr, uid, context=None): if context is None: context = {} id = self.search(cr, uid, [('user_id', '=', context.get('user_id', uid))], context=context) if id: journal = self.browse(cr, uid, id[0], context=context) if journal.journal_id: return journal.journal_id.id return False
if context is None: context = {} id = self.search(cr, uid, [('user_id', '=', context.get('user_id', uid))], context=context) if id: prod = self.browse(cr, uid, id[0], context=context) if prod.product_id: return prod.product_id.id
md = self.pool.get('ir.model.data') try: result = md.get_object_reference(cr, uid, 'hr_timesheet', 'product_consultant') return result[1] except ValueError, e: pass
def _getEmployeeProduct(self, cr, uid, context=None): if context is None: context = {} id = self.search(cr, uid, [('user_id', '=', context.get('user_id', uid))], context=context) if id: prod = self.browse(cr, uid, id[0], context=context) if prod.product_id: return prod.product_id.id return False
fp = open(addons.get_module_resource('survey', 'report') + file_name + '.pdf', 'wb+');
ret_file_name = addons.get_module_resource('survey', 'report') + file_name + '.pdf' fp = open(ret_file_name, 'wb+');
def create_report(self, cr, uid, res_ids, report_name=False, file_name=False, context=None): """ If any user give answer of survey then last create report of this answer and if 'E-mail Notification on Answer' set True in survey then send mail on responsible person of this survey and attach survey answer report in pdf ...
account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context)
writeoff_acc_id = False for entry in move.reconcile_id.line_new_ids: writeoff_acc_id = entry.account_id.id break account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context)
def button_confirm(self, cr, uid, ids, context={}): done = [] res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') account_bank_statement_line_obj = \ self.pool.get('account...