rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
cr.close() def execute(self, db, uid, object, method, *args, **kw):
return True def execute(self, db, uid, model, method, *args, **kw):
def log_fct(self, db, uid, object, method, fct_src, *args): """ Logging function: This function is performs logging oprations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @param fct_src: execute method of Object proxy @return: Returns result as per method of Object proxy """ logged_uids = [] pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0] if method in ('create'): res_id = fct_src(db, uid, object, method, *args) cr.commit() new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0] if 'id' in new_value: del new_value['id'] if not logged_uids or uid in logged_uids: resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id]) resource_name = resource_name and resource_name[0][1] or '' vals = { "method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name } id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field in new_value: if new_value[field]: line = { 'name': field, 'new_value': new_value[field], 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object) } lines.append(line) self.create_log_line(cr, uid, id, model_object, lines) cr.commit() cr.close() return res_id
@param method: method to log: create, read, write, unlink @return: Returns result as per method of Object proxy """
@param method: get any method and create log @return: Returns result as per method of Object proxy """ pool = pooler.get_pool(db) model_pool = pool.get('ir.model') rule_pool = pool.get('audittrail.rule') cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] fct_src = super(audittrail_objects_proxy, self).execute def my_fct(db, uid, model, method, *args): rule = False model_ids = model_pool.search(cr, uid, [('model', '=', model)]) model_id = model_ids and model_ids[0] or False for model_name in pool.obj_list(): if model_name == 'audittrail.rule': rule = True if not rule: return fct_src(db, uid, model, method, *args) if not model_id: return fct_src(db, uid, model, method, *args) rule_ids = rule_pool.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'subscribed')]) if not rule_ids: return fct_src(db, uid, model, method, *args) for thisrule in rule_pool.browse(cr, uid, rule_ids): for user in thisrule.user_id: logged_uids.append(user.id) if not logged_uids or uid in logged_uids: if method in ('read', 'write', 'create', 'unlink'): if getattr(thisrule, 'log_' + method): return self.log_fct(db, uid, model, method, fct_src, *args) elif method not in ('default_get','read','fields_view_get','fields_get','search','search_count','name_search','name_get','get','request_get', 'get_sc', 'unlink', 'write', 'create'): if thisrule.log_action: return self.log_fct(db, uid, model, method, fct_src, *args) return fct_src(db, uid, model, method, *args) res = my_fct(db, uid, model, method, *args) cr.close() return res def exec_workflow(self, db, uid, model, method, *args, **argv):
def execute(self, db, uid, object, method, *args, **kw): """ Overrides Object Proxy execute method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @return: Returns result as per method of Object proxy """ pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] fct_src = super(audittrail_objects_proxy, self).execute
fct_src = super(audittrail_objects_proxy, self).execute def my_fct(db, uid, object, method, *args): field = method rule = False obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) for obj_name in pool.obj_list(): if obj_name == 'audittrail.rule': rule = True if not rule: return fct_src(db, uid, object, method, *args) if not obj_ids: return fct_src(db, uid, object, method, *args) rule_ids = pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')]) if not rule_ids: return fct_src(db, uid, object, method, *args) for thisrule in pool.get('audittrail.rule').browse(cr, uid, rule_ids): for user in thisrule.user_id: logged_uids.append(user.id) if not logged_uids or uid in logged_uids: if field in ('read', 'write', 'create', 'unlink'): if getattr(thisrule, 'log_' + field): return self.log_fct(db, uid, object, method, fct_src, *args) return fct_src(db, uid, object, method, *args) res = my_fct(db, uid, object, method, *args)
fct_src = super(audittrail_objects_proxy, self).exec_workflow field = method rule = False model_pool = pool.get('ir.model') rule_pool = pool.get('audittrail.rule') model_ids = model_pool.search(cr, uid, [('model', '=', model)]) for obj_name in pool.obj_list(): if obj_name == 'audittrail.rule': rule = True if not rule: cr.close() return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv) if not model_ids: cr.close() return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv) rule_ids = rule_pool.search(cr, uid, [('object_id', 'in', model_ids), ('state', '=', 'subscribed')]) if not rule_ids: cr.close() return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv) for thisrule in rule_pool.browse(cr, uid, rule_ids): for user in thisrule.user_id: logged_uids.append(user.id) if not logged_uids or uid in logged_uids: if thisrule.log_workflow: cr.close() return self.log_fct(db, uid, model, method, fct_src, *args) cr.close() return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv)
def execute(self, db, uid, object, method, *args, **kw): """ Overrides Object Proxy execute method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @param method: method to log: create, read, write, unlink @return: Returns result as per method of Object proxy """ pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] fct_src = super(audittrail_objects_proxy, self).execute
return res
return True
def my_fct(db, uid, object, method, *args): field = method rule = False obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)]) for obj_name in pool.obj_list(): if obj_name == 'audittrail.rule': rule = True if not rule: return fct_src(db, uid, object, method, *args) if not obj_ids: return fct_src(db, uid, object, method, *args) rule_ids = pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')]) if not rule_ids: return fct_src(db, uid, object, method, *args)
if int(vat[7:10]) > 121: return False
def check_vat_it(self, vat): ''' Check Italy VAT number. ''' if len(vat) != 11: return False try: int(vat) except: return False if int(vat[0:7]) <= 0: return False if int(vat[7:10]) <= 0: return False if int(vat[7:10]) > 100 and int(vat[7:10]) < 120: return False if int(vat[7:10]) > 121: return False
help="Total of Prospect Registrations"),
help="Total of Prospect Registrati./event/event.py:41:ons"),
def write(self, cr, uid, ids, vals, context=None): """ Writes values in one or several fields. @param ids: List of Event registration type's IDs @param vals: dictionary with values to update. @return: True """ register_pool = self.pool.get('event.registration') res = super(event_event, self).write(cr, uid, ids, vals, context=context) if vals.get('date_begin', False) or vals.get('mail_auto_confirm', False) or vals.get('mail_confirm', False): for event in self.browse(cr, uid, ids, context=context): #change the deadlines of the registration linked to this event register_values = {} if vals.get('date_begin', False): register_values['date_deadline'] = vals['date_begin']
(_check_recursion, 'Error ! You cannot create recursive event.', ['parent_id'])
(_check_recursion, 'Error ! You cannot create recursive event.', ['parent_id']), (_check_closing_date, 'Error ! Closing Date cannot be set before Beginning Date.', ['date_end']),
def _check_recursion(self, cr, uid, ids): """ Checks for recursion level for event """ level = 100
prod_obj = self.pool.get('product.template') location_obj = self.pool.get('stock.location') lot_obj = self.pool.get('stock.report.prodlots') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line') data_obj = self.pool.get('ir.model.data') res = self.read(cr, uid, ids[0], ['new_price']) new_price = res.get('new_price',[]) data = prod_obj.browse(cr, uid, rec_id) diff = data.standard_price - new_price prod_obj.write(cr, uid, rec_id, {'standard_price': new_price}) loc_ids = location_obj.search(cr, uid, [('account_id','<>',False),('usage','=','internal')]) lot_ids = lot_obj.search(cr, uid, [('location_id', 'in', loc_ids),('product_id','=',rec_id)]) qty = 0 debit = 0.0 credit = 0.0 stock_input_acc = data.property_stock_account_input.id or data.categ_id.property_stock_account_input_categ.id stock_output_acc = data.property_stock_account_output.id or data.categ_id.property_stock_account_output_categ.id for lots in lot_obj.browse(cr, uid, lot_ids): qty += lots.name if stock_input_acc and stock_output_acc and lot_ids: move_id = move_obj.create(cr, uid, {'journal_id': data.categ_id.property_stock_journal.id}) if diff > 0: credit = qty * diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_input_acc, 'credit': credit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): credit = lots.name * diff move_line_obj.create(cr, uid, { 'name': 'Expense', 'account_id': lots.location_id.account_id.id, 'debit': credit, 'move_id': move_id }) elif diff < 0: debit = qty * -diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_output_acc, 'debit': debit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): debit = lots.name * -diff move_line_obj.create(cr, uid, { 'name': 'Income', 'account_id': lots.location_id.account_id.id, 'credit': debit, 'move_id': move_id }) else: raise osv.except_osv(_('Warning!'),_('No Change in Price.')) else: raise osv.except_osv(_('Warning!'),_('No Accounts are defined for ' 'this product on its location.\nCan\'t create Move.')) id2 = data_obj._get_id(cr, uid, 'account', 'view_move_tree') id3 = data_obj._get_id(cr, uid, 'account', 'view_move_form') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'account.move', 'res_id' : move_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window',
assert rec_id, _('Active ID is not set in Context') prod_obj = self.pool.get('product.product') res = self.browse(cr, uid, ids) datas = { 'new_price' : res[0].new_price, 'stock_output_account' : res[0].stock_account_output.id, 'stock_input_account' : res[0].stock_account_input.id, 'stock_journal' : res[0].stock_journal.id
def change_price(self, cr, uid, ids, context): """ Changes the Standard Price of Product. And creates an account move accordingly. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: """ rec_id = context and context.get('active_id', False) prod_obj = self.pool.get('product.template') location_obj = self.pool.get('stock.location') lot_obj = self.pool.get('stock.report.prodlots') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line') data_obj = self.pool.get('ir.model.data') res = self.read(cr, uid, ids[0], ['new_price']) new_price = res.get('new_price',[]) data = prod_obj.browse(cr, uid, rec_id) diff = data.standard_price - new_price prod_obj.write(cr, uid, rec_id, {'standard_price': new_price}) loc_ids = location_obj.search(cr, uid, [('account_id','<>',False),('usage','=','internal')]) lot_ids = lot_obj.search(cr, uid, [('location_id', 'in', loc_ids),('product_id','=',rec_id)]) qty = 0 debit = 0.0 credit = 0.0 stock_input_acc = data.property_stock_account_input.id or data.categ_id.property_stock_account_input_categ.id stock_output_acc = data.property_stock_account_output.id or data.categ_id.property_stock_account_output_categ.id for lots in lot_obj.browse(cr, uid, lot_ids): qty += lots.name if stock_input_acc and stock_output_acc and lot_ids: move_id = move_obj.create(cr, uid, {'journal_id': data.categ_id.property_stock_journal.id}) if diff > 0: credit = qty * diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_input_acc, 'credit': credit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): credit = lots.name * diff move_line_obj.create(cr, uid, { 'name': 'Expense', 'account_id': lots.location_id.account_id.id, 'debit': credit, 'move_id': move_id }) elif diff < 0: debit = qty * -diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_output_acc, 'debit': debit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): debit = lots.name * -diff move_line_obj.create(cr, uid, { 'name': 'Income', 'account_id': lots.location_id.account_id.id, 'credit': debit, 'move_id': move_id }) else: raise osv.except_osv(_('Warning!'),_('No Change in Price.')) else: raise osv.except_osv(_('Warning!'),_('No Accounts are defined for ' 'this product on its location.\nCan\'t create Move.')) id2 = data_obj._get_id(cr, uid, 'account', 'view_move_tree') id3 = data_obj._get_id(cr, uid, 'account', 'view_move_form') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'account.move', 'res_id' : move_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window', } prod_obj.do_change_standard_price(cr, uid, [rec_id], datas, context) return {}
def draft_validate(self, cr, uid, ids, *args):
def draft_validate(self, cr, uid, ids, context=None):
def draft_validate(self, cr, uid, ids, *args): """ Validates picking directly from draft state. @return: True """ wf_service = netsvc.LocalService("workflow") self.draft_force_assign(cr, uid, ids) for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines] self.pool.get('stock.move').force_assign(cr, uid, move_ids) wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
self.action_move(cr, uid, [pick.id]) wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr) return True
context.update({'active_ids':ids}) return { 'name': 'Make Picking', 'view_type': 'form', 'view_mode': 'form', 'res_model': 'stock.partial.picking', 'type': 'ir.actions.act_window', 'target': 'new', 'nodestroy': True, 'context':context }
def draft_validate(self, cr, uid, ids, *args): """ Validates picking directly from draft state. @return: True """ wf_service = netsvc.LocalService("workflow") self.draft_force_assign(cr, uid, ids) for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines] self.pool.get('stock.move').force_assign(cr, uid, move_ids) wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
WHERE emp.id IN %s', (tuple(parent_ids),)) parent_ids = [x[0] for x in cr.fetchall() if x[0]]
WHERE emp.id IN %s AND res.user_id IS NOT NULL', (tuple(parent_ids),)) parent_ids = [x[0] for x in cr.fetchall()]
def _parent_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} result = {} obj_dept = self.pool.get('hr.department') for user_id in ids: emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)], context=context) cr.execute('SELECT emp.department_id FROM hr_employee AS emp \ JOIN resource_resource AS res ON res.id = emp.resource_id \ JOIN hr_department as dept ON dept.id = emp.department_id \ WHERE res.user_id = %s AND emp.department_id IS NOT NULL AND dept.manager_id IS NOT NULL', (user_id,)) ids_dept = [x[0] for x in cr.fetchall()] parent_ids = [] if ids_dept: data_dept = obj_dept.read(cr, uid, ids_dept, ['manager_id'], context=context) parent_ids = map(lambda x: x['manager_id'][0], data_dept) cr.execute('SELECT res.user_id FROM hr_employee AS emp JOIN resource_resource AS res ON res.id=emp.resource_id \ WHERE emp.id IN %s', (tuple(parent_ids),)) parent_ids = [x[0] for x in cr.fetchall() if x[0]] result[user_id] = parent_ids return result
class record(yaml.YAMLObject): yaml_tag = u'!record' def __init__(self, model, id=None, attrs={}): self.model = model self.id = id self.attrs=attrs def __repr__(self): return '!record {model: %s, id: %s}:' % (str(self.model,), str(self.id,)) class workflow(yaml.YAMLObject): yaml_tag = u'!workflow' def __init__(self, model, action, ref=None): self.model = model self.ref = ref self.action=action def __repr__(self): return '!workflow {model: %s, action: %s, ref: %s}' % (str(self.model,), str(self.action,), str(self.ref,)) class ref(yaml.YAMLObject): yaml_tag = u'!ref' def __init__(self, expr="False"): self.expr = expr def __repr__(self): return 'ref(%s)' % (str(self.expr,)) class eval(yaml.YAMLObject): yaml_tag = u'!eval' def __init__(self, expr="False"): self.expr = expr def __repr__(self): return 'eval(%s)' % (str(self.expr,)) class function(yaml.YAMLObject): yaml_tag = u'!python' def __init__(self, model, action=None,attrs={}): self.model = model self.action = action self.attrs=attrs def __repr__(self): return '!python {model: %s}: |' % (str(self.model), )
from tools import yaml_tag
def doc_createXElement(xdoc, tagName): e = xElement(tagName) e.ownerDocument = xdoc return e
ids = ','.join([str(x) for x in context['periods']]) query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids, where_move_state, where_move_lines_by_date)
if initial_bal: query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause, where_move_state, where_move_lines_by_date) period_ids = fiscalperiod_obj.search(cr, uid, [('id', 'in', context['periods'])], order='date_start', limit=1) if period_ids and period_ids[0]: first_period = fiscalperiod_obj.browse(cr, uid, period_ids[0], context=context) periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<', first_period.date_start)]) periods = ','.join([str(x) for x in periods]) if periods: query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) OR id in (%s)) %s %s" % (fiscalyear_clause, periods, where_move_state, where_move_lines_by_date) else: ids = ','.join([str(x) for x in context['periods']]) query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids, where_move_state, where_move_lines_by_date)
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
res.update({'trans_nbr':data['credit']})
res.update({'credit':data['credit']})
def default_get(self, cr, uid, fields, context=None): res = super(account_move_line_reconcile, self).default_get(cr, uid, fields, context=context) data = self.trans_rec_get(cr, uid, context['active_ids'], context) if 'trans_nbr' in fields: res.update({'trans_nbr':data['trans_nbr']}) if 'credit' in fields: res.update({'trans_nbr':data['credit']}) if 'debit' in fields: res.update({'trans_nbr':data['debit']}) if 'writeoff' in fields: res.update({'trans_nbr':data['writeoff']}) return res
res.update({'trans_nbr':data['debit']})
res.update({'debit':data['debit']})
def default_get(self, cr, uid, fields, context=None): res = super(account_move_line_reconcile, self).default_get(cr, uid, fields, context=context) data = self.trans_rec_get(cr, uid, context['active_ids'], context) if 'trans_nbr' in fields: res.update({'trans_nbr':data['trans_nbr']}) if 'credit' in fields: res.update({'trans_nbr':data['credit']}) if 'debit' in fields: res.update({'trans_nbr':data['debit']}) if 'writeoff' in fields: res.update({'trans_nbr':data['writeoff']}) return res
res.update({'trans_nbr':data['writeoff']})
res.update({'writeoff':data['writeoff']})
def default_get(self, cr, uid, fields, context=None): res = super(account_move_line_reconcile, self).default_get(cr, uid, fields, context=context) data = self.trans_rec_get(cr, uid, context['active_ids'], context) if 'trans_nbr' in fields: res.update({'trans_nbr':data['trans_nbr']}) if 'credit' in fields: res.update({'trans_nbr':data['credit']}) if 'debit' in fields: res.update({'trans_nbr':data['debit']}) if 'writeoff' in fields: res.update({'trans_nbr':data['writeoff']}) return res
'allounce':round(allow), 'deduction':round(deduct), 'grows':round(rs.basic + allow), 'net':round(rs.basic + allow - deduct),
'allounce':allow, 'deduction':deduct, 'grows':rs.basic + allow, 'net':rs.basic + allow - deduct,
def _calculate(self, cr, uid, ids, field_names, arg, context=None): slip_line_obj = self.pool.get('hr.payslip.line') if context is None: context = {} res = {} for rs in self.browse(cr, uid, ids, context=context): allow = 0.0 deduct = 0.0 others = 0.0 obj = {'basic':rs.basic} if rs.igross > 0: obj['gross'] = rs.igross if rs.inet > 0: obj['net'] = rs.inet for line in rs.line_ids: amount = 0.0 if line.amount_type == 'per': try: amount = line.amount * eval(str(line.category_id.base), obj) except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ' % (e))) elif line.amount_type in ('fix', 'func'): amount = line.amount cd = line.category_id.code.lower() obj[cd] = amount contrib = 0.0 if line.type == 'allowance': allow += amount others += contrib amount -= contrib elif line.type == 'deduction': deduct += amount others -= contrib amount += contrib elif line.type == 'advance': others += amount elif line.type == 'loan': others += amount elif line.type == 'otherpay': others += amount slip_line_obj.write(cr, uid, [line.id], {'total':amount}, context=context)
'total_pay':round(rs.basic + allow - deduct)
'total_pay':rs.basic + allow - deduct
def _calculate(self, cr, uid, ids, field_names, arg, context=None): slip_line_obj = self.pool.get('hr.payslip.line') if context is None: context = {} res = {} for rs in self.browse(cr, uid, ids, context=context): allow = 0.0 deduct = 0.0 others = 0.0 obj = {'basic':rs.basic} if rs.igross > 0: obj['gross'] = rs.igross if rs.inet > 0: obj['net'] = rs.inet for line in rs.line_ids: amount = 0.0 if line.amount_type == 'per': try: amount = line.amount * eval(str(line.category_id.base), obj) except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ' % (e))) elif line.amount_type in ('fix', 'func'): amount = line.amount cd = line.category_id.code.lower() obj[cd] = amount contrib = 0.0 if line.type == 'allowance': allow += amount others += contrib amount -= contrib elif line.type == 'deduction': deduct += amount others -= contrib amount += contrib elif line.type == 'advance': others += amount elif line.type == 'loan': others += amount elif line.type == 'otherpay': others += amount slip_line_obj.write(cr, uid, [line.id], {'total':amount}, context=context)
'basic_before_leaves': fields.float('Basic Salary', readonly=True, digits=(16, 2)), 'leaves': fields.float('Leave Deductions', readonly=True, digits=(16, 2)), 'basic': fields.float('Net Basic', readonly=True, digits=(16, 2)), 'grows': fields.function(_calculate, method=True, store=True, multi='dc', string='Gross Salary', type='float', digits=(16, 2)), 'net': fields.function(_calculate, method=True, store=True, multi='dc', string='Net Salary', digits=(16, 2)), 'allounce': fields.function(_calculate, method=True, store=True, multi='dc', string='Allowance', digits=(16, 2)), 'deduction': fields.function(_calculate, method=True, store=True, multi='dc', string='Deduction', digits=(16, 2)), 'other_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Others', digits=(16, 2)), 'total_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Total Payment', digits=(16, 2)),
'basic_before_leaves': fields.float('Basic Salary', readonly=True, digits_compute=dp.get_precision('Account')), 'leaves': fields.float('Leave Deductions', readonly=True, digits_compute=dp.get_precision('Account')), 'basic': fields.float('Net Basic', readonly=True, digits_compute=dp.get_precision('Account')), 'grows': fields.function(_calculate, method=True, store=True, multi='dc', string='Gross Salary', digits_compute=dp.get_precision('Account')), 'net': fields.function(_calculate, method=True, store=True, multi='dc', string='Net Salary', digits_compute=dp.get_precision('Account')), 'allounce': fields.function(_calculate, method=True, store=True, multi='dc', string='Allowance', digits_compute=dp.get_precision('Account')), 'deduction': fields.function(_calculate, method=True, store=True, multi='dc', string='Deduction', digits_compute=dp.get_precision('Account')), 'other_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Others', digits_compute=dp.get_precision('Account')), 'total_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Total Payment', digits_compute=dp.get_precision('Account')),
def _calculate(self, cr, uid, ids, field_names, arg, context=None): slip_line_obj = self.pool.get('hr.payslip.line') if context is None: context = {} res = {} for rs in self.browse(cr, uid, ids, context=context): allow = 0.0 deduct = 0.0 others = 0.0 obj = {'basic':rs.basic} if rs.igross > 0: obj['gross'] = rs.igross if rs.inet > 0: obj['net'] = rs.inet for line in rs.line_ids: amount = 0.0 if line.amount_type == 'per': try: amount = line.amount * eval(str(line.category_id.base), obj) except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ' % (e))) elif line.amount_type in ('fix', 'func'): amount = line.amount cd = line.category_id.code.lower() obj[cd] = amount contrib = 0.0 if line.type == 'allowance': allow += amount others += contrib amount -= contrib elif line.type == 'deduction': deduct += amount others -= contrib amount += contrib elif line.type == 'advance': others += amount elif line.type == 'loan': others += amount elif line.type == 'otherpay': others += amount slip_line_obj.write(cr, uid, [line.id], {'total':amount}, context=context)
'total': fields.float('Sub Total', readonly=True, digits=(16, 4)),
'total': fields.float('Sub Total', readonly=True, digits_compute=dp.get_precision('Account')),
def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}}
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') 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
'AND "user" IN %s',(parent_ids, user_ids,))
'AND "user" IN %s',(parent_ids, tuple(user_ids),))
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
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 []
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
'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
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 []
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)
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}
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
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
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
key = operator.itemgetter(0)
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {}
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 """
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
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
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)
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)
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
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
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
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)
'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 """
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 """
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 {}
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)
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)
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
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')
_rec_name = "date_time"
_rec_name = "summary"
def write(self, cr, uid, ids, vals, context=None):
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={}):
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
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')
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', }
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', }
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', }
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', }
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', }
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
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.')
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')
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
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]
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]
'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]
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 {}
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
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
print "========", bom.product_id.name
def _compute_price(bom): print bom.product_id price = 0
print "XXXXXXXXXXXXX", p, test_obj.child_ids
def _compute_price(bom): print bom.product_id price = 0
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
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]
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]
if res_obj and len(res_obj): res_obj = res_obj[0]
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context={}): company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.name for att in self.browse(cr, uid, ids, context=context): sign = att.sent_by_uid and att.sent_by_uid.signature or '' sign = '<br>'.join(sign and sign.split('\n') or []) res_obj = att.ref if res_obj and len(res_obj): res_obj = res_obj[0] sub = '[%s Invitation][%d] %s' % (company, att.id, res_obj.name) att_infos = [] other_invitaion_ids = self.search(cr, uid, [('ref','=',att.ref)]) for att2 in self.browse(cr, uid, other_invitaion_ids): att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ att2.email) + ' - Status: ' + att2.state.title()) body_vals = {'name': res_obj.name, 'start_date': res_obj.date, 'end_date': res_obj.date_deadline or False, 'description': res_obj.description or '-', 'location': res_obj.location or '-', 'attendees': '<br>'.join(att_infos), 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', 'sign': sign, 'company': company } body = html_invitation % body_vals if mail_to and email_from: tools.email_send( email_from, mail_to, sub, body, subtype='html', reply_to=email_from ) return True
other_invitaion_ids = self.search(cr, uid, [('ref','=',att.ref)])
other_invitaion_ids = self.search(cr, uid, [('ref','=', att.ref._name + ',' + str(att.ref.id))])
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context={}): company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.name for att in self.browse(cr, uid, ids, context=context): sign = att.sent_by_uid and att.sent_by_uid.signature or '' sign = '<br>'.join(sign and sign.split('\n') or []) res_obj = att.ref if res_obj and len(res_obj): res_obj = res_obj[0] sub = '[%s Invitation][%d] %s' % (company, att.id, res_obj.name) att_infos = [] other_invitaion_ids = self.search(cr, uid, [('ref','=',att.ref)]) for att2 in self.browse(cr, uid, other_invitaion_ids): att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ att2.email) + ' - Status: ' + att2.state.title()) body_vals = {'name': res_obj.name, 'start_date': res_obj.date, 'end_date': res_obj.date_deadline or False, 'description': res_obj.description or '-', 'location': res_obj.location or '-', 'attendees': '<br>'.join(att_infos), 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', 'sign': sign, 'company': company } body = html_invitation % body_vals if mail_to and email_from: tools.email_send( email_from, mail_to, sub, body, subtype='html', reply_to=email_from ) return True
rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False
rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value_reference','res_id']) pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value_reference','res_id']) rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False acc_id = False bank_id = False fiscal_position = False
rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False
rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value_reference','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value_reference','res_id']) rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not pay_res_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} account_obj = self.pool.get('account.account') if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = account_obj.browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configuration Error !'), _('Invoice line account company does not match with invoice company.')) else: continue if company_id and type: if type in ('out_invoice'): journal_type = 'sale' elif type in ('out_refund'): journal_type = 'sale_refund' elif type in ('in_refund'): journal_type = 'purchase_refund' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configuration Error !'), _('Can\'t find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Financial Accounting\Accounts\Journals.' % (journal_type))) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, [])
app_acc_in = account_obj.browse(cr, uid, in_pro_id)[0]
my_value = property_obj.read(cr,uid,in_pro_id,['name','value_reference','res_id']) account_id = int (my_value[0]["value_reference"].split(",")[1]) app_acc_in = account_obj.browse(cr, uid, [account_id])[0]
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos_obj = self.pool.get('account.fiscal.position') fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id) or False
t = payment.mode and payment.mode.type.id or None
t = None
def create_payment(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line') payment_obj = self.pool.get('payment.line') if context is None: context = {} data = self.read(cr, uid, ids, [])[0] line_ids = data['entries'] if not line_ids: return {}
company_data = self.pool.get('base.setup.company').read(cr, uid, company_id)[0]
company_data = self.pool.get('base.setup.company').read(cr, uid, company_id) company_data = company_data and company_data[0]
def execute(self, cr, uid, ids, context=None): company_id = self.pool.get('base.setup.company').search(cr, uid, []) company_data = self.pool.get('base.setup.company').read(cr, uid, company_id)[0] country1 = '' if company_data.get('country_id', False): country = self.pool.get('res.country').read(cr, uid, company_data['country_id'],['name'])['name'] for res in self.read(cr, uid, ids): email = res.get('email','') result = "\ncompany: "+ str(company_data.get('name','')) result += "\nname: " + str(res.get('name','')) result += "\nphone: " + str(res.get('phone','')) result += "\ncity: " + str(company_data.get('city','')) result += "\ncountry: " + str(country) result += "\nindustry: " + str(res.get('industry', '')) result += "\ntotal_employees: " + str(res.get('total_employees', '')) result += "\nplan_use: " + str(res.get('use_openerp', False)) result += "\nsell_openerp: " + str(res.get('sell_openerp', False)) result += "\nebook: " + str(res.get('ebook',False)) result += "\ngtk: " + str(True) misc.upload_data(email, result, type='SURVEY')
'context' : context
'context' : context, 'nodestroy':True,
def action_print_survey(self, cr, uid, ids, context=None): """ If response is available then print this response otherwise print survey form(print template of the survey). @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Survey IDs @param context: A standard dictionary for contextual values @return : Dictionary value for print survey form. """ if not context: context = {} datas = {} if 'response_id' in context: response_id = context.get('response_id', 0) datas['ids'] = [context.get('survey_id', 0)] else: response_id = self.pool.get('survey.response').search(cr, uid, [('survey_id','=', ids)], context=context) datas['ids'] = ids page_setting = {'orientation': 'vertical', 'without_pagebreak': 0, 'paper_size': 'letter', 'page_number': 1, 'survey_title': 1} report = {} if response_id and response_id[0]: context.update({'survey_id': datas['ids']}) datas['form'] = page_setting datas['model'] = 'survey.print.answer' report = { 'type': 'ir.actions.report.xml', 'report_name': 'survey.browse.response', 'datas': datas, 'context' : context } else:
dt=DateTime.strptime(order.date_order, '%Y-%m-%d') + DateTime.RelativeDateTime(days=line.delay or 0.0)
dt = datetime.strptime(order.date_order, '%Y-%m-%d') + relativedelta(days=line.delay or 0.0)
def _get_commitment_date(self, cr, uid, ids, name, arg, context={}): res = {} dates_list = [] for order in self.browse(cr, uid, ids): dates_list = [] for line in order.order_line: dt=DateTime.strptime(order.date_order, '%Y-%m-%d') + DateTime.RelativeDateTime(days=line.delay or 0.0) dt_s = dt.strftime('%Y-%m-%d') dates_list.append(dt_s) if dates_list: res[order.id] = min(dates_list) return res
result = mod_obj._get_id(cr, uid, module, wizard) id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] return act_obj.read(cr, uid, [id])[0]
result = obj_model._get_id(cr, uid, module, wizard) id = obj_model.read(cr, uid, [result], ['res_id'])[0]['res_id'] return obj_act.read(cr, uid, [id])[0]
def launch_wizard(self, cr, uid, ids, context=None): """ Search for a wizard to launch according to the type. If type is manual. just confirm the order. """ obj_payment_order = self.pool.get('payment.order') obj_model = self.pool.get('ir.model.data') obj_act = self.pool.get('ir.actions.act_window') order= obj_payment_order.browse(cr, uid, context['active_id'], context) t = order.mode and order.mode.type.code or 'manual' if t == 'manual' : obj_payment_order.set_done(cr,uid,context['active_id'],context) return {}
message = _('Voucher ') + " '" + inv.name + "' "+ _("is confirm")
message = _('Voucher ') + " '" + inv.name + "' "+ _("is confirmed")
def action_move_line_create(self, cr, uid, ids, *args):
context.update({'uom': uom})
context.update(uom=uom, compute_child=False)
def fill_inventory(self, cr, uid, ids, context): """ To fill stock inventory according to products available in the selected locations. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs if we want more than one @param context: A standard dictionary @return: """ inventory_line_obj = self.pool.get('stock.inventory.line') location_obj = self.pool.get('stock.location') product_obj = self.pool.get('product.product') stock_location_obj = self.pool.get('stock.location') for fill_inventory in self.browse(cr, uid, ids): res = {} res_location = {} if fill_inventory.recursive : location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', fill_inventory.location_id.id)]) for location in location_ids : res = location_obj._product_get(cr, uid, location) res_location[location] = res else: context.update({'compute_child': False}) res = location_obj._product_get(cr, uid, fill_inventory.location_id.id, context=context) res_location[fill_inventory.location_id.id] = res
if result['product_uom_id'] and (not result['product_uom_id'] == default_uom):
if result.get('product_uom_id',False) and (not result['product_uom_id'] == default_uom):
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') project_obj = self.pool.get('project.project') uom_obj = self.pool.get('product.uom') if isinstance(ids, (long, int)): ids = [ids,]
result['product_uom_qty'] = qty
result['product_uom_qty'] = pack.qty
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sale form !\nPlease set one customer before choosing a product.')) warning = {} product_uom_obj = self.pool.get('product.uom') partner_obj = self.pool.get('res.partner') product_obj = self.pool.get('product.product') if partner_id: lang = partner_obj.browse(cr, uid, partner_id).lang context = {'lang': lang, 'partner_id': partner_id}
res = super(wiz_auc_lots_numerotate_per_lot, self).default_get(cr, uid, fields, context=context)
res = super(auction_lots_numerotate_per_lot, self).default_get(cr, uid, fields, context=context)
def default_get(self, cr, uid, fields, context): """ To get default values for the object. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dictionary which of fields with values. """ res = super(wiz_auc_lots_numerotate_per_lot, self).default_get(cr, uid, fields, context=context) active_id = context.get('active_id',False) active_model = context.get('active_model') if active_id and (active_model and active_model!='auction.lots'): return res lots_obj = self.pool.get('auction.lots') lots = lots_obj.browse(cr, uid, active_id) if 'bord_vnd_id' in fields and context.get('bord_vnd_id',False): res['bord_vnd_id'] = context.get('bord_vnd_id') if 'lot_num' in fields and context.get('lot_num',False): res['lot_num'] = context.get('lot_num') if 'lot_est1' in fields: res['lot_est1'] = lots.lot_est1 if 'lot_est2' in fields: res['lot_est2'] = lots.lot_est2 if 'name' in fields: res['name'] = lots.name if 'obj_desc' in fields: res['obj_desc'] = lots.obj_desc if 'obj_num' in fields: res['obj_num'] = lots.obj_num return res
date_and_hours_by_cal = [(op.production_id.date_planned, op.hour, op.workcenter_id.calendar_id.id) for op in ops]
date_and_hours_by_cal = [(op.date_planned, op.hour, op.workcenter_id.calendar_id.id) for op in ops if op.date_planned]
def _get_date_end(self, cr, uid, ids, field_name, arg, context): """ Finds ending date. @return: Dictionary of values. """ ops = self.browse(cr, uid, ids, context=context) date_and_hours_by_cal = [(op.production_id.date_planned, op.hour, op.workcenter_id.calendar_id.id) for op in ops] intervals = self.pool.get('resource.calendar').interval_get_multi(cr, uid, date_and_hours_by_cal)
i = intervals[(op.date_planned, op.hour, op.workcenter_id.calendar_id.id)]
i = intervals.get((op.date_planned, op.hour, op.workcenter_id.calendar_id.id))
def _get_date_end(self, cr, uid, ids, field_name, arg, context): """ Finds ending date. @return: Dictionary of values. """ ops = self.browse(cr, uid, ids, context=context) date_and_hours_by_cal = [(op.production_id.date_planned, op.hour, op.workcenter_id.calendar_id.id) for op in ops] intervals = self.pool.get('resource.calendar').interval_get_multi(cr, uid, date_and_hours_by_cal)
def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False):
def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False, context=None): if context is None: context = {}
def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False): account_obj = self.pool.get('account.account') journal_obj = self.pool.get('account.journal') currency_obj = self.pool.get('res.currency') if (not currency_id) or (not account_id): return {} result = {} acc = account_obj.browse(cr, uid, account_id) if (amount>0) and journal: x = journal_obj.browse(cr, uid, journal).default_credit_account_id if x: acc = x v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, account=acc) result['value'] = { 'debit': v > 0 and v or 0.0, 'credit': v < 0 and -v or 0.0 } return result
v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, account=acc)
context.update({'date': date}) v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, account=acc, context=context)
def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False): account_obj = self.pool.get('account.account') journal_obj = self.pool.get('account.journal') currency_obj = self.pool.get('res.currency') if (not currency_id) or (not account_id): return {} result = {} acc = account_obj.browse(cr, uid, account_id) if (amount>0) and journal: x = journal_obj.browse(cr, uid, journal).default_credit_account_id if x: acc = x v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, account=acc) result['value'] = { 'debit': v > 0 and v or 0.0, 'credit': v < 0 and -v or 0.0 } return result
res[id]=[x for x in l if x <> line.id]
partial_ids.append(line.id) res[id] =[x for x in l if x <> line.id and x not in 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 data_lines = self.pool.get('account.move.line').browse(cr,uid,move_lines) 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) res[id]=[x for x in l if x <> line.id] return res
lines += map(lambda x: x.id, m.reconcile_id.line_id)
temp_lines = map(lambda x: x.id, m.reconcile_id.line_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): if m.reconcile_id: lines += map(lambda x: x.id, m.reconcile_id.line_id) elif m.reconcile_partial_id: lines += map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) src.append(m.id) lines = filter(lambda x: x not in src, lines) result[invoice.id] = lines return result
lines += map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids)
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]
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): if m.reconcile_id: lines += map(lambda x: x.id, m.reconcile_id.line_id) elif m.reconcile_partial_id: lines += map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) src.append(m.id) lines = filter(lambda x: x not in src, lines) result[invoice.id] = lines return result
resource_id = len(resource_ids) or resource_ids[0]
if resource_ids: resource_id = len(resource_ids) or resource_ids[0]
def _compute_day(self, cr, uid, ids, fields, args, context={}): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Openday’s IDs @return: difference between current date and log date @param context: A standard dictionary for contextual values """ cal_obj = self.pool.get('resource.calendar') res_obj = self.pool.get('resource.resource')
number = self.pool.get('ir.sequence').get(cr, uid, 'account.cash.statement')
if statement.name and statement.name == '/': number = self.pool.get('ir.sequence').get(cr, uid, 'account.cash.statement') vals.update({ 'name':number })
def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ cash_pool = self.pool.get('account.cashbox.line') statement_pool = self.pool.get('account.bank.statement')
vals = {
vals.update({
def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ cash_pool = self.pool.get('account.cashbox.line') statement_pool = self.pool.get('account.bank.statement')
'name':number }
})
def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ cash_pool = self.pool.get('account.cashbox.line') statement_pool = self.pool.get('account.bank.statement')
except ValueError:
except:
def create(self, cr, uid, data, context=None): if context is None: context = {} user_id = super(res_users, self).create(cr, uid, data, context) data_obj = self.pool.get('ir.model.data') try: data_id = data_obj._get_id(cr, uid, 'crm', 'ir_ui_view_sc_calendar0') view_id = data_obj.browse(cr, uid, data_id, context=context).res_id self.pool.get('ir.ui.view_sc').copy(cr, uid, view_id, default = { 'user_id': user_id}, context=context) except ValueError: # Tolerate a missing shortcut. See product/product.py for similar code. logging.getLogger('orm').warning('Skipped Products shortcut for user "%s"', data.get('name','<new')) return user_id
objid = self.pool.get('ir.model.data')
data_pool = self.pool.get('ir.model.data')
def _get_root_calendar_directory(self, cr, uid, context=None): objid = self.pool.get('ir.model.data') try: mid = objid._get_id(cr, uid, 'document', 'dir_calendars') if not mid: return False root_id = objid.read(cr, uid, mid, ['res_id'])['res_id'] root_cal_dir = self.browse(cr,uid, root_id, context=context) return root_cal_dir.name except Exception: logger = logging.getLogger('document') logger.warning('Cannot set root directory for Calendars:', exc_info=True) return False return False