rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def or curr_c.account_receivable.id
args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def.id or curr_c.account_receivable.id
args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def or curr_c.account_receivable.id
9188a9c47b10cbea19db8c7701d349e1bdbd83ef /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9188a9c47b10cbea19db8c7701d349e1bdbd83ef/pos.py
params += max_amount
params += (max_amount,)
def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', False) and form.get('max_amount') or 0.0 power = form['power'] allow_write_off = form['allow_write_off'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: params = (account_id,) if not allow_write_off: query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL AND state <> 'draft' GROUP BY partner_id HAVING ABS(SUM(debit-credit)) = 0.0 AND count(*)>0""" else: query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL AND state <> 'draft' GROUP BY partner_id HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0""" params += max_amount # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query, params) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if allow_write_off: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) else: move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={})
c3cbb6649c3539d096dd630a2ee258cb80933b45 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c3cbb6649c3539d096dd630a2ee258cb80933b45/account_automatic_reconcile.py
exists, r_id = caldav.uid2openobjectid(cr, val['id'], context.get('model'), \
exists, r_id = calendar.uid2openobjectid(cr, val['id'], context.get('model'), \
def check_import(self, cr, uid, vals, context={}): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param vals: Get Values @param context: A standard dictionary for contextual values """ ids = [] model_obj = self.pool.get(context.get('model')) recur_pool = {} try: for val in vals: exists, r_id = caldav.uid2openobjectid(cr, val['id'], context.get('model'), \ val.get('recurrent_id')) if val.has_key('create_date'): val.pop('create_date') u_id = val.get('id', None) val.pop('id') if exists and r_id: val.update({'recurrent_uid': exists}) model_obj.write(cr, uid, [r_id], val) ids.append(r_id) elif exists: # Compute value of duration if 'date_deadline' in val and 'duration' not in val: start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S') end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S') diff = end - start val['duration'] = (diff.seconds/float(86400) + diff.days) * 24 model_obj.write(cr, uid, [exists], val) ids.append(exists) else: if u_id in recur_pool and val.get('recurrent_id'): val.update({'recurrent_uid': recur_pool[u_id]}) revent_id = model_obj.create(cr, uid, val) ids.append(revent_id) else: event_id = model_obj.create(cr, uid, val) recur_pool[u_id] = event_id ids.append(event_id) except Exception, e: raise osv.except_osv(('Error !'), (str(e))) return ids
9d4e369c847ce2bd696bdeb9d356e6d2d72f313d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d4e369c847ce2bd696bdeb9d356e6d2d72f313d/crm_caldav.py
def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from', False), context={}):
def email_send(self, cr, uid, obj, emails, body, emailfrom=None, context=None):
def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from', False), context={}): """ send email @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 email: pass the emails @param emailfrom: Pass name the email From else False @param context: A standard dictionary for contextual values """ body = self.format_mail(obj, body) if not emailfrom: if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and\ obj.user_id.address_id.email: emailfrom = obj.user_id.address_id.email
c2b346743214ee3e9cac1aefeb2b874c6d090634 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c2b346743214ee3e9cac1aefeb2b874c6d090634/base_action_rule.py
self.email_send(cr, uid, obj, emails, action.act_mail_body)
email_from = eval(action.act_email_from, { 'user' : self.pool.get('res.users').browse(cr, uid, uid, context=context), 'obj' : obj, }) self.email_send(cr, uid, obj, emails, action.act_mail_body, emailfrom=email_from)
def do_action(self, cr, uid, action, model_obj, obj, context={}): """ Do Action @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 action: pass action @param model_obj: pass Model object @param context: A standard dictionary for contextual values """
c2b346743214ee3e9cac1aefeb2b874c6d090634 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c2b346743214ee3e9cac1aefeb2b874c6d090634/base_action_rule.py
attrs['selection'] = self.pool.get(relation).name_search(cr, user, '', dom, context=context)
attrs['selection'] = self.pool.get(relation).name_search(cr, user, '', dom, context=context,limit=None)
def __view_look_dom(self, cr, user, node, view_id, context=None): if not context: context = {} result = False fields = {} childs = True
7d81ac0cde8243d593c270a4497e0c9d1611d35e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7d81ac0cde8243d593c270a4497e0c9d1611d35e/orm.py
res = obj.create(cr, uid, data, context)
obj.create(cr, uid, data, context)
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \ email_from=False, message_id=False, references=None, attach=None, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param cases: a browse record list @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used @param history: Value True/False, If True it makes entry in case History otherwise in Case Log @param email: Email address if any @param details: Details of case history if any @param atach: Attachment sent in email @param context: A standard dictionary for contextual values""" if context is None: context = {} if attach is None: attach = []
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
'name':fields.char('Subject', size=128), 'model': fields.char('Object Name', size=128), 'res_id': fields.integer('Resource ID'),
'name':fields.char('Subject', size=128), 'model': fields.char('Object Name', size=128, select=1), 'res_id': fields.integer('Resource ID', select=1),
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \ email_from=False, message_id=False, references=None, attach=None, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param cases: a browse record list @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used @param history: Value True/False, If True it makes entry in case History otherwise in Case Log @param email: Email address if any @param details: Details of case history if any @param atach: Attachment sent in email @param context: A standard dictionary for contextual values""" if context is None: context = {} if attach is None: attach = []
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
'date': fields.datetime('Date'),
'date': fields.datetime('Date'),
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \ email_from=False, message_id=False, references=None, attach=None, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param cases: a browse record list @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used @param history: Value True/False, If True it makes entry in case History otherwise in Case Log @param email: Email address if any @param details: Details of case history if any @param atach: Attachment sent in email @param context: A standard dictionary for contextual values""" if context is None: context = {} if attach is None: attach = []
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
'user_id': fields.many2one('res.users', 'User Responsible', readonly=True), 'message': fields.text('Description'), 'email_from': fields.char('Email From', size=84), 'email_to': fields.char('Email To', size=84), 'email_cc': fields.char('Email CC', size=84), 'email_bcc': fields.char('Email BCC', size=84),
'user_id': fields.many2one('res.users', 'User Responsible', readonly=True), 'message': fields.text('Description'), 'email_from': fields.char('Email From', size=84), 'email_to': fields.char('Email To', size=84), 'email_cc': fields.char('Email CC', size=84), 'email_bcc': fields.char('Email BCC', size=84),
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \ email_from=False, message_id=False, references=None, attach=None, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param cases: a browse record list @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used @param history: Value True/False, If True it makes entry in case History otherwise in Case Log @param email: Email address if any @param details: Details of case history if any @param atach: Attachment sent in email @param context: A standard dictionary for contextual values""" if context is None: context = {} if attach is None: attach = []
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
'description': fields.text('Description'), 'partner_id': fields.many2one('res.partner', 'Partner', required=False), 'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments'),
'description': fields.text('Description'), 'partner_id': fields.many2one('res.partner', 'Partner', required=False), 'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments'),
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \ email_from=False, message_id=False, references=None, attach=None, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param cases: a browse record list @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used @param history: Value True/False, If True it makes entry in case History otherwise in Case Log @param email: Email address if any @param details: Details of case history if any @param atach: Attachment sent in email @param context: A standard dictionary for contextual values""" if context is None: context = {} if attach is None: attach = []
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
msg_id = msg_pool.create(cr, uid, msg_data, context=context)
msg_pool.create(cr, uid, msg_data, context=context)
def history(self, cr, uid, model, res_ids, msg, attach, context=None): """This function creates history for mails fetched @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param model: OpenObject Model @param res_ids: Ids of the record of OpenObject model created @param msg: Email details @param attach: Email attachments """ if isinstance(res_ids, (int, long)): res_ids = [res_ids]
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
return res_id
return res_id, att_ids
def create_record(msg): if hasattr(model_pool, 'message_new'): res_id = model_pool.message_new(cr, uid, msg, context) else: data = { 'name': msg.get('subject'), 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'user_id': False, 'description': msg.get('body'), 'state' : 'draft', } data.update(self.get_partner(cr, uid, msg.get('from'), context=context)) res_id = model_pool.create(cr, uid, data, context=context)
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
counter = 1
def create_record(msg): if hasattr(model_pool, 'message_new'): res_id = model_pool.message_new(cr, uid, msg, context) else: data = { 'name': msg.get('subject'), 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'user_id': False, 'description': msg.get('body'), 'state' : 'draft', } data.update(self.get_partner(cr, uid, msg.get('from'), context=context)) res_id = model_pool.create(cr, uid, data, context=context)
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
elif part.get_content_maintype()=='application' or part.get_content_maintype()=='image' or part.get_content_maintype()=='text':
elif part.get_content_maintype() in ('application', 'image', 'text'):
def create_record(msg): if hasattr(model_pool, 'message_new'): res_id = model_pool.message_new(cr, uid, msg, context) else: data = { 'name': msg.get('subject'), 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'user_id': False, 'description': msg.get('body'), 'state' : 'draft', } data.update(self.get_partner(cr, uid, msg.get('from'), context=context)) res_id = model_pool.create(cr, uid, data, context=context)
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
new_res_id = create_record(msg)
new_res_id, attachment_ids = create_record(msg)
def create_record(msg): if hasattr(model_pool, 'message_new'): res_id = model_pool.message_new(cr, uid, msg, context) else: data = { 'name': msg.get('subject'), 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'user_id': False, 'description': msg.get('body'), 'state' : 'draft', } data.update(self.get_partner(cr, uid, msg.get('from'), context=context)) res_id = model_pool.create(cr, uid, data, context=context)
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
attach = msg.get('attachments', {}).items(),
attach = attachments.items(),
def create_record(msg): if hasattr(model_pool, 'message_new'): res_id = model_pool.message_new(cr, uid, msg, context) else: data = { 'name': msg.get('subject'), 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'user_id': False, 'description': msg.get('body'), 'state' : 'draft', } data.update(self.get_partner(cr, uid, msg.get('from'), context=context)) res_id = model_pool.create(cr, uid, data, context=context)
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
self.history(cr, uid, model, res_ids, msg, att_ids, context=context)
self.history(cr, uid, model, res_ids, msg, attachment_ids, context=context)
def create_record(msg): if hasattr(model_pool, 'message_new'): res_id = model_pool.message_new(cr, uid, msg, context) else: data = { 'name': msg.get('subject'), 'email_from': msg.get('from'), 'email_cc': msg.get('cc'), 'user_id': False, 'description': msg.get('body'), 'state' : 'draft', } data.update(self.get_partner(cr, uid, msg.get('from'), context=context)) res_id = model_pool.create(cr, uid, data, context=context)
25f3c114cde830404ca9430e1cd75cadc8bfd6fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/25f3c114cde830404ca9430e1cd75cadc8bfd6fd/mail_gateway.py
bom_parent = bom_obj.browse(cr, uid, context['active_id'])
bom_id = context and context.get('active_id', False) or False cr.execute('select id from mrp_bom') if all(bom_id != r[0] for r in cr.fetchall()): ids.sort() bom_id = ids[0] bom_parent = bom_obj.browse(cr, uid, bom_id)
def _child_compute(self, cr, uid, ids, name, arg, context={}): """ Gets child bom. @param self: The object pointer @param cr: The current row, from the database cursor, @param uid: The current user ID for security checks @param ids: List of selected IDs @param name: Name of the field @param arg: User defined argument @param context: A standard dictionary for contextual values @return: Dictionary of values """ result = {} bom_obj = self.pool.get('mrp.bom') bom_parent = bom_obj.browse(cr, uid, context['active_id']) for bom in self.browse(cr, uid, ids, context=context): if bom_parent.multi_level_bom or bom.id == context['active_id']: result[bom.id] = map(lambda x: x.id, bom.bom_lines) else: result[bom.id] = [] if bom.bom_lines: continue ok = ((name=='child_complete_ids') and (bom.product_id.supply_method=='produce')) if (bom.type=='phantom' or ok) and bom_parent.multi_level_bom: sids = bom_obj.search(cr, uid, [('bom_id','=',False),('product_id','=',bom.product_id.id)]) if sids: bom2 = bom_obj.browse(cr, uid, sids[0], context=context) result[bom.id] += map(lambda x: x.id, bom2.bom_lines)
ab65a9c67cd6c1fac4415711c2e9229744ac7b30 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ab65a9c67cd6c1fac4415711c2e9229744ac7b30/mrp.py
if bom_parent.multi_level_bom or bom.id == context['active_id']:
if (bom_parent and bom_parent.multi_level_bom) or bom.id == bom_id:
def _child_compute(self, cr, uid, ids, name, arg, context={}): """ Gets child bom. @param self: The object pointer @param cr: The current row, from the database cursor, @param uid: The current user ID for security checks @param ids: List of selected IDs @param name: Name of the field @param arg: User defined argument @param context: A standard dictionary for contextual values @return: Dictionary of values """ result = {} bom_obj = self.pool.get('mrp.bom') bom_parent = bom_obj.browse(cr, uid, context['active_id']) for bom in self.browse(cr, uid, ids, context=context): if bom_parent.multi_level_bom or bom.id == context['active_id']: result[bom.id] = map(lambda x: x.id, bom.bom_lines) else: result[bom.id] = [] if bom.bom_lines: continue ok = ((name=='child_complete_ids') and (bom.product_id.supply_method=='produce')) if (bom.type=='phantom' or ok) and bom_parent.multi_level_bom: sids = bom_obj.search(cr, uid, [('bom_id','=',False),('product_id','=',bom.product_id.id)]) if sids: bom2 = bom_obj.browse(cr, uid, sids[0], context=context) result[bom.id] += map(lambda x: x.id, bom2.bom_lines)
ab65a9c67cd6c1fac4415711c2e9229744ac7b30 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ab65a9c67cd6c1fac4415711c2e9229744ac7b30/mrp.py
where active")
WHERE active")
def pre_action(self, cr, uid, ids, model, context=None): # Searching for action rules cr.execute("SELECT model.model, rule.id FROM base_action_rule rule \ LEFT JOIN ir_model model on (model.id = rule.model_id) \ where active") res = cr.fetchall() # Check if any rule matching with current object for obj_name, rule_id in res: if not (model == obj_name): continue else: obj = self.pool.get(obj_name) self._action(cr, uid, [rule_id], obj.browse(cr, uid, ids, context=context), context=context) return True
42ca50081352be6ecc44b3cc746553dbbda5c0a0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/42ca50081352be6ecc44b3cc746553dbbda5c0a0/base_action_rule.py
'company_id': fields.many2one('res.company', 'Company', select=True, required=True),
'company_id': fields.many2one('res.company', 'Company', select=True, required=False),
def _dept_name_get_fnc(self, cr, uid, ids, prop, unknow_none, context): res = self.name_get(cr, uid, ids, context) return dict(res)
3c2cd6a12a802f1d27c6bedffcd368e0175d424c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3c2cd6a12a802f1d27c6bedffcd368e0175d424c/hr_department.py
avg(100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor))::decimal(16,2) as negociation,
avg(case when t.standard_price <= 0 then (100.0 * (l.price_unit*l.product_qty*u.factor)) else (100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor)) end) as negociation,
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_report') cr.execute(""" create or replace view purchase_report as ( select min(l.id) as id, s.date_order as date, to_char(s.date_order, 'YYYY') as name, to_char(s.date_order, 'MM') as month, to_char(s.date_order, 'YYYY-MM-DD') as day, s.state, s.date_approve, date_trunc('day',s.minimum_planned_date) as expected_date, s.partner_address_id, s.dest_address_id, s.pricelist_id, s.validator, s.warehouse_id as warehouse_id, s.partner_id as partner_id, s.create_uid as user_id, s.company_id as company_id, l.product_id, t.categ_id as category_id, l.product_uom as product_uom, s.location_id as location_id, sum(l.product_qty*u.factor) as quantity, extract(epoch from age(s.date_approve,s.date_order))/(24*60*60)::decimal(16,2) as delay, extract(epoch from age(l.date_planned,s.date_order))/(24*60*60)::decimal(16,2) as delay_pass, count(*) as nbr, (l.price_unit*l.product_qty*u.factor)::decimal(16,2) as price_total, avg(100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor))::decimal(16,2) as negociation, sum(t.standard_price*l.product_qty*u.factor)::decimal(16,2) as price_standard, (sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average from purchase_order s left join purchase_order_line l on (s.id=l.order_id) left join product_product p on (l.product_id=p.id) left join product_template t on (p.product_tmpl_id=t.id) left join product_uom u on (u.id=l.product_uom) where l.product_id is not null group by s.company_id, s.create_uid, s.partner_id, l.product_qty, u.factor, s.location_id, l.price_unit, s.date_approve, l.date_planned, l.product_uom, date_trunc('day',s.minimum_planned_date), s.partner_address_id, s.pricelist_id, s.validator, s.dest_address_id, l.product_id, t.categ_id, s.date_order, to_char(s.date_order, 'YYYY'), to_char(s.date_order, 'MM'), to_char(s.date_order, 'YYYY-MM-DD'), s.state, s.warehouse_id ) """)
876bcf590be102c0ac1cd0a0f0048fe20f7fe929 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/876bcf590be102c0ac1cd0a0f0048fe20f7fe929/purchase_report.py
'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases")
'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases"), 'resource_calendar_id': fields.many2one('resource.calendar', 'Working Time', help="Timetable working hours to adjust the gantt diagram report"),
def phase_done(self, cr, uid, ids,*args): self.write(cr, uid, ids, {'state': 'done'}) return True
350baa314cdadc1ba4c88fb972a876dea678c6bc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/350baa314cdadc1ba4c88fb972a876dea678c6bc/project.py
if company_currency_id==st_line.account_id.currency_id.id: amount_cur = st_line.amount else: amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, st_line.account_id.currency_id.id, amount, context=context, account=acc_cur) val['amount_currency'] = amount_cur
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, st_line.account_id.currency_id.id, amount, context=context, account=acc_cur) val['amount_currency'] = -amount_cur
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): res_currency_obj = self.pool.get('res.currency') 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.bank.statement.line') st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context) st = st_line.statement_id
3b368f40344361c82c02193ec64ff949cc93656e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3b368f40344361c82c02193ec64ff949cc93656e/account_bank_statement.py
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res_users_obj = self.pool.get('res.users') res_currency_obj = self.pool.get('res.currency') res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res account_id = False line = self.browse(cursor, user, line_id) if not line or (line and not line[0].account_id): part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id
3b368f40344361c82c02193ec64ff949cc93656e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3b368f40344361c82c02193ec64ff949cc93656e/account_bank_statement.py
data['amount'] = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0) data['balance'] = cur_price_unit
amount = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0)
def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None): taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
6ba1955ac1d0e009b238908d0f5be2adf8f44220 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6ba1955ac1d0e009b238908d0f5be2adf8f44220/account.py
print "RULE: %s" % (rule,) print " %s" % (rule.last_run,)
def _check(self, cr, uid, automatic=False, use_new_cursor=False, \ context=None): """ This Function is call by scheduler. """ rule_pool = self.pool.get('base.action.rule') rule_ids = rule_pool.search(cr, uid, [], context=context) self._register_hook(cr, uid, rule_ids, context=context)
6027763a6ac656c9fd5dd6a4377e6c24ecd91e0c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6027763a6ac656c9fd5dd6a4377e6c24ecd91e0c/base_action_rule.py
print " OBJ: %s" % (obj_id,)
def _check(self, cr, uid, automatic=False, use_new_cursor=False, \ context=None): """ This Function is call by scheduler. """ rule_pool = self.pool.get('base.action.rule') rule_ids = rule_pool.search(cr, uid, [], context=context) self._register_hook(cr, uid, rule_ids, context=context)
6027763a6ac656c9fd5dd6a4377e6c24ecd91e0c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6027763a6ac656c9fd5dd6a4377e6c24ecd91e0c/base_action_rule.py
print " D: %s" % (d,)
def _check(self, cr, uid, automatic=False, use_new_cursor=False, \ context=None): """ This Function is call by scheduler. """ rule_pool = self.pool.get('base.action.rule') rule_ids = rule_pool.search(cr, uid, [], context=context) self._register_hook(cr, uid, rule_ids, context=context)
6027763a6ac656c9fd5dd6a4377e6c24ecd91e0c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6027763a6ac656c9fd5dd6a4377e6c24ecd91e0c/base_action_rule.py
print " RUNNING"
def _check(self, cr, uid, automatic=False, use_new_cursor=False, \ context=None): """ This Function is call by scheduler. """ rule_pool = self.pool.get('base.action.rule') rule_ids = rule_pool.search(cr, uid, [], context=context) self._register_hook(cr, uid, rule_ids, context=context)
6027763a6ac656c9fd5dd6a4377e6c24ecd91e0c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6027763a6ac656c9fd5dd6a4377e6c24ecd91e0c/base_action_rule.py
date_formatted = strptime(date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
date_formatted = time.strptime(date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
def _get_and_change_date_format_for_swiss (self,date_to_format): date_formatted='' print date_to_format if date_to_format: date_formatted = strptime(date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y') return date_formatted
2777e022aa3487d0d5fb436df80ed7a522eb3554 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2777e022aa3487d0d5fb436df80ed7a522eb3554/bvr_report.py
if not partner.ean13: continue if len(partner.ean13) not in [13,14,8]: return False try: int(partner.ean13) except: return False oddsum=0 evensum=0 total=0 eanvalue=partner.ean13 reversevalue = eanvalue[::-1] finalean=reversevalue[1:] for i in range(len(finalean)): if is_pair(i): oddsum += int(finalean[i]) else: evensum += int(finalean[i]) total=(oddsum * 3) + evensum check = int(10 - math.ceil(total % 10.0)) if check != int(partner.ean13[-1]): return False return True
res = check_ean(partner.ean13) return res
def _check_ean_key(self, cr, uid, ids): for partner in self.browse(cr, uid, ids): if not partner.ean13: continue if len(partner.ean13) not in [13,14,8]: return False try: int(partner.ean13) except: return False oddsum=0 evensum=0 total=0 eanvalue=partner.ean13 reversevalue = eanvalue[::-1] finalean=reversevalue[1:]
05a612012c00d1880266fc26fdf83943ff821296 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/05a612012c00d1880266fc26fdf83943ff821296/product.py
ids = self.search(cr, user, [('code', '=', name)] + args,
ids = self.search(cr, user, [('code', 'ilike', name)] + args,
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80): if not args: args=[] if not context: context={} ids = False if len(name) == 2: ids = self.search(cr, user, [('code', '=', name)] + args, limit=limit, context=context) if not ids: ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context) return self.name_get(cr, user, ids, context)
6a5c13c0188a2d91ab7dd73f52c35b6680daa06d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6a5c13c0188a2d91ab7dd73f52c35b6680daa06d/country.py
emp_ids = obj_emp.search(cr, uid, [('category_id', '=', record.category_id.id)])
emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)])
def holidays_validate(self, cr, uid, ids, *args): obj_emp = self.pool.get('hr.employee') data_holiday = self.browse(cr, uid, ids) self.check_holidays(cr, uid, ids) vals = {'state':'validate'} ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) if ids2: if data_holiday[0].state == 'validate1': vals['manager_id2'] = ids2[0] else: vals['manager_id'] = ids2[0] else: raise osv.except_osv(_('Warning !'), _('No user related to the selected employee.')) self.write(cr, uid, ids, vals) for record in data_holiday: if record.holiday_type == 'employee' and record.type == 'remove': vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': record.employee_id.calendar_id.id, 'company_id': record.employee_id.company_id.id, 'resource_id': record.employee_id.resource_id.id, 'holiday_id': record.id } self._create_resource_leave(cr, uid, vals) elif record.holiday_type == 'category' and record.type == 'remove': emp_ids = obj_emp.search(cr, uid, [('category_id', '=', record.category_id.id)]) for emp in obj_emp.browse(cr, uid, emp_ids): vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': emp.calendar_id.id, 'company_id': emp.company_id.id, 'resource_id': emp.resource_id.id, 'holiday_id':record.id } self._create_resource_leave(cr, uid, vals) return True
279d41f156ee676cae9373e27b6354b7f07c9a9a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/279d41f156ee676cae9373e27b6354b7f07c9a9a/hr_holidays.py
'resource_id': fields.many2one('resource.resource', 'Resource', required=True),
'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade', required=True),
def set_done(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'done'}) return True
f5707955cdf4beee85a0b02e96e56a4746b9504e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f5707955cdf4beee85a0b02e96e56a4746b9504e/project_long_term.py
'target': 'new',
'target': 'current',
def invoice_pay_customer(self, cr, uid, ids, context={}): if not ids: return [] inv = self.browse(cr, uid, ids[0], context=context) return { 'name':_("Pay Invoice"), 'view_mode': 'form', 'view_id': False, 'view_type': 'form', 'res_model': 'account.voucher', 'type': 'ir.actions.act_window', 'nodestroy': True, 'target': 'new', 'domain': '[]', 'context': { 'default_partner_id': inv.partner_id.id, 'default_amount': inv.residual, 'default_name':inv.name, 'close_after_process': True, 'invoice_type':inv.type, 'invoice_id':inv.id, 'default_type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment' } }
b51521b97daa579ac3c4d647c41d582b3c68ff05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b51521b97daa579ac3c4d647c41d582b3c68ff05/invoice.py
Logger().notifyChannel('%s' % title, LOG_DEBUG_RPC, pformat(msg))
if tools.config['log_level'] == logging.DEBUG_RPC: Logger().notifyChannel('%s' % title, LOG_DEBUG_RPC, pformat(msg))
def log(self, title, msg): Logger().notifyChannel('%s' % title, LOG_DEBUG_RPC, pformat(msg))
2f0ff7766a28a952e65d5bf4ed7bbbc23b6dc1c8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2f0ff7766a28a952e65d5bf4ed7bbbc23b6dc1c8/netsvc.py
db = pooler.get_db_only(cr.dbname) interface.register_all(db)
pool.get('ir.actions.report.xml').register_all(cr)
def upload_report(self, cr, uid, report_id, file_sxw, file_type, context): ''' Untested function ''' pool = pooler.get_pool(cr.dbname) sxwval = StringIO(base64.decodestring(file_sxw)) if file_type=='sxw': fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_oo2rml.xsl'),'rb') if file_type=='odt': fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_odt2rml.xsl'),'rb') report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], { 'report_sxw_content': base64.decodestring(file_sxw), 'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read())), }) db = pooler.get_db_only(cr.dbname) interface.register_all(db) return True
eee6870817d7c80b624ba067ad9fdf713bb00e4f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/eee6870817d7c80b624ba067ad9fdf713bb00e4f/base_report_designer.py
def _amount_reconciled(self, cursor, user, ids, name, args, context=None): if not ids: return {} res_currency_obj = self.pool.get('res.currency') res = {} company_currency_id = False
3750db76b595c7d880580965769a0fe56a91923e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3750db76b595c7d880580965769a0fe56a91923e/account_voucher.py
if not company_currency_id: company_currency_id = line.company_id.id
def _amount_reconciled(self, cursor, user, ids, name, args, context=None): if not ids: return {} res_currency_obj = self.pool.get('res.currency') res = {} company_currency_id = False
3750db76b595c7d880580965769a0fe56a91923e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3750db76b595c7d880580965769a0fe56a91923e/account_voucher.py
res[line.id] = res_currency_obj.compute(cursor, user, company_currency_id, line.statement_id.currency.id, line.voucher_id.amount, context=context)
res[line.id] = line.voucher_id.amount
def _amount_reconciled(self, cursor, user, ids, name, args, context=None): if not ids: return {} res_currency_obj = self.pool.get('res.currency') res = {} company_currency_id = False
3750db76b595c7d880580965769a0fe56a91923e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3750db76b595c7d880580965769a0fe56a91923e/account_voucher.py
domain = [('object_id.name', '=', model),
domain = [('object_id.model', '=', model),
def signal(self, cr, uid, model, res_id, signal, context=None): if not signal: raise ValueError('signal cannot be False')
d675dc9bd8a6670b9802331a869bb1482c7c31cb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d675dc9bd8a6670b9802331a869bb1482c7c31cb/marketing_campaign.py
result = Activities.process(activity.id, workitem.id,
result = Activities.process(cr, uid, activity.id, workitem.id,
def _process_one(self, cr, uid, workitem, context=None): if workitem.state != 'todo': return
d675dc9bd8a6670b9802331a869bb1482c7c31cb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d675dc9bd8a6670b9802331a869bb1482c7c31cb/marketing_campaign.py
except Exception, e: workitem.write({'state': 'exception', 'error_msg': str(e)},
except Exception: tb = "".join(format_exception(*exc_info())) workitem.write({'state': 'exception', 'error_msg': tb},
def _process_one(self, cr, uid, workitem, context=None): if workitem.state != 'todo': return
d675dc9bd8a6670b9802331a869bb1482c7c31cb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d675dc9bd8a6670b9802331a869bb1482c7c31cb/marketing_campaign.py
t_id=t_data.id
t_id = t_data.id
def _fnct_write(self,obj,cr, uid, ids, field_name, values, args, context=None): if values and field_name: self._field_get2(cr, uid, obj, context) relation = obj._name res = {} if type(ids) != type([]): ids=[ids] objlst = obj.browse(cr, uid, ids) for data in objlst: t_id=None t_data = data relation = obj._name for i in range(len(self.arg)): field_detail = self._relations[i] relation = field_detail['object'] if not t_data[self.arg[i]]: t_data = False break if field_detail['type'] in ('one2many', 'many2many'): if self._type != "many2one": t_id=t_data.id t_data = t_data[self.arg[i]][0] else: t_id=t_data['id'] t_data = t_data[self.arg[i]] if t_id: obj.pool.get(field_detail['object']).write(cr,uid,[t_id],{args[-1]:values}, context=context)
cab8f8f0fb5d4fa0e7957d27942bdfd383ef399f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cab8f8f0fb5d4fa0e7957d27942bdfd383ef399f/fields.py
t_id=t_data['id']
t_id = t_data['id']
def _fnct_write(self,obj,cr, uid, ids, field_name, values, args, context=None): if values and field_name: self._field_get2(cr, uid, obj, context) relation = obj._name res = {} if type(ids) != type([]): ids=[ids] objlst = obj.browse(cr, uid, ids) for data in objlst: t_id=None t_data = data relation = obj._name for i in range(len(self.arg)): field_detail = self._relations[i] relation = field_detail['object'] if not t_data[self.arg[i]]: t_data = False break if field_detail['type'] in ('one2many', 'many2many'): if self._type != "many2one": t_id=t_data.id t_data = t_data[self.arg[i]][0] else: t_id=t_data['id'] t_data = t_data[self.arg[i]] if t_id: obj.pool.get(field_detail['object']).write(cr,uid,[t_id],{args[-1]:values}, context=context)
cab8f8f0fb5d4fa0e7957d27942bdfd383ef399f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cab8f8f0fb5d4fa0e7957d27942bdfd383ef399f/fields.py
if ctx.get('action_id', False): return ctx['action_id']
if ctx.get('active_id', False): return ctx['active_id']
def _get_picking(self, cr, uid, ctx=None): if ctx is None: ctx = {} if ctx.get('action_id', False): return ctx['action_id'] return False
a22787cadf9fdef396f44178ea5b249acbdced9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a22787cadf9fdef396f44178ea5b249acbdced9c/stock.py
if context.get('action_id', False): picking = picking_obj.browse(cr, uid, [context['action_id']])[0]
if context.get('active_id', False): picking = picking_obj.browse(cr, uid, [context['active_id']])[0]
def _get_picking_address(self, cr, uid, context=None): picking_obj = self.pool.get('stock.picking') if context is None: context = {} if context.get('action_id', False): picking = picking_obj.browse(cr, uid, [context['action_id']])[0] return picking.address_id and picking.address_id.id or False return False
a22787cadf9fdef396f44178ea5b249acbdced9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a22787cadf9fdef396f44178ea5b249acbdced9c/stock.py
st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context)
st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id.id, context)
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') account_analytic_line_obj = self.pool.get('account.analytic.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
8386fa5580c1af8a5070e0fce854dac2280e8158 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8386fa5580c1af8a5070e0fce854dac2280e8158/account_bank_statement.py
cr.execute("SELECT production_id, move_id from mrp_production_move_ids where production_id in %s and move_id in %s", [tuple(ids), tuple(valid_move_ids)]) related_move_map = cr.fetchall() related_move_dict = dict((k, list(set([v[1] for v in itr]))) for k, itr in groupby(related_move_map, itemgetter(0))) res.update(related_move_dict)
if valid_move_ids: cr.execute("SELECT production_id, move_id from mrp_production_move_ids where production_id in %s and move_id in %s", [tuple(ids), tuple(valid_move_ids)]) related_move_map = cr.fetchall() related_move_dict = dict((k, list(set([v[1] for v in itr]))) for k, itr in groupby(related_move_map, itemgetter(0))) res.update(related_move_dict)
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {}
fa9a98c6924b0cf1a8d56dbbe71f29ea910f682c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fa9a98c6924b0cf1a8d56dbbe71f29ea910f682c/mrp.py
def get_recurrent_ids(self, cr, uid, ids, start_date, until_date, limit=100):
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100):
def get_recurrent_ids(self, cr, uid, ids, start_date, until_date, limit=100): if not limit: limit = 100 if ids and (start_date or until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 start_date = start_date and datetime.datetime.strptime(start_date, "%Y-%m-%d") or False until_date = until_date and datetime.datetime.strptime(until_date, "%Y-%m-%d") or False for data in cr.dictfetchall(): if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
4f9aefa2a1589f080154fd62ab0ed432072da6bd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4f9aefa2a1589f080154fd62ab0ed432072da6bd/crm_meeting.py
if ids and (start_date or until_date):
if ids and (base_start_date or base_until_date):
def get_recurrent_ids(self, cr, uid, ids, start_date, until_date, limit=100): if not limit: limit = 100 if ids and (start_date or until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 start_date = start_date and datetime.datetime.strptime(start_date, "%Y-%m-%d") or False until_date = until_date and datetime.datetime.strptime(until_date, "%Y-%m-%d") or False for data in cr.dictfetchall(): if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
4f9aefa2a1589f080154fd62ab0ed432072da6bd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4f9aefa2a1589f080154fd62ab0ed432072da6bd/crm_meeting.py
count = 0 start_date = start_date and datetime.datetime.strptime(start_date, "%Y-%m-%d") or False until_date = until_date and datetime.datetime.strptime(until_date, "%Y-%m-%d") or False for data in cr.dictfetchall():
count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False
def get_recurrent_ids(self, cr, uid, ids, start_date, until_date, limit=100): if not limit: limit = 100 if ids and (start_date or until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 start_date = start_date and datetime.datetime.strptime(start_date, "%Y-%m-%d") or False until_date = until_date and datetime.datetime.strptime(until_date, "%Y-%m-%d") or False for data in cr.dictfetchall(): if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids
4f9aefa2a1589f080154fd62ab0ed432072da6bd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4f9aefa2a1589f080154fd62ab0ed432072da6bd/crm_meeting.py
until_date = arg[2]
until_date = arg[2]
def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): args_without_date = [] start_date = False until_date = False for arg in args: if arg[0] not in ('date', unicode('date')): args_without_date.append(arg) else: if arg[1] in ('>', '>='): start_date = arg[2] elif arg[1] in ('<', '<='): until_date = arg[2]
4f9aefa2a1589f080154fd62ab0ed432072da6bd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4f9aefa2a1589f080154fd62ab0ed432072da6bd/crm_meeting.py
return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): args_without_date = [] start_date = False until_date = False for arg in args: if arg[0] not in ('date', unicode('date')): args_without_date.append(arg) else: if arg[1] in ('>', '>='): start_date = arg[2] elif arg[1] in ('<', '<='): until_date = arg[2]
4f9aefa2a1589f080154fd62ab0ed432072da6bd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4f9aefa2a1589f080154fd62ab0ed432072da6bd/crm_meeting.py
except:
except SyntaxError: raise except TypeError: raise except Exception, e:
def test_expr(expr, allowed_codes, mode="eval"): """test_expr(expression, allowed_codes[, mode]) -> code_object Test that the expression contains only the allowed opcodes. If the expression is valid and contains only allowed codes, return the compiled code object. Otherwise raise a ValueError. """ try: code_obj = compile(expr, "", mode) except: raise ValueError("%s is not a valid expression" % expr) for code in _get_opcodes(code_obj): if code not in allowed_codes: raise ValueError("opcode %s not allowed (%r)" % (opname[code], expr)) return code_obj
4afe236b0c036f98d97a5d4bf30b630957599ef5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4afe236b0c036f98d97a5d4bf30b630957599ef5/safe_eval.py
if record_id is None:
if record_id is None or not record_id:
def create(self, cr, user, vals, context=None): """ Create new record with specified value
33a7b33730ce2641a2190f690585cfda8ffa6084 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/33a7b33730ce2641a2190f690585cfda8ffa6084/orm.py
res[line.id]['price_subtotal']= round(res[line.id]['price_subtotal'], int(config['price_accuracy'])) res[line.id]['price_subtotal_incl']= round(res[line.id]['price_subtotal_incl'], int(config['price_accuracy']))
res[line.id]['price_subtotal']= round(res[line.id]['price_subtotal'], int(config['price_accuracy'])) res[line.id]['price_subtotal_incl']= round(res[line.id]['price_subtotal_incl'], int(config['price_accuracy']))
def _amount_line2(self, cr, uid, ids, name, args, context=None): """ Return the subtotal excluding taxes with respect to price_type. """ res = {} tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') for line in self.browse(cr, uid, ids): cur = line.invoice_id and line.invoice_id.currency_id or False res_init = super(account_invoice_line, self)._amount_line(cr, uid, [line.id], name, args, context) res[line.id] = { 'price_subtotal': 0.0, 'price_subtotal_incl': 0.0, 'data': [] } if not line.quantity: continue if line.invoice_id: product_taxes = [] if line.product_id: if line.invoice_id.type in ('out_invoice', 'out_refund'): product_taxes = filter(lambda x: x.price_include, line.product_id.taxes_id) else: product_taxes = filter(lambda x: x.price_include, line.product_id.supplier_taxes_id)
00064d587f4deedf05f2d56e698b374d48290692 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/00064d587f4deedf05f2d56e698b374d48290692/invoice_tax_incl.py
sum(ail.quantity*ail.price_unit)/sum(ail.quantity*u.factor)*count(ail.product_id)::decimal(16,2) as price_average,
(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*ail.price_unit*-1) else sum(ail.quantity*ail.price_unit) end)/(case when ai.type in ('out_refund','in_invoice') then sum(ail.quantity*u.factor*-1) else sum(ail.quantity*u.factor) end) as price_average,
def init(self, cr): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( select min(ail.id) as id, ai.date_invoice as date, to_char(ai.date_invoice, 'YYYY') as year, to_char(ai.date_invoice, 'MM') as month, to_char(ai.date_invoice, 'YYYY-MM-DD') as day, ail.product_id, ai.partner_id as partner_id, ai.payment_term as payment_term, ai.period_id as period_id, u.name as uom_name, ai.currency_id as currency_id, ai.journal_id as journal_id, ai.fiscal_position as fiscal_position, ai.user_id as user_id, ai.company_id as company_id, count(ail.*) as nbr, ai.type as type, ai.state, pt.categ_id, ai.date_due as date_due, ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity * u.factor * -1 else ail.quantity * u.factor end) as product_qty, sum(case when ai.type in ('out_refund','in_invoice') then ail.quantity*ail.price_unit * -1 else ail.quantity*ail.price_unit end) as price_total, sum(case when ai.type in ('out_refund','in_invoice') then ai.amount_total * -1 else ai.amount_total end) as price_total_tax, sum(ail.quantity*ail.price_unit)/sum(ail.quantity*u.factor)*count(ail.product_id)::decimal(16,2) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml left join account_invoice as a ON (a.move_id=aml.move_id) left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as delay_to_pay, (case when ai.type in ('out_refund','in_invoice') then ai.residual * -1 else ai.residual end)/(select count(l.*) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) where a.id=ai.id) as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) left join product_template pt on (pt.id=ail.product_id) left join product_uom u on (u.id=ail.uos_id) group by ail.product_id, ai.date_invoice, ai.id, to_char(ai.date_invoice, 'YYYY'), to_char(ai.date_invoice, 'MM'), to_char(ai.date_invoice, 'YYYY-MM-DD'), ai.partner_id, ai.payment_term, ai.period_id, u.name, ai.currency_id, ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id, ai.date_due, ai.address_contact_id, ai.address_invoice_id, ai.account_id, ai.partner_bank_id, ai.residual, ai.amount_total ) """)
754a0cec0d060d7f4226325f52eaa7843a6c8b12 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/754a0cec0d060d7f4226325f52eaa7843a6c8b12/account_invoice_report.py
if int(vat[0:2]) == 0 and len(vat) == 10:
if int(vat[0:2]) in (0, 10, 20) and len(vat) == 10:
def check_vat_sk(self, vat): ''' Check Slovakia VAT number. ''' try: int(vat) except: return False if len(vat) not in(9, 10): return False
154eea64433d2734620100671b96a9ca091af774 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/154eea64433d2734620100671b96a9ca091af774/base_vat.py
help="Number of operations this workcenter can do."), 'hour_nbr': fields.float('Number of Hours', required=True, help="Time in hours for doing one cycle."),
help="Number of iterations this workcenter has to do in the specified operation of the routing."), 'hour_nbr': fields.float('Number of Hours', required=True, help="Time in hours for this workcenter to achieve the operation of the specified routing."),
def on_change_product_cost(self, cr, uid, ids, product_id, context=None): if context is None: context = {} value = {}
88bee41f4677f19485945249bc058516d640fb24 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/88bee41f4677f19485945249bc058516d640fb24/mrp.py
'unit_amount': wc.costs_hour * wc.time_cycle,
'unit_amount': wc_line.hour,
def _costs_generate(self, cr, uid, production): """ Calculates total costs at the end of the production. @param production: Id of production order. @return: Calculated amount. """ amount = 0.0 analytic_line_obj = self.pool.get('account.analytic.line') for wc_line in production.workcenter_lines: wc = wc_line.workcenter_id if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.hour * wc.costs_hour account = wc.costs_hour_account_id.id if value and account: amount += value analytic_line_obj.create(cr, uid, { 'name': wc_line.name + ' (H)', 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, 'ref': wc.code, 'product_id': wc.product_id.id, 'unit_amount': wc.costs_hour * wc.time_cycle, 'product_uom_id': wc.product_id.uom_id.id } ) if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.cycle * wc.costs_cycle account = wc.costs_cycle_account_id.id if value and account: amount += value analytic_line_obj.create(cr, uid, { 'name': wc_line.name+' (C)', 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, 'ref': wc.code, 'product_id': wc.product_id.id, 'unit_amount': wc.costs_hour * wc.time_cycle, 'product_uom_id': wc.product_id.uom_id.id } ) return amount
88bee41f4677f19485945249bc058516d640fb24 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/88bee41f4677f19485945249bc058516d640fb24/mrp.py
'unit_amount': wc.costs_hour * wc.time_cycle,
'unit_amount': wc_line.cycle,
def _costs_generate(self, cr, uid, production): """ Calculates total costs at the end of the production. @param production: Id of production order. @return: Calculated amount. """ amount = 0.0 analytic_line_obj = self.pool.get('account.analytic.line') for wc_line in production.workcenter_lines: wc = wc_line.workcenter_id if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.hour * wc.costs_hour account = wc.costs_hour_account_id.id if value and account: amount += value analytic_line_obj.create(cr, uid, { 'name': wc_line.name + ' (H)', 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, 'ref': wc.code, 'product_id': wc.product_id.id, 'unit_amount': wc.costs_hour * wc.time_cycle, 'product_uom_id': wc.product_id.uom_id.id } ) if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.cycle * wc.costs_cycle account = wc.costs_cycle_account_id.id if value and account: amount += value analytic_line_obj.create(cr, uid, { 'name': wc_line.name+' (C)', 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, 'ref': wc.code, 'product_id': wc.product_id.id, 'unit_amount': wc.costs_hour * wc.time_cycle, 'product_uom_id': wc.product_id.uom_id.id } ) return amount
88bee41f4677f19485945249bc058516d640fb24 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/88bee41f4677f19485945249bc058516d640fb24/mrp.py
def _get_company(self, cr, uid, ids, context={}):
def _get_company(self, cr, uid, context={}):
def _get_company(self, cr, uid, ids, context={}): user_obj = self.pool.get('res.users') company_obj = self.pool.get('res.company') user = user_obj.browse(cr, uid, uid, context=context) if user.company_id: return user.company_id.id else: return company_obj.search(cr, uid, [('parent_id', '=', False)])[0]
90ba7bc60b1c0644b4185e251941c4356e3144b7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/90ba7bc60b1c0644b4185e251941c4356e3144b7/account_vat.py
return {'value': {'work_email':mail}}
return {'value': {'work_email':mail.user_email}}
def onchange_user(self, cr, uid, ids, user_id, context=None): mail = self.pool.get('res.users').browse(cr,uid,user_id) return {'value': {'work_email':mail}}
73807c946566486ccea324eafa772748ad03c152 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/73807c946566486ccea324eafa772748ad03c152/hr.py
if inv.type == 'out_invoice': xml_id = 'action_invoice_tree1' elif inv.type == 'in_invoice': xml_id = 'action_invoice_tree2' elif inv.type == 'out_refund':
if inv.type in ('out_invoice', 'out_refund'):
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
0d5ea8b1427b71b0d6c57de045636d33be002d51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0d5ea8b1427b71b0d6c57de045636d33be002d51/account_invoice_refund.py
'create_date': fields.datetime('Latest Date of Inventory'), }
'date': fields.datetime('Latest Inventory Date'), }
def unlink(self, cr, uid, ids, context={}): raise osv.except_osv(_('Error !'), _('You cannot delete any record!'))
268a1cc776f5749cadd6c7e0afe68b9a29727b8b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/268a1cc776f5749cadd6c7e0afe68b9a29727b8b/report_stock.py
l.id as id,
min(l.id) as id,
def init(self, cr): cr.execute(""" create or replace view report_stock_lines_date as ( select l.id as id, p.id as product_id, max(l.create_date) as create_date from product_product p left outer join stock_inventory_line l on (p.id=l.product_id) where l.create_date is not null group by p.id,l.id )""")
268a1cc776f5749cadd6c7e0afe68b9a29727b8b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/268a1cc776f5749cadd6c7e0afe68b9a29727b8b/report_stock.py
max(l.create_date) as create_date
max(s.date) as date
def init(self, cr): cr.execute(""" create or replace view report_stock_lines_date as ( select l.id as id, p.id as product_id, max(l.create_date) as create_date from product_product p left outer join stock_inventory_line l on (p.id=l.product_id) where l.create_date is not null group by p.id,l.id )""")
268a1cc776f5749cadd6c7e0afe68b9a29727b8b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/268a1cc776f5749cadd6c7e0afe68b9a29727b8b/report_stock.py
group by p.id,l.id
and s.state = 'done' group by p.id
def init(self, cr): cr.execute(""" create or replace view report_stock_lines_date as ( select l.id as id, p.id as product_id, max(l.create_date) as create_date from product_product p left outer join stock_inventory_line l on (p.id=l.product_id) where l.create_date is not null group by p.id,l.id )""")
268a1cc776f5749cadd6c7e0afe68b9a29727b8b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/268a1cc776f5749cadd6c7e0afe68b9a29727b8b/report_stock.py
new_data[n] = data[n]
new_data[n] = data[n]
def __getitem__(self, name): if name == 'id': return self._id if name not in self._data[self._id]: # build the list of fields we will fetch
69912380fb2b59460c20c93979c213b238adb5af /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/69912380fb2b59460c20c93979c213b238adb5af/orm.py
% self._name)
% self._name)
def create(self, cr, user, vals, context=None): """ create(cr, user, vals, context) -> int cr = database cursor user = user id vals = dictionary of the form {'field_name':field_value, ...} """ if not context: context = {} self.pool.get('ir.model.access').check(cr, user, self._name, 'create')
69912380fb2b59460c20c93979c213b238adb5af /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/69912380fb2b59460c20c93979c213b238adb5af/orm.py
amount = currency_obj.compute(cr, user, line.currency_id.id,
amount = currency_obj.compute(cr, uid, line.currency_id.id,
def populate_statement(self, cr, uid, ids, context=None):
99847457a7067cc0587b33a46cbfb85f48f441f7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/99847457a7067cc0587b33a46cbfb85f48f441f7/account_statement_from_invoice.py
amount = currency_obj.compute(cr, user, line.invoice.currency_id.id,
amount = currency_obj.compute(cr, uid, line.invoice.currency_id.id,
def populate_statement(self, cr, uid, ids, context=None):
99847457a7067cc0587b33a46cbfb85f48f441f7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/99847457a7067cc0587b33a46cbfb85f48f441f7/account_statement_from_invoice.py
__logger = logging.getLogger('orm') __schema = logging.getLogger('orm.schema')
def exists(self, cr, uid, id, context=None): return id in self.datas
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logger = netsvc.Logger()
def _check_removed_columns(self, cr, log=False): logger = netsvc.Logger() # iterate on the database columns to drop the NOT NULL constraints # of fields which were required but have been removed (or will be added by another module) columns = [c for c in self._columns if not (isinstance(self._columns[c], fields.function) and not self._columns[c].store)] columns += ('id', 'write_uid', 'write_date', 'create_uid', 'create_date') # openerp access columns cr.execute("SELECT a.attname, a.attnotnull" " FROM pg_class c, pg_attribute a" " WHERE c.relname=%s" " AND c.oid=a.attrelid" " AND a.attisdropped=%s" " AND pg_catalog.format_type(a.atttypid, a.atttypmod) NOT IN ('cid', 'tid', 'oid', 'xid')" " AND a.attname NOT IN %s", (self._table, False, tuple(columns))),
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logger.notifyChannel("orm", netsvc.LOG_DEBUG, "column %s is in the table %s but not in the corresponding object %s" % (column['attname'], self._table, self._name))
self.__logger.debug("column %s is in the table %s but not in the corresponding object %s", column['attname'], self._table, self._name)
def _check_removed_columns(self, cr, log=False): logger = netsvc.Logger() # iterate on the database columns to drop the NOT NULL constraints # of fields which were required but have been removed (or will be added by another module) columns = [c for c in self._columns if not (isinstance(self._columns[c], fields.function) and not self._columns[c].store)] columns += ('id', 'write_uid', 'write_date', 'create_uid', 'create_date') # openerp access columns cr.execute("SELECT a.attname, a.attnotnull" " FROM pg_class c, pg_attribute a" " WHERE c.relname=%s" " AND c.oid=a.attrelid" " AND a.attisdropped=%s" " AND pg_catalog.format_type(a.atttypid, a.atttypmod) NOT IN ('cid', 'tid', 'oid', 'xid')" " AND a.attname NOT IN %s", (self._table, False, tuple(columns))),
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': column '%s': dropped NOT NULL constraint" % (self._table, column['attname']))
self.__schema.debug("Table '%s': column '%s': dropped NOT NULL constraint", self._table, column['attname'])
def _check_removed_columns(self, cr, log=False): logger = netsvc.Logger() # iterate on the database columns to drop the NOT NULL constraints # of fields which were required but have been removed (or will be added by another module) columns = [c for c in self._columns if not (isinstance(self._columns[c], fields.function) and not self._columns[c].store)] columns += ('id', 'write_uid', 'write_date', 'create_uid', 'create_date') # openerp access columns cr.execute("SELECT a.attname, a.attnotnull" " FROM pg_class c, pg_attribute a" " WHERE c.relname=%s" " AND c.oid=a.attrelid" " AND a.attisdropped=%s" " AND pg_catalog.format_type(a.atttypid, a.atttypmod) NOT IN ('cid', 'tid', 'oid', 'xid')" " AND a.attname NOT IN %s", (self._table, False, tuple(columns))),
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logger = netsvc.Logger()
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': created" % (self._table, ))
self.__schema.debug("Table '%s': created", self._table)
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logger.notifyChannel('orm', netsvc.LOG_ERROR, 'create a column parent_left on object %s: fields.integer(\'Left Parent\', select=1)' % (self._table, )) logging.getLogger('schema').info("Table '%s': added column '%s' with definition=%s" % (self._table, 'parent_left', 'INTEGER'))
self.__logger.error('create a column parent_left on object %s: fields.integer(\'Left Parent\', select=1)', self._table) self.__schema.debug("Table '%s': added column '%s' with definition=%s", self._table, 'parent_left', 'INTEGER')
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logger.notifyChannel('orm', netsvc.LOG_ERROR, 'create a column parent_right on object %s: fields.integer(\'Right Parent\', select=1)' % (self._table, )) logging.getLogger('schema').info("Table '%s': added column '%s' with definition=%s" % (self._table, 'parent_right', 'INTEGER'))
self.__logger.error('create a column parent_right on object %s: fields.integer(\'Right Parent\', select=1)', self._table) self.__schema.debug("Table '%s': added column '%s' with definition=%s", self._table, 'parent_right', 'INTEGER')
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logger.notifyChannel('orm', netsvc.LOG_ERROR, "The column %s on object %s must be set as ondelete='cascade'" % (self._parent_name, self._name))
self.__logger.error("The column %s on object %s must be set as ondelete='cascade'", self._parent_name, self._name)
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': added column '%s' with definition=%s" % (self._table, k, logs[k]))
self.__schema.debug("Table '%s': added column '%s' with definition=%s", self._table, k, logs[k])
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': added foreign key '%s' with definition=REFERENCES \"%s\" ON DELETE SET NULL" % (
self.__schema.debug("Table '%s': added foreign key '%s' with definition=REFERENCES \"%s\" ON DELETE SET NULL",
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
)
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Create table '%s': relation between '%s' and '%s'" % (f._rel, self._table, ref))
self.__schema.debug("Create table '%s': relation between '%s' and '%s'", f._rel, self._table, ref)
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': renamed column '%s' to '%s'" % (self._table, f.oldname, k))
self.__schema.debug("Table '%s': renamed column '%s' to '%s'", self._table, f.oldname, k)
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if getattr(self, '_auto', True): cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (self._table,)) if not cr.rowcount: cr.execute('CREATE TABLE "%s" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS' % (self._table,)) cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'", "''"))) create = True
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logger.notifyChannel('orm', netsvc.LOG_INFO, 'column %s (%s) in table %s removed: converted to a function !\n' % (k, f.string, self._table))
self.__logger.info('column %s (%s) in table %s removed: converted to a function !\n', k, f.string, self._table)
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': dropped column '%s' with cascade" % (self._table, k))
self.__schema.debug("Table '%s': dropped column '%s' with cascade", self._table, k)
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': column '%s' (type varchar) changed size from %s to %s" % (self._table, k, f_pg_size, f.size))
self.__schema.debug("Table '%s': column '%s' (type varchar) changed size from %s to %s", self._table, k, f_pg_size, f.size)
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': column '%s' changed type from %s to %s" % (self._table, k, c[0], c[1]))
self.__schema.debug("Table '%s': column '%s' changed type from %s to %s", self._table, k, c[0], c[1])
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': column '%s' has changed type (DB=%s, def=%s), data moved to column %s !" % (
self.__schema.debug("Table '%s': column '%s' has changed type (DB=%s, def=%s), data moved to column %s !",
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
)
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': column '%s': added NOT NULL constraint" % (self._table, k))
self.__schema.debug("Table '%s': column '%s': added NOT NULL constraint", self._table, k)
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
"ALTER TABLE %s ALTER COLUMN %s SET NOT NULL" % ( self._table, k, self._table, k) logger.notifyChannel('schema', netsvc.LOG_WARNING, msg)
"ALTER TABLE %s ALTER COLUMN %s SET NOT NULL" self.__schema.warn(msg, self._table, k, self._table, k)
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
logging.getLogger('schema').info("Table '%s': column '%s': dropped NOT NULL constraint" % (self._table, k))
self.__schema.debug("Table '%s': column '%s': dropped NOT NULL constraint", self._table, k)
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
"Use a search view instead if you simply want to make the field searchable." % (self._table, k, f._type) logger.notifyChannel('schema', netsvc.LOG_WARNING, msg)
"Use a search view instead if you simply want to make the field searchable." self.__schema.warn(msg, self._table, k, f._type)
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py
msg = "Table '%s': dropping index for column '%s' of type '%s' as it is not required anymore" % (self._table, k, f._type) logger.notifyChannel('schema', netsvc.LOG_WARNING, msg)
msg = "Table '%s': dropping index for column '%s' of type '%s' as it is not required anymore" self.__schema.warn(msg, self._table, k, f._type)
f_pg_def = res[0]
a73711cb180c536a45540480eccaf5c3f0aa8ad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a73711cb180c536a45540480eccaf5c3f0aa8ad3/orm.py