rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
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 'qty' in fields: res.update({'qty': move.product_qty}) if 'use_exist' in fields: res.update({'use_exist': (move.picking_id and move.picking_id.type=='out' and True) or False}) | if context.get('active_id'): 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 'qty' in fields: res.update({'qty': move.product_qty}) if 'use_exist' in fields: res.update({'use_exist': (move.picking_id and move.picking_id.type=='out' and True) or False}) | 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 """ |
HOST = config.get('ftp_server_address', detect_ip_addr()) PORT = int(config.get('ftp_server_port', '8021')) address = (HOST, PORT) ftpd = ftpserver.FTPServer(address, ftpserver.FTPHandler) | ftpd = ftpserver.FTPServer((HOST, PORT), ftpserver.FTPHandler) | def run(self): autho = authorizer.authorizer() ftpserver.FTPHandler.authorizer = autho ftpserver.max_cons = 300 ftpserver.max_cons_per_ip = 50 ftpserver.FTPHandler.abstracted_fs = abstracted_fs.abstracted_fs if PASSIVE_PORTS: ftpserver.FTPHandler.passive_ports = PASSIVE_PORTS |
ds = ftp_server() ds.start() | if HOST.lower() == 'none': netsvc.Logger().notifyChannel("FTP", netsvc.LOG_INFO, "\n Server FTP Not Started\n") else: netsvc.Logger().notifyChannel("FTP", netsvc.LOG_INFO, "\n Serving FTP on %s:%s\n" % (HOST, PORT)) ds = ftp_server() ds.start() | def run(self): autho = authorizer.authorizer() ftpserver.FTPHandler.authorizer = autho ftpserver.max_cons = 300 ftpserver.max_cons_per_ip = 50 ftpserver.FTPHandler.abstracted_fs = abstracted_fs.abstracted_fs if PASSIVE_PORTS: ftpserver.FTPHandler.passive_ports = PASSIVE_PORTS |
cr.execute('select sum(nb_register) from event_registration where id IN %s', (tuple(reg_ids),)) number = cr.fetchone() | number = 0.0 if reg_ids: cr.execute('select sum(nb_register) from event_registration where id IN %s', (tuple(reg_ids),)) number = cr.fetchone() | def _get_register(self, cr, uid, ids, fields, args, context=None): """Get Confirm or uncofirm register value. @param ids: List of Event registration type's id @param fields: List of function fields(register_current and register_prospect). @param context: A standard dictionary for contextual values @return: Dictionary of function fields value. """ register_pool = self.pool.get('event.registration') res = {} for event in self.browse(cr, uid, ids, context): res[event.id] = {} for field in fields: res[event.id][field] = False state = [] if 'register_current' in fields: state += ['open', 'done'] if 'register_prospect' in fields: state.append('draft') |
res[event.id]['register_current'] = number and number[0] or 0.0 | res[event.id]['register_current'] = number and number[0] | def _get_register(self, cr, uid, ids, fields, args, context=None): """Get Confirm or uncofirm register value. @param ids: List of Event registration type's id @param fields: List of function fields(register_current and register_prospect). @param context: A standard dictionary for contextual values @return: Dictionary of function fields value. """ register_pool = self.pool.get('event.registration') res = {} for event in self.browse(cr, uid, ids, context): res[event.id] = {} for field in fields: res[event.id][field] = False state = [] if 'register_current' in fields: state += ['open', 'done'] if 'register_prospect' in fields: state.append('draft') |
res[event.id]['register_prospect'] = number and number[0] or 0.0 | res[event.id]['register_prospect'] = number and number[0] | def _get_register(self, cr, uid, ids, fields, args, context=None): """Get Confirm or uncofirm register value. @param ids: List of Event registration type's id @param fields: List of function fields(register_current and register_prospect). @param context: A standard dictionary for contextual values @return: Dictionary of function fields value. """ register_pool = self.pool.get('event.registration') res = {} for event in self.browse(cr, uid, ids, context): res[event.id] = {} for field in fields: res[event.id][field] = False state = [] if 'register_current' in fields: state += ['open', 'done'] if 'register_prospect' in fields: state.append('draft') |
if data['form']['period_from'] == False or data['form']['period_to'] == False: | if not data['form']['period_from'] or not data['form']['period_to']: | def _build_context(self, cr, uid, ids, data, context=None): if context is None: context = {} 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': if data['form']['period_from'] == False or data['form']['period_to'] == False: raise osv.except_osv(_('Error'),_('Select Start period and End 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 |
hr_evaluation_obj = self.pool.get('hr_evaluation.evaluation') | hr_evaluation_interview_obj = self.pool.get('hr.evaluation.interview') | def send_mail(self, cr, uid, ids, context=None): hr_evaluation_obj = self.pool.get('hr_evaluation.evaluation') if context is None: context = {} evaluation_data = self.read(cr, uid, ids, context=context)[0] for waiting_id in hr_evaluation_obj.browse(cr, uid, evaluation_data['evaluation_id'], context=context).survey_request_ids: if waiting_id.state == "waiting_answer" and waiting_id.user_to_review_id.work_email : msg = " Hello %s, \n\n Kindly post your response for %s survey. \n\n Thanks," %(waiting_id.user_to_review_id.name, waiting_id.survey_id.title) tools.email_send(tools.config['email_from'], [waiting_id.user_to_review_id.work_email],\ 'Reminder to fill up Survey', msg) return {'type': 'ir.actions.act_window_close'} |
for waiting_id in hr_evaluation_obj.browse(cr, uid, evaluation_data['evaluation_id'], context=context).survey_request_ids: if waiting_id.state == "waiting_answer" and waiting_id.user_to_review_id.work_email : msg = " Hello %s, \n\n Kindly post your response for %s survey. \n\n Thanks," %(waiting_id.user_to_review_id.name, waiting_id.survey_id.title) tools.email_send(tools.config['email_from'], [waiting_id.user_to_review_id.work_email],\ | current_interview = hr_evaluation_interview_obj.browse(cr, uid, evaluation_data.get('evaluation_id')) if current_interview.state == "waiting_answer" and current_interview.user_to_review_id.work_email : msg = " Hello %s, \n\n Kindly post your response for '%s' survey interview. \n\n Thanks," %(current_interview.user_to_review_id.name, current_interview.survey_id.title) tools.email_send(tools.config['email_from'], [current_interview.user_to_review_id.work_email],\ | def send_mail(self, cr, uid, ids, context=None): hr_evaluation_obj = self.pool.get('hr_evaluation.evaluation') if context is None: context = {} evaluation_data = self.read(cr, uid, ids, context=context)[0] for waiting_id in hr_evaluation_obj.browse(cr, uid, evaluation_data['evaluation_id'], context=context).survey_request_ids: if waiting_id.state == "waiting_answer" and waiting_id.user_to_review_id.work_email : msg = " Hello %s, \n\n Kindly post your response for %s survey. \n\n Thanks," %(waiting_id.user_to_review_id.name, waiting_id.survey_id.title) tools.email_send(tools.config['email_from'], [waiting_id.user_to_review_id.work_email],\ 'Reminder to fill up Survey', msg) return {'type': 'ir.actions.act_window_close'} |
move.write(cr, uid, [move.id], {'state': 'done'}) | move.write({'state': 'done'}) | def test_finished(self, cr, uid, ids): """ Tests whether the move is in done or cancel state or not. @return: True or False """ move_ids = self.pool.get('stock.move').search(cr, uid, [('picking_id', 'in', ids)]) for move in self.pool.get('stock.move').browse(cr, uid, move_ids): if move.state not in ('done', 'cancel'): if move.product_qty != 0.0: return False else: move.write(cr, uid, [move.id], {'state': 'done'}) return True |
'description' : """ * Save the Thunderbird plugin. \n * Follow the Steps to configure OpenERP in Thunderbird. \n -> 1. Go to Tools > OpenERP Synchronization. \n -> 2. check data (configured by default). \n -> 3. Click Test Connection. \n -> 4. A message appears with state of your connection. \n -> 5. If your connection failed, check if your database is open, and check your data. \n -> 6. If you have a good connection, click Ok and start to archive mail in OpenERP. | 'description' : """ * Save the Thunderbird plugin. \n * Follow the Steps to configure OpenERP in Thunderbird. \n -> 1. Go to Tools > OpenERP Synchronization. \n -> 2. check data (configured by default). \n -> 3. Click Test Connection. \n -> 4. A message appears with state of your connection. \n -> 5. If your connection failed, check if your database is open, and check your data. \n -> 6. If you have a good connection, click Ok and start to archive mail in OpenERP.""" | def default_get(self, cr, uid, fields, context={}): data = super(thunderbird_installer, self).default_get(cr, uid, fields, context) pdf_file = open(config['addons_path'] + "/thunderbird/doc/Installation Guide to OpenERP Thunderbid Plug-in.pdf", 'r') data['pdf_file'] = base64.encodestring(pdf_file.read()) file = open(config['addons_path'] + "/thunderbird/plugin/OpenERP_plugin-2.0.xpi", 'r') data['plugin_file'] = base64.encodestring(file.read()) return data |
fiscal_date_start = fiscal_obj.browse(cr, uid, [data['form']['fiscalyear_id']], context=context)[0].date_start result_initial_bal['empty_fy_allow'] = True result_initial_bal['fiscalyear'] = fiscal_obj.search(cr, uid, [('date_stop', '<', fiscal_date_start), ('state', '=', 'draft')], context=context) result_initial_bal['date_from'] = '0001-01-01' result_initial_bal['date_to'] = (datetime.datetime.strptime(fiscal_date_start, "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') | if data['form']['fiscalyear_id']: fiscal_date_start = fiscal_obj.browse(cr, uid, [data['form']['fiscalyear_id']], context=context)[0].date_start result_initial_bal['empty_fy_allow'] = True result_initial_bal['fiscalyear'] = fiscal_obj.search(cr, uid, [('date_stop', '<', fiscal_date_start), ('state', '=', 'draft')], context=context) result_initial_bal['date_from'] = '0001-01-01' result_initial_bal['date_to'] = (datetime.datetime.strptime(fiscal_date_start, "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') | def _build_contexts(self, cr, uid, ids, data, context=None): if context is None: context = {} result = {} period_obj = self.pool.get('account.period') fiscal_obj = self.pool.get('account.fiscalyear') result['fiscalyear'] = 'fiscalyear_id' in data['form'] and data['form']['fiscalyear_id'] or False result['journal_ids'] = 'journal_ids' in data['form'] and data['form']['journal_ids'] or False result['chart_account_id'] = 'chart_account_id' in data['form'] and data['form']['chart_account_id'] or False result_initial_bal = result.copy() if data['form']['filter'] == 'filter_date': result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] result_initial_bal['date_from'] = '0001-01-01' result_initial_bal['date_to'] = (datetime.datetime.strptime(data['form']['date_from'], "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') elif data['form']['filter'] == 'filter_period': if not data['form']['period_from'] or not data['form']['period_to']: raise osv.except_osv(_('Error'),_('Select a starting and an ending period')) result['periods'] = self._build_periods(cr, uid, data['form']['period_from'], data['form']['period_to']) first_period = self.pool.get('account.period').search(cr, uid, [], order='date_start', limit=1)[0] result_initial_bal['periods'] = self._build_periods(cr, uid, first_period, data['form']['period_from']) else: fiscal_date_start = fiscal_obj.browse(cr, uid, [data['form']['fiscalyear_id']], context=context)[0].date_start result_initial_bal['empty_fy_allow'] = True #Improve me => there should be something generic in account.move.line -> query get result_initial_bal['fiscalyear'] = fiscal_obj.search(cr, uid, [('date_stop', '<', fiscal_date_start), ('state', '=', 'draft')], context=context) result_initial_bal['date_from'] = '0001-01-01' result_initial_bal['date_to'] = (datetime.datetime.strptime(fiscal_date_start, "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') return result, result_initial_bal |
for vals in self.read(cr, uid, ids, context=context): user = vals.get('user_id') | for vals in self.browse(cr, uid, ids, context=context): user = vals.user_id | def do_accept(self, cr, uid, ids, context=None, *args): """ Update state which value is accepted. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of calendar attendee’s IDs. @return: True """ if not context: context = {} for vals in self.read(cr, uid, ids, context=context): user = vals.get('user_id') if user: ref = vals.get('ref', None) if ref: if ref.user_id.id != user[0]: defaults = {'user_id': user[0]} new_event = model_obj.copy(cr, uid, event, default=defaults, context=context) self.write(cr, uid, ids, {'state': 'accepted'}, context) return True |
ref = vals.get('ref', None) if ref: if ref.user_id.id != user[0]: defaults = {'user_id': user[0]} new_event = model_obj.copy(cr, uid, event, default=defaults, context=context) self.write(cr, uid, ids, {'state': 'accepted'}, context) | mod_obj = self.pool.get(vals.ref._name) if vals.ref: if vals.ref.user_id.id != user.id: defaults = {'user_id': user.id} new_event = mod_obj.copy(cr, uid, vals.ref.id, default=defaults, context=context) self.write(cr, uid, vals.id, {'state': 'accepted'}, context) | def do_accept(self, cr, uid, ids, context=None, *args): """ Update state which value is accepted. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of calendar attendee’s IDs. @return: True """ if not context: context = {} for vals in self.read(cr, uid, ids, context=context): user = vals.get('user_id') if user: ref = vals.get('ref', None) if ref: if ref.user_id.id != user[0]: defaults = {'user_id': user[0]} new_event = model_obj.copy(cr, uid, event, default=defaults, context=context) self.write(cr, uid, ids, {'state': 'accepted'}, context) return True |
'priority': fields.selection(crm_report.AVAILABLE_PRIORITIES, 'Priority'), | 'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'), | def _get_data(self, cr, uid, ids, field_name, arg, context={}): |
if self.date_lst and data['form']['initial_balance'] : | if data['form']['initial_balance']: | def set_context(self, objects, data, ids, report_type=None): PARTNER_REQUEST = '' if (data['model'] == 'res.partner'): ## Si on imprime depuis les partenaires if ids: #PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")" PARTNER_REQUEST = "AND line.partner_id IN %s",(tuple(ids),) # Transformation des date # # |
else: | def set_context(self, objects, data, ids, report_type=None): PARTNER_REQUEST = '' if (data['model'] == 'res.partner'): ## Si on imprime depuis les partenaires if ids: #PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")" PARTNER_REQUEST = "AND line.partner_id IN %s",(tuple(ids),) # Transformation des date # # |
|
if self.date_lst_string: self.cr.execute( "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit,l.amount_currency,c.code AS currency_code " \ "FROM account_move_line l " \ "LEFT JOIN account_journal j " \ "ON (l.journal_id = j.id) " \ "LEFT JOIN res_currency c on (l.currency_id=c.id)" \ "WHERE l.partner_id = %s " \ "AND l.account_id IN %s"\ "AND l.date IN (" + self.date_lst_string + ")" " " + RECONCILE_TAG + " "\ "ORDER BY l.id", (partner.id, tuple(self.account_ids),)) res = self.cr.dictfetchall() sum = 0.0 for r in res: sum = r['debit'] - r['credit'] r['progress'] = sum full_account.append(r) | self.cr.execute( "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit,l.amount_currency,c.code AS currency_code " \ "FROM account_move_line l " \ "LEFT JOIN account_journal j " \ "ON (l.journal_id = j.id) " \ "LEFT JOIN res_currency c on (l.currency_id=c.id)" \ "WHERE l.partner_id = %s " \ "AND l.account_id IN %s AND " + self.query +" " \ " " + RECONCILE_TAG + " "\ "ORDER BY l.id", (partner.id, tuple(self.account_ids))) res = self.cr.dictfetchall() sum = 0.0 for r in res: sum = r['debit'] - r['credit'] r['progress'] = sum full_account.append(r) | def lines(self, partner,data): full_account = [] if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND l.reconcile_id IS NULL" |
if self.date_lst_string: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")" , (partner.id,tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 | self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE partner_id = %s " \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND " + self.query + " " , (partner.id,tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 | def _sum_debit_partner(self, partner, data): result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['initial_balance'] : self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (partner.id, tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 |
if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")", (partner.id, tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 | self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE partner_id=%s " \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND " + self.query + " " , (partner.id, tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 | def _sum_credit_partner(self, partner, data): result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['initial_balance'] : self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (partner.id, tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 |
if self.date_lst_string: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 | self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND " + self.query + " " , (tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 | def _sum_debit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['initial_balance'] : self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 |
if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 | self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND " + self.query + " " , (tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 | def _sum_credit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 if data['form']['reconcil'] : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.date_lst and data['form']['initial_balance'] : self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id IN %s" \ "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , (tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 |
cr.execute(""" create or replace view report_timesheet_task_user as ( | tools.drop_view_if_exists(cr, 'report_timesheet_task_user') cr.execute(""" create or replace view report_timesheet_task_user as ( | def init(self, cr): cr.execute(""" create or replace view report_timesheet_task_user as ( select ((r.id*12)+to_number(months.m_id,'99'))::integer as id, months.name as name, r.id as user_id, to_char(to_date(months.name, 'YYYY/MM/DD'),'YYYY') as year, to_char(to_date(months.name, 'YYYY/MM/DD'),'MM') as month from res_users r, (select to_char(p.date,'YYYY-MM-01') as name, to_char(p.date,'MM') as m_id from project_task_work p |
data.update({'date': context['date']}) | def do_print(self, cr, uid, ids, context=None): if context is None: context = {} data = self.read(cr, uid, ids, [])[0] res = self._get_partners_followp(cr, uid, ids, context)['to_update'] to_update = res data['followup_id'] = 'followup_id' in context and context['followup_id'] or False date = 'date' in context and context['date'] or data['date'] for id in to_update.keys(): if to_update[id]['partner_id'] in data['partner_ids']: cr.execute( "UPDATE account_move_line "\ "SET followup_line_id=%s, followup_date=%s "\ "WHERE id=%s", (to_update[id]['level'], date, int(id),)) |
|
return user.context_project_id | return user.context_project_id.id | def _get_project(self, cr, uid, context): user = self.pool.get('res.users').browse(cr,uid,uid, context=context) if user.context_project_id: return user.context_project_id return False |
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition=False, price_unit=False, address_invoice_id=False, context={}): res_prod = super(account_invoice_line,self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition, price_unit, address_invoice_id, context) | def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition=False, price_unit=False, address_invoice_id=False, currency_id=False, context={}): res_prod = super(account_invoice_line,self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition, price_unit, address_invoice_id, currency_id=currency_id, context=context) | def account_get(self, cr, uid, product_id=None, partner_id=None, user_id=None, date=None, context={}): domain = [] if product_id: domain += ['|',('product_id','=',product_id)] domain += [('product_id','=',False)] if partner_id: domain += ['|',('partner_id','=',partner_id)] domain += [('partner_id','=',False)] if user_id: domain += ['|',('user_id','=',uid)] domain += [('user_id','=',False)] if date: domain += ['|',('date_start','<=',date),('date_start','=',False)] domain += ['|',('date_stop','>=',date),('date_stop','=',False)] best_index = -1 res = False for rec in self.browse(cr, uid, self.search(cr, uid, domain, context=context), context=context): index = 0 if rec.product_id: index+=1 if rec.partner_id: index+=1 if rec.user_id: index+=1 if rec.date_start: index+=1 if rec.date_stop: index+=1 if index>best_index: res = rec best_index = index return res |
lines = move.line_id if lines: ref_line = lines[0] ref_chart_account = _get_chart_account(cursor, user, ref_line.account_id) parent_left = ref_chart_account.parent_left parent_right = ref_chart_account.parent_right result = True for line in lines[1:]: if not (line.account_id.parent_left > parent_left and line.account_id.parent_left < parent_right): raise osv.except_osv(_('Error !'), _('You cannot validate a move unless accounts in its entry lines are in same Chart Of Accounts !')) | top = None for line in move.line_id: account = line.account_id while account: account2 = account account = account.parent_id if not top: top = account2.id elif top<>account2.id: raise osv.except_osv(_('Error !'), _('You cannot validate a Journal Entry unless all journal items are in same chart of accounts !')) | def _get_chart_account(cursor, user, account): if account.parent_id: chart_account = _get_chart_account(cursor, user, account.parent_id) else: chart_account = account return chart_account |
if move.picking_id and move.picking_id.type=="internal": return True | def _check_tracking(self, cr, uid, ids): """ Checks if production lot is assigned to stock move or not. @return: True or False """ for move in self.browse(cr, uid, ids): if move.picking_id and move.picking_id.type=="internal": return True if not move.prodlot_id and \ (move.state == 'done' and \ ( \ (move.product_id.track_production and move.location_id.usage=='production') or \ (move.product_id.track_production and move.location_dest_id.usage=='production') or \ (move.product_id.track_incoming and move.location_id.usage in ('supplier','internal')) or \ (move.product_id.track_outgoing and move.location_dest_id.usage in ('customer','internal')) \ )): return False return True |
|
(move.product_id.track_production and move.location_id.usage=='production') or \ (move.product_id.track_production and move.location_dest_id.usage=='production') or \ (move.product_id.track_incoming and move.location_id.usage in ('supplier','internal')) or \ (move.product_id.track_outgoing and move.location_dest_id.usage in ('customer','internal')) \ | (move.product_id.track_production and move.location_id.usage == 'production') or \ (move.product_id.track_production and move.location_dest_id.usage == 'production') or \ (move.product_id.track_incoming and move.location_id.usage == 'supplier') or \ (move.product_id.track_outgoing and move.location_dest_id.usage == 'customer') \ | def _check_tracking(self, cr, uid, ids): """ Checks if production lot is assigned to stock move or not. @return: True or False """ for move in self.browse(cr, uid, ids): if move.picking_id and move.picking_id.type=="internal": return True if not move.prodlot_id and \ (move.state == 'done' and \ ( \ (move.product_id.track_production and move.location_id.usage=='production') or \ (move.product_id.track_production and move.location_dest_id.usage=='production') or \ (move.product_id.track_incoming and move.location_id.usage in ('supplier','internal')) or \ (move.product_id.track_outgoing and move.location_dest_id.usage in ('customer','internal')) \ )): return False return True |
'group_invoice_lines': fields.boolean('Group invoice lines', help="If this box is checked, the system will try to group the accounting lines when generating them from invoices."), | 'group_invoice_lines': fields.boolean('Group Invoice Lines', help="If this box is checked, the system will try to group the accounting lines when generating them from invoices."), | def _col_get(self, cr, user, context={}): result = [] cols = self.pool.get('account.move.line')._columns for col in cols: if col in ('period_id', 'journal_id'): continue |
'move_id': fields.many2one('account.move', 'Journal Entry', readonly=True, select=1, help="Link to the automatically generated Journal Items."), | 'move_id': fields.many2one('account.move', 'Journal Entry', readonly=True, select=1, ondelete='restrict', help="Link to the automatically generated Journal Items."), | def _get_invoice_from_reconcile(self, cr, uid, ids, context=None): move = {} for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids, context=context): for line in r.line_partial_ids: move[line.move_id.id] = True for line in r.line_id: move[line.move_id.id] = True |
res = super(event_make_invoice, self).default_get(cr, uid, fields_list, context) return res | return super(event_make_invoice, self).default_get(cr, uid, fields_list, context) | def default_get(self, cr, uid, fields_list, context=None): res = super(event_make_invoice, self).default_get(cr, uid, fields_list, context) return res |
def make_invoice(self, cr, uid, ids, context={}): | def make_invoice(self, cr, uid, ids, context=None): | def make_invoice(self, cr, uid, ids, context={}): |
mod_obj =self.pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter') id = mod_obj.read(cr, uid, result, ['res_id']) | form_id = mod_obj._get_id(cr, uid, 'account', 'invoice_form') form_res = mod_obj.browse(cr, uid, form_id, context=context).res_id tree_id = mod_obj._get_id(cr, uid, 'account', 'invoice_tree') tree_res = mod_obj.browse(cr, uid, tree_id, context=context).res_id | def make_invoice(self, cr, uid, ids, context={}): |
'search_view_id': id['id'] | def make_invoice(self, cr, uid, ids, context={}): |
|
'parent_id': fields.many2one('account.account', 'Parent', ondelete='cascade'), | 'parent_id': fields.many2one('account.account', 'Parent', ondelete='cascade', domain=[('type','=','view')]), | def _get_child_ids(self, cr, uid, ids, field_name, arg, context={}): result = {} for record in self.browse(cr, uid, ids, context): if record.child_parent_ids: result[record.id] = [x.id for x in record.child_parent_ids] else: result[record.id] = [] |
if self._debug: self._doclog.debug("Trying to read \"%s\".."% fpath) | def get_file(self, cr, uid, id, file_node, mode, context=None): if context is None: context = {} boo = self.browse(cr, uid, id, context) if not boo.online: raise RuntimeError('media offline') ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context) if boo.type == 'filestore': if not ira.store_fname: # On a migrated db, some files may have the wrong storage type # try to fix their directory. if ira.file_size: self._doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id) raise IOError(errno.ENOENT, 'No file can be located') fpath = os.path.join(boo.path, ira.store_fname) if self._debug: self._doclog.debug("Trying to read \"%s\".."% fpath) return nodefd_file(file_node, path=fpath, mode=mode) |
|
if self._debug: self._doclog.debug("Trying to obtain db_datas for ir.attachment[%d]", ira.id) | def get_file(self, cr, uid, id, file_node, mode, context=None): if context is None: context = {} boo = self.browse(cr, uid, id, context) if not boo.online: raise RuntimeError('media offline') ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context) if boo.type == 'filestore': if not ira.store_fname: # On a migrated db, some files may have the wrong storage type # try to fix their directory. if ira.file_size: self._doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id) raise IOError(errno.ENOENT, 'No file can be located') fpath = os.path.join(boo.path, ira.store_fname) if self._debug: self._doclog.debug("Trying to read \"%s\".."% fpath) return nodefd_file(file_node, path=fpath, mode=mode) |
|
data['badge_title'] = contact_id.title | data['badge_title'] = contact_id.title.name | def onchange_contact_id(self, cr, uid, ids, contact, partner): data ={} if not contact: return data |
if data_event.user_id.id: return {'value': {'user_id':data_event.user_id.id}} | def onchange_event(self, cr, uid, ids, event_id, partner_invoice_id): context={} if not event_id: return {'value': {'unit_price': False, 'event_product': False}} data_event = self.pool.get('event.event').browse(cr, uid, event_id) context['currency_id'] = data_event.currency_id.id if data_event.product_id: if not partner_invoice_id: unit_price=self.pool.get('product.product').price_get(cr, uid, [data_event.product_id.id], context=context)[data_event.product_id.id] return {'value': {'unit_price': unit_price, 'event_product': data_event.product_id.name, 'currency_id': data_event.currency_id.id}} data_partner = self.pool.get('res.partner').browse(cr, uid, partner_invoice_id) context.update({'partner_id': data_partner}) unit_price = self.pool.get('product.product')._product_price(cr, uid, [data_event.product_id.id], False, False, {'pricelist': data_partner.property_product_pricelist.id})[data_event.product_id.id] return {'value': {'unit_price': unit_price, 'event_product': data_event.product_id.name, 'currency_id': data_event.currency_id.id}} return {'value': {'unit_price': False, 'event_product': False}} |
|
tracking = context.get('tracking', False) last_track = [line.tracking_id.id for line in self.browse(cr, uid, ids)[0].picking_id.move_lines if line.tracking_id] if not last_track: last_track = tracking_obj.create(cr, uid, {}, context=context) else: last_track.sort() last_track = last_track[-1] self.write(cr, uid, ids, {'tracking_id': last_track}) | for line in self.browse(cr, uid, ids, context=context): last_track = None if line.picking_id: tracking_ids = [l.tracking_id.id for l in line.picking_id.move_lines if l.tracking_id] if tracking_ids: last_track = max(tracking_ids) if not last_track: last_track = tracking_obj.create(cr, uid, {}, context=context) self.write(cr, uid, line.id, {'tracking_id': last_track}, context=context) | def setlast_tracking(self, cr, uid, ids, context=None): tracking_obj = self.pool.get('stock.tracking') tracking = context.get('tracking', False) last_track = [line.tracking_id.id for line in self.browse(cr, uid, ids)[0].picking_id.move_lines if line.tracking_id] if not last_track: last_track = tracking_obj.create(cr, uid, {}, context=context) else: last_track.sort() last_track = last_track[-1] self.write(cr, uid, ids, {'tracking_id': last_track}) return True |
part_ids.append(res['id']) | if res: part_ids.append(res['id']) | def assign_partner(self, cr, uid, ids, context=None): ok = False for part in self.browse(cr, uid, ids, context=context): if not part.country_id: continue addr = ', '.join(filter(None, [part.street, (part.zip or '')+' '+(part.city or ''), part.state_id and part.state_id.name, part.country_id and part.country_id.name])) result = geo_find(addr.encode('utf8')) if result: self.write(cr, uid, [part.id], { 'partner_latitude': result[0], 'partner_longitude': result[1] }, context=context) |
WHERE journal_id = %s \ ORDER BY date DESC,id DESC LIMIT 1', (journal_id,)) | WHERE journal_id = %s AND NOT state = %s \ ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft')) | def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None): if not journal_id: return {'value': {'currency': False}} |
original = [header, sender, to, sentdate, desc] | if case.user_id.signature: signature = '--\n' + case.user_id.signature original = [header, sender, to, sentdate, desc, signature] | def get_reply_defaults(self, cr, uid, fields, context=None): """ This function gets default values for reply mail """ hist_obj = self.pool.get('crm.case.history') res_ids = context and context.get('active_ids', []) or [] |
cr, uid, ids, tax, vals={'account_paid_id': account}) | cr, uid, id, tax, vals={'account_paid_id': account}) | def on_change_paid(self, cr, uid, id, tax, account): return self._on_change( cr, uid, ids, tax, vals={'account_paid_id': account}) |
'date_expected': fields.datetime('Scheduled Date', required=True, help="Scheduled date for the processing of this move"), | 'date_expected': fields.datetime('Scheduled Date', states={'done': [('readonly', True)]},required=True, help="Scheduled date for the processing of this move"), | 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 |
tools.pdf_utils.fill_pdf(addons.get_module_resource('l10n_lu','wizard', '2008_DECL_F_M10.pdf'), '/tmp/output.pdf', result) self.obj = external_pdf(file('/tmp/output.pdf').read()) | tmp_file = tempfile.mkstemp(".pdf")[1] try: tools.pdf_utils.fill_pdf(addons.get_module_resource('l10n_lu','wizard', '2008_DECL_F_M10.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: try: os.remove(tmp_file) except: pass | def create(self, cr, uid, ids, datas, context=None): |
except Exception, e: | except Exception: | def create(self, cr, uid, ids, datas, context=None): |
recs = obj_move_line.read(cr, uid, data['ids'], ['reconcile_id','reconcile_partial_id']) | recs = obj_move_line.read(cr, uid, context['active_ids'], ['reconcile_id','reconcile_partial_id']) | def trans_unrec(self, cr, uid, ids, context=None): obj_move_line = self.pool.get('account.move.line') obj_move_reconcile = self.pool.get('account.move.reconcile') if context is None: context = {} recs = obj_move_line.read(cr, uid, data['ids'], ['reconcile_id','reconcile_partial_id']) unlink_ids = [] full_recs = filter(lambda x: x['reconcile_id'], recs) rec_ids = [rec['reconcile_id'][0] for rec in full_recs] part_recs = filter(lambda x: x['reconcile_partial_id'], recs) part_rec_ids = [rec['reconcile_partial_id'][0] for rec in part_recs] unlink_ids += rec_ids unlink_ids += part_rec_ids |
'fiscal_position': o.partner_id.property_account_position.id, | 'fiscal_position': o.fiscal_position.id or o.partner_id.property_account_position.id, | def action_invoice_create(self, cr, uid, ids, *args): res = False |
return format_body(body % data) | return self.format_body(body % data) | def format_mail(self, obj, body): data = { 'object_id': obj.id, 'object_subject': hasattr(obj, 'name') and obj.name or False, 'object_date': hasattr(obj, 'date') and obj.date or False, 'object_description': hasattr(obj, 'description') and obj.description or False, 'object_user': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.name) or '/', 'object_user_email': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email) or '/', 'object_user_phone': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.address_id and obj.user_id.address_id.phone) or '/', 'partner': hasattr(obj, 'partner_id') and (obj.partner_id and obj.partner_id.name) or '/', 'partner_email': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and obj.partner_address_id.email) or '/', } return format_body(body % data) |
parent_ids = [x[0] for x in cr.fetchall()] | parent_ids = [x[0] for x in cr.fetchall() if x[0]] | def _parent_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} result = {} obj_dept = self.pool.get('hr.department') for user_id in ids: emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)]) cr.execute('SELECT emp.department_id FROM hr_employee AS emp \ JOIN resource_resource AS res ON res.id = emp.resource_id \ JOIN hr_department as dept ON dept.id = emp.department_id \ WHERE res.user_id = %s AND emp.department_id IS NOT NULL AND dept.manager_id IS NOT NULL', (user_id,)) ids_dept = [x[0] for x in cr.fetchall()] parent_ids = [] if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['manager_id'], context=context) parent_ids = map(lambda x: x['manager_id'][0], data_dept) cr.execute('SELECT res.user_id FROM hr_employee AS emp JOIN resource_resource AS res ON res.id=emp.resource_id \ WHERE emp.id IN %s', (tuple(parent_ids),)) parent_ids = [x[0] for x in cr.fetchall()] result[user_id] = parent_ids return result |
signature = '' if case.user_id.signature: signature = '--\n' + case.user_id.signature | def get_reply_defaults(self, cr, uid, fields, context=None): """ This function gets default values for reply mail """ hist_obj = self.pool.get('crm.case.history') res_ids = context and context.get('active_ids', []) or [] |
|
original = '\n'.join(original) res['text']=original | res['text']= '\n'.join(original) | def get_reply_defaults(self, cr, uid, fields, context=None): """ This function gets default values for reply mail """ hist_obj = self.pool.get('crm.case.history') res_ids = context and context.get('active_ids', []) or [] |
obj_pool.__setattr__('create', self._create(obj_pool.create, model, context=context)) obj_pool.__setattr__('write', self._write(obj_pool.write, model, context=context)) | if not hasattr(obj_pool, 'base_action_ruled'): obj_pool.create = self._create(obj_pool.create, model, context=context) obj_pool.write = self._write(obj_pool.write, model, context=context) obj_pool.base_action_ruled = True | def _register_hook(self, cr, uid, ids, context=None): if not context: context = {} for action_rule in self.browse(cr, uid, ids, context=context): model = action_rule.model_id.model obj_pool = self.pool.get(model) obj_pool.__setattr__('create', self._create(obj_pool.create, model, context=context)) obj_pool.__setattr__('write', self._write(obj_pool.write, model, context=context)) return True |
price = price_obj.price_get(self.cr, self.uid, [lines[id].pricelist_id.id], lines[id].product_id.id, lines[id].unit_amount, ctx)[lines[id].pricelist_id.id] | price = price_obj.price_get(self.cr, self.uid, [lines[id].account_id.pricelist_id.id], lines[id].product_id.id, lines[id].unit_amount, ctx)[lines[id].account_id.pricelist_id.id] | def _lines_a(self, general_account_id, account_id, date1, date2): self.cr.execute("SELECT aal.id AS id, aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj, aal.unit_amount AS quantity \ FROM account_analytic_line AS aal, account_analytic_journal AS aaj \ WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) AND (aal.date>=%s) AND (aal.date<=%s) \ AND (aal.journal_id=aaj.id) \ ORDER BY aal.date, aaj.code, aal.code", (general_account_id, account_id, date1, date2)) res = self.cr.dictfetchall() |
mid = objid._get_id(cr, uid, 'caldav', 'document_directory_calendars0') | mid = objid._get_id(cr, uid, 'document', 'dir_calendars') | def _get_root_calendar_directory(self, cr, uid, context=None): objid = self.pool.get('ir.model.data') try: mid = objid._get_id(cr, uid, 'caldav', 'document_directory_calendars0') if not mid: return False root_id = objid.read(cr, uid, mid, ['res_id'])['res_id'] root_cal_dir = self.browse(cr,uid, root_id, context=context) return root_cal_dir.name except Exception: logger = logging.getLogger('document') logger.warning('Cannot set root directory for Calendars:', exc_info=True) return False return False |
} | } val=0.0 cur_obj = self.pool.get('res.currency') cur = order.pricelist_id.currency_id | def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') res={} for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount for payment in order.payments: res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0) for line in order.lines: if order.price_type!='tax_excluded': res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_inv(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) else: res[order.id]['amount_tax'] = tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty)['total_included'] return res |
res[order.id]['amount_tax'] = tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty)['total_included'] | for c in self.pool.get('account.tax').compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.qty, line.product_id, line.order_id.partner_id)['taxes']: val += c['amount'] res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val) | def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') res={} for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount for payment in order.payments: res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0) for line in order.lines: if order.price_type!='tax_excluded': res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_inv(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) else: res[order.id]['amount_tax'] = tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty)['total_included'] return res |
name, | production.name, | def action_confirm(self, cr, uid, ids): """ Confirms production order. @return: Newly generated picking Id. """ picking_id = False proc_ids = [] seq_obj = self.pool.get('ir.sequence') pick_obj = self.pool.get('stock.picking') move_obj = self.pool.get('stock.move') proc_obj = self.pool.get('procurement.order') wf_service = netsvc.LocalService("workflow") for production in self.browse(cr, uid, ids): if not production.product_lines: self.action_compute(cr, uid, [production.id]) production = self.browse(cr, uid, [production.id])[0] routing_loc = None pick_type = 'internal' address_id = False if production.bom_id.routing_id and production.bom_id.routing_id.location_id: routing_loc = production.bom_id.routing_id.location_id if routing_loc.usage <> 'internal': pick_type = 'out' address_id = routing_loc.address_id and routing_loc.address_id.id or False routing_loc = routing_loc.id pick_name = seq_obj.get(cr, uid, 'stock.picking.' + pick_type) picking_id = pick_obj.create(cr, uid, { 'name': pick_name, 'origin': (production.origin or '').split(':')[0] + ':' + production.name, 'type': pick_type, 'move_type': 'one', 'state': 'auto', 'address_id': address_id, 'auto_picking': self._get_auto_picking(cr, uid, production), 'company_id': production.company_id.id, }) |
('picking', 'Invoice from Picking'), | ('picking', 'Invoice from Delivery'), | def _get_order(self, cr, uid, ids, context=None): if context is None: context = {} result = {} for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): result[line.order_id.id] = True return result.keys() |
res[event.id]['register_current'] = len(reg_ids) | res[event.id]['register_current'] = number and number[0] or 0.0 | def _get_register(self, cr, uid, ids, fields, args, context=None): """Get Confirm or uncofirm register value. @param ids: List of Event registration type's id @param fields: List of function fields(register_current and register_prospect). @param context: A standard dictionary for contextual values @return: Dictionary of function fields value. """ register_pool = self.pool.get('event.registration') res = {} for event in self.browse(cr, uid, ids, context=context): res[event.id] = {} for field in fields: res[event.id][field] = False state = [] if 'register_current' in fields: state += ['open', 'done'] if 'register_prospect' in fields: state.append('draft') |
res[event.id]['register_prospect'] = len(reg_ids) | res[event.id]['register_prospect'] = number and number[0] or 0.0 | def _get_register(self, cr, uid, ids, fields, args, context=None): """Get Confirm or uncofirm register value. @param ids: List of Event registration type's id @param fields: List of function fields(register_current and register_prospect). @param context: A standard dictionary for contextual values @return: Dictionary of function fields value. """ register_pool = self.pool.get('event.registration') res = {} for event in self.browse(cr, uid, ids, context=context): res[event.id] = {} for field in fields: res[event.id][field] = False state = [] if 'register_current' in fields: state += ['open', 'done'] if 'register_prospect' in fields: state.append('draft') |
message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals['name'] or "n/a") + _(" with origin")+" '" + (vals['origin'] or "n/a") + "' "+ _("is created.") | message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals['name'] or "n/a") + _(" with origin")+" '" + (vals.get('origin') or "n/a") + "' "+ _("is created.") | def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) type_list = { 'out':_('Packing List'), 'in':_('Reception'), 'internal': _('Internal picking'), 'delivery': _('Delivery order') } new_id = super(stock_picking, self).create(cr, user, vals, context) if not vals.get('auto_picking', False): message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals['name'] or "n/a") + _(" with origin")+" '" + (vals['origin'] or "n/a") + "' "+ _("is created.") self.log(cr, user, new_id, message) return new_id |
for rec in self.read(cr, uid, ids, ['number_of_days_temp','date_from','date_to']): | for rec in self.read(cr, uid, ids, ['number_of_days_temp','date_from','date_to', 'type']): | def _check_date(self, cr, uid, ids): for rec in self.read(cr, uid, ids, ['number_of_days_temp','date_from','date_to']): if rec['number_of_days_temp'] < 0: return False date_from = time.strptime(rec['date_from'], '%Y-%m-%d %H:%M:%S') date_to = time.strptime(rec['date_to'], '%Y-%m-%d %H:%M:%S') if date_from > date_to: return False return True |
'progress': fields.related('task_id', 'progress', string='Progress (%)',group_operator="avg", store=True), | 'progress': fields.function(_hours_get, method=True, string='Progress (%)', multi='hours', group_operator="avg", help="Computed as: Time Spent / Total Time.", store = { 'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['task_id'], 10), 'project.task': (_get_issue_task, ['progress'], 10), 'project.task.work': (_get_issue_work, ['hours'], 10), }), | def _compute_day(self, cr, uid, ids, fields, args, context=None): if context is None: context = {} """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Openday’s IDs @return: difference between current date and log date @param context: A standard dictionary for contextual values """ cal_obj = self.pool.get('resource.calendar') res_obj = self.pool.get('resource.resource') |
request_pool = self.pool.get('res.request') | request = self.pool.get('res.request') | def do_close(self, cr, uid, ids, context=None): """ Close Task """ if context is None: context = {} request_pool = self.pool.get('res.request') for task in self.browse(cr, uid, ids, context=context): project = task.project_id if project: # Send request to project manager if project.warn_manager and project.user_id and (project.user_id.id != uid): request.create(cr, uid, { 'name': _("Task '%s' closed") % task.name, 'state': 'waiting', 'act_from': uid, 'act_to': project.user_id.id, 'ref_partner_id': task.partner_id.id, 'ref_doc1': 'project.task,%d'% (task.id,), 'ref_doc2': 'project.project,%d'% (project.id,), }) for parent_id in task.parent_ids: if parent_id.state in ('pending','draft'): reopen = True for child in parent_id.child_ids: if child.id != task.id and child.state not in ('done','cancelled'): reopen = False if reopen: self.do_reopen(cr, uid, [parent_id.id]) self.write(cr, uid, [task.id], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0}) message = _('Task ') + " '" + task.name + "' "+ _("is Done.") self.log(cr, uid, task.id, message) return True |
'date_deadline': fields.datetime('Deadline', help="Deadline Date is automatically computed from Start Date + Duration"), | def _set_attendee_data(self, cr, uid, id, name, value, arg, context): if not value: return eventdata = self.browse(cr, uid, id, context=context) att_len = len(eventdata.attendee_ids) if att_len == len(value.split(',')): return if att_len > len(value.split(',')): for attendee in eventdata.attendee_ids[len(value.split(',')):]: self.write(cr, uid, id, {'attendee_ids': [(3, attendee.id)]}) return attendee_obj = self.pool.get('calendar.attendee') for val in value.split(',')[att_len:]: attendee_id = attendee_obj.create(cr, uid, {'cn': val.strip()}) self.write(cr, uid, id, {'attendee_ids': [(4, attendee_id)]}) return |
|
self.do_alarm_create(cr, uid, ids) | self.do_alarm_create(cr, uid, new_ids) | def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): if isinstance(ids, (str, int, long)): select = [ids] else: select = ids new_ids = [] for id in select: id = common.caldav_id2real_id(id) if not id in new_ids: new_ids.append(id) if 'case_id' in vals: vals['case_id'] = common.caldav_id2real_id(vals['case_id']) res = super(crm_meeting, self).write(cr, uid, new_ids, vals, context=context) self.do_alarm_create(cr, uid, ids) return res |
date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): | date_invoice=False, payment_term=False, partner_bank=False, company_id=False): | def onchange_partner_id(self, cr, uid, ids, type, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): """ Function that is call when the partner of the invoice is changed it will retriev and set the good bank partner bank""" res = super(account_invoice, self).onchange_partner_id( cr, uid, ids, type, partner_id, date_invoice, payment_term ) bank_id = False if partner_id: p = self.pool.get('res.partner').browse(cr, uid, partner_id) if p.bank_ids: bank_id = p.bank_ids[0].id |
if partner_bank_id != bank_id: | if partner_bank != bank_id: | def onchange_partner_id(self, cr, uid, ids, type, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): """ Function that is call when the partner of the invoice is changed it will retriev and set the good bank partner bank""" res = super(account_invoice, self).onchange_partner_id( cr, uid, ids, type, partner_id, date_invoice, payment_term ) bank_id = False if partner_id: p = self.pool.get('res.partner').browse(cr, uid, partner_id) if p.bank_ids: bank_id = p.bank_ids[0].id |
base = cur_obj.compute(cr, uid, currency_id, company_currency, base, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) | base = cur_obj.compute(cr, uid, currency_id, company_currency, base*factor, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) | def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency = False if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: base = cur_obj.compute(cr, uid, currency_id, company_currency, base, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'base_amount':base}} |
tax_sign = 1 | factor = 1 | def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency = False tax_sign = 1 if ids: tax_amount = self.read(cr, uid, ids[0], ['tax_amount'])['tax_amount'] if tax_amount < 0: tax_sign = -1 elif tax_amount == 0: tax_sign = 0 if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*tax_sign, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount': amount}} |
tax_amount = self.read(cr, uid, ids[0], ['tax_amount'])['tax_amount'] if tax_amount < 0: tax_sign = -1 elif tax_amount == 0: tax_sign = 0 | factor = self.read(cr, uid, ids[0], ['factor_tax'])['factor_tax'] | def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency = False tax_sign = 1 if ids: tax_amount = self.read(cr, uid, ids[0], ['tax_amount'])['tax_amount'] if tax_amount < 0: tax_sign = -1 elif tax_amount == 0: tax_sign = 0 if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*tax_sign, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount': amount}} |
amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*tax_sign, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) | amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*factor, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) | def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency = False tax_sign = 1 if ids: tax_amount = self.read(cr, uid, ids[0], ['tax_amount'])['tax_amount'] if tax_amount < 0: tax_sign = -1 elif tax_amount == 0: tax_sign = 0 if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*tax_sign, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount': amount}} |
'name': fields.char('Name', size=64, required=True), | 'name': fields.char('Name', size=64, required=True, states={'confirm': [('readonly', True)]}), | def _currency(self, cursor, user, ids, name, args, context=None): res = {} res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') default_currency = res_users_obj.browse(cursor, user, user, context=context).company_id.currency_id for statement in self.browse(cursor, user, ids, context=context): currency = statement.journal_id.currency if not currency: currency = default_currency res[statement.id] = currency.id currency_names = {} for currency_id, currency_name in res_currency_obj.name_get(cursor, user, [x for x in res.values()], context=context): currency_names[currency_id] = currency_name for statement_id in res.keys(): currency_id = res[statement_id] res[statement_id] = (currency_id, currency_names[currency_id]) return res |
'email': cal_data.value.replace('MAILTO:',''), | 'email': cal_data.value.lower().replace('mailto:',''), | 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 """ |
if valid_moves: for move in self.browse(cr, uid, valid_moves): if move.name =='/': new_name = False journal = move.journal_id if invoice and invoice.internal_number: new_name = invoice.internal_number | if not valid_moves: raise osv.except_osv(_('Integrity Error !'), _('You cannot validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !')) for move in self.browse(cr, uid, valid_moves): if move.name =='/': new_name = False journal = move.journal_id if invoice and invoice.internal_number: new_name = invoice.internal_number else: if journal.sequence_id: c = {'fiscalyear_id': move.period_id.fiscalyear_id.id} new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c) | def post(self, cr, uid, ids, context=None): invoice = context.get('invoice', False) valid_moves = self.validate(cr, uid, ids, context) if valid_moves: for move in self.browse(cr, uid, valid_moves): if move.name =='/': new_name = False journal = move.journal_id |
if journal.sequence_id: c = {'fiscalyear_id': move.period_id.fiscalyear_id.id} new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c) else: raise osv.except_osv(_('Error'), _('No sequence defined in the journal !')) if new_name: self.write(cr, uid, [move.id], {'name':new_name}) cr.execute('UPDATE account_move '\ 'SET state=%s '\ 'WHERE id IN %s', ('posted', tuple(valid_moves),)) else: raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !')) | raise osv.except_osv(_('Error'), _('No sequence defined on the journal !')) if new_name: self.write(cr, uid, [move.id], {'name':new_name}) cr.execute('UPDATE account_move '\ 'SET state=%s '\ 'WHERE id IN %s', ('posted', tuple(valid_moves),)) | def post(self, cr, uid, ids, context=None): invoice = context.get('invoice', False) valid_moves = self.validate(cr, uid, ids, context) if valid_moves: for move in self.browse(cr, uid, valid_moves): if move.name =='/': new_name = False journal = move.journal_id |
amount = currency_obj.compute(cursor, user, line.currency_id.id, | amount = currency_obj.compute(cr, user, line.currency_id.id, | def populate_statement(self, cr, uid, ids, context=None): |
amount = currency_obj.compute(cursor, user, line.invoice.currency_id.id, | amount = currency_obj.compute(cr, user, line.invoice.currency_id.id, | def populate_statement(self, cr, uid, ids, context=None): |
rec = anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, uid, time.strftime('%Y-%m-%d'), context) | rec = anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, sale_line.order_id.user_id.id, time.strftime('%Y-%m-%d'), context) | def invoice_line_create(self, cr, uid, ids, context=None): create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context) if not ids: return create_ids sale_line = self.browse(cr, uid, ids[0], context) inv_line_obj = self.pool.get('account.invoice.line') anal_def_obj = self.pool.get('account.analytic.default') for line in inv_line_obj.browse(cr, uid, create_ids, context): rec = anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, uid, time.strftime('%Y-%m-%d'), context) |
db = pooler.get_db_only(db_name) cr = db.cursor() cr.execute("select id from ir_module_module where name = 'document' and state='installed' ") res=cr.fetchone() if res and len(res): self.db_name_list.append(db_name) cr.close() | cr = None try: db = pooler.get_db_only(db_name) cr = db.cursor() cr.execute("SELECT id FROM ir_module_module WHERE name = 'document' AND state='installed' ") res=cr.fetchone() if res and len(res): self.db_name_list.append(db_name) except Exception, e: self.parent.log_error("Exception in db list: %s" % e) finally: if cr: cr.close() | def db_list(self): s = netsvc.ExportService.getService('db') result = s.exp_list() self.db_name_list=[] for db_name in result: db = pooler.get_db_only(db_name) cr = db.cursor() cr.execute("select id from ir_module_module where name = 'document' and state='installed' ") res=cr.fetchone() if res and len(res): self.db_name_list.append(db_name) cr.close() return self.db_name_list |
class res_users(osv.osv): _inherit = 'res.users' def _get_group(self, cr, uid, context=None): result = super(res_users, self)._get_group(cr, uid, context=context) dataobj = self.pool.get('ir.model.data') try: dummy,group_id = dataobj.get_object_reference(cr, 1, 'product', 'group_product_manager') result.append(group_id) except ValueError: pass return result _defaults = { 'groups_id': _get_group, } res_users() | def price_get(self, cr, uid, supplier_ids, product_id, product_qty=1, context=None): """ Calculate price from supplier pricelist. @param supplier_ids: Ids of res.partner object. @param product_id: Id of product. @param product_qty: specify quantity to purchase. """ if type(supplier_ids) in (int,long,): supplier_ids = [supplier_ids] res = {} product_pool = self.pool.get('product.product') partner_pool = self.pool.get('res.partner') pricelist_pool = self.pool.get('product.pricelist') currency_pool = self.pool.get('res.currency') currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id for supplier in partner_pool.browse(cr, uid, supplier_ids, context=context): # Compute price from standard price of product price = product_pool.price_get(cr, uid, [product_id], 'standard_price')[product_id] |
|
if hours.get(task.id, 0.0) > res[task.id]['total_hours']: res[task.id]['progress'] = round(100 - (max(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 100)) % 100, 2) | if task.state =='done': res[task.id]['progress'] = 100.0 | def _hours_get(self, cr, uid, ids, field_names, args, context=None): res = {} cr.execute("SELECT task_id, COALESCE(SUM(hours),0) FROM project_task_work WHERE task_id =ANY(%s) GROUP BY task_id",(ids,)) hours = dict(cr.fetchall()) for task in self.browse(cr, uid, ids, context=context): res[task.id] = {'effective_hours': hours.get(task.id, 0.0), 'total_hours': task.remaining_hours + hours.get(task.id, 0.0)} if (task.remaining_hours + hours.get(task.id, 0.0)): if hours.get(task.id, 0.0) > res[task.id]['total_hours']: res[task.id]['progress'] = round(100 - (max(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 100)) % 100, 2) else: res[task.id]['progress'] = round(min(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 100),2) else: res[task.id]['progress'] = 0.0 if task.state in ('done','cancel'): res[task.id]['progress'] = 100.0 res[task.id]['delay_hours'] = res[task.id]['total_hours'] - task.planned_hours return res |
res[task.id]['progress'] = round(min(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 100),2) | res[task.id]['progress'] = round(min(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 99.99),2) | def _hours_get(self, cr, uid, ids, field_names, args, context=None): res = {} cr.execute("SELECT task_id, COALESCE(SUM(hours),0) FROM project_task_work WHERE task_id =ANY(%s) GROUP BY task_id",(ids,)) hours = dict(cr.fetchall()) for task in self.browse(cr, uid, ids, context=context): res[task.id] = {'effective_hours': hours.get(task.id, 0.0), 'total_hours': task.remaining_hours + hours.get(task.id, 0.0)} if (task.remaining_hours + hours.get(task.id, 0.0)): if hours.get(task.id, 0.0) > res[task.id]['total_hours']: res[task.id]['progress'] = round(100 - (max(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 100)) % 100, 2) else: res[task.id]['progress'] = round(min(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 100),2) else: res[task.id]['progress'] = 0.0 if task.state in ('done','cancel'): res[task.id]['progress'] = 100.0 res[task.id]['delay_hours'] = res[task.id]['total_hours'] - task.planned_hours return res |
event.add('dtend').value = ics_datetime(event_obj.date_deadline) | if not event_obj.date_deadline[10:]: short = True else: short = False event.add('dtend').value = ics_datetime(event_obj.date_deadline, short) | def ics_datetime(idate, short=False): if idate: if short: return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) else: return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S') else: return False |
msg['subject'] = ' '.join(map(lambda (x, y): unicode(x, y or 'ascii'), decode_header(msg_txt.get('Subject')))) | msg['subject'] = _decode_header(msg_txt.get('Subject')) | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) |
msg['from'] = msg_txt.get('From') | msg['from'] = _decode_header(msg_txt.get('From')) | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) |
msg['to'] = msg_txt.get('Delivered-To') | msg['to'] = _decode_header(msg_txt.get('Delivered-To')) | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) |
msg['cc'] = msg_txt.get('Cc') | msg['cc'] = _decode_header(msg_txt.get('Cc')) | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) |
msg['reply'] = msg_txt.get('Reply-To') | msg['reply'] = _decode_header(msg_txt.get('Reply-To')) | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) |
if part.get_content_subtype() == 'html': body = html2plaintext(content) elif part.get_content_subtype() == 'plain': body = content | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) |
|
attachents[filename] = part.get_payload(decode=True) | attachents[filename] = content else: if encoding: content = unicode(content, encoding) if part.get_content_subtype() == 'html': body = html2plaintext(content) elif part.get_content_subtype() == 'plain': body = content | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) |
body += part.get_payload(decode=True) | res = part.get_payload(decode=True) if encoding: res = res.decode(encoding).encode('utf-8') body += res | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) |
encoding = msg_txt.get_content_charset('utf-8') msg['body'] = msg['body'].decode(encoding).encode('utf-8') | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) |
|
val = property_obj.browse(cr, uid,prop_ids[0]).value | val = property_obj.browse(cr, uid,prop_ids[0]).value_reference | def create_returns2(self, cr, uid, ids, context): record_id = context.get('record_id', False) order_obj =self.pool.get('pos.order') line_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") uom_obj =self. pool.get('product.uom') wf_service = netsvc.LocalService("workflow") #Todo :Need to clean the code if record_id: picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) data=self.read(cr,uid,ids)[0] clone_list = [] date_cur=time.strftime('%Y-%m-%d') |
stock_dest_id = int(val.split(',')[1]) | stock_dest_id = val.id | def create_returns2(self, cr, uid, ids, context): record_id = context.get('record_id', False) order_obj =self.pool.get('pos.order') line_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") uom_obj =self. pool.get('product.uom') wf_service = netsvc.LocalService("workflow") #Todo :Need to clean the code if record_id: picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) data=self.read(cr,uid,ids)[0] clone_list = [] date_cur=time.strftime('%Y-%m-%d') |
val = property_obj.browse(cr, uid,prop_ids[0]).value | val = property_obj.browse(cr, uid,prop_ids[0]).value_reference | def select_product(self, cr, uid, ids, context): """ To get the product and quantity and add in order . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : Retrun the add product form again for adding more product """ if not context.get('record_id', False): super(add_product).select_product(cr,uid,ids) else: record_id=context.get('record_id', False) data = self.read(cr, uid, ids)[0] order_obj = self.pool.get('pos.order') lines_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") invoice_obj= self.pool.get('account.invoice') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = self.pool.get('product.uom') prod_obj=self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") return_boj=self.pool.get('pos.return') order_obj.add_product(cr, uid, record_id,data['product_id'],data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [record_id], context=context): prod=data['product_id'] qty=data['quantity'] prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid,prop_ids[0]).value cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = int(val.split(',')[1]) prod_id=prod_obj.browse(cr,uid,prod) new_picking=picking_obj.create(cr,uid,{ 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', 'type':'out', 'date':date_cur, }) new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty, 'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id), 'picking_id':new_picking, 'product_uom':prod_id.uom_id.id, 'location_id':location_id, 'product_id':prod_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,record_id,{'last_out_picking':new_picking}) return { 'name': _('Add Product'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'pos.add.product', 'view_id': False, 'target':'new', 'context':context, 'views': False, 'type': 'ir.actions.act_window', } |
stock_dest_id = int(val.split(',')[1]) | stock_dest_id = val.id | def select_product(self, cr, uid, ids, context): """ To get the product and quantity and add in order . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : Retrun the add product form again for adding more product """ if not context.get('record_id', False): super(add_product).select_product(cr,uid,ids) else: record_id=context.get('record_id', False) data = self.read(cr, uid, ids)[0] order_obj = self.pool.get('pos.order') lines_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") invoice_obj= self.pool.get('account.invoice') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = self.pool.get('product.uom') prod_obj=self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") return_boj=self.pool.get('pos.return') order_obj.add_product(cr, uid, record_id,data['product_id'],data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [record_id], context=context): prod=data['product_id'] qty=data['quantity'] prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid,prop_ids[0]).value cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = int(val.split(',')[1]) prod_id=prod_obj.browse(cr,uid,prod) new_picking=picking_obj.create(cr,uid,{ 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', 'type':'out', 'date':date_cur, }) new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty, 'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id), 'picking_id':new_picking, 'product_uom':prod_id.uom_id.id, 'location_id':location_id, 'product_id':prod_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,record_id,{'last_out_picking':new_picking}) return { 'name': _('Add Product'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'pos.add.product', 'view_id': False, 'target':'new', 'context':context, 'views': False, 'type': 'ir.actions.act_window', } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.