rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def attendance_action_change(self, cr, uid, ids, type='action', context={}, dt=False, *args): id = False warning_sign = 'sign' if type == 'sign_in': warning_sign = "Sign In" elif type == 'sign_out': warning_sign = "Sign Out" for emp in self.read(cr, uid, ids, ['id'], context=context): if not self._action_check(cr, uid, emp['id'], dt, context): raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the administrator to correct attendances.')%(warning_sign,)) res = {'action' : type, 'employee_id' : emp['id']} if dt: res['name'] = dt id = self.pool.get('hr.attendance').create(cr, uid, res, context=context) if type != 'action': return id return True
f1918969ee73de516c55b6894138ddae2fb76ce8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f1918969ee73de516c55b6894138ddae2fb76ce8/hr_attendance.py
default.update({'name': group_name +' (copy)'})
default.update({'name': _('%s (copy)')%group_name})
def copy(self, cr, uid, id, default=None, context={}): group_name = self.read(cr, uid, [id], ['name'])[0]['name'] default.update({'name': group_name +' (copy)'}) return super(groups, self).copy(cr, uid, id, default, context)
4d406ba4748c4d84f2261f081595271ee065f7c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4d406ba4748c4d84f2261f081595271ee065f7c3/res_user.py
def copy(self, cr, uid, id, default={}, context={}, done_list=[], local=False): group = self.browse(cr, uid, id, context=context) default = default.copy() if not 'name' in default: default['name'] = group['name'] default['name'] = default['name'] + _(' (copy)') return super(groups, self).copy(cr, uid, id, default, context=context)
def create(self, cr, uid, vals, context=None): if 'name' in vals: if vals['name'].startswith('-'): raise osv.except_osv(_('Error'), _('The name of the group can not start with "-"')) gid = super(groups, self).create(cr, uid, vals, context=context) if context and context.get('noadmin', False): pass else: # assign this new group to user_root user_obj = self.pool.get('res.users') aid = user_obj.browse(cr, 1, user_obj._get_admin_id(cr)) if aid: aid.write({'groups_id': [(4, gid)]}) return gid
4d406ba4748c4d84f2261f081595271ee065f7c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4d406ba4748c4d84f2261f081595271ee065f7c3/res_user.py
"use the standard `logging.getLogger` API instead")
"use the standard `logging.getLogger` API instead", PendingDeprecationWarning, stacklevel=2)
def __init__(self): warnings.warn("The netsvc.Logger API shouldn't be used anymore, please " "use the standard `logging.getLogger` API instead") super(Logger, self).__init__()
9150c0695ffbf7f76809f2811c27aaeb7177e087 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9150c0695ffbf7f76809f2811c27aaeb7177e087/netsvc.py
"the standard `logging` module instead")
"the standard `logging` module instead", PendingDeprecationWarning, stacklevel=2)
def notifyChannel(self, name, level, msg): warnings.warn("notifyChannel API shouldn't be used anymore, please use " "the standard `logging` module instead") from service.web_services import common
9150c0695ffbf7f76809f2811c27aaeb7177e087 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9150c0695ffbf7f76809f2811c27aaeb7177e087/netsvc.py
def onchange_uos_quantity(self, cr, uid, ids, product_id, product_uos_qty, product_uos, product_uom): """ On change of product quantity finds UoM and UoS quantities @param product_id: Product id @param product_uos_qty: Changed UoS Quantity of product @param product_uom: Unit of measure of product @param product_uos: Unit of sale of product @return: Dictionary of values """ result = { 'product_qty': 0.00 }
16f6a1eebc8fbc9a60923408704bdf6fe22f8217 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/16f6a1eebc8fbc9a60923408704bdf6fe22f8217/stock.py
def action_done(self, cr, uid, ids, context=None): """ Finished the inventory @return: True """
16f6a1eebc8fbc9a60923408704bdf6fe22f8217 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/16f6a1eebc8fbc9a60923408704bdf6fe22f8217/stock.py
product_context.update(uom=line.product_uom.id)
product_context.update(uom=line.product_uom.id,date=inv.date)
def action_confirm(self, cr, uid, ids, context=None): """ Confirm the inventory and writes its finished date @return: True """ if context is None: context = {} # to perform the correct inventory corrections we need analyze stock location by # location, never recursively, so we use a special context product_context = dict(context, compute_child=False)
16f6a1eebc8fbc9a60923408704bdf6fe22f8217 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/16f6a1eebc8fbc9a60923408704bdf6fe22f8217/stock.py
'date': inv.date,
def action_confirm(self, cr, uid, ids, context=None): """ Confirm the inventory and writes its finished date @return: True """ if context is None: context = {} # to perform the correct inventory corrections we need analyze stock location by # location, never recursively, so we use a special context product_context = dict(context, compute_child=False)
16f6a1eebc8fbc9a60923408704bdf6fe22f8217 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/16f6a1eebc8fbc9a60923408704bdf6fe22f8217/stock.py
def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False):
def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):
def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False): """ Changes UoM and name if product_id changes. @param location_id: Location id @param product: Changed product_id @param uom: UoM product @return: Dictionary of changed values """ if not product: return {} if not uom: prod = self.pool.get('product.product').browse(cr, uid, [product], {'uom': uom})[0] uom = prod.uom_id.id amount = self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom})[product] result = {'product_qty': amount, 'product_uom': uom} return {'value': result}
16f6a1eebc8fbc9a60923408704bdf6fe22f8217 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/16f6a1eebc8fbc9a60923408704bdf6fe22f8217/stock.py
amount = self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom})[product]
amount = self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom, 'to_date': to_date})[product]
def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False): """ Changes UoM and name if product_id changes. @param location_id: Location id @param product: Changed product_id @param uom: UoM product @return: Dictionary of changed values """ if not product: return {} if not uom: prod = self.pool.get('product.product').browse(cr, uid, [product], {'uom': uom})[0] uom = prod.uom_id.id amount = self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom})[product] result = {'product_qty': amount, 'product_uom': uom} return {'value': result}
16f6a1eebc8fbc9a60923408704bdf6fe22f8217 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/16f6a1eebc8fbc9a60923408704bdf6fe22f8217/stock.py
params = right[:]
params = right and right[:] or []
def __leaf_to_sql(self, leaf, table): if leaf == self.__DUMMY_LEAF: return ('(1=1)', []) left, operator, right = leaf
91a867f9de43c5124315d75dfcc201df991cc307 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/91a867f9de43c5124315d75dfcc201df991cc307/expression.py
def __leaf_to_sql(self, leaf, table): if leaf == self.__DUMMY_LEAF: return ('(1=1)', []) left, operator, right = leaf
91a867f9de43c5124315d75dfcc201df991cc307 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/91a867f9de43c5124315d75dfcc201df991cc307/expression.py
else: if operator == 'in': query = '(%s.%s IS NULL)' % (table._table, left) else: query = '(%s.%s IS NOT NULL)' % (table._table, left)
def __leaf_to_sql(self, leaf, table): if leaf == self.__DUMMY_LEAF: return ('(1=1)', []) left, operator, right = leaf
91a867f9de43c5124315d75dfcc201df991cc307 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/91a867f9de43c5124315d75dfcc201df991cc307/expression.py
query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s) OR id IN (%s)) %s %s" % (fiscalyear_clause, periods, where_move_state, where_move_lines_by_date)
query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s) AND id IN (%s)) %s %s" % (fiscalyear_clause, periods, where_move_state, where_move_lines_by_date)
def _query_get(self, cr, uid, obj='l', context=None): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') account_obj = self.pool.get('account.account') fiscalyear_ids = [] if context is None: context = {} initial_bal = context.get('initial_bal', False) company_clause = " " if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: #for initial balance as well as for normal query, we check only the selected FY because the best practice is to generate the FY opening entries fiscalyear_ids = [context['fiscalyear']]
55ef479cf0b40fbf6bb0aec9660af00df2104a24 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/55ef479cf0b40fbf6bb0aec9660af00df2104a24/account_move_line.py
elif (txt is not None) and (txt is not False):
elif txt and (txt is not None) and (txt is not False):
def _process_text(self, txt): if not self.localcontext: return str2xml(txt) if not txt: return '' result = '' sps = _regex.split(txt) while sps: # This is a simple text to translate to_translate = tools.ustr(sps.pop(0)) result += tools.ustr(self.localcontext.get('translate', lambda x:x)(to_translate)) if sps: try: txt = None expr = sps.pop(0) txt = eval(expr, self.localcontext) if txt and isinstance(txt, basestring): txt = tools.ustr(txt) except Exception: pass if isinstance(txt, basestring): result += str2xml(txt) elif (txt is not None) and (txt is not False): result += ustr(txt) return result
cfad3fdbb9d13b9a605f09d2ab6dbf7be5c77130 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cfad3fdbb9d13b9a605f09d2ab6dbf7be5c77130/utils.py
'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', readonly=True, states={'draft': [('readonly', False)]}),
'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', states={'draft': [('readonly', False)]}),
def unlink(self, cr, uid, ids, context=None): for move in self.browse(cr, uid, ids, context=context): if move.state != 'draft': raise osv.except_osv(_('UserError'), _('You can only delete draft moves.')) return super(stock_move, self).unlink( cr, uid, ids, context=context)
861b74a08121eb833cfa23b3981c24fc2d3d81da /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/861b74a08121eb833cfa23b3981c24fc2d3d81da/stock.py
dict = self.style_properties_dict[(s.getAttribute("style:name")).encode("latin-1")] or {}
dict = self.style_properties_dict[(s.getAttribute("style:name")).encode("utf-8")] or {}
def normalizeStyleProperties(self): """Transfer all style:style-properties attributes from the self.style_properties_hierarchical dict to the automatic-styles from content.xml. Use this function to preprocess content.xml for XSLT transformations etc.Do not try to implement this function with XSlT - believe me, it's a terrible task...""" styles_styles = self.styles_dom.getElementsByTagName("style:style") automatic_styles = self.content_dom.getElementsByTagName("office:automatic-styles")[0] for s in styles_styles: automatic_styles.appendChild(s.cloneNode(deep=1)) content_styles = self.content_dom.getElementsByTagName("style:style") # these are the content_styles with styles_styles added!!! for s in content_styles: c = self.findChildrenByName(s,"style:properties") if c == []: # some derived automatic styles do not have "style:properties": temp = self.content_dom.createElement("style:properties") s.appendChild(temp) c = self.findChildrenByName(s,"style:properties") c = c[0] dict = self.style_properties_dict[(s.getAttribute("style:name")).encode("latin-1")] or {} for attribute in dict.keys(): c.setAttribute(self.openOfficeStringUtf8(attribute),self.openOfficeStringUtf8(dict[attribute]))
c4851f039c96e0215fde839e16d5b5e0400a1ab4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c4851f039c96e0215fde839e16d5b5e0400a1ab4/tiny_sxw2rml.py
name = s.getAttribute("style:name").encode("latin-1")
name = s.getAttribute("style:name").encode("utf-8")
def buildStyleDict(self): """Store all style:style-nodes from content.xml and styles.xml in self.style_dict. Caution: in this dict the nodes from two dom apis are merged!""" for st in (self.styles_dom,self.content_dom): for s in st.getElementsByTagName("style:style"): name = s.getAttribute("style:name").encode("latin-1") self.style_dict[name] = s return True
c4851f039c96e0215fde839e16d5b5e0400a1ab4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c4851f039c96e0215fde839e16d5b5e0400a1ab4/tiny_sxw2rml.py
parent = self.style_dict[style_name].getAttribute("style:parent-style-name").encode("latin-1")
parent = self.style_dict[style_name].getAttribute("style:parent-style-name").encode("utf-8")
def getStylePropertiesDict(self,style_name): res = {}
c4851f039c96e0215fde839e16d5b5e0400a1ab4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c4851f039c96e0215fde839e16d5b5e0400a1ab4/tiny_sxw2rml.py
res[attr] = c.getAttribute(attr).encode("latin-1")
res[attr] = c.getAttribute(attr).encode("utf-8")
def getStylePropertiesDict(self,style_name): res = {}
c4851f039c96e0215fde839e16d5b5e0400a1ab4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c4851f039c96e0215fde839e16d5b5e0400a1ab4/tiny_sxw2rml.py
domain=[('type','=','cr')], context={'default_type':'cr'}),
domain=[('type','=','cr')], context={'default_type':'cr'}, readonly=True, states={'draft':[('readonly',False)]}),
def _get_currency(self, cr, uid, context): user = self.pool.get('res.users').browse(cr, uid, uid) if user.company_id: return user.company_id.currency_id.id return False
a408fd8234d1e27254be9b5bfdd2483b7ff7f77e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a408fd8234d1e27254be9b5bfdd2483b7ff7f77e/voucher.py
domain=[('type','=','dr')], context={'default_type':'dr'}),
domain=[('type','=','dr')], context={'default_type':'dr'}, readonly=True, states={'draft':[('readonly',False)]}),
def _get_currency(self, cr, uid, context): user = self.pool.get('res.users').browse(cr, uid, uid) if user.company_id: return user.company_id.currency_id.id return False
a408fd8234d1e27254be9b5bfdd2483b7ff7f77e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a408fd8234d1e27254be9b5bfdd2483b7ff7f77e/voucher.py
['invoice', 'delivery', 'contact'])
['default', 'invoice', 'delivery', 'contact'])
def makeOrder(self, cr, uid, ids, context=None): """ This function create Quotation on given case. @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm make sale' ids @param context: A standard dictionary for contextual values @return : Dictionary value of created sale order. """ if not context: context = {}
2f9a1347ccab3c9e044adcafb2ebf4c60218100d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2f9a1347ccab3c9e044adcafb2ebf4c60218100d/crm_make_sale.py
'close': 1
def _get_shop_id(self, cr, uid, ids, context=None): if context is None: context = {} cmpny_id = self.pool.get('res.users')._get_company(cr, uid, context=context) shop = self.pool.get('sale.shop').search(cr, uid, [('company_id', '=', cmpny_id)]) return shop and shop[0] or False
2f9a1347ccab3c9e044adcafb2ebf4c60218100d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2f9a1347ccab3c9e044adcafb2ebf4c60218100d/crm_make_sale.py
if workitem_ids: self.process(cr, uid, workitem_ids, context)
if workitem_ids: self.process(cr, uid, workitem_ids, context)
def process_all(self, cr, uid, camp_ids=None, context={}): camp_obj = self.pool.get('marketing.campaign') if not camp_ids: camp_ids = camp_obj.search(cr, uid, [('state','=','running')], context=context) for camp in camp_obj.browse(cr, uid, camp_ids, context=context): if camp.mode in ('test_realtime','active'): workitem_ids = self.search(cr, uid, [('state', '=', 'todo'), ('date','<=', time.strftime('%Y-%m-%d %H:%M:%S'))]) elif camp.mode == 'test': workitem_ids = self.search(cr, uid, [('state', '=', 'todo')]) else: # manual states are not processed automatically workitem_ids = [] if workitem_ids: self.process(cr, uid, workitem_ids, context)
4d4484ca391be360b65388c3d343e84aaa937b09 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4d4484ca391be360b65388c3d343e84aaa937b09/marketing_campaign.py
if not context:
if context is None:
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ Search for record/s with or without domain
22f85f783ada9dd1ece26f6cd1afb4ab08534b93 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/22f85f783ada9dd1ece26f6cd1afb4ab08534b93/orm.py
if ids: cr.execute('select number_of_days_temp from hr_holidays where id in ('+','.join(map(str, ids))+')') res = cr.fetchall() if res and res[0][0] < 0:
for rec in self.read(cr, uid, ids, ['number_of_days','date_from','date_to']): if rec['number_of_days'] < 0:
def _check_date(self, cr, uid, ids): if ids: cr.execute('select number_of_days_temp from hr_holidays where id in ('+','.join(map(str, ids))+')') res = cr.fetchall() if res and res[0][0] < 0: return False return True
f495432c7f7629ebc36337557faa7b5fb9ccc964 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f495432c7f7629ebc36337557faa7b5fb9ccc964/hr_holidays.py
return True _constraints = [(_check_date, 'Start date should not be larger than end date! ', ['number_of_days'])]
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 _constraints = [(_check_date, 'Start date should not be larger than end date!\nNumber of Days should be greater than 1!', ['number_of_days'])]
def _check_date(self, cr, uid, ids): if ids: cr.execute('select number_of_days_temp from hr_holidays where id in ('+','.join(map(str, ids))+')') res = cr.fetchall() if res and res[0][0] < 0: return False return True
f495432c7f7629ebc36337557faa7b5fb9ccc964 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f495432c7f7629ebc36337557faa7b5fb9ccc964/hr_holidays.py
total_amount = 0.0 if inv.tax_amount: total_amount = inv.amount + inv.tax_amount
total_amount = inv.amount
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
d4ff1f58bea753671b299017e5489a9b9d3a8c71 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d4ff1f58bea753671b299017e5489a9b9d3a8c71/voucher.py
res[r[1]].append(r[0])
if r[0] not in res[r[1]]: res[r[1]].append(r[0])
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {} if not values: values = {} res = {} if not ids: return res for id in ids: res[id] = [] if offset: warnings.warn("Specifying offset at a many2many.get() may produce unpredictable results.", DeprecationWarning, stacklevel=2) obj = obj.pool.get(self._obj)
6decbe75377c19f8552784ecad59ef24a64aebc5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6decbe75377c19f8552784ecad59ef24a64aebc5/fields.py
fields_def = self.__view_look_dom(cr, user, node, view_id, context=context)
26bb219a74ca586de0f935e544991a9202da311f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/26bb219a74ca586de0f935e544991a9202da311f/orm.py
msg += "\n\nEither you wrongly customised this view, or some modules bringing those views are not compatible with your current data model"
msg += "\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model"
fields_def = self.__view_look_dom(cr, user, node, view_id, context=context)
26bb219a74ca586de0f935e544991a9202da311f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/26bb219a74ca586de0f935e544991a9202da311f/orm.py
result += self.localcontext.get('translate', lambda x:x)(sps.pop(0))
result += tools.ustr(self.localcontext.get('translate', lambda x:x)(sps.pop(0)))
def _process_text(self, txt): if not self.localcontext: return str2xml(txt) if not txt: return '' result = '' sps = _regex.split(txt) while sps: # This is a simple text to translate result += self.localcontext.get('translate', lambda x:x)(sps.pop(0)) if sps: try: expr = sps.pop(0) txt = eval(expr,self.localcontext) if txt and (isinstance(txt, unicode) or isinstance(txt, str)): txt = self.localcontext.get('translate', lambda x:x)(txt) except Exception,e: tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR, 'report :\n%s\n%s\nexpr: %s' % (tb_s, str(e), expr.encode('utf-8'))) if type(txt)==type('') or type(txt)==type(u''): txt2 = str2xml(txt) result1 = tools.ustr(txt2) result = result + str(result1) # To avoid concatenation of unicode and str elif (txt is not None) and (txt is not False): result += str(txt) return result
d961fd76daac5c66b843b0c4327a5822b5b16e46 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d961fd76daac5c66b843b0c4327a5822b5b16e46/utils.py
txt = self.localcontext.get('translate', lambda x:x)(txt)
txt = tools.ustr(self.localcontext.get('translate', lambda x:x)(txt))
def _process_text(self, txt): if not self.localcontext: return str2xml(txt) if not txt: return '' result = '' sps = _regex.split(txt) while sps: # This is a simple text to translate result += self.localcontext.get('translate', lambda x:x)(sps.pop(0)) if sps: try: expr = sps.pop(0) txt = eval(expr,self.localcontext) if txt and (isinstance(txt, unicode) or isinstance(txt, str)): txt = self.localcontext.get('translate', lambda x:x)(txt) except Exception,e: tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR, 'report :\n%s\n%s\nexpr: %s' % (tb_s, str(e), expr.encode('utf-8'))) if type(txt)==type('') or type(txt)==type(u''): txt2 = str2xml(txt) result1 = tools.ustr(txt2) result = result + str(result1) # To avoid concatenation of unicode and str elif (txt is not None) and (txt is not False): result += str(txt) return result
d961fd76daac5c66b843b0c4327a5822b5b16e46 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d961fd76daac5c66b843b0c4327a5822b5b16e46/utils.py
result1 = tools.ustr(txt2) result = result + str(result1)
result += tools.ustr(txt2)
def _process_text(self, txt): if not self.localcontext: return str2xml(txt) if not txt: return '' result = '' sps = _regex.split(txt) while sps: # This is a simple text to translate result += self.localcontext.get('translate', lambda x:x)(sps.pop(0)) if sps: try: expr = sps.pop(0) txt = eval(expr,self.localcontext) if txt and (isinstance(txt, unicode) or isinstance(txt, str)): txt = self.localcontext.get('translate', lambda x:x)(txt) except Exception,e: tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR, 'report :\n%s\n%s\nexpr: %s' % (tb_s, str(e), expr.encode('utf-8'))) if type(txt)==type('') or type(txt)==type(u''): txt2 = str2xml(txt) result1 = tools.ustr(txt2) result = result + str(result1) # To avoid concatenation of unicode and str elif (txt is not None) and (txt is not False): result += str(txt) return result
d961fd76daac5c66b843b0c4327a5822b5b16e46 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d961fd76daac5c66b843b0c4327a5822b5b16e46/utils.py
result += str(txt)
result += tools.ustr(txt)
def _process_text(self, txt): if not self.localcontext: return str2xml(txt) if not txt: return '' result = '' sps = _regex.split(txt) while sps: # This is a simple text to translate result += self.localcontext.get('translate', lambda x:x)(sps.pop(0)) if sps: try: expr = sps.pop(0) txt = eval(expr,self.localcontext) if txt and (isinstance(txt, unicode) or isinstance(txt, str)): txt = self.localcontext.get('translate', lambda x:x)(txt) except Exception,e: tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR, 'report :\n%s\n%s\nexpr: %s' % (tb_s, str(e), expr.encode('utf-8'))) if type(txt)==type('') or type(txt)==type(u''): txt2 = str2xml(txt) result1 = tools.ustr(txt2) result = result + str(result1) # To avoid concatenation of unicode and str elif (txt is not None) and (txt is not False): result += str(txt) return result
d961fd76daac5c66b843b0c4327a5822b5b16e46 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d961fd76daac5c66b843b0c4327a5822b5b16e46/utils.py
'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit,
def __init__(self, cr, uid, name, context=None): super(third_party_ledger, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, 'sum_credit_partner': self._sum_credit_partner, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self._get_account, 'get_filter': self._get_filter, 'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date, 'get_fiscalyear': self._get_fiscalyear, 'get_start_date':self._get_start_date, 'get_end_date': self._get_end_date, 'get_journal': self._get_journal, 'get_partners':self._get_partners, 'get_intial_balance':self._get_intial_balance, 'display_initial_balance':self._display_initial_balance, 'display_currency':self._display_currency, 'get_target_move': self._get_target_move, })
33fa22f0ff5d3dc5bab99620831a2c268a91835f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/33fa22f0ff5d3dc5bab99620831a2c268a91835f/account_partner_ledger.py
return result_tmp
return result_tmp + result_init
def _sum_debit_partner(self, partner): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted']
33fa22f0ff5d3dc5bab99620831a2c268a91835f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/33fa22f0ff5d3dc5bab99620831a2c268a91835f/account_partner_ledger.py
return result_tmp def _sum_debit(self): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] if not self.ids: return 0.0 result_tmp = 0.0 result_init = 0.0 if self.reconcil : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.initial_balance: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l, " \ "account_move AS m " "WHERE partner_id IN %s" \ "AND m.id = l.move_id " \ "AND m.state IN %s " "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND " + self.init_query + " ", (tuple(self.partner_ids), tuple(move_state), tuple(self.account_ids))) contemp = self.cr.fetchone() if contemp != None: result_init = contemp[0] or 0.0 else: result_init = result_tmp + 0.0 self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l, " \ "account_move AS m " "WHERE partner_id IN %s" \ "AND m.id = l.move_id " \ "AND m.state IN %s " "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND " + self.query + " " , (tuple(self.partner_ids), tuple(move_state) ,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): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted']
33fa22f0ff5d3dc5bab99620831a2c268a91835f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/33fa22f0ff5d3dc5bab99620831a2c268a91835f/account_partner_ledger.py
def _sum_credit(self): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] if not self.ids: return 0.0 result_tmp = 0.0 result_init = 0.0 if self.reconcil : RECONCILE_TAG = " " else: RECONCILE_TAG = "AND reconcile_id IS NULL" if self.initial_balance: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l, " \ "account_move AS m " "WHERE partner_id IN %s" \ "AND m.id = l.move_id " \ "AND m.state IN %s " "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND " + self.init_query + " ", (tuple(self.partner_ids), tuple(move_state), tuple(self.account_ids))) contemp = self.cr.fetchone() if contemp != None: result_init = contemp[0] or 0.0 else: result_init = result_tmp + 0.0 self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l, " \ "account_move AS m " "WHERE partner_id IN %s" \ "AND m.id = l.move_id " \ "AND m.state IN %s " "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND " + self.query + " " , (tuple(self.partner_ids), tuple(move_state), 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 return result_tmp + result_init
def _sum_credit(self): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted']
33fa22f0ff5d3dc5bab99620831a2c268a91835f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/33fa22f0ff5d3dc5bab99620831a2c268a91835f/account_partner_ledger.py
reference = obj_inv.reference or ''
reference = obj_inv.reference or number or ''
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {})
f603f8e3635ca7bce6b4ab02bd7dfd8003912512 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f603f8e3635ca7bce6b4ab02bd7dfd8003912512/invoice.py
'title': _('Bad Lot Assignation !'),
'title': _('Insufficient Stock in Lot !'),
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, context=None): """ On change of production lot gives a warning message. @param prodlot_id: Changed production lot id @param product_qty: Quantity of product @param loc_id: Location id @param product_id: Product id @return: Warning message """ if not prodlot_id or not loc_id: return {} ctx = context and context.copy() or {} ctx['location_id'] = loc_id prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, ctx) location = self.pool.get('stock.location').browse(cr, uid, loc_id) warning = {} if (location.usage == 'internal') and (product_qty > (prodlot.stock_available or 0.0)): warning = { 'title': _('Bad Lot Assignation !'), 'message': _('You are moving %.2f products but only %.2f available in this lot.') % (product_qty, prodlot.stock_available or 0.0) } return {'warning': warning}
1b74ce256736079146d2340019c95af0bd276610 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1b74ce256736079146d2340019c95af0bd276610/stock.py
if node.text:
if node.text or node.tail:
def preprocess_rml(self, root_node,type='pdf'): _regex1 = re.compile("\[\[(.*?)(repeatIn\(.*?\s*,\s*[\'\"].*?[\'\"]\s*(?:,\s*(.*?)\s*)?\s*\))(.*?)\]\]") _regex11= re.compile("\[\[(.*?)(repeatIn\(.*?\s*\(.*?\s*[\'\"].*?[\'\"]\s*\),[\'\"].*?[\'\"](?:,\s*(.*?)\s*)?\s*\))(.*?)\]\]") _regex2 = re.compile("\[\[(.*?)(removeParentNode\(\s*(?:['\"](.*?)['\"])\s*\))(.*?)\]\]") _regex3 = re.compile("\[\[\s*(.*?setTag\(\s*['\"](.*?)['\"]\s*,\s*['\"].*?['\"]\s*(?:,.*?)?\).*?)\s*\]\]") for node in root_node: if node.tag == etree.Comment: continue if node.text: def _sub3(txt): n = node while n.tag != txt.group(2): n = n.getparent() n.set('rml_tag', txt.group(1)) return "[[ '' ]]" def _sub2(txt): if txt.group(3): n = node try: while n.tag != txt.group(3): n = n.getparent() except: n = node else: n = node.getparent() n.set('rml_except', txt.group(0)[2:-2]) return txt.group(0) def _sub1(txt): if len(txt.group(4)) > 1: return " " match = rml_parents if type == 'odt': match = odt_parents if type == 'sxw': match = sxw_parents if type =='html2html': match = html_parents if txt.group(3): match = [txt.group(3)] n = node while n.tag not in match: n = n.getparent() n.set('rml_loop', txt.group(2)) return '[['+txt.group(1)+"''"+txt.group(4)+']]' t = _regex1.sub(_sub1, node.text) if t == " ": t = _regex11.sub(_sub1, node.text) t = _regex3.sub(_sub3, t) node.text = _regex2.sub(_sub2, t) self.preprocess_rml(node,type) return root_node
94b0ad26df4e0c4a067b89cdc4a481be12a22bf0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/94b0ad26df4e0c4a067b89cdc4a481be12a22bf0/preprocess.py
t = _regex1.sub(_sub1, node.text)
t = _regex1.sub(_sub1, node.text or node.tail)
def _sub1(txt): if len(txt.group(4)) > 1: return " " match = rml_parents if type == 'odt': match = odt_parents if type == 'sxw': match = sxw_parents if type =='html2html': match = html_parents if txt.group(3): match = [txt.group(3)] n = node while n.tag not in match: n = n.getparent() n.set('rml_loop', txt.group(2)) return '[['+txt.group(1)+"''"+txt.group(4)+']]'
94b0ad26df4e0c4a067b89cdc4a481be12a22bf0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/94b0ad26df4e0c4a067b89cdc4a481be12a22bf0/preprocess.py
t = _regex11.sub(_sub1, node.text)
t = _regex11.sub(_sub1, node.text or node.tail)
def _sub1(txt): if len(txt.group(4)) > 1: return " " match = rml_parents if type == 'odt': match = odt_parents if type == 'sxw': match = sxw_parents if type =='html2html': match = html_parents if txt.group(3): match = [txt.group(3)] n = node while n.tag not in match: n = n.getparent() n.set('rml_loop', txt.group(2)) return '[['+txt.group(1)+"''"+txt.group(4)+']]'
94b0ad26df4e0c4a067b89cdc4a481be12a22bf0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/94b0ad26df4e0c4a067b89cdc4a481be12a22bf0/preprocess.py
if (pick.type == 'in'):
if (pick.type == 'in') and 'purchase_id' in pick._columns.keys():
def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @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 which we want default values @param context: A standard dictionary @return: A dictionary which of fields with values. """
fd0169cb95c512eff4ab18880d48e02587110c12 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fd0169cb95c512eff4ab18880d48e02587110c12/stock_partial_picking.py
if (pick.type == 'out'):
if (pick.type == 'out') and 'sale_id' in pick._columns.keys():
def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @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 which we want default values @param context: A standard dictionary @return: A dictionary which of fields with values. """
fd0169cb95c512eff4ab18880d48e02587110c12 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fd0169cb95c512eff4ab18880d48e02587110c12/stock_partial_picking.py
ids = self.search(cr, user, [('code', operator, name.split()[0]), ('name', operator, name.split()[1])]+ args, limit=limit)
operand1,operand2 = name.split(' ',1) ids = self.search(cr, user, [('code', operator, operand1), ('name', operator, operand2)]+ args, limit=limit)
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: args = [] if not context: context = {} args = args[:] ids = [] try: if name and str(name).startswith('partner:'): part_id = int(name.split(':')[1]) part = self.pool.get('res.partner').browse(cr, user, part_id, context) args += [('id', 'in', (part.property_account_payable.id, part.property_account_receivable.id))] name = False if name and str(name).startswith('type:'): type = name.split(':')[1] args += [('type', '=', type)] name = False except: pass if name: ids = self.search(cr, user, [('code', '=like', name+"%")]+args, limit=limit) if not ids: ids = self.search(cr, user, [('shortcut', '=', name)]+ args, limit=limit) if not ids: ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit) if not ids and len(name.split()) >= 2: ids = self.search(cr, user, [('code', operator, name.split()[0]), ('name', operator, name.split()[1])]+ args, limit=limit) else: ids = self.search(cr, user, args, context=context, limit=limit) return self.name_get(cr, user, ids, context=context)
f2e519b591a57fc1d4d61e80c145b10fafc00100 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f2e519b591a57fc1d4d61e80c145b10fafc00100/account.py
email_text = MIMEText(mail_body, _subtype=subtype, _charset='utf-8')
email_text = MIMEText(email_body, _subtype=subtype, _charset='utf-8')
def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False, attach=None, openobject_id=False, ssl=False, debug=False, subtype='plain', x_headers=None, priority='3'): """Send an email.""" import smtplib from email.MIMEText import MIMEText from email.MIMEBase import MIMEBase from email.MIMEMultipart import MIMEMultipart from email.Header import Header from email.Utils import formatdate, COMMASPACE from email.Utils import formatdate, COMMASPACE from email import Encoders import netsvc if x_headers is None: x_headers = {} if not ssl: ssl = config.get('smtp_ssl', False) if not (email_from or config['email_from']): raise ValueError("Sending an email requires either providing a sender " "address or having configured one") if not email_from: email_from = config.get('email_from', False) if not email_cc: email_cc = [] if not email_bcc: email_bcc = [] if not body: body = u'' try: email_body = body.encode('utf-8') except (UnicodeEncodeError, UnicodeDecodeError): email_body = body email_text = MIMEText(mail_body, _subtype=subtype, _charset='utf-8') if attach: msg = MIMEMultipart() else: msg = email_text msg['Subject'] = Header(ustr(subject), 'utf-8') msg['From'] = email_from del msg['Reply-To'] if reply_to: msg['Reply-To'] = reply_to else: msg['Reply-To'] = msg['From'] msg['To'] = COMMASPACE.join(email_to) if email_cc: msg['Cc'] = COMMASPACE.join(email_cc) if email_bcc: msg['Bcc'] = COMMASPACE.join(email_bcc) msg['Date'] = formatdate(localtime=True) # Add OpenERP Server information msg['X-Generated-By'] = 'OpenERP (http://www.openerp.com)' msg['X-OpenERP-Server-Host'] = socket.gethostname() msg['X-OpenERP-Server-Version'] = release.version msg['X-Priority'] = priorities.get(priority, '3 (Normal)') # Add dynamic X Header for key, value in x_headers.iteritems(): msg['X-OpenERP-%s' % key] = str(value) if openobject_id: msg['Message-Id'] = "<%s-openobject-%s@%s>" % (time.time(), openobject_id, socket.gethostname()) if attach: msg.attach(email_text) for (fname,fcontent) in attach: part = MIMEBase('application', "octet-stream") part.set_payload( fcontent ) Encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"' % (fname,)) msg.attach(part) class WriteToLogger(object): def __init__(self): self.logger = netsvc.Logger() def write(self, s): self.logger.notifyChannel('email_send', netsvc.LOG_DEBUG, s) smtp_server = config['smtp_server'] if smtp_server.startswith('maildir:/'): from mailbox import Maildir maildir_path = smtp_server[8:] try: mdir = Maildir(maildir_path,factory=None, create = True) mdir.add(msg.as_string(True)) return True except Exception,e: netsvc.Logger().notifyChannel('email_send (maildir)', netsvc.LOG_ERROR, e) return False try: oldstderr = smtplib.stderr s = smtplib.SMTP() try: # in case of debug, the messages are printed to stderr. if debug: smtplib.stderr = WriteToLogger() s.set_debuglevel(int(bool(debug))) # 0 or 1 s.connect(smtp_server, config['smtp_port']) if ssl: s.ehlo() s.starttls() s.ehlo() if config['smtp_user'] or config['smtp_password']: s.login(config['smtp_user'], config['smtp_password']) s.sendmail(email_from, flatten([email_to, email_cc, email_bcc]), msg.as_string() ) finally: s.quit() if debug: smtplib.stderr = oldstderr except Exception, e: netsvc.Logger().notifyChannel('email_send', netsvc.LOG_ERROR, e) return False return True
2dd21b183e956dcfb1b5755986500c1cadc30409 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2dd21b183e956dcfb1b5755986500c1cadc30409/misc.py
def _makeOrder(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) case_obj = pool.get('crm.case') sale_obj = pool.get('sale.order') partner_obj = pool.get('res.partner') sale_line_obj = pool.get('sale.order.line')
98c0c350443f94f2e610594c870cff2cdd5e73cf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/98c0c350443f94f2e610594c870cff2cdd5e73cf/makesale.py
'fiscal_position': fpos
'fiscal_position': fpos,
def _makeOrder(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) case_obj = pool.get('crm.case') sale_obj = pool.get('sale.order') partner_obj = pool.get('res.partner') sale_line_obj = pool.get('sale.order.line')
98c0c350443f94f2e610594c870cff2cdd5e73cf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/98c0c350443f94f2e610594c870cff2cdd5e73cf/makesale.py
if journal.currency: result = {'value': { 'currency_id': journal.currency.id
currency_id = journal.currency and journal.currency.id or journal.company_id.currency_id.id result = {'value': { 'currency_id': currency_id,
def onchange_journal_id(self, cr, uid, ids, journal_id): if journal_id: journal = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal.currency: result = {'value': { 'currency_id': journal.currency.id } } return result user_company = self.pool.get('res.users').browse(cr, uid, [uid])[0].company_id result = {'value': { 'currency_id': user_company.currency_id.id } } return result
5b7264282b8ab93d6d0119460684a550cd1f2d69 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5b7264282b8ab93d6d0119460684a550cd1f2d69/invoice.py
return result user_company = self.pool.get('res.users').browse(cr, uid, [uid])[0].company_id result = {'value': { 'currency_id': user_company.currency_id.id } }
def onchange_journal_id(self, cr, uid, ids, journal_id): if journal_id: journal = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal.currency: result = {'value': { 'currency_id': journal.currency.id } } return result user_company = self.pool.get('res.users').browse(cr, uid, [uid])[0].company_id result = {'value': { 'currency_id': user_company.currency_id.id } } return result
5b7264282b8ab93d6d0119460684a550cd1f2d69 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5b7264282b8ab93d6d0119460684a550cd1f2d69/invoice.py
def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=100):
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=100): if not args: args = [] ids = [] if context.get('journal_type', False): args += [('type','=',context.get('journal_type'))]
3b9c2c2e6d57123ec1157d7ace285096460e138f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3b9c2c2e6d57123ec1157d7ace285096460e138f/account.py
def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=100): if not args: args = [] ids = [] if context.get('journal_type', False): args += [('type','=',context.get('journal_type'))]
3b9c2c2e6d57123ec1157d7ace285096460e138f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3b9c2c2e6d57123ec1157d7ace285096460e138f/account.py
ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit, context=context)
ids = self.search(cr, user, [('name', 'ilike', name)]+ args, limit=limit, context=context)
def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=100): if not args: args = [] ids = [] if context.get('journal_type', False): args += [('type','=',context.get('journal_type'))]
3b9c2c2e6d57123ec1157d7ace285096460e138f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3b9c2c2e6d57123ec1157d7ace285096460e138f/account.py
except KeyError, e:
except KeyError:
def _get_views(self, cr, uid, ids, field_name=None, arg=None, context={}): res = {} model_data_obj = self.pool.get('ir.model.data') view_obj = self.pool.get('ir.ui.view') report_obj = self.pool.get('ir.actions.report.xml') menu_obj = self.pool.get('ir.ui.menu') mlist = self.browse(cr, uid, ids, context=context) mnames = {} for m in mlist: mnames[m.name] = m.id res[m.id] = { 'menus_by_module':'', 'reports_by_module':'', 'views_by_module': '' } view_id = model_data_obj.search(cr,uid,[('module','in', mnames.keys()), ('model','in',('ir.ui.view','ir.actions.report.xml','ir.ui.menu'))]) for data_id in model_data_obj.browse(cr,uid,view_id,context): # We use try except, because views or menus may not exist try: key = data_id['model'] if key=='ir.ui.view': try: v = view_obj.browse(cr,uid,data_id.res_id) aa = v.inherit_id and '* INHERIT ' or '' res[mnames[data_id.module]]['views_by_module'] += aa + v.name + ' ('+v.type+')\n' except: pass elif key=='ir.actions.report.xml': res[mnames[data_id.module]]['reports_by_module'] += report_obj.browse(cr,uid,data_id.res_id).name + '\n' elif key=='ir.ui.menu': try: m = menu_obj.browse(cr,uid,data_id.res_id) res[mnames[data_id.module]]['menus_by_module'] += m.complete_name + '\n' except: pass except KeyError, e: pass return res
9d8bbcbb602f7f3461be85a118eb79eb8c061018 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d8bbcbb602f7f3461be85a118eb79eb8c061018/module.py
except Exception, e:
except Exception:
def download(self, cr, uid, ids, download=True, context=None): res = [] for mod in self.browse(cr, uid, ids, context=context): if not mod.url: continue match = re.search('-([a-zA-Z0-9\._-]+)(\.zip)', mod.url, re.I) version = '0' if match: version = match.group(1) if parse_version(mod.installed_version or '0') >= parse_version(version): continue res.append(mod.url) if not download: continue zipfile = urllib.urlopen(mod.url).read() fname = addons.get_module_path(str(mod.name)+'.zip', downloaded=True) try: fp = file(fname, 'wb') fp.write(zipfile) fp.close() except Exception, e: raise orm.except_orm(_('Error'), _('Can not create the module file:\n %s') % (fname,)) terp = self.get_module_info(mod.name) self.write(cr, uid, mod.id, self.get_values_from_terp(terp)) cr.execute('DELETE FROM ir_module_module_dependency ' \ 'WHERE module_id = %s', (mod.id,)) self._update_dependencies(cr, uid, mod.id, terp.get('depends', [])) self._update_category(cr, uid, mod.id, terp.get('category', 'Uncategorized')) # Import module zimp = zipimport.zipimporter(fname) zimp.load_module(mod.name) return res
9d8bbcbb602f7f3461be85a118eb79eb8c061018 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9d8bbcbb602f7f3461be85a118eb79eb8c061018/module.py
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, orderby=False, context=None):
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, orderby=False, context=None): raise NotImplementedError(_('The read_group method is not implemented on this object !'))
62e83fd5a0172eea46483dc64bca371b215a864b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/62e83fd5a0172eea46483dc64bca371b215a864b/orm.py
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, orderby=False, context=None):
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, orderby=False, context=None): """ Get the list of records in list view grouped by the given ``groupby`` fields
62e83fd5a0172eea46483dc64bca371b215a864b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/62e83fd5a0172eea46483dc64bca371b215a864b/orm.py
import libxslt import libxml2
from lxml import etree from StringIO import StringIO
def sxw2rml(sxw_file, xsl, output='.', save_pict=False): import libxslt import libxml2 tool = PyOpenOffice(output, save_pict = save_pict) res = tool.unpackNormalize(sxw_file) styledoc = libxml2.parseDoc(xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseMemory(res,len(res)) result = style.applyStylesheet(doc, None) root = result.xpathEval("/document/stylesheet") if root: root=root[0] images = libxml2.newNode("images") for img in tool.images: node = libxml2.newNode('image') node.setProp('name', img) node.setContent( base64.encodestring(tool.images[img])) images.addChild(node) root.addNextSibling(images) try: xml = style.saveResultToString(result) return xml except: return result
60936534d1975b3943355ef76194a640d430bd6a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60936534d1975b3943355ef76194a640d430bd6a/tiny_sxw2rml.py
styledoc = libxml2.parseDoc(xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseMemory(res,len(res)) result = style.applyStylesheet(doc, None) root = result.xpathEval("/document/stylesheet")
f = StringIO(xsl) styledoc = etree.parse(f) style = etree.XSLT(styledoc) f = StringIO(res) doc = etree.parse(f) result = style(doc) root = etree.XPathEvaluator(result)("/document/stylesheet")
def sxw2rml(sxw_file, xsl, output='.', save_pict=False): import libxslt import libxml2 tool = PyOpenOffice(output, save_pict = save_pict) res = tool.unpackNormalize(sxw_file) styledoc = libxml2.parseDoc(xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseMemory(res,len(res)) result = style.applyStylesheet(doc, None) root = result.xpathEval("/document/stylesheet") if root: root=root[0] images = libxml2.newNode("images") for img in tool.images: node = libxml2.newNode('image') node.setProp('name', img) node.setContent( base64.encodestring(tool.images[img])) images.addChild(node) root.addNextSibling(images) try: xml = style.saveResultToString(result) return xml except: return result
60936534d1975b3943355ef76194a640d430bd6a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60936534d1975b3943355ef76194a640d430bd6a/tiny_sxw2rml.py
images = libxml2.newNode("images")
images = etree.Element("images")
def sxw2rml(sxw_file, xsl, output='.', save_pict=False): import libxslt import libxml2 tool = PyOpenOffice(output, save_pict = save_pict) res = tool.unpackNormalize(sxw_file) styledoc = libxml2.parseDoc(xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseMemory(res,len(res)) result = style.applyStylesheet(doc, None) root = result.xpathEval("/document/stylesheet") if root: root=root[0] images = libxml2.newNode("images") for img in tool.images: node = libxml2.newNode('image') node.setProp('name', img) node.setContent( base64.encodestring(tool.images[img])) images.addChild(node) root.addNextSibling(images) try: xml = style.saveResultToString(result) return xml except: return result
60936534d1975b3943355ef76194a640d430bd6a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60936534d1975b3943355ef76194a640d430bd6a/tiny_sxw2rml.py
node = libxml2.newNode('image') node.setProp('name', img) node.setContent( base64.encodestring(tool.images[img])) images.addChild(node) root.addNextSibling(images)
node = etree.Element('image', name=img) node.text = base64.encodestring(tool.images[img]) images.append(node) root.append(images)
def sxw2rml(sxw_file, xsl, output='.', save_pict=False): import libxslt import libxml2 tool = PyOpenOffice(output, save_pict = save_pict) res = tool.unpackNormalize(sxw_file) styledoc = libxml2.parseDoc(xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseMemory(res,len(res)) result = style.applyStylesheet(doc, None) root = result.xpathEval("/document/stylesheet") if root: root=root[0] images = libxml2.newNode("images") for img in tool.images: node = libxml2.newNode('image') node.setProp('name', img) node.setContent( base64.encodestring(tool.images[img])) images.addChild(node) root.addNextSibling(images) try: xml = style.saveResultToString(result) return xml except: return result
60936534d1975b3943355ef76194a640d430bd6a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60936534d1975b3943355ef76194a640d430bd6a/tiny_sxw2rml.py
xml = style.saveResultToString(result)
xml = str(result)
def sxw2rml(sxw_file, xsl, output='.', save_pict=False): import libxslt import libxml2 tool = PyOpenOffice(output, save_pict = save_pict) res = tool.unpackNormalize(sxw_file) styledoc = libxml2.parseDoc(xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseMemory(res,len(res)) result = style.applyStylesheet(doc, None) root = result.xpathEval("/document/stylesheet") if root: root=root[0] images = libxml2.newNode("images") for img in tool.images: node = libxml2.newNode('image') node.setProp('name', img) node.setContent( base64.encodestring(tool.images[img])) images.addChild(node) root.addNextSibling(images) try: xml = style.saveResultToString(result) return xml except: return result
60936534d1975b3943355ef76194a640d430bd6a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60936534d1975b3943355ef76194a640d430bd6a/tiny_sxw2rml.py
f = StringIO.StringIO(file(fname).read())
f = fname
def sxw2rml(sxw_file, xsl, output='.', save_pict=False): import libxslt import libxml2 tool = PyOpenOffice(output, save_pict = save_pict) res = tool.unpackNormalize(sxw_file) styledoc = libxml2.parseDoc(xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseMemory(res,len(res)) result = style.applyStylesheet(doc, None) root = result.xpathEval("/document/stylesheet") if root: root=root[0] images = libxml2.newNode("images") for img in tool.images: node = libxml2.newNode('image') node.setProp('name', img) node.setContent( base64.encodestring(tool.images[img])) images.addChild(node) root.addNextSibling(images) try: xml = style.saveResultToString(result) return xml except: return result
60936534d1975b3943355ef76194a640d430bd6a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60936534d1975b3943355ef76194a640d430bd6a/tiny_sxw2rml.py
if quantity_rest <= 0:
if quantity_rest < 0:
def split(self, cr, uid, ids, move_ids, context=None): """ To split stock moves into production lot @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs if we want more than one @param move_ids: the ID or list of IDs of stock move we want to split @param context: A standard dictionary @return: """ prodlot_obj = self.pool.get('stock.production.lot') ir_sequence_obj = self.pool.get('ir.sequence') move_obj = self.pool.get('stock.move') new_move = [] for data in self.browse(cr, uid, ids): for move in move_obj.browse(cr, uid, move_ids): move_qty = move.product_qty quantity_rest = move.product_qty uos_qty_rest = move.product_uos_qty new_move = [] for line in data.line_ids: quantity = line.quantity
b5ed5d2ccad62da30eb92e76c8f43611dfc232fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b5ed5d2ccad62da30eb92e76c8f43611dfc232fd/stock_move.py
current_move = move_obj.copy(cr, uid, move.id, default_val) new_move.append(current_move)
if quantity_rest > 0: current_move = move_obj.copy(cr, uid, move.id, default_val) new_move.append(current_move) if quantity_rest == 0: current_move = move.id
def split(self, cr, uid, ids, move_ids, context=None): """ To split stock moves into production lot @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs if we want more than one @param move_ids: the ID or list of IDs of stock move we want to split @param context: A standard dictionary @return: """ prodlot_obj = self.pool.get('stock.production.lot') ir_sequence_obj = self.pool.get('ir.sequence') move_obj = self.pool.get('stock.move') new_move = [] for data in self.browse(cr, uid, ids): for move in move_obj.browse(cr, uid, move_ids): move_qty = move.product_qty quantity_rest = move.product_qty uos_qty_rest = move.product_uos_qty new_move = [] for line in data.line_ids: quantity = line.quantity
b5ed5d2ccad62da30eb92e76c8f43611dfc232fd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b5ed5d2ccad62da30eb92e76c8f43611dfc232fd/stock_move.py
def get_module_from_path(path,mod_paths=None): if not mod_paths: def_path = os.path.abspath(os.path.join(tools.config['root_path'], 'addons')) ad_paths= map(lambda m: os.path.abspath(m.strip()),tools.config['addons_path'].split(',')) mod_paths=[def_path] for adp in ad_paths: mod_paths.append(adp) if not adp.startswith('/'): mod_paths.append(os.path.join(def_path,adp)) elif adp.startswith(def_path): mod_paths.append(adp[len(def_path)+1:]) for mp in mod_paths: if path.startswith(mp) and (os.path.dirname(path) != mp): path = path[len(mp)+1:] return path.split(os.path.sep)[0]
def get_module_from_path(path, mod_paths=None): path_dir = os.path.dirname(path[1:]) if path_dir: if os.path.exists(os.path.join(tools.config['addons_path'],path[1:])): return path.split(os.path.sep)[1] else: root_addons = os.path.join(tools.config['root_path'], 'addons') if os.path.exists(os.path.join(root_addons,path[1:])): return path.split(os.path.sep)[1]
def get_module_from_path(path,mod_paths=None): if not mod_paths: # First, construct a list of possible paths def_path = os.path.abspath(os.path.join(tools.config['root_path'], 'addons')) # default addons path (base) ad_paths= map(lambda m: os.path.abspath(m.strip()),tools.config['addons_path'].split(',')) mod_paths=[def_path] for adp in ad_paths: mod_paths.append(adp) if not adp.startswith('/'): mod_paths.append(os.path.join(def_path,adp)) elif adp.startswith(def_path): mod_paths.append(adp[len(def_path)+1:])
773238132b42fa48ac87322f3fbf430936006f44 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/773238132b42fa48ac87322f3fbf430936006f44/translate.py
def get_module_from_path(path,mod_paths=None): if not mod_paths: # First, construct a list of possible paths def_path = os.path.abspath(os.path.join(tools.config['root_path'], 'addons')) # default addons path (base) ad_paths= map(lambda m: os.path.abspath(m.strip()),tools.config['addons_path'].split(',')) mod_paths=[def_path] for adp in ad_paths: mod_paths.append(adp) if not adp.startswith('/'): mod_paths.append(os.path.join(def_path,adp)) elif adp.startswith(def_path): mod_paths.append(adp[len(def_path)+1:])
773238132b42fa48ac87322f3fbf430936006f44 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/773238132b42fa48ac87322f3fbf430936006f44/translate.py
if 'analytic_account_id' in vals and vals['analytic_account_id']:
if vals.get('analytic_account_id',False):
def create(self, cr, uid, vals, context=None, check=True): if not context: context={} account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals and 'journal_id' not in context: context['journal_id'] = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
0398d67493ad4d8dd4f6e0123963e9a32ff7574d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0398d67493ad4d8dd4f6e0123963e9a32ff7574d/account_move_line.py
'partner_id': fields.many2one('res.partner', 'Partner', select=1),
'partner_id': fields.many2one('res.partner', 'Partner', select=1, ondelete='restrict'),
def _get_move_lines(self, cr, uid, ids, context=None): result = [] for move in self.pool.get('account.move').browse(cr, uid, ids, context=context): for line in move.line_id: result.append(line.id) return result
488a43b7170f94011e2f438805b27b5cca29adcd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/488a43b7170f94011e2f438805b27b5cca29adcd/account_move_line.py
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)
41a15f72a02613fc823e32c36f48444d555f1bb6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/41a15f72a02613fc823e32c36f48444d555f1bb6/mail_gateway.py
body = tools.html2plaintext(content)
body = tools.ustr(tools.html2plaintext(content))
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)
41a15f72a02613fc823e32c36f48444d555f1bb6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/41a15f72a02613fc823e32c36f48444d555f1bb6/mail_gateway.py
body = content
body = tools.ustr(content)
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)
41a15f72a02613fc823e32c36f48444d555f1bb6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/41a15f72a02613fc823e32c36f48444d555f1bb6/mail_gateway.py
res = tools.ustr(res)
res = tools.ustr(res, encoding)
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)
41a15f72a02613fc823e32c36f48444d555f1bb6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/41a15f72a02613fc823e32c36f48444d555f1bb6/mail_gateway.py
for line in self.browse(cr, uid, ids): if line.journal_id.internal_sequence: seq_no = obj_sequence.get_id(cr, uid, line.journal_id.internal_sequence.id, context=context)
for move in self.browse(cr, uid, ids, context): if move.journal_id.internal_sequence_id: seq_no = obj_sequence.get_id(cr, uid, move.journal_id.internal_sequence_id.id, context=context)
def post(self, cr, uid, ids, context=None): obj_sequence = self.pool.get('ir.sequence') res = super(account_move, self).post(cr, uid, ids, context=context) seq_no = False for line in self.browse(cr, uid, ids): if line.journal_id.internal_sequence: seq_no = obj_sequence.get_id(cr, uid, line.journal_id.internal_sequence.id, context=context) if seq_no: self.write(cr, uid, [line.id], {'internal_sequence_number': seq_no}) return res
18a03628af95800807077569e07780a7509f76d9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/18a03628af95800807077569e07780a7509f76d9/account_sequence.py
self.write(cr, uid, [line.id], {'internal_sequence_number': seq_no})
self.write(cr, uid, [move.id], {'internal_sequence_number': seq_no})
def post(self, cr, uid, ids, context=None): obj_sequence = self.pool.get('ir.sequence') res = super(account_move, self).post(cr, uid, ids, context=context) seq_no = False for line in self.browse(cr, uid, ids): if line.journal_id.internal_sequence: seq_no = obj_sequence.get_id(cr, uid, line.journal_id.internal_sequence.id, context=context) if seq_no: self.write(cr, uid, [line.id], {'internal_sequence_number': seq_no}) return res
18a03628af95800807077569e07780a7509f76d9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/18a03628af95800807077569e07780a7509f76d9/account_sequence.py
'References':"%s" % (message_id)
x_headers['References'] = "%s" % (message_id)
def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """
f6b5858e5c28f9c375a2beab229becadbdea2b68 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f6b5858e5c28f9c375a2beab229becadbdea2b68/crm_send_email.py
name = cls._name or parent_name
name = cls._name or parent_names
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: if isinstance(parent_names, (str, unicode)): name = cls._name or parent_name parent_names = [parent_names] else: name = cls._name if not name: raise TypeError('_name is mandatory in case of multiple inheritance')
fad2b1bb64361c64321cd8f726f9ef8479372e00 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fad2b1bb64361c64321cd8f726f9ef8479372e00/osv.py
name = cls._name or parent_name
name = cls._name or parent_names
def createInstance(cls, pool, module, cr): parent_names = getattr(cls, '_inherit', None) if parent_names: if isinstance(parent_names, (str, unicode)): name = cls._name or parent_name parent_names = [parent_names] else: name = cls._name if not name: raise TypeError('_name is mandatory in case of multiple inheritance')
fad2b1bb64361c64321cd8f726f9ef8479372e00 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/fad2b1bb64361c64321cd8f726f9ef8479372e00/osv.py
if type(value) == type(''): parse_format = DHM_FORMAT if (not date_time): return str(value)
def formatLang(self, value, digits=2, date=False,date_time=False, grouping=True, monetary=False): if isinstance(value, (str, unicode)) and not value: return '' if not self.lang_dict_called: self._get_lang_dict() self.lang_dict_called = True
e389b5d89333dc4e8320e307c2a01f186c8f6d0e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e389b5d89333dc4e8320e307c2a01f186c8f6d0e/report_sxw.py
res['value'].update({'purchase_price': purchase_price})
price = self.pool.get('res.currency').compute(cr, uid, frm_cur, to_cur, purchase_price, round=False) res['value'].update({'purchase_price': price})
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): res = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag) if product: purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price res['value'].update({'purchase_price': purchase_price}) return res
f32adf267a672519e1fc6125fcf596e6e6c504d8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f32adf267a672519e1fc6125fcf596e6e6c504d8/sale_margin.py
raise
return (-1, res, 'Line ' + str(counter) +' : ' + str(e), '' )
fields_def = self.fields_get(cr, uid, context=context)
50747906e7de269d22c302b3114335dcddd65cca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/50747906e7de269d22c302b3114335dcddd65cca/orm.py
res[voucher.id] = abs(voucher.amount - abs(credit - debit))
res[voucher.id] = abs(voucher.amount - abs(credit - debit))
def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None): if not ids: return {} res = {} debit = credit = 0.0 for voucher in self.browse(cr, uid, ids, context=context): for l in voucher.line_dr_ids: debit += l.amount for l in voucher.line_cr_ids: credit += l.amount res[voucher.id] = abs(voucher.amount - abs(credit - debit)) return res
87049df61d356f2a2fdc27857afde71632dfb74d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/87049df61d356f2a2fdc27857afde71632dfb74d/account_voucher.py
'company_id': fields.related('voucher_id','company_id', relation='res.company', string='Company', store=True),
'company_id': fields.related('voucher_id','company_id', relation='res.company', type='many2one', string='Company', store=True),
def _compute_balance(self, cr, uid, ids, name, args, context=None): currency_pool = self.pool.get('res.currency') rs_data = {} for line in self.browse(cr, uid, ids): res = {} company_currency = line.voucher_id.journal_id.company_id.currency_id.id voucher_currency = line.voucher_id.currency_id.id move_line = line.move_line_id or False
87049df61d356f2a2fdc27857afde71632dfb74d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/87049df61d356f2a2fdc27857afde71632dfb74d/account_voucher.py
cr.execute('update "' + self._table + '" set ' + \ string.join(upd0, ',') + ' where id = %s', upd1)
if upd0 and upd1: cr.execute('update "' + self._table + '" set ' + \ string.join(upd0, ',') + ' where id = %s', upd1)
def _store_set_values(self, cr, uid, ids, fields, context): field_flag = False field_dict = {} if self._log_access: cr.execute('select id,write_date from '+self._table+' where id in ('+','.join(map(str, ids))+')') res = cr.fetchall() for r in res: if r[1]: field_dict.setdefault(r[0], []) res_date = time.strptime((r[1])[:19], '%Y-%m-%d %H:%M:%S') write_date = datetime.datetime.fromtimestamp(time.mktime(res_date)) for i in self.pool._store_function.get(self._name, []): if i[5]: up_write_date = write_date + datetime.timedelta(hours=i[5]) if datetime.datetime.now() < up_write_date: if i[1] in fields: field_dict[r[0]].append(i[1]) if not field_flag: field_flag = True todo = {} keys = [] for f in fields: if self._columns[f]._multi not in keys: keys.append(self._columns[f]._multi) todo.setdefault(self._columns[f]._multi, []) todo[self._columns[f]._multi].append(f) for key in keys: val = todo[key] if key: # uid == 1 for accessing objects having rules defined on store fields result = self._columns[val[0]].get(cr, self, ids, val, 1, context=context) for id,value in result.items(): if field_flag: for f in value.keys(): if f in field_dict[id]: value.pop(f) upd0 = [] upd1 = [] for v in value: if v not in val: continue if self._columns[v]._type in ('many2one', 'one2one'): try: value[v] = value[v][0] except: pass upd0.append('"'+v+'"='+self._columns[v]._symbol_set[0]) upd1.append(self._columns[v]._symbol_set[1](value[v])) upd1.append(id) cr.execute('update "' + self._table + '" set ' + \ string.join(upd0, ',') + ' where id = %s', upd1)
ee854ffcf19de888170d8a9fc62b7664f8b82b3a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ee854ffcf19de888170d8a9fc62b7664f8b82b3a/orm.py
def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): """ Consumed product with specific quatity from specific source location @param cr: the database cursor @param uid: the user id @param ids: ids of stock move object to be consumed @param quantity : specify consume quantity @param location_id : specify source location @param context: context arguments @return: Consumed lines """ if context is None: context = {} if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
bcdfc08fb79a3005f6a98430318d7bfcd41ad6fc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bcdfc08fb79a3005f6a98430318d7bfcd41ad6fc/stock.py
def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): """ Consumed product with specific quatity from specific source location @param cr: the database cursor @param uid: the user id @param ids: ids of stock move object to be consumed @param quantity : specify consume quantity @param location_id : specify source location @param context: context arguments @return: Consumed lines """ if context is None: context = {} if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
bcdfc08fb79a3005f6a98430318d7bfcd41ad6fc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bcdfc08fb79a3005f6a98430318d7bfcd41ad6fc/stock.py
if move.product_id.track_production and location_id:
if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): """ Consumed product with specific quatity from specific source location @param cr: the database cursor @param uid: the user id @param ids: ids of stock move object to be consumed @param quantity : specify consume quantity @param location_id : specify source location @param context: context arguments @return: Consumed lines """ if context is None: context = {} if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
bcdfc08fb79a3005f6a98430318d7bfcd41ad6fc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bcdfc08fb79a3005f6a98430318d7bfcd41ad6fc/stock.py
if move.product_id.track_production and location_id:
if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): """ Consumed product with specific quatity from specific source location @param cr: the database cursor @param uid: the user id @param ids: ids of stock move object to be consumed @param quantity : specify consume quantity @param location_id : specify source location @param context: context arguments @return: Consumed lines """ if context is None: context = {} if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
bcdfc08fb79a3005f6a98430318d7bfcd41ad6fc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bcdfc08fb79a3005f6a98430318d7bfcd41ad6fc/stock.py
elif ext == '.yaml':
elif ext == '.yml':
def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs): # **kwargs is passed directly to convert_xml_import if not status: status = {} status = status.copy() package_todo = [] statusi = 0 pool = pooler.get_pool(cr.dbname) migrations = MigrationManager(cr, graph) has_updates = False modobj = None logger.notifyChannel('init', netsvc.LOG_DEBUG, 'loading %d packages..' % len(graph)) for package in graph: logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading objects' % package.name) migrations.migrate_module(package, 'pre') register_class(package.name) modules = pool.instanciate(package.name, cr) if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'): init_module_objects(cr, package.name, modules) cr.commit() for package in graph: status['progress'] = (float(statusi)+0.1) / len(graph) m = package.name mid = package.id if modobj is None: modobj = pool.get('ir.module.module') if modobj and perform_checks: modobj.check(cr, 1, [mid]) idref = {} status['progress'] = (float(statusi)+0.4) / len(graph) mode = 'update' if hasattr(package, 'init') or package.state == 'to install': mode = 'init' if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'): has_updates = True for kind in ('init', 'update'): if package.state=='to upgrade': # upgrading the module information modobj.write(cr, 1, [mid], { 'description': package.data.get('description', ''), 'shortdesc': package.data.get('name', ''), 'author': package.data.get('author', 'Unknown'), 'website': package.data.get('website', ''), 'license': package.data.get('license', 'GPL-2'), 'certificate': package.data.get('certificate') or None, }) for filename in package.data.get('%s_xml' % kind, []): logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, filename)) name, ext = os.path.splitext(filename) fp = tools.file_open(opj(m, filename)) if ext == '.csv': noupdate=False if kind == 'init': noupdate=True tools.convert_csv_import(cr, m, os.path.basename(filename), fp.read(), idref, mode=mode, noupdate=noupdate) elif ext == '.sql': queries = fp.read().split(';') for query in queries: new_query = ' '.join(query.split()) if new_query: cr.execute(new_query) elif ext == '.yaml': tools.convert_yaml_import(cr, m, fp, idref, mode=mode, **kwargs) else: tools.convert_xml_import(cr, m, fp, idref, mode=mode, **kwargs) fp.close() if hasattr(package, 'demo') or (package.dbdemo and package.state != 'installed'): status['progress'] = (float(statusi)+0.75) / len(graph) for xml in package.data.get('demo_xml', []): name, ext = os.path.splitext(xml) logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, xml)) fp = tools.file_open(opj(m, xml)) if ext == '.csv': tools.convert_csv_import(cr, m, os.path.basename(xml), fp.read(), idref, mode=mode, noupdate=True) else: tools.convert_xml_import(cr, m, fp, idref, mode=mode, noupdate=True, **kwargs) fp.close() cr.execute('update ir_module_module set demo=%s where id=%s', (True, mid)) package_todo.append(package.name) migrations.migrate_module(package, 'post') if modobj: ver = release.major_version + '.' + package.data.get('version', '1.0') # Set new modules and dependencies modobj.write(cr, 1, [mid], {'state': 'installed', 'latest_version': ver}) cr.commit() # Update translations for all installed languages modobj.update_translations(cr, 1, [mid], None) cr.commit() package.state = 'installed' for kind in ('init', 'demo', 'update'): if hasattr(package, kind): delattr(package, kind) statusi += 1 cr.execute('select model from ir_model where state=%s', ('manual',)) for model in cr.dictfetchall(): pool.get('ir.model').instanciate(cr, 1, model['model'], {}) pool.get('ir.model.data')._process_end(cr, 1, package_todo) cr.commit() return has_updates
52185a68e951a1e59525b20c7eff4d58a6111225 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/52185a68e951a1e59525b20c7eff4d58a6111225/__init__.py
case.user_id.address_id.email) or tools.config.get('email_from',False)})
case.user_id.address_id.email and \ "%s <%s>" % (case.user_id.name, case.user_id.address_id.email)) or \ tools.config.get('email_from',False)})
def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {}
170bc320cc2ff1a86628679cd4a7c8ce38b047c4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/170bc320cc2ff1a86628679cd4a7c8ce38b047c4/crm_send_email.py
def _get_journal(self, cr, uid, context={}): journal_pool = self.pool.get('account.journal') if context.get('journal_id', False): return context.get('journal_id') if not context.get('journal_id', False) and context.get('search_default_journal_id', False): return context.get('search_default_journal_id') ttype = context.get('type', 'bank') res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1) return res and res[0] or False
a6c16ae879ae1b7c6b5cc027559bd6bb0eb33e96 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a6c16ae879ae1b7c6b5cc027559bd6bb0eb33e96/voucher.py
'date_due': fields.date('Due Date'),
'date_due': fields.date('Due Date', readonly=True, states={'draft':[('readonly',False)]}),
def _get_partner(self, cr, uid, context={}): return context.get('partner_id', False)
3db30f732752ade5c9c2e3f43b43414620071ca3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3db30f732752ade5c9c2e3f43b43414620071ca3/voucher.py
if line[1]: line_amount = voucher_line_pool.browse(cr, uid, line[1]).untax_amount else: line_amount = line[2].get('amount')
line_amount = line[2].get('amount')
def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context={}): tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') position_pool = self.pool.get('account.fiscal.position') voucher_line_pool = self.pool.get('account.voucher.line') res = { 'tax_amount':False, 'amount':False, } voucher_total_tax = 0.0 voucher_total = 0.0 voucher_line_ids = [] total = 0.0 total_tax = 0.0 for line in line_ids: line_amount = 0.0 if line[1]: line_amount = voucher_line_pool.browse(cr, uid, line[1]).untax_amount else: line_amount = line[2].get('amount') voucher_line_ids += [line[1]] voucher_total += line_amount total = voucher_total total_tax = 0.0 if tax_id: tax = [tax_pool.browse(cr, uid, tax_id)] if partner_id: partner = partner_pool.browse(cr, uid, partner_id) or False taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax) tax = tax_pool.browse(cr, uid, taxes) if not tax[0].price_include: for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes'): total_tax += tax_line.get('amount') total += total_tax res.update({ 'amount':total, 'tax_amount':total_tax })
3db30f732752ade5c9c2e3f43b43414620071ca3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3db30f732752ade5c9c2e3f43b43414620071ca3/voucher.py
'amount':total,
'amount':total or voucher_total,
def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context={}): tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') position_pool = self.pool.get('account.fiscal.position') voucher_line_pool = self.pool.get('account.voucher.line') res = { 'tax_amount':False, 'amount':False, } voucher_total_tax = 0.0 voucher_total = 0.0 voucher_line_ids = [] total = 0.0 total_tax = 0.0 for line in line_ids: line_amount = 0.0 if line[1]: line_amount = voucher_line_pool.browse(cr, uid, line[1]).untax_amount else: line_amount = line[2].get('amount') voucher_line_ids += [line[1]] voucher_total += line_amount total = voucher_total total_tax = 0.0 if tax_id: tax = [tax_pool.browse(cr, uid, tax_id)] if partner_id: partner = partner_pool.browse(cr, uid, partner_id) or False taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax) tax = tax_pool.browse(cr, uid, taxes) if not tax[0].price_include: for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes'): total_tax += tax_line.get('amount') total += total_tax res.update({ 'amount':total, 'tax_amount':total_tax })
3db30f732752ade5c9c2e3f43b43414620071ca3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3db30f732752ade5c9c2e3f43b43414620071ca3/voucher.py
def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context={}): tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') position_pool = self.pool.get('account.fiscal.position') voucher_line_pool = self.pool.get('account.voucher.line') res = { 'tax_amount':False, 'amount':False, } voucher_total_tax = 0.0 voucher_total = 0.0 voucher_line_ids = [] total = 0.0 total_tax = 0.0 for line in line_ids: line_amount = 0.0 if line[1]: line_amount = voucher_line_pool.browse(cr, uid, line[1]).untax_amount else: line_amount = line[2].get('amount') voucher_line_ids += [line[1]] voucher_total += line_amount total = voucher_total total_tax = 0.0 if tax_id: tax = [tax_pool.browse(cr, uid, tax_id)] if partner_id: partner = partner_pool.browse(cr, uid, partner_id) or False taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax) tax = tax_pool.browse(cr, uid, taxes) if not tax[0].price_include: for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes'): total_tax += tax_line.get('amount') total += total_tax res.update({ 'amount':total, 'tax_amount':total_tax })
3db30f732752ade5c9c2e3f43b43414620071ca3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3db30f732752ade5c9c2e3f43b43414620071ca3/voucher.py
def _get_payment_term_lines(term_id, amount): term_pool = self.pool.get('account.payment.term') if term_id and amount: terms = term_pool.compute(cr, uid, term_id, amount) return terms return False
3db30f732752ade5c9c2e3f43b43414620071ca3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3db30f732752ade5c9c2e3f43b43414620071ca3/voucher.py