rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
d1, d2 = self.pool.get('ir.rule').domain_get(cr, user, self._name)
d1, d2, tables = self.pool.get('ir.rule').domain_get(cr, user, self._name, 'read', context=context)
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: context={} if not ids: return []
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)]))
parent_ids = tuple(account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)]))
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') account_ids = [int(str(int(x))[:-6]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_month ' \ 'WHERE account_id IN %s ' \ 'AND month_id IN %s ',(parent_ids, month_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(int(obj_id))[:-6])])]): if child_id != int(str(int(obj_id))[:-6]): res[obj_id] += res.get(int(child_id * 1000000 + int(str(int(obj_id))[-6:])), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
'AND month_id IN %s ',(parent_ids, month_ids,))
'AND month_id IN %s ',(parent_ids, tuple(month_ids),))
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') account_ids = [int(str(int(x))[:-6]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_month ' \ 'WHERE account_id IN %s ' \ 'AND month_id IN %s ',(parent_ids, month_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(int(obj_id))[:-6])])]): if child_id != int(str(int(obj_id))[:-6]): res[obj_id] += res.get(int(child_id * 1000000 + int(str(int(obj_id))[-6:])), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
d1, d2 = self.pool.get('ir.rule').domain_get(cr, user, self._name)
d1, d2, tables = self.pool.get('ir.rule').domain_get(cr, user, self._name)
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: context={} if not ids: return []
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: context={} if not ids: return []
c5d41a033c771d541bb8180ab97ee58fb5b17bb5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5d41a033c771d541bb8180ab97ee58fb5b17bb5/account_analytic_analysis.py
if field._properties:
if field._properties and ((not field.store) or field._fnct_search):
def rg(ids, table, parent): if not ids: return [] ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context) return ids + rg(ids2, table, parent)
9148fc2662f99d7578a9688919567b94ee89e42d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9148fc2662f99d7578a9688919567b94ee89e42d/expression.py
if not field.store: if not field._fnct_search: self.__exp[i] = self.__DUMMY_LEAF else: subexp = field.search(cr, uid, table, left, [self.__exp[i]], context=context) self.__exp[i] = '&' self.__exp.insert(i + 1, self.__DUMMY_LEAF) for j, se in enumerate(subexp): self.__exp.insert(i + 2 + j, se)
if not field._fnct_search: self.__exp[i] = self.__DUMMY_LEAF else: subexp = field.search(cr, uid, table, left, [self.__exp[i]], context=context) self.__exp[i] = '&' self.__exp.insert(i + 1, self.__DUMMY_LEAF) for j, se in enumerate(subexp): self.__exp.insert(i + 2 + j, se)
def rg(ids, table, parent): if not ids: return [] ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context) return ids + rg(ids2, table, parent)
9148fc2662f99d7578a9688919567b94ee89e42d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9148fc2662f99d7578a9688919567b94ee89e42d/expression.py
picking_obj = self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for pick_id in picking_ids: wf_service.trg_write(uid, 'stock.picking', pick_id, cr)
def action_done(self, cr, uid, ids, context={}): """ Makes the move done and if all moves are done, it will finish the picking. @return: """ track_flag = False picking_ids = [] product_uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') product_obj=self.pool.get('product.product') move_obj = self.pool.get('account.move') for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting', 'confirmed'): self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) else: pass # self.action_done(cr, uid, [move.move_dest_id.id]) if move.move_dest_id.auto_validate: self.action_done(cr, uid, [move.move_dest_id.id], context=context)
a9c2f1f7c5b98414aa911bbe5c47d05abea8a277 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a9c2f1f7c5b98414aa911bbe5c47d05abea8a277/stock.py
datas.append(str(value[1])) else: datas.append(str(value))
datas.append(ustr(value[1])) else: datas.append(ustr(value))
def export_data(self, cr, uid, ids, fields_to_export, context=None): if not context: context = {} data_l = self.read(cr, uid, ids, ['sql_query'], context) final_datas = [] #start Loop for i in data_l: datas = [] for key, value in i.items(): if key not in fields_to_export: continue if isinstance(value, tuple): datas.append(str(value[1])) else: datas.append(str(value)) final_datas += [datas] #End Loop return {'datas': final_datas}
e2ba8cb627c6a1a16183009042159112ac671260 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e2ba8cb627c6a1a16183009042159112ac671260/base_report_creator.py
def _amount_total(self, cr, uid, ids, field_name, arg, context): """ Calculates total amount. @param field_name: Name of field. @param arg: Argument @return: Dictionary of values. """ res = {} untax = self._amount_untaxed(cr, uid, ids, field_name, arg, context) tax = self._amount_tax(cr, uid, ids, field_name, arg, context) cur_obj = self.pool.get('res.currency') for id in ids: repair = self.browse(cr, uid, [id])[0] cur = repair.pricelist_id.currency_id res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0)) return res
d24451dcd60465f12661380032cf600cdea1a4b1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d24451dcd60465f12661380032cf600cdea1a4b1/mrp_repair.py
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } inv_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: if not repair.partner_id.property_account_receivable: raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name ) account_id = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': account_id, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
d24451dcd60465f12661380032cf600cdea1a4b1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d24451dcd60465f12661380032cf600cdea1a4b1/mrp_repair.py
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } inv_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: if not repair.partner_id.property_account_receivable: raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name ) account_id = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': account_id, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
d24451dcd60465f12661380032cf600cdea1a4b1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d24451dcd60465f12661380032cf600cdea1a4b1/mrp_repair.py
self.write(cr, uid, ids, {'state': 'ready'})
for repair in self.browse(cr, uid, ids, context=context): self.pool.get('mrp.repair.line').write(cr, uid, [l.id for l in repair.operations], {'state': 'confirmed'}) self.write(cr, uid, [repair.id], {'state': 'ready'})
def action_repair_ready(self, cr, uid, ids, context=None): """ Writes repair order state to 'Ready' @return: True """ self.write(cr, uid, ids, {'state': 'ready'}) return True
d24451dcd60465f12661380032cf600cdea1a4b1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d24451dcd60465f12661380032cf600cdea1a4b1/mrp_repair.py
self.write(cr, uid, ids, {'state': 'under_repair'})
for repair in self.browse(cr, uid, ids, context=context): self.pool.get('mrp.repair.line').write(cr, uid, [l.id for l in repair.operations], {'state': 'confirmed'}) self.write(cr, uid, [repair.id], {'state': 'under_repair'})
def action_repair_start(self, cr, uid, ids, context=None): """ Writes repair order state to 'Under Repair' @return: True """ self.write(cr, uid, ids, {'state': 'under_repair'}) return True
d24451dcd60465f12661380032cf600cdea1a4b1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d24451dcd60465f12661380032cf600cdea1a4b1/mrp_repair.py
repair_line_obj.write(cr, uid, [move.id], {'move_id': move_id})
repair_line_obj.write(cr, uid, [move.id], {'move_id': move_id, 'state': 'done'})
def action_repair_done(self, cr, uid, ids, context=None): """ Creates stock move and picking for repair order. @return: Picking ids. """ res = {} move_obj = self.pool.get('stock.move') wf_service = netsvc.LocalService("workflow") repair_line_obj = self.pool.get('mrp.repair.line') seq_obj = self.pool.get('ir.sequence') pick_obj = self.pool.get('stock.picking') for repair in self.browse(cr, uid, ids, context=context): for move in repair.operations: move_id = move_obj.create(cr, uid, { 'name': move.name, 'product_id': move.product_id.id, 'product_qty': move.product_uom_qty, 'product_uom': move.product_uom.id, 'address_id': repair.address_id and repair.address_id.id or False, 'location_id': move.location_id.id, 'location_dest_id': move.location_dest_id.id, 'tracking_id': False, 'state': 'done', }) repair_line_obj.write(cr, uid, [move.id], {'move_id': move_id}) if repair.deliver_bool: pick_name = seq_obj.get(cr, uid, 'stock.picking.out') picking = pick_obj.create(cr, uid, { 'name': pick_name, 'origin': repair.name, 'state': 'draft', 'move_type': 'one', 'address_id': repair.address_id and repair.address_id.id or False, 'note': repair.internal_notes, 'invoice_state': 'none', 'type': 'out', }) move_id = move_obj.create(cr, uid, { 'name': repair.name, 'picking_id': picking, 'product_id': repair.product_id.id, 'product_qty': 1.0, 'product_uom': repair.product_id.uom_id.id, 'prodlot_id': repair.prodlot_id and repair.prodlot_id.id or False, 'address_id': repair.address_id and repair.address_id.id or False, 'location_id': repair.location_id.id, 'location_dest_id': repair.location_dest_id.id, 'tracking_id': False, 'state': 'assigned', }) wf_service.trg_validate(uid, 'stock.picking', picking, 'button_confirm', cr) self.write(cr, uid, [repair.id], {'state': 'done', 'picking_id': picking}) res[repair.id] = picking else: self.write(cr, uid, [repair.id], {'state': 'done'}) return res
d24451dcd60465f12661380032cf600cdea1a4b1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d24451dcd60465f12661380032cf600cdea1a4b1/mrp_repair.py
key = operator.itemgetter(0)
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {}
737db203a65bc75bdfb2cde7d1b55ec5496b147d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/737db203a65bc75bdfb2cde7d1b55ec5496b147d/mrp.py
def widget_add(self, cr, uid, ids, context=None):
def add_res_widget(self, cr, uid, ids, context=None):
def widget_add(self, cr, uid, ids, context=None): if context is None: context = {} wizard = self.read(cr, uid, ids)[0] self.pool.get('res.widget.user').create(cr, uid, {'user_id':uid, 'widget_id':wizard['widget_id']}) return {}
a578d8a6bfd93daacb709ff48e0665bb901e7d20 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a578d8a6bfd93daacb709ff48e0665bb901e7d20/res_widget.py
return {}
return {'type': 'ir.actions.act_window_close'}
def widget_add(self, cr, uid, ids, context=None): if context is None: context = {} wizard = self.read(cr, uid, ids)[0] self.pool.get('res.widget.user').create(cr, uid, {'user_id':uid, 'widget_id':wizard['widget_id']}) return {}
a578d8a6bfd93daacb709ff48e0665bb901e7d20 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a578d8a6bfd93daacb709ff48e0665bb901e7d20/res_widget.py
raise except_orm(_('Invalid Architecture!'),_("There is no view of type '%s' defined for the structure!") % view_type)
def _inherit_apply_rec(result, inherit_id): # get all views which inherit from (ie modify) this view cr.execute('select arch,id from ir_ui_view where inherit_id=%s and model=%s order by priority', (inherit_id, self._name)) sql_inherit = cr.fetchall() for (inherit, id) in sql_inherit: result = _inherit_apply(result, inherit) result = _inherit_apply_rec(result, id) return result
eef29eefb2f48eda988c6d93b2a91be7931548a2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/eef29eefb2f48eda988c6d93b2a91be7931548a2/orm.py
logger.notifyChannel('ERROR', netsvc.LOG_TEST, str(e))
logger.notifyChannel('ERROR', netsvc.LOG_TEST, e)
def load_test(cr, module_name, id_map, mode): cr.commit() if not tools.config.options['test-disable']: try: _load_data(cr, module_name, id_map, mode, 'test') except Exception, e: if tools.config.options['test-continue']: logger.notifyChannel('ERROR', netsvc.LOG_TEST, str(e)) pass else: raise Exception finally: if tools.config.options['test-rollback']: cr.rollback() else: cr.commit()
0fb50cd625e30eee277d16b4c4a4413c7a79049a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0fb50cd625e30eee277d16b4c4a4413c7a79049a/__init__.py
raise Exception
raise
def load_test(cr, module_name, id_map, mode): cr.commit() if not tools.config.options['test-disable']: try: _load_data(cr, module_name, id_map, mode, 'test') except Exception, e: if tools.config.options['test-continue']: logger.notifyChannel('ERROR', netsvc.LOG_TEST, str(e)) pass else: raise Exception finally: if tools.config.options['test-rollback']: cr.rollback() else: cr.commit()
0fb50cd625e30eee277d16b4c4a4413c7a79049a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0fb50cd625e30eee277d16b4c4a4413c7a79049a/__init__.py
done = []
def selection_field(in_field): col_obj = self.pool.get(in_field.keys()[0]) if f[i] in col_obj._columns.keys(): return col_obj._columns[f[i]] elif f[i] in col_obj._inherits.keys(): selection_field(col_obj._inherits) else: return False
602815a5adcdd7d92cfe88ee9efad5b97a89e1ef /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/602815a5adcdd7d92cfe88ee9efad5b97a89e1ef/orm.py
break
if [x for x in fields2 if x]: break
def selection_field(in_field): col_obj = self.pool.get(in_field.keys()[0]) if f[i] in col_obj._columns.keys(): return col_obj._columns[f[i]] elif f[i] in col_obj._inherits.keys(): selection_field(col_obj._inherits) else: return False
602815a5adcdd7d92cfe88ee9efad5b97a89e1ef /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/602815a5adcdd7d92cfe88ee9efad5b97a89e1ef/orm.py
def sort_result(self, accounts, context={}): # On boucle sur notre rapport result_accounts = [] ind=0 old_level=0 while ind<len(accounts): # account_elem = accounts[ind] #
416220ea9040ed5dcc762b7b67b8baa0756981a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/416220ea9040ed5dcc762b7b67b8baa0756981a9/tax_report.py
def sort_result(self, accounts, context={}): # On boucle sur notre rapport result_accounts = [] ind=0 old_level=0 while ind<len(accounts): # account_elem = accounts[ind] #
416220ea9040ed5dcc762b7b67b8baa0756981a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/416220ea9040ed5dcc762b7b67b8baa0756981a9/tax_report.py
exval = map(lambda x: x.strftime('%Y%m%dT%H%M%S'), exdates) self.ical_set(cal_data.name.lower(), ','.join(exval), 'value')
exvals = [] for exdate in exdates: exvals.append(datetime.fromtimestamp(time.mktime(exdate.utctimetuple())).strftime('%Y%m%dT%H%M%S')) self.ical_set(cal_data.name.lower(), ','.join(exvals), 'value')
def parse_ics(self, cr, uid, child, cal_children=None, context=None): """ parse calendaring and scheduling information @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """
8058b7ff54c722c9aa3b735cb437d7f9d352139b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/8058b7ff54c722c9aa3b735cb437d7f9d352139b/calendar.py
for id in ids: move_lines = self.move_line_id_payment_get(cr, uid, [id]) if not move_lines: res[id] = []
for invoice in self.browse(cr, uid, ids, context=context): id = invoice.id res[id] = [] if not invoice.move_id:
def _get_lines(self, cr, uid, ids, name, arg, context=None): res = {} for id in ids: move_lines = self.move_line_id_payment_get(cr, uid, [id]) if not move_lines: res[id] = [] continue res[id] = [] data_lines = self.pool.get('account.move.line').browse(cr, uid, move_lines) partial_ids = []# Keeps the track of ids where partial payments are done with payment terms for line in data_lines: ids_line = [] if line.reconcile_id: ids_line = line.reconcile_id.line_id elif line.reconcile_partial_id: ids_line = line.reconcile_partial_id.line_partial_ids l = map(lambda x: x.id, ids_line) partial_ids.append(line.id) res[id] =[x for x in l if x <> line.id and x not in partial_ids] return res
3af18d7dc239849f8930c42babb62cbecd933bd2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3af18d7dc239849f8930c42babb62cbecd933bd2/invoice.py
res[id] = [] data_lines = self.pool.get('account.move.line').browse(cr, uid, move_lines) partial_ids = []
data_lines = invoice.move_id.line_id partial_ids = []
def _get_lines(self, cr, uid, ids, name, arg, context=None): res = {} for id in ids: move_lines = self.move_line_id_payment_get(cr, uid, [id]) if not move_lines: res[id] = [] continue res[id] = [] data_lines = self.pool.get('account.move.line').browse(cr, uid, move_lines) partial_ids = []# Keeps the track of ids where partial payments are done with payment terms for line in data_lines: ids_line = [] if line.reconcile_id: ids_line = line.reconcile_id.line_id elif line.reconcile_partial_id: ids_line = line.reconcile_partial_id.line_partial_ids l = map(lambda x: x.id, ids_line) partial_ids.append(line.id) res[id] =[x for x in l if x <> line.id and x not in partial_ids] return res
3af18d7dc239849f8930c42babb62cbecd933bd2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3af18d7dc239849f8930c42babb62cbecd933bd2/invoice.py
moves = self.move_line_id_payment_get(cr, uid, [invoice.id])
def _compute_lines(self, cr, uid, ids, name, args, context=None): result = {} for invoice in self.browse(cr, uid, ids, context): moves = self.move_line_id_payment_get(cr, uid, [invoice.id]) src = [] lines = [] for m in self.pool.get('account.move.line').browse(cr, uid, moves, context): temp_lines = []#Added temp list to avoid duplicate records if m.reconcile_id: temp_lines = map(lambda x: x.id, m.reconcile_id.line_id) elif m.reconcile_partial_id: temp_lines = map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) lines += [x for x in temp_lines if x not in lines] src.append(m.id)
3af18d7dc239849f8930c42babb62cbecd933bd2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3af18d7dc239849f8930c42babb62cbecd933bd2/invoice.py
for m in self.pool.get('account.move.line').browse(cr, uid, moves, context): temp_lines = [] if m.reconcile_id: temp_lines = map(lambda x: x.id, m.reconcile_id.line_id) elif m.reconcile_partial_id: temp_lines = map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) lines += [x for x in temp_lines if x not in lines] src.append(m.id)
if invoice.move_id: for m in invoice.move_id.line_id: temp_lines = [] if m.reconcile_id: temp_lines = map(lambda x: x.id, m.reconcile_id.line_id) elif m.reconcile_partial_id: temp_lines = map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) lines += [x for x in temp_lines if x not in lines] src.append(m.id)
def _compute_lines(self, cr, uid, ids, name, args, context=None): result = {} for invoice in self.browse(cr, uid, ids, context): moves = self.move_line_id_payment_get(cr, uid, [invoice.id]) src = [] lines = [] for m in self.pool.get('account.move.line').browse(cr, uid, moves, context): temp_lines = []#Added temp list to avoid duplicate records if m.reconcile_id: temp_lines = map(lambda x: x.id, m.reconcile_id.line_id) elif m.reconcile_partial_id: temp_lines = map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) lines += [x for x in temp_lines if x not in lines] src.append(m.id)
3af18d7dc239849f8930c42babb62cbecd933bd2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3af18d7dc239849f8930c42babb62cbecd933bd2/invoice.py
res = []
print '** la' if not ids: return [] result = self.move_line_id_payment_gets(cr, uid, ids, *args) return result.get(ids[0], []) def move_line_id_payment_gets(self, cr, uid, ids, *args): print '** ICI' res = {}
def move_line_id_payment_get(self, cr, uid, ids, *args): res = [] if not ids: return res cr.execute('SELECT l.id '\ 'FROM account_move_line l '\ 'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\ 'WHERE i.id IN %s '\ 'AND l.account_id=i.account_id', (tuple(ids),)) res = map(itemgetter(0), cr.fetchall()) return res
3af18d7dc239849f8930c42babb62cbecd933bd2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3af18d7dc239849f8930c42babb62cbecd933bd2/invoice.py
cr.execute('SELECT l.id '\
cr.execute('SELECT i.id, l.id '\
def move_line_id_payment_get(self, cr, uid, ids, *args): res = [] if not ids: return res cr.execute('SELECT l.id '\ 'FROM account_move_line l '\ 'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\ 'WHERE i.id IN %s '\ 'AND l.account_id=i.account_id', (tuple(ids),)) res = map(itemgetter(0), cr.fetchall()) return res
3af18d7dc239849f8930c42babb62cbecd933bd2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3af18d7dc239849f8930c42babb62cbecd933bd2/invoice.py
res = map(itemgetter(0), cr.fetchall())
for r in cr.fetchall(): res.setdefault(r[0], []) res[r[0]].append( r[1] )
def move_line_id_payment_get(self, cr, uid, ids, *args): res = [] if not ids: return res cr.execute('SELECT l.id '\ 'FROM account_move_line l '\ 'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\ 'WHERE i.id IN %s '\ 'AND l.account_id=i.account_id', (tuple(ids),)) res = map(itemgetter(0), cr.fetchall()) return res
3af18d7dc239849f8930c42babb62cbecd933bd2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3af18d7dc239849f8930c42babb62cbecd933bd2/invoice.py
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ search parnter address @param self: The object pointer @param cr: the current row, from the database cursor, @param user: the current user @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @param offset: The Number of Results to Pass @param limit: The Number of Results to Return @param context: A standard dictionary for contextual values """ if context is None: context = {} if context.get('address_partner_id',False): args.append(('partner_id', '=', context['address_partner_id'])) return super(res_partner_address, self).search(cr, user, args, offset, limit, order, context, count)
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ search parnter address @param self: The object pointer @param cr: the current row, from the database cursor, @param user: the current user @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @param offset: The Number of Results to Pass @param limit: The Number of Results to Return @param context: A standard dictionary for contextual values """ if context is None: context = {} if context.get('address_partner_id',False): args.append(('partner_id', '=', context['address_partner_id'])) return super(res_partner_address, self).search(cr, user, args, offset, limit, order, context, count)
e5cc5d6fa28a7e31dce2ad954b2bac8353b09e8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e5cc5d6fa28a7e31dce2ad954b2bac8353b09e8f/base_contact.py
'name': fields.related('address_id','partner_id', type='many2one',\
'name': fields.related('address_id', 'partner_id', type='many2one',\
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ search parnter job @param self: The object pointer @param cr: the current row, from the database cursor, @param user: the current user @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @param offset: The Number of Results to Pass @param limit: The Number of Results to Return @param context: A standard dictionary for contextual values """
e5cc5d6fa28a7e31dce2ad954b2bac8353b09e8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e5cc5d6fa28a7e31dce2ad954b2bac8353b09e8f/base_contact.py
'address_id': fields.many2one('res.partner.address','Address', \
'address_id': fields.many2one('res.partner.address', 'Address', domain=[('partner_id', '=', name)], \
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ search parnter job @param self: The object pointer @param cr: the current row, from the database cursor, @param user: the current user @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @param offset: The Number of Results to Pass @param limit: The Number of Results to Return @param context: A standard dictionary for contextual values """
e5cc5d6fa28a7e31dce2ad954b2bac8353b09e8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e5cc5d6fa28a7e31dce2ad954b2bac8353b09e8f/base_contact.py
def onchange_partner(self, cr, uid, _, partner_id, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user, @param _: List of IDs, @partner_id : ID of the Partner selected, @param context: A standard dictionary for contextual values """ return {'value': {'address_id': False}} def onchange_address(self, cr, uid, _, address_id, context=None): """ @@param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user, @param _: List of IDs, @address_id : ID of the Address selected, @param context: A standard dictionary for contextual values """ partner_id = False if address_id: address = self.pool.get('res.partner.address')\ .browse(cr, uid, address_id, context) partner_id = address.partner_id.id return {'value': {'name': partner_id}}
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ search parnter job @param self: The object pointer @param cr: the current row, from the database cursor, @param user: the current user @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @param offset: The Number of Results to Pass @param limit: The Number of Results to Return @param context: A standard dictionary for contextual values """
e5cc5d6fa28a7e31dce2ad954b2bac8353b09e8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e5cc5d6fa28a7e31dce2ad954b2bac8353b09e8f/base_contact.py
def _get_def_storage(self, cr, uid, context=None): if context and context.has_key('default_parent_id'): # Use the same storage as the parent.. diro = self.browse(cr, uid, context['default_parent_id']) if diro.storage_id: return diro.storage_id.id objid=self.pool.get('ir.model.data') try: mid = objid._get_id(cr, uid, 'document', 'storage_default') return objid.browse(cr, uid, mid, context=context).res_id except Exception: return None
2c71620b6faa9d1b680b0a333dfaf7ec5a93abad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2c71620b6faa9d1b680b0a333dfaf7ec5a93abad/document_directory.py
'ressource_id': lambda *a: 0,
'ressource_id': lambda *a: 0,
def _get_def_storage(self, cr, uid, context=None): if context and context.has_key('default_parent_id'): # Use the same storage as the parent.. diro = self.browse(cr, uid, context['default_parent_id']) if diro.storage_id: return diro.storage_id.id objid=self.pool.get('ir.model.data') try: mid = objid._get_id(cr, uid, 'document', 'storage_default') return objid.browse(cr, uid, mid, context=context).res_id except Exception: return None
2c71620b6faa9d1b680b0a333dfaf7ec5a93abad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2c71620b6faa9d1b680b0a333dfaf7ec5a93abad/document_directory.py
def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): cr.execute('select distinct parent_id from document_directory where id in ('+','.join(map(str,ids))+')') ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False level -= 1 return True
2c71620b6faa9d1b680b0a333dfaf7ec5a93abad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2c71620b6faa9d1b680b0a333dfaf7ec5a93abad/document_directory.py
def get_object(self, cr, uid, uri, context=None): """ Return a node object for the given uri. This fn merely passes the call to node_context """ if not context: context = {} return nodes.get_node_context(cr, uid, context).get_uri(cr, uri)
2c71620b6faa9d1b680b0a333dfaf7ec5a93abad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2c71620b6faa9d1b680b0a333dfaf7ec5a93abad/document_directory.py
def get_dir_permissions(self, cr, uid, ids ): """Check what permission user 'uid' has on directory 'id' """ assert len(ids) == 1 id = ids[0] cr.execute( "SELECT count(dg.item_id) AS needs, count(ug.uid) AS has " \ " FROM document_directory_group_rel dg " \ " LEFT OUTER JOIN res_groups_users_rel ug " \ " ON (dg.group_id = ug.gid AND ug.uid = %s) " \ " WHERE dg.item_id = %s ", (uid, id)) needs, has = cr.fetchone() if needs and not has: return 1 # still allow to descend into. else: return 15
2c71620b6faa9d1b680b0a333dfaf7ec5a93abad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2c71620b6faa9d1b680b0a333dfaf7ec5a93abad/document_directory.py
def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): """ try to locate the node in uri, Return a tuple (node_dir, remaining_path) """ return (nodes.node_database(context=ncontext), uri)
2c71620b6faa9d1b680b0a333dfaf7ec5a93abad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2c71620b6faa9d1b680b0a333dfaf7ec5a93abad/document_directory.py
if currency.company_id != company_id:
if currency.company_id.id != company_id:
def onchange_currency_id(self, cr, uid, ids, curr_id, company_id): if curr_id: currency = self.pool.get('res.currency').browse(cr, uid, curr_id) if currency.company_id != company_id: raise osv.except_osv(_('Configration Error !'), _('Can not select currency that is not related to current company.\nPlease select accordingly !.')) return {}
d5cd014da19401dc1aebed1284a2491d20545462 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d5cd014da19401dc1aebed1284a2491d20545462/invoice.py
mod_names.remove('all')
if 'all' in mod_names: mod_names.remove('all')
def _check_module_names(cr, module_names): mod_names = set(module_names) if 'base' in mod_names: # ignore dummy 'all' module mod_names.remove('all') if mod_names: cr.execute("SELECT count(id) AS count FROM ir_module_module WHERE name in %s", (tuple(mod_names),)) if cr.dictfetchone()['count'] != len(mod_names): # find out what module name(s) are incorrect: cr.execute("SELECT name FROM ir_module_module") incorrect_names = mod_names.difference([x['name'] for x in cr.dictfetchall()]) logging.getLogger('init').warning('invalid module names, ignored: %s', ", ".join(incorrect_names))
ba4f8ad2233f5657461663e5d5a710a1f8a43f31 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ba4f8ad2233f5657461663e5d5a710a1f8a43f31/__init__.py
'value': { 'warning' : _("Please keep in mind that data currently displayed may not be relevant after switching to another company. If you have unsaved changes, please make sure to save and close the forms before switching to a different company (you can click on Cancel now)"), }
'warning' : { 'title': _("Company Switch Warning"), 'message': _("Please keep in mind that documents currently displayed may not be relevant after switching to another company. If you have unsaved changes, please make sure to save and close all forms before switching to a different company. (You can click on Cancel in the User Preferences now)"), }
def on_change_company_id(self, cr, uid, ids, company_id): return { 'value': { 'warning' : _("Please keep in mind that data currently displayed may not be relevant after switching to another company. If you have unsaved changes, please make sure to save and close the forms before switching to a different company (you can click on Cancel now)"), } }
da52ec057996edb84c2e351fdf3bb62e5a51dbe1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/da52ec057996edb84c2e351fdf3bb62e5a51dbe1/res_user.py
if method not in ['execute','exec_workflow','obj_list']: raise KeyError("Method not supported %s" % method)
if method == 'obj_list': raise NameError("obj_list has been discontinued via RPC as of 6.0, please query ir.model directly!") if method not in ['execute','exec_workflow']: raise NameError("Method not available %s" % method)
def dispatch(self, method, auth, params): (db, uid, passwd ) = params[0:3] params = params[3:] if method not in ['execute','exec_workflow','obj_list']: raise KeyError("Method not supported %s" % method) security.check(db,uid,passwd) ls = netsvc.LocalService('object_proxy') fn = getattr(ls, method) res = fn(db, uid, *params) return res
14b7e37bf5d01391a34b09baff483528ea4cbf66 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/14b7e37bf5d01391a34b09baff483528ea4cbf66/web_services.py
if 'account_id' in line: line['account_id'] = line.get('account_id', False) and line['account_id'][0] if 'product_id' in line: line['product_id'] = line.get('product_id', False) and line['product_id'][0] if 'uos_id' in line: line['uos_id'] = line.get('uos_id', False) and line['uos_id'][0]
for field in ('company_id', 'partner_id', 'account_id', 'product_id', 'uos_id', 'account_analytic_id', 'tax_code_id', 'base_code_id'): line[field] = line.get(field, False) and line[field][0]
def _refund_cleanup_lines(self, cr, uid, lines): for line in lines: del line['id'] del line['invoice_id'] if 'account_id' in line: line['account_id'] = line.get('account_id', False) and line['account_id'][0] if 'product_id' in line: line['product_id'] = line.get('product_id', False) and line['product_id'][0] if 'uos_id' in line: line['uos_id'] = line.get('uos_id', False) and line['uos_id'][0] if 'invoice_line_tax_id' in line: line['invoice_line_tax_id'] = [(6,0, line.get('invoice_line_tax_id', [])) ] if 'account_analytic_id' in line: line['account_analytic_id'] = line.get('account_analytic_id', False) and line['account_analytic_id'][0] if 'tax_code_id' in line : if isinstance(line['tax_code_id'],tuple) and len(line['tax_code_id']) >0 : line['tax_code_id'] = line['tax_code_id'][0] if 'base_code_id' in line : if isinstance(line['base_code_id'],tuple) and len(line['base_code_id']) >0 : line['base_code_id'] = line['base_code_id'][0] return map(lambda x: (0,0,x), lines)
39adf6db6d2474d1715ad3dbfdcf600dc74a36d4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/39adf6db6d2474d1715ad3dbfdcf600dc74a36d4/invoice.py
if 'account_analytic_id' in line: line['account_analytic_id'] = line.get('account_analytic_id', False) and line['account_analytic_id'][0] if 'tax_code_id' in line : if isinstance(line['tax_code_id'],tuple) and len(line['tax_code_id']) >0 : line['tax_code_id'] = line['tax_code_id'][0] if 'base_code_id' in line : if isinstance(line['base_code_id'],tuple) and len(line['base_code_id']) >0 : line['base_code_id'] = line['base_code_id'][0]
def _refund_cleanup_lines(self, cr, uid, lines): for line in lines: del line['id'] del line['invoice_id'] if 'account_id' in line: line['account_id'] = line.get('account_id', False) and line['account_id'][0] if 'product_id' in line: line['product_id'] = line.get('product_id', False) and line['product_id'][0] if 'uos_id' in line: line['uos_id'] = line.get('uos_id', False) and line['uos_id'][0] if 'invoice_line_tax_id' in line: line['invoice_line_tax_id'] = [(6,0, line.get('invoice_line_tax_id', [])) ] if 'account_analytic_id' in line: line['account_analytic_id'] = line.get('account_analytic_id', False) and line['account_analytic_id'][0] if 'tax_code_id' in line : if isinstance(line['tax_code_id'],tuple) and len(line['tax_code_id']) >0 : line['tax_code_id'] = line['tax_code_id'][0] if 'base_code_id' in line : if isinstance(line['base_code_id'],tuple) and len(line['base_code_id']) >0 : line['base_code_id'] = line['base_code_id'][0] return map(lambda x: (0,0,x), lines)
39adf6db6d2474d1715ad3dbfdcf600dc74a36d4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/39adf6db6d2474d1715ad3dbfdcf600dc74a36d4/invoice.py
logger.info('Email successfully send to: %s', address)
logger.info('Email successfully sent to: %s', address)
def run(self, cr, uid, ids, context=None): logger = logging.getLogger(self._name) if context is None: context = {} for action in self.browse(cr, uid, ids, context): obj_pool = self.pool.get(action.model_id.model) obj = obj_pool.browse(cr, uid, context['active_id'], context=context) cxt = { 'context': dict(context), # copy context to prevent side-effects of eval 'object': obj, 'time':time, 'cr': cr, 'pool' : self.pool, 'uid' : uid } expr = eval(str(action.condition), cxt) if not expr: continue
03f310034619ef65b3597dd4ef6531b677ef090c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/03f310034619ef65b3597dd4ef6531b677ef090c/ir_actions.py
help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Avaiable\'.\n When the picking it done the state is \'Done\'.\
help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Available\'.\n When the picking is done the state is \'Done\'.\
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
164e463c97d9110ef08efa5f1bf8319ad62188ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/164e463c97d9110ef08efa5f1bf8319ad62188ec/stock.py
def _check_percent(self, cr, uid, ids, context={}): obj = self.browse(cr, uid, ids[0]) if obj.value == 'procent' and ( obj.value_amount < 0.0 or obj.value_amount > 1.0): return False return True
2eb60e24babd20c86f98b3b6c66f9a79a742b4c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2eb60e24babd20c86f98b3b6c66f9a79a742b4c3/account.py
cr.execute("update account_account set active='f' where id=%s" % (account_id))
cr.execute("update account_account set active='f' where id in " + str(tuple(acc_ids)))
def execute(self, cr, uid, ids, context=None): obj_multi = self.browse(cr, uid, ids[0]) obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') data_pool = self.pool.get('ir.model.data')
2eb60e24babd20c86f98b3b6c66f9a79a742b4c3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2eb60e24babd20c86f98b3b6c66f9a79a742b4c3/account.py
_rec_name = "date_time"
_rec_name = "summary"
def write(self, cr, uid, ids, vals, context=None):
b6a3f0eda07bcba4287b3bd94781ace592c98e44 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b6a3f0eda07bcba4287b3bd94781ace592c98e44/wiki.py
line1 = text1.splitlines(1) line2 = text2.splitlines(1)
line1 = line2 = '' if text1: line1 = text1.splitlines(1) if text2: line2 = text2.splitlines(1) if (not line1 and not line2) or (line1 == line2): raise osv.except_osv(_('Warning !'), _('There are no chnages in revisions'))
def getDiff(self, cr, uid, v1, v2, context={}):
b6a3f0eda07bcba4287b3bd94781ace592c98e44 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b6a3f0eda07bcba4287b3bd94781ace592c98e44/wiki.py
t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref _fix_multiple_roots(node) return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res
t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') idref2 = {} if f_search: idref2 = _get_idref(self, cr, uid, f_model, context, idref) q = unsafe_eval(f_search, idref2) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') idref2 = {} if a_eval: idref2 = _get_idref(self, cr, uid, f_model, context, idref) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref _fix_multiple_roots(node) return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res
def _eval_xml(self, node, pool, cr, uid, idref, context=None): if context is None: context = {} if node.tag in ('field','value'): t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref _fix_multiple_roots(node) return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res elif node.tag == "getitem": for n in node: res=_eval_xml(self,n,pool,cr,uid,idref) if not res: raise LookupError elif node.get('type') in ("int", "list"): return res[int(node.get('index'))] else: return res[node.get('index','').encode("utf8")] elif node.tag == "function": args = [] a_eval = node.get('eval','') if a_eval: idref['ref'] = lambda x: self.id_get(cr, False, x) args = unsafe_eval(a_eval, idref) for n in node: return_val = _eval_xml(self,n, pool, cr, uid, idref, context) if return_val is not None: args.append(return_val) model = pool.get(node.get('model','')) method = node.get('name','') res = getattr(model, method)(cr, uid, *args) return res elif node.tag == "test": return node.text
1dde0f53daa37992cefe2ea79d4fd07111e0d96e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1dde0f53daa37992cefe2ea79d4fd07111e0d96e/convert.py
d_search = rec.get("search",'')
d_search = rec.get("search",'').encode('utf-8')
def _tag_delete(self, cr, rec, data_node=None): d_model = rec.get("model",'') d_search = rec.get("search",'') d_id = rec.get("id",'') ids = [] if d_search: ids = self.pool.get(d_model).search(cr, self.uid, unsafe_eval(d_search)) if d_id: try: ids.append(self.id_get(cr, d_model, d_id)) except: # d_id cannot be found. doesn't matter in this case pass if ids: self.pool.get(d_model).unlink(cr, self.uid, ids) self.pool.get('ir.model.data')._unlink(cr, self.uid, d_model, ids)
1dde0f53daa37992cefe2ea79d4fd07111e0d96e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1dde0f53daa37992cefe2ea79d4fd07111e0d96e/convert.py
ids = self.pool.get(d_model).search(cr, self.uid, unsafe_eval(d_search))
idref = _get_idref(self, cr, self.uid, d_model, context={}, idref={}) ids = self.pool.get(d_model).search(cr, self.uid, unsafe_eval(d_search, idref))
def _tag_delete(self, cr, rec, data_node=None): d_model = rec.get("model",'') d_search = rec.get("search",'') d_id = rec.get("id",'') ids = [] if d_search: ids = self.pool.get(d_model).search(cr, self.uid, unsafe_eval(d_search)) if d_id: try: ids.append(self.id_get(cr, d_model, d_id)) except: # d_id cannot be found. doesn't matter in this case pass if ids: self.pool.get(d_model).unlink(cr, self.uid, ids) self.pool.get('ir.model.data')._unlink(cr, self.uid, d_model, ids)
1dde0f53daa37992cefe2ea79d4fd07111e0d96e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1dde0f53daa37992cefe2ea79d4fd07111e0d96e/convert.py
if not trans and ('base_model_name' in context):
if trans == node.get('string') and ('base_model_name' in context):
def check_group(node): if node.get('groups'): groups = node.get('groups').split(',') access_pool = self.pool.get('ir.model.access') can_see = any(access_pool.check_groups(cr, user, group) for group in groups) if not can_see: node.set('invisible', '1') if 'attrs' in node.attrib: del(node.attrib['attrs']) #avoid making field visible later del(node.attrib['groups']) return can_see else: return True
d3e84488759a02974cbd72ae0306268a63fea158 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d3e84488759a02974cbd72ae0306268a63fea158/orm.py
query = "SELECT arch,name,field_parent,id,type,inherit_id FROM ir_ui_view WHERE id=%s"
query = "SELECT arch,name,field_parent,id,type,inherit_id,model FROM ir_ui_view WHERE id=%s"
def _find(node, node2): if node2.tag == 'xpath': res = node.xpath(node2.get('expr')) if res: return res[0] else: return None else: for n in node.getiterator(node2.tag): res = True if node2.tag == 'field': # only compare field names, a field can be only once in a given view # at a given level (and for multilevel expressions, we should use xpath # inheritance spec anyway) if node2.get('name') == n.get('name'): return n else: continue for attr in node2.attrib: if attr == 'position': continue if n.get(attr): if n.get(attr) == node2.get(attr): continue res = False if res: return n return None
d3e84488759a02974cbd72ae0306268a63fea158 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d3e84488759a02974cbd72ae0306268a63fea158/orm.py
arch,name,field_parent,id,type,inherit_id
arch,name,field_parent,id,type,inherit_id,model
def _find(node, node2): if node2.tag == 'xpath': res = node.xpath(node2.get('expr')) if res: return res[0] else: return None else: for n in node.getiterator(node2.tag): res = True if node2.tag == 'field': # only compare field names, a field can be only once in a given view # at a given level (and for multilevel expressions, we should use xpath # inheritance spec anyway) if node2.get('name') == n.get('name'): return n else: continue for attr in node2.attrib: if attr == 'position': continue if n.get(attr): if n.get(attr) == node2.get(attr): continue res = False if res: return n return None
d3e84488759a02974cbd72ae0306268a63fea158 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d3e84488759a02974cbd72ae0306268a63fea158/orm.py
xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=context)
if parent_view_model != self._name: ctx = context.copy() ctx['base_model_name'] = parent_view_model else: ctx = context xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx)
def _inherit_apply_rec(result, inherit_id): # get all views which inherit from (ie modify) this view cr.execute('select arch,id from ir_ui_view where inherit_id=%s and model=%s order by priority', (inherit_id, self._name)) sql_inherit = cr.fetchall() for (inherit, id) in sql_inherit: result = _inherit_apply(result, inherit, id) result = _inherit_apply_rec(result, id) return result
d3e84488759a02974cbd72ae0306268a63fea158 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d3e84488759a02974cbd72ae0306268a63fea158/orm.py
res[purchase.id] = False
res[purchase.id] = time.strftime('%Y-%m-%d %H:%M:%S')
def _minimum_planned_date(self, cr, uid, ids, field_name, arg, context=None): res={} purchase_obj=self.browse(cr, uid, ids, context=context) for purchase in purchase_obj: res[purchase.id] = False if purchase.order_line: min_date=purchase.order_line[0].date_planned for line in purchase.order_line: if line.date_planned < min_date: min_date=line.date_planned res[purchase.id]=min_date return res
50ee734cae98a03e89c883507d3434a6d8f38c58 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/50ee734cae98a03e89c883507d3434a6d8f38c58/purchase.py
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)
38092d24bfffa416ecf15943b691da4b98c71fd8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/38092d24bfffa416ecf15943b691da4b98c71fd8/fields.py
res[prop.res_id.id][prop.fields_id.name] = value or False
avil_id = obj.pool.get(value._name).search(cr, uid, [('id','=',value.id)], context=context) res[prop.res_id.id][prop.fields_id.name] = (avil_id and value) and value or False
def _fnct_read(self, obj, cr, uid, ids, prop_name, obj_dest, context=None): properties = obj.pool.get('ir.property') domain = [('fields_id.model', '=', obj._name), ('fields_id.name','in',prop_name)] domain += [('res_id','in', [obj._name + ',' + str(oid) for oid in ids])] nids = properties.search(cr, uid, domain, context=context) default_val,replaces = self._get_defaults(obj, cr, uid, prop_name, context)
38092d24bfffa416ecf15943b691da4b98c71fd8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/38092d24bfffa416ecf15943b691da4b98c71fd8/fields.py
period_start = datetime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1)
period_start = datetime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1)
def _get_new_period_start(self, cr, uid, context=None): cr.execute("select max(date_stop) from stock_period") result = cr.fetchone() last_date = result and result[0] or False if last_date: period_start = datetime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1) period_start = period_start - relativedelta(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second) else: period_start = datetime.today() return period_start.strftime('%Y-%m-%d')
754c921bd02858cd0a09ecc9a5cfbcf1146071ab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/754c921bd02858cd0a09ecc9a5cfbcf1146071ab/stock_planning_create_periods.py
def _get_new_period_start(self, cr, uid, context=None): cr.execute("select max(date_stop) from stock_period") result = cr.fetchone() last_date = result and result[0] or False if last_date: period_start = datetime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1) period_start = period_start - relativedelta(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second) else: period_start = datetime.today() return period_start.strftime('%Y-%m-%d')
754c921bd02858cd0a09ecc9a5cfbcf1146071ab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/754c921bd02858cd0a09ecc9a5cfbcf1146071ab/stock_planning_create_periods.py
while ds.strftime('%Y-%m-%d') < p.date_stop:
while ds.strftime('%Y-%m-%d') <= p.date_stop:
def create_stock_periods(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily') period_obj = self.pool.get('stock.period') lines = [] for p in self.browse(cr, uid, ids, context=context): dt = p.date_start ds = datetime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d') < p.date_stop: if name =='Daily': de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y-%m-%d') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name =="Weekly": de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name == "Monthly": de = ds + relativedelta(months=interval, minutes=-1) new_name = ds.strftime('%Y/%m') new_id =period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(months=interval) lines.append(new_id) return { 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'view_type': 'form', "view_mode": 'tree, form', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
754c921bd02858cd0a09ecc9a5cfbcf1146071ab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/754c921bd02858cd0a09ecc9a5cfbcf1146071ab/stock_planning_create_periods.py
de = ds + relativedelta(days=interval, minutes =-1)
de = ds + relativedelta(days=(interval + 1), seconds =-1)
def create_stock_periods(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily') period_obj = self.pool.get('stock.period') lines = [] for p in self.browse(cr, uid, ids, context=context): dt = p.date_start ds = datetime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d') < p.date_stop: if name =='Daily': de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y-%m-%d') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name =="Weekly": de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name == "Monthly": de = ds + relativedelta(months=interval, minutes=-1) new_name = ds.strftime('%Y/%m') new_id =period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(months=interval) lines.append(new_id) return { 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'view_type': 'form', "view_mode": 'tree, form', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
754c921bd02858cd0a09ecc9a5cfbcf1146071ab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/754c921bd02858cd0a09ecc9a5cfbcf1146071ab/stock_planning_create_periods.py
ds = ds + relativedelta(days=interval) + 1
ds = ds + relativedelta(days=(interval + 1))
def create_stock_periods(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily') period_obj = self.pool.get('stock.period') lines = [] for p in self.browse(cr, uid, ids, context=context): dt = p.date_start ds = datetime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d') < p.date_stop: if name =='Daily': de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y-%m-%d') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name =="Weekly": de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name == "Monthly": de = ds + relativedelta(months=interval, minutes=-1) new_name = ds.strftime('%Y/%m') new_id =period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(months=interval) lines.append(new_id) return { 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'view_type': 'form', "view_mode": 'tree, form', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
754c921bd02858cd0a09ecc9a5cfbcf1146071ab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/754c921bd02858cd0a09ecc9a5cfbcf1146071ab/stock_planning_create_periods.py
de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W')
de = ds + relativedelta(days=(interval + 1), seconds =-1) if dt_stp < de: de = dt_stp + relativedelta(days=1,seconds =-1) else: de = ds + relativedelta(days=(interval + 1), seconds =-1) start_week = ds.strftime('%W') start_year = ds.strftime('%Y') end_week = de.strftime('%W') end_year = de.strftime('%Y') if start_year <> end_year: if end_week == '00': new_name = "Week " + start_week +"-" + start_year else: new_name = "Week " + start_week +", " + start_year +" - Week " +end_week +", " + end_year elif start_week == end_week: new_name = "Week " + start_week +"-" +start_year else: new_name = "Week " + start_week +"-" + end_week+", " + start_year
def create_stock_periods(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily') period_obj = self.pool.get('stock.period') lines = [] for p in self.browse(cr, uid, ids, context=context): dt = p.date_start ds = datetime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d') < p.date_stop: if name =='Daily': de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y-%m-%d') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name =="Weekly": de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name == "Monthly": de = ds + relativedelta(months=interval, minutes=-1) new_name = ds.strftime('%Y/%m') new_id =period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(months=interval) lines.append(new_id) return { 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'view_type': 'form', "view_mode": 'tree, form', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
754c921bd02858cd0a09ecc9a5cfbcf1146071ab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/754c921bd02858cd0a09ecc9a5cfbcf1146071ab/stock_planning_create_periods.py
ds = ds + relativedelta(days=interval) + 1
ds = ds + relativedelta(days=(interval + 1))
def create_stock_periods(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily') period_obj = self.pool.get('stock.period') lines = [] for p in self.browse(cr, uid, ids, context=context): dt = p.date_start ds = datetime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d') < p.date_stop: if name =='Daily': de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y-%m-%d') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name =="Weekly": de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name == "Monthly": de = ds + relativedelta(months=interval, minutes=-1) new_name = ds.strftime('%Y/%m') new_id =period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(months=interval) lines.append(new_id) return { 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'view_type': 'form', "view_mode": 'tree, form', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
754c921bd02858cd0a09ecc9a5cfbcf1146071ab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/754c921bd02858cd0a09ecc9a5cfbcf1146071ab/stock_planning_create_periods.py
de = ds + relativedelta(months=interval, minutes=-1)
de = ds + relativedelta(months=interval, seconds=-1) if dt_stp < de: de = dt_stp + relativedelta(days=1,seconds =-1) else: de = ds + relativedelta(months=interval, seconds=-1)
def create_stock_periods(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily') period_obj = self.pool.get('stock.period') lines = [] for p in self.browse(cr, uid, ids, context=context): dt = p.date_start ds = datetime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d') < p.date_stop: if name =='Daily': de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y-%m-%d') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name =="Weekly": de = ds + relativedelta(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W') new_id = period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(days=interval) + 1 if name == "Monthly": de = ds + relativedelta(months=interval, minutes=-1) new_name = ds.strftime('%Y/%m') new_id =period_obj.create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + relativedelta(months=interval) lines.append(new_id) return { 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'view_type': 'form', "view_mode": 'tree, form', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
754c921bd02858cd0a09ecc9a5cfbcf1146071ab /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/754c921bd02858cd0a09ecc9a5cfbcf1146071ab/stock_planning_create_periods.py
invoices = self.read(cr, uid, ids, ['move_id'])
invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
def action_cancel(self, cr, uid, ids, *args): account_move_obj = self.pool.get('account.move') invoices = self.read(cr, uid, ids, ['move_id']) for i in invoices: if i['move_id']: account_move_obj.button_cancel(cr, uid, [i['move_id'][0]]) # delete the move this invoice was pointing to # Note that the corresponding move_lines and move_reconciles # will be automatically deleted too account_move_obj.unlink(cr, uid, [i['move_id'][0]]) self.write(cr, uid, ids, {'state':'cancel', 'move_id':False}) self._log_event(cr, uid, ids,-1.0, 'Cancel Invoice') return True
4678c890a665b399e06491741c3eddc8527f9e6f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/4678c890a665b399e06491741c3eddc8527f9e6f/invoice.py
self._log.exception('Cannot rename "%s" to "%s" at "%s"', src, dst_basename, dst_basedir)
self._log.exception('Cannot rename "%s" to "%s" at "%s"', src, datacr[2], datacr[1])
def rename(self, src, datacr): """ Renaming operation, the effect depends on the src: * A file: read, create and remove * A directory: change the parent and reassign childs to ressource """ cr = datacr[0] try: nname = _to_unicode(datacr[2]) ret = src.move_to(cr, datacr[1], new_name=nname) # API shouldn't wait for us to write the object assert (ret is True) or (ret is False) cr.commit() except Exception,err: self._log.exception('Cannot rename "%s" to "%s" at "%s"', src, dst_basename, dst_basedir) raise OSError(1,'Operation not permited.')
796ed8e5987aa04cb2f4aa2cc950254363e29195 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/796ed8e5987aa04cb2f4aa2cc950254363e29195/abstracted_fs.py
account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context)
if previous_partial: account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) else: account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context)
def button_confirm(self, cr, uid, ids, context={}): done = [] res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') account_bank_statement_line_obj = \ self.pool.get('account.bank.statement.line')
d3f70e05fe7a19eaad75ecc398febd6d4527aa2a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d3f70e05fe7a19eaad75ecc398febd6d4527aa2a/account_bank_statement.py
icon = tools.file_open(icon_path,'rb').read() return base64.encodestring(icon)
if icon_path: icon = tools.file_open(icon_path,'rb').read() icon_image = base64.encodestring(icon) return icon_image
def read_image(self, path): path_info = path.split(',') icon_path = addons.get_module_resource(path_info[0],path_info[1]) icon = tools.file_open(icon_path,'rb').read() return base64.encodestring(icon)
d4b2226607975d4b91dd044bb33375062ed4f19b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d4b2226607975d4b91dd044bb33375062ed4f19b/ir_ui_menu.py
if picking_id: wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
def action_ship_create(self, cr, uid, ids, *args): wf_service = netsvc.LocalService("workflow") picking_id = False move_obj = self.pool.get('stock.move') proc_obj = self.pool.get('procurement.order') company = self.pool.get('res.users').browse(cr, uid, uid).company_id for order in self.browse(cr, uid, ids, context={}): proc_ids = [] output_id = order.shop_id.warehouse_id.lot_output_id.id picking_id = False for line in order.order_line: proc_id = False date_planned = datetime.now() + relativedelta(days=line.delay or 0.0) date_planned = (date_planned - timedelta(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
54ae65bc49e1ca211bfd02d70f537690d203f0e1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/54ae65bc49e1ca211bfd02d70f537690d203f0e1/sale.py
if ok: list_ids = [] for tmp in move.line_id: list_ids.append(tmp.id) self.pool.get('account.move.line').create_analytic_lines(cr, uid, list_ids, context)
if ok: list_ids = [] for tmp in move.line_id: list_ids.append(tmp.id) self.pool.get('account.move.line').create_analytic_lines(cr, uid, list_ids, context)
def validate(self, cr, uid, ids, context={}): if context and ('__last_update' in context): del context['__last_update'] ok = True for move in self.browse(cr, uid, ids, context): #unlink analytic lines on move_lines for obj_line in move.line_id: for obj in obj_line.analytic_lines: self.pool.get('account.analytic.line').unlink(cr,uid,obj.id)
047be686745c2903a886a3417584640a076ce7a6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/047be686745c2903a886a3417584640a076ce7a6/account.py
reference = obj_inv.reference
reference = obj_inv.reference or ''
def action_number(self, cr, uid, ids, *args): for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference if not number: tmp_context = { 'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id } if obj_inv.journal_id.invoice_sequence_id: sequence_id = obj_inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sequence_id, 'id', context=tmp_context) else: number = self.pool.get('ir.sequence').get_id(cr, uid, 'account.invoice.%s' % invtype, 'code', context=tmp_context) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) for inv_id, name in self.name_get(cr, uid, [id]): message = _('Invoice ') + " '" + name + "' "+ _("is validated.") self.log(cr, uid, inv_id, message) return True
95f5f1f0c8b337738d3504ea57d5284feea036e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/95f5f1f0c8b337738d3504ea57d5284feea036e9/invoice.py
perc_state = (state_cases / float(case.nbr_cases) ) * 100
perc_state = (state_cases / float(case.nbr) ) * 100
def _get_data(self, cr, uid, ids, field_name, arg, context={}): res = {} state_perc = 0.0 avg_ans = 0.0 for case in self.browse(cr, uid, ids, context): if field_name != 'avg_answers': state = field_name[5:] cr.execute("select count(*) from crm_opportunity where section_id =%s and state='%s'"%(case.section_id.id,state)) state_cases = cr.fetchone()[0] perc_state = (state_cases / float(case.nbr_cases) ) * 100 res[case.id] = perc_state else: model_name = self._name.split('report.') if len(model_name) < 2: res[case.id] = 0.0 else: model_name = model_name[1]
30c239414fe282ec5d6bf5c7c50dc9a3f64ada6c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/30c239414fe282ec5d6bf5c7c50dc9a3f64ada6c/report_crm.py
avg_ans = logs / case.nbr_cases
avg_ans = logs / case.nbr
def _get_data(self, cr, uid, ids, field_name, arg, context={}): res = {} state_perc = 0.0 avg_ans = 0.0 for case in self.browse(cr, uid, ids, context): if field_name != 'avg_answers': state = field_name[5:] cr.execute("select count(*) from crm_opportunity where section_id =%s and state='%s'"%(case.section_id.id,state)) state_cases = cr.fetchone()[0] perc_state = (state_cases / float(case.nbr_cases) ) * 100 res[case.id] = perc_state else: model_name = self._name.split('report.') if len(model_name) < 2: res[case.id] = 0.0 else: model_name = model_name[1]
30c239414fe282ec5d6bf5c7c50dc9a3f64ada6c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/30c239414fe282ec5d6bf5c7c50dc9a3f64ada6c/report_crm.py
'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True),
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
def _get_data(self, cr, uid, ids, field_name, arg, context={}): res = {} state_perc = 0.0 avg_ans = 0.0 for case in self.browse(cr, uid, ids, context): if field_name != 'avg_answers': state = field_name[5:] cr.execute("select count(*) from crm_opportunity where section_id =%s and state='%s'"%(case.section_id.id,state)) state_cases = cr.fetchone()[0] perc_state = (state_cases / float(case.nbr_cases) ) * 100 res[case.id] = perc_state else: model_name = self._name.split('report.') if len(model_name) < 2: res[case.id] = 0.0 else: model_name = model_name[1]
30c239414fe282ec5d6bf5c7c50dc9a3f64ada6c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/30c239414fe282ec5d6bf5c7c50dc9a3f64ada6c/report_crm.py
model_pool._history(cr, uid, [case], _('Send'), history=True, email=False) model_pool.write(cr, uid, [case.id], { 'som': False, 'canal_id': False, })
model_pool._history(cr, uid, [case], _('Send'), history=True, email=False)
def _mass_mail_send(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) hist_obj = pool.get('crm.case.history').browse(cr,uid,data['ids'])[0] model = hist_obj.log_id.model_id.model model_pool = pool.get(model) case = model_pool.browse(cr, uid, hist_obj.log_id.res_id) model_pool._history(cr, uid, [case], _('Send'), history=True, email=False) model_pool.write(cr, uid, [case.id], { 'som': False, 'canal_id': False, }) emails = [data['form']['to']] + (data['form']['cc'] or '').split(',') emails = filter(None, emails) body = data['form']['text'] if case.user_id.signature: body += '\n\n%s' % (case.user_id.signature) tools.email_send( case.user_id.address_id.email, emails, data['form']['subject'], model_pool.format_body(body), reply_to=case.section_id.reply_to, openobject_id=str(case.id), subtype="html" ) return {}
56244b68f7af69f77db9c2bd5cb62a0ef00ee903 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/56244b68f7af69f77db9c2bd5cb62a0ef00ee903/wizard_crm_send_email.py
value = elements[0]
value = self._get_first_result(elements)
def _eval_field(self, model, field_name, expression): column = model._columns[field_name] if is_ref(expression): if expression.model: other_model_name = expression.model else: other_model_name = column._obj other_model = self.get_model(other_model_name) if expression.search: q = eval(expression.search, self.eval_context) ids = other_model.search(self.cr, self.uid, q) if expression.use: instances = other_model.browse(self.cr, self.uid, ids) elements = [inst[expression.use] for inst in instances] else: elements = ids if column._type in ("many2many", "one2many"): value = [(6, 0, elements)] else: # many2one value = elements[0] elif column._type == "many2one": value = self.get_id(expression) elif column._type == "one2many": other_model = self.get_model(column._obj) value = [(0, 0, self._create_record(other_model, fields)) for fields in expression] elif column._type == "many2many": ids = [self.get_id(xml_id) for xml_id in expression] value = [(6, 0, ids)] else: # scalar field if is_eval(expression): value = eval(expression.expression, self.eval_context) else: value = expression # raise YamlImportException('Unsupported column "%s" or value %s:%s' % (field_name, type(expression), expression)) return value
7043023dd859943a2cf5fa3e3e86652ad427f6e5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7043023dd859943a2cf5fa3e3e86652ad427f6e5/yaml_import.py
flist = groupby
group_by = groupby if fget[groupby]['type'] in ('date','datetime'): flist = "to_char(%s,'yyyy-mm') as %s "%(groupby,groupby) groupby = "to_char(%s,'yyyy-mm')"%(groupby) else: flist = groupby
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): context = context or {} self.pool.get('ir.model.access').check(cr, uid, self._name, 'read', context=context) if not fields: fields = self._columns.keys()
27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7/orm.py
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): context = context or {} self.pool.get('ir.model.access').check(cr, uid, self._name, 'read', context=context) if not fields: fields = self._columns.keys()
27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7/orm.py
if fget[groupby]['type'] == 'many2one': d[groupby] = d[groupby] and d[groupby][1] or ''
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): context = context or {} self.pool.get('ir.model.access').check(cr, uid, self._name, 'read', context=context) if not fields: fields = self._columns.keys()
27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7/orm.py
today = datetime.date.today() if d[groupby][:10] == str(today): d[groupby] = 'Today'
dt = datetime.datetime.strptime(alldata[d['id']][groupby][:7],'%Y-%m') days = calendar.monthrange(dt.year, dt.month)[1] if d[groupby][:7] == today.strftime('%Y-%m'): d[groupby] = 'This Month'
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): context = context or {} self.pool.get('ir.model.access').check(cr, uid, self._name, 'read', context=context) if not fields: fields = self._columns.keys()
27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7/orm.py
d['__domain'] = [(groupby,'=',alldata[d['id']][groupby] or False)] + domain
d['__domain'] = [(groupby,'>=',alldata[d['id']][groupby] and datetime.datetime.strptime(alldata[d['id']][groupby][:7] + '-01','%Y-%m-%d').strftime('%Y-%m-%d') or False),\ (groupby,'<=',alldata[d['id']][groupby] and datetime.datetime.strptime(alldata[d['id']][groupby][:7] + '-' + str(days),'%Y-%m-%d').strftime('%Y-%m-%d') or False)] + domain elif fget[groupby]['type'] == 'many2one': d[groupby] = d[groupby] and d[groupby][1] or ''
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): context = context or {} self.pool.get('ir.model.access').check(cr, uid, self._name, 'read', context=context) if not fields: fields = self._columns.keys()
27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/27dbc19d1f7a0ba675a91c3ae1c88699c1d30ad7/orm.py
data_picking = self.browse(cr, uid, ids, context) for picking in data_picking:
uom_obj = self.pool.get('product.uom') for picking in self.browse(cr, uid, ids, context):
def _cal_weight(self, cr, uid, ids, name, args, context=None): res = {} data_picking = self.browse(cr, uid, ids, context) for picking in data_picking: total_weight = 0.00 if picking.move_lines: weight = 0.00 for move in picking.move_lines: if move.product_id.weight > 0.00: weight = (move.product_uos_qty * move.product_id.weight) total_weight += weight res[picking.id] = total_weight return res
d9c5b69c4166abc4e565909bc3c724dd057dc00f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d9c5b69c4166abc4e565909bc3c724dd057dc00f/stock.py
if picking.move_lines: weight = 0.00 for move in picking.move_lines: if move.product_id.weight > 0.00: weight = (move.product_uos_qty * move.product_id.weight) total_weight += weight
for move in picking.move_lines: total_weight += move.weight
def _cal_weight(self, cr, uid, ids, name, args, context=None): res = {} data_picking = self.browse(cr, uid, ids, context) for picking in data_picking: total_weight = 0.00 if picking.move_lines: weight = 0.00 for move in picking.move_lines: if move.product_id.weight > 0.00: weight = (move.product_uos_qty * move.product_id.weight) total_weight += weight res[picking.id] = total_weight return res
d9c5b69c4166abc4e565909bc3c724dd057dc00f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d9c5b69c4166abc4e565909bc3c724dd057dc00f/stock.py
'weight': fields.function(_cal_weight, method=True, type='float', string='Weight',digits_compute= dp.get_precision('Stock Weight'),
'weight': fields.function(_cal_weight, method=True, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'),
def _get_picking_line(self, cr, uid, ids, context=None): result = {} for line in self.pool.get('stock.move').browse(cr, uid, ids, context=context): result[line.picking_id.id] = True return result.keys()
d9c5b69c4166abc4e565909bc3c724dd057dc00f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d9c5b69c4166abc4e565909bc3c724dd057dc00f/stock.py
print "========", bom.product_id.name
def _compute_price(bom): print bom.product_id price = 0
c537d51792837a370cd94ef7eb7067d7965565f0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c537d51792837a370cd94ef7eb7067d7965565f0/product.py
print "XXXXXXXXXXXXX", p, test_obj.child_ids
def _compute_price(bom): print bom.product_id price = 0
c537d51792837a370cd94ef7eb7067d7965565f0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c537d51792837a370cd94ef7eb7067d7965565f0/product.py
result += txt
result += unicode(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 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 += txt return result
f886f8f43b6d627dcd6c6900e61bee3bc2c59648 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/f886f8f43b6d627dcd6c6900e61bee3bc2c59648/utils.py
limit = datetime.strptime(move.date_planned, '%Y-%m-%d %H:%M:%S') + relativedelta(months=product.warranty)
limit = datetime.strptime(move.date_expected, '%Y-%m-%d %H:%M:%S') + relativedelta(months=product.warranty)
def onchange_move_id(self, cr, uid, ids, prod_id=False, move_id=False): """ On change of move id sets values of guarantee limit, source location, destination location, partner and partner address. @param prod_id: Id of product in current record. @param move_id: Changed move. @return: Dictionary of values. """ data = {} data['value'] = {} if not prod_id: return data if move_id: move = self.pool.get('stock.move').browse(cr, uid, move_id) product = self.pool.get('product.product').browse(cr, uid, prod_id) limit = datetime.strptime(move.date_planned, '%Y-%m-%d %H:%M:%S') + relativedelta(months=product.warranty) data['value']['guarantee_limit'] = limit.strftime('%Y-%m-%d') data['value']['location_id'] = move.location_dest_id.id data['value']['location_dest_id'] = move.location_dest_id.id if move.address_id: data['value']['partner_id'] = move.address_id.partner_id and move.address_id.partner_id.id else: data['value']['partner_id'] = False data['value']['address_id'] = move.address_id and move.address_id.id d = self.onchange_partner_id(cr, uid, ids, data['value']['partner_id'], data['value']['address_id']) data['value'].update(d['value']) return data
ded4526a934a1096b93f3bcbf733055defd0bb7d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ded4526a934a1096b93f3bcbf733055defd0bb7d/mrp_repair.py
def refund(self, cr, uid, ids, date=None, period_id=None, description=None):
def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None):
def refund(self, cr, uid, ids, date=None, period_id=None, description=None): map_old_new = {} refund_ids = [] for old_inv_id in ids: new_id = super(account_invoice,self).refund(cr, uid, ids, date=date, period_id=period_id, description=description) refund_ids += new_id map_old_new[old_inv_id] = new_id[0]
cbea6a2d9a37b768b84716ca85849f17c7ebc827 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cbea6a2d9a37b768b84716ca85849f17c7ebc827/account_tax_include.py
new_id = super(account_invoice,self).refund(cr, uid, ids, date=date, period_id=period_id, description=description)
new_id = super(account_invoice,self).refund(cr, uid, ids, date=date, period_id=period_id, description=description, journal_id=journal_id)
def refund(self, cr, uid, ids, date=None, period_id=None, description=None): map_old_new = {} refund_ids = [] for old_inv_id in ids: new_id = super(account_invoice,self).refund(cr, uid, ids, date=date, period_id=period_id, description=description) refund_ids += new_id map_old_new[old_inv_id] = new_id[0]
cbea6a2d9a37b768b84716ca85849f17c7ebc827 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cbea6a2d9a37b768b84716ca85849f17c7ebc827/account_tax_include.py