rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
self.obj_pl = report_pl.report_pl_account_horizontal(cr, uid, name, context=context) | self.obj_pl = account_profit_loss.report_pl_account_horizontal(cr, uid, name, context=context) | def __init__(self, cr, uid, name, context=None): super(report_balancesheet_horizontal, self).__init__(cr, uid, name, context=context) self.obj_pl = report_pl.report_pl_account_horizontal(cr, uid, name, context=context) self.result_sum_dr = 0.0 self.result_sum_cr = 0.0 self.result = {} self.res_bl = {} self.result_temp = [] self.localcontext.update({ 'time': time, 'get_abs' : self.get_abs, 'get_lines' : self.get_lines, 'get_lines_another' : self.get_lines_another, 'get_company': self._get_company, 'get_currency': self._get_currency, 'sum_dr' : self.sum_dr, 'sum_cr' : self.sum_cr, 'get_data':self.get_data, 'get_pl_balance':self.get_pl_balance, 'get_fiscalyear': self._get_fiscalyear, 'get_account': self._get_account, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_sortby': self._get_sortby, 'get_filter': self._get_filter, 'get_journal': self._get_journal, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_company':self._get_company, |
ids = map(lambda x: base_calendar_id2real_id(x), ids) | ids = map(lambda x: base_calendar.base_calendar_id2real_id(x), ids) | def export_cal(self, cr, uid, ids, context={}): ids = map(lambda x: base_calendar_id2real_id(x), ids) event_data = self.read(cr, uid, ids) event_obj = self.pool.get('basic.calendar.event') ical = event_obj.export_cal(cr, uid, event_data, context={'model': self._name}) return ical.serialize() |
period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])[0]['date_start'] period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])[0]['date_stop'] | period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start'] period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop'] | def _build_context(self, cr, uid, ids, data, context = None): result = {} result['fiscalyear'] = data['form']['fiscalyear_id'] and data['form']['fiscalyear_id'] or False if data['form']['filter'] == 'filter_date': result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] elif data['form']['filter'] == 'filter_period': if data['form']['period_from'] == False or data['form']['period_to'] == False: raise osv.except_osv(_('Error'),_('Select Start period and End period')) period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])[0]['date_start'] period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])[0]['date_stop'] cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) result['periods'] = lambda x: x[0], cr.fetchall() return result |
new_qty = data['form']['return%s' % move.id] returned_qty = move.product_qty for rec in move.move_stock_return_history: returned_qty -= rec.product_qty if returned_qty != new_qty: set_invoice_state_to_none = False | def _create_returns(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) move_obj = pool.get('stock.move') pick_obj = pool.get('stock.picking') uom_obj = pool.get('product.uom') pick=pick_obj.browse(cr, uid, [data['id']])[0] new_picking=None date_cur=time.strftime('%Y-%m-%d %H:%M:%S') for move in move_obj.browse(cr, uid, data['form'].get('returns',[])): if not new_picking: if pick.type=='out': new_type='in' elif pick.type=='in': new_type='out' else: new_type='internal' new_picking=pick_obj.copy(cr, uid, pick.id, {'name':'%s (return)' % pick.name, 'move_lines':[], 'state':'draft', 'type':new_type, 'date':date_cur, 'invoice_state':data['form']['invoice_state'],}) new_location=move.location_dest_id.id new_move=move_obj.copy(cr, uid, move.id, { 'product_qty': data['form']['return%s' % move.id], 'product_uos_qty': uom_obj._compute_qty(cr, uid, move.product_uom.id, data['form']['return%s' % move.id], move.product_uos.id), 'picking_id':new_picking, 'state':'draft', 'location_id':new_location, 'location_dest_id':move.location_id.id, 'date':date_cur, 'date_planned':date_cur,}) move_obj.write(cr, uid, [move.id], {'move_stock_return_history':[(4,new_move)]}) if new_picking: wf_service = netsvc.LocalService("workflow") if new_picking: wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) pick_obj.force_assign(cr, uid, [new_picking], context) return new_picking |
|
'product_qty': data['form']['return%s' % move.id], | 'product_qty': new_qty, | def _create_returns(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) move_obj = pool.get('stock.move') pick_obj = pool.get('stock.picking') uom_obj = pool.get('product.uom') pick=pick_obj.browse(cr, uid, [data['id']])[0] new_picking=None date_cur=time.strftime('%Y-%m-%d %H:%M:%S') for move in move_obj.browse(cr, uid, data['form'].get('returns',[])): if not new_picking: if pick.type=='out': new_type='in' elif pick.type=='in': new_type='out' else: new_type='internal' new_picking=pick_obj.copy(cr, uid, pick.id, {'name':'%s (return)' % pick.name, 'move_lines':[], 'state':'draft', 'type':new_type, 'date':date_cur, 'invoice_state':data['form']['invoice_state'],}) new_location=move.location_dest_id.id new_move=move_obj.copy(cr, uid, move.id, { 'product_qty': data['form']['return%s' % move.id], 'product_uos_qty': uom_obj._compute_qty(cr, uid, move.product_uom.id, data['form']['return%s' % move.id], move.product_uos.id), 'picking_id':new_picking, 'state':'draft', 'location_id':new_location, 'location_dest_id':move.location_id.id, 'date':date_cur, 'date_planned':date_cur,}) move_obj.write(cr, uid, [move.id], {'move_stock_return_history':[(4,new_move)]}) if new_picking: wf_service = netsvc.LocalService("workflow") if new_picking: wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) pick_obj.force_assign(cr, uid, [new_picking], context) return new_picking |
data['form']['return%s' % move.id], move.product_uos.id), | new_qty, move.product_uos.id), | def _create_returns(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) move_obj = pool.get('stock.move') pick_obj = pool.get('stock.picking') uom_obj = pool.get('product.uom') pick=pick_obj.browse(cr, uid, [data['id']])[0] new_picking=None date_cur=time.strftime('%Y-%m-%d %H:%M:%S') for move in move_obj.browse(cr, uid, data['form'].get('returns',[])): if not new_picking: if pick.type=='out': new_type='in' elif pick.type=='in': new_type='out' else: new_type='internal' new_picking=pick_obj.copy(cr, uid, pick.id, {'name':'%s (return)' % pick.name, 'move_lines':[], 'state':'draft', 'type':new_type, 'date':date_cur, 'invoice_state':data['form']['invoice_state'],}) new_location=move.location_dest_id.id new_move=move_obj.copy(cr, uid, move.id, { 'product_qty': data['form']['return%s' % move.id], 'product_uos_qty': uom_obj._compute_qty(cr, uid, move.product_uom.id, data['form']['return%s' % move.id], move.product_uos.id), 'picking_id':new_picking, 'state':'draft', 'location_id':new_location, 'location_dest_id':move.location_id.id, 'date':date_cur, 'date_planned':date_cur,}) move_obj.write(cr, uid, [move.id], {'move_stock_return_history':[(4,new_move)]}) if new_picking: wf_service = netsvc.LocalService("workflow") if new_picking: wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) pick_obj.force_assign(cr, uid, [new_picking], context) return new_picking |
addr, port = self.request.getsockname() | if hasattr(self.request, 'getsockname'): addr, port = self.request.getsockname() | def setup(self): self.davpath = '/'+config.get_misc('webdav','vdir','webdav') addr, port = self.server.server_name, self.server.server_port server_proto = getattr(self.server,'proto', 'http').lower() try: addr, port = self.request.getsockname() except Exception, e: self.log_error("Cannot calculate own address:" , e) # Too early here to use self.headers self.baseuri = "%s://%s:%d/"% (server_proto, addr, port) self.IFACE_CLASS = openerp_dav_handler(self, self.verbose) |
self.log_error("Cannot calculate own address:" , e) | self.log_error("Cannot calculate own address: %s" , e) | def setup(self): self.davpath = '/'+config.get_misc('webdav','vdir','webdav') addr, port = self.server.server_name, self.server.server_port server_proto = getattr(self.server,'proto', 'http').lower() try: addr, port = self.request.getsockname() except Exception, e: self.log_error("Cannot calculate own address:" , e) # Too early here to use self.headers self.baseuri = "%s://%s:%d/"% (server_proto, addr, port) self.IFACE_CLASS = openerp_dav_handler(self, self.verbose) |
reference = obj_inv.reference or number or '' | reference = obj_inv.reference or '' | def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) |
ref = reference | if not reference: ref = self._convert_ref(cr, uid, number) else: ref = reference | def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) |
ttype = context.get('ttype', False) | ttype = context.get('type', False) | def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ Returns a list of ids based on search domain {args} @param cr: A database cursor @param user: ID of the user currently logged in @param args: list of conditions to be applied in search opertion @param offset: default from first record, you can start from nth record @param limit: number of records to be obtained as a result of search opertion @param order: ordering on any field(s) @param context: context arguments, like lang, time zone @param count: @return: Returns a list of ids based on search domain """ if not context: context = {} ttype = context.get('ttype', False) partner = context.get('partner_id', False) voucher = context.get('voucher', False) if voucher and not partner: raise osv.except_osv(_('Invalid Partner !'), _('Please select the partner !')) if ttype and ttype in ('receipt'): args += [('journal_id.type','in', ['sale', 'purchase_refund'])] elif ttype and ttype in ('payment'): args += [('journal_id.type','in', ['purchase', 'sale_refund'])] elif ttype and ttype in('sale', 'purchase'): raise osv.except_osv(_('Invalid action !'), _('You can not reconcile sales, purchase, or journal voucher with invoice !')) args += [('journal_id.type','=', 'do_not_allow_search')] res = super(account_move, self).search(cr, user, args, offset, limit, order, context, count) return res |
if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'): | if (m.product_id.cost_method == 'average'): | def view_init(self, cr, uid, fields_list, context=None): res = super(stock_partial_move, self).view_init(cr, uid, fields_list, context=context) move_obj = self.pool.get('stock.move') if not context: context={} for m in move_obj.browse(cr, uid, context.get('active_ids', [])): if m.state in ('done', 'cancel'): raise osv.except_osv(_('Invalid action !'), _('Cannot deliver products which are already delivered !')) |
if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'): | if m.product_id.cost_method == 'average': | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): result = super(stock_partial_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) move_obj = self.pool.get('stock.move') move_ids = context.get('active_ids', False) move_ids = move_obj.search(cr, uid, [('id','in',move_ids)]) _moves_arch_lst = """<form string="Deliver Products"> <separator colspan="4" string="Delivery Information"/> <field name="date" colspan="2"/> <separator colspan="4" string="Move Detail"/> """ _moves_fields = result['fields'] if move_ids and view_type in ['form']: for m in move_obj.browse(cr, uid, move_ids, context): if m.state in ('done', 'cancel'): continue _moves_fields.update({ 'move%s_product_id'%(m.id) : { 'string': _('Product'), 'type' : 'many2one', 'relation': 'product.product', 'required' : True, 'readonly' : True, }, 'move%s_product_qty'%(m.id) : { 'string': _('Quantity'), 'type' : 'float', 'required': True, }, 'move%s_product_uom'%(m.id) : { 'string': _('Product UOM'), 'type' : 'many2one', 'relation': 'product.uom', 'required' : True, 'readonly' : True, }, 'move%s_prodlot_id'%(m.id): { 'string': _('Production Lot'), 'type': 'many2one', 'relation': 'stock.production.lot', } }) |
if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'): | if m.product_id.cost_method == 'average': | def do_partial(self, cr, uid, ids, context): """ Makes partial moves and pickings done. @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. """ |
def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): | def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): | def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids |
result = [] | def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids |
|
ids = result return ids | if isinstance(select, (str, int, long)): return result and result[0] or False return result | def get_recurrent_ids(self, cr, uid, ids, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") result = [] count = 0 for data in cr.dictfetchall(): start_date = base_start_date and datetime.datetime.strptime(base_start_date, "%Y-%m-%d") or False until_date = base_until_date and datetime.datetime.strptime(base_until_date, "%Y-%m-%d") or False if count > limit: break event_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") if start_date and start_date <= event_date: start_date = event_date if not data['rrule']: if start_date and event_date < start_date: continue if until_date and event_date > until_date: continue idval = common.real_id2caldav_id(data['id'], data['date']) result.append(idval) count += 1 else: exdate = data['exdate'] and data['exdate'].split(',') or [] event_obj = self.pool.get('basic.calendar.event') rrule_str = data['rrule'] new_rrule_str = [] rrule_until_date = False is_until = False for rule in rrule_str.split(';'): name, value = rule.split('=') if name == "UNTIL": is_until = True value = parser.parse(value) rrule_until_date = parser.parse(value.strftime("%Y-%m-%d")) if until_date and until_date >= rrule_until_date: until_date = rrule_until_date if until_date: value = until_date.strftime("%Y%m%d%H%M%S") new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) if not is_until and until_date: value = until_date.strftime("%Y%m%d%H%M%S") name = "UNTIL" new_rule = '%s=%s' % (name, value) new_rrule_str.append(new_rule) new_rrule_str = ';'.join(new_rrule_str) start_date = datetime.datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") rdates = event_obj.get_recurrent_dates(str(new_rrule_str), exdate, start_date) for rdate in rdates: r_date = datetime.datetime.strptime(rdate, "%Y-%m-%d %H:%M:%S") if start_date and r_date < start_date: continue if until_date and r_date > until_date: continue idval = common.real_id2caldav_id(data['id'], rdate) result.append(idval) count += 1 ids = result return ids |
if not isinstance(res,list): res= [res] | def search(self, cr, uid, args, offset=0, limit=100, order=None, context=None, count=False): args_without_date = [] start_date = False until_date = False for arg in args: if arg[0] not in ('date', unicode('date')): args_without_date.append(arg) else: if arg[1] in ('>', '>='): start_date = arg[2] elif arg[1] in ('<', '<='): until_date = arg[2] res = super(crm_meeting, self).search(cr, uid, args_without_date, offset, limit, order, context, count) if not isinstance(res,list): res= [res] return self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit) |
|
'voucher_type':inv.type, | 'type' : inv.type, | def action_move_line_create(self, cr, uid, ids, *args): for inv in self.browse(cr, uid, ids): if inv.move_id: continue company_currency = inv.company_id.currency_id.id |
pricelist_version_ids = product_pricelist_version_obj.search(cr, uid, []) | pricelist_version_ids = self.pool.get('product.pricelist').search(cr, uid, []) | def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst |
obj = self.pool.get(template.object_name.model) | def unlink_action(self, cr, uid, ids, context): for template in self.browse(cr, uid, ids, context): obj = self.pool.get(template.object_name.model) try: if template.ref_ir_act_window: self.pool.get('ir.actions.act_window').unlink(cr, uid, template.ref_ir_act_window.id, context) if template.ref_ir_value: self.pool.get('ir.values').unlink(cr, uid, template.ref_ir_value.id, context) except: raise osv.except_osv(_("Warning"), _("Deletion of Record failed")) |
|
def _sheet_search(self, cursor, user, obj, name, args, context): | def _sheet_search(self, cursor, user, obj, name, args, context=None): | def _sheet_search(self, cursor, user, obj, name, args, context): if not len(args): return [] sheet_obj = self.pool.get('hr_timesheet_sheet.sheet') |
def _sheet_search(self, cursor, user, obj, name, args, context={}): | def _sheet_search(self, cursor, user, obj, name, args, context=None): | def _sheet_search(self, cursor, user, obj, name, args, context={}): if not len(args): return [] sheet_obj = self.pool.get('hr_timesheet_sheet.sheet') |
AND l2.id IN %%s AND """ + \ | AND l2.id IN %s AND """ + \ | def _balance(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} c = context.copy() c['initital_bal'] = True sql = """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2 WHERE l2.account_id = l1.account_id AND l1.id <= l2.id AND l2.id IN %%s AND """ + \ self._query_get(cr, uid, obj='l1', context=c) + \ " GROUP BY l2.id" |
def _inherit_apply(src, inherit): | def raise_view_error(error_msg, child_view_id): view, child_view = self.pool.get('ir.ui.view').browse(cr, user, [view_id, child_view_id], context) raise AttributeError(("View definition error for inherited view '%(xml_id)s' on '%(model)s' model: " + error_msg) % { 'xml_id': child_view.xml_id, 'parent_xml_id': view.xml_id, 'model': self._name, }) def _inherit_apply(src, inherit, inherit_id=None): | def _inherit_apply(src, inherit): def _find(node, node2): if node2.tag == 'xpath': res = node.xpath(node2.get('expr')) if res: return res[0] else: return None else: for n in node.getiterator(node2.tag): res = True if node2.tag == 'field': # only compare field names, a field can be only once in a given view # at a given level (and for multilevel expressions, we should use xpath # inheritance spec anyway) if node2.get('name') == n.get('name'): return n else: continue for attr in node2.attrib: if attr == 'position': continue if n.get(attr): if n.get(attr) == node2.get(attr): continue res = False if res: return n return None |
raise AttributeError(_('Unknown position in inherited view %s !') % pos) | raise_view_error("Invalid position value: '%s'" % pos, inherit_id) | def _find(node, node2): if node2.tag == 'xpath': res = node.xpath(node2.get('expr')) if res: return res[0] else: return None else: for n in node.getiterator(node2.tag): res = True if node2.tag == 'field': # only compare field names, a field can be only once in a given view # at a given level (and for multilevel expressions, we should use xpath # inheritance spec anyway) if node2.get('name') == n.get('name'): return n else: continue for attr in node2.attrib: if attr == 'position': continue if n.get(attr): if n.get(attr) == node2.get(attr): continue res = False if res: return n return None |
raise AttributeError(_("Couldn't find tag '%s' in parent view !") % tag) | raise_view_error("Element '%s' not found in parent view '%%(parent_xml_id)s'" % tag, inherit_id) | def _find(node, node2): if node2.tag == 'xpath': res = node.xpath(node2.get('expr')) if res: return res[0] else: return None else: for n in node.getiterator(node2.tag): res = True if node2.tag == 'field': # only compare field names, a field can be only once in a given view # at a given level (and for multilevel expressions, we should use xpath # inheritance spec anyway) if node2.get('name') == n.get('name'): return n else: continue for attr in node2.attrib: if attr == 'position': continue if n.get(attr): if n.get(attr) == node2.get(attr): continue res = False if res: return n return None |
result = _inherit_apply(result, inherit) | result = _inherit_apply(result, inherit, id) | def _inherit_apply_rec(result, inherit_id): # get all views which inherit from (ie modify) this view cr.execute('select arch,id from ir_ui_view where inherit_id=%s and model=%s order by priority', (inherit_id, self._name)) sql_inherit = cr.fetchall() for (inherit, id) in sql_inherit: result = _inherit_apply(result, inherit) result = _inherit_apply_rec(result, id) return result |
res_id = False | def _process_email(self, cr, uid, server, message, context={}): history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) msg = {} if not message_id: return False fields = msg_txt.keys() msg['id'] = message_id msg['message-id'] = message_id if 'Subject' in fields: msg['subject'] = msg_txt.get('Subject') if 'Content-Type' in fields: msg['content-type'] = msg_txt.get('Content-Type') if 'From' in fields: msg['from'] = msg_txt.get('From') if 'Delivered-To' in fields: msg['to'] = msg_txt.get('Delivered-To') if 'Cc' in fields: msg['cc'] = msg_txt.get('Cc') if 'Reply-To' in fields: msg['reply'] = msg_txt.get('Reply-To') if 'Date' in fields: msg['date'] = msg_txt.get('Date') if 'Content-Transfer-Encoding' in fields: msg['encoding'] = msg_txt.get('Content-Transfer-Encoding') if 'References' in fields: msg['references'] = msg_txt.get('References') |
|
model_pool.message_update(cr, uid, [history.res_id], vals, msg, context=context) | if hasattr(model_pool, 'message_update'): model_pool.message_update(cr, uid, [history.res_id], vals, msg, context=context) else: logger.notifyChannel('imap', netsvc.LOG_WARNING, 'method def message_update is not define in model %s' % (model_pool._name)) return False | def _process_email(self, cr, uid, server, message, context={}): history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) msg = {} if not message_id: return False fields = msg_txt.keys() msg['id'] = message_id msg['message-id'] = message_id if 'Subject' in fields: msg['subject'] = msg_txt.get('Subject') if 'Content-Type' in fields: msg['content-type'] = msg_txt.get('Content-Type') if 'From' in fields: msg['from'] = msg_txt.get('From') if 'Delivered-To' in fields: msg['to'] = msg_txt.get('Delivered-To') if 'Cc' in fields: msg['cc'] = msg_txt.get('Cc') if 'Reply-To' in fields: msg['reply'] = msg_txt.get('Reply-To') if 'Date' in fields: msg['date'] = msg_txt.get('Date') if 'Content-Transfer-Encoding' in fields: msg['encoding'] = msg_txt.get('Content-Transfer-Encoding') if 'References' in fields: msg['references'] = msg_txt.get('References') |
res_id = model_pool.message_new(cr, uid, msg, context) | if hasattr(model_pool, 'message_new'): res_id = model_pool.message_new(cr, uid, msg, context) else: logger.notifyChannel('imap', netsvc.LOG_WARNING, 'method def message_new is not define in model %s' % (model_pool._name)) return False | def _process_email(self, cr, uid, server, message, context={}): history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) msg = {} if not message_id: return False fields = msg_txt.keys() msg['id'] = message_id msg['message-id'] = message_id if 'Subject' in fields: msg['subject'] = msg_txt.get('Subject') if 'Content-Type' in fields: msg['content-type'] = msg_txt.get('Content-Type') if 'From' in fields: msg['from'] = msg_txt.get('From') if 'Delivered-To' in fields: msg['to'] = msg_txt.get('Delivered-To') if 'Cc' in fields: msg['cc'] = msg_txt.get('Cc') if 'Reply-To' in fields: msg['reply'] = msg_txt.get('Reply-To') if 'Date' in fields: msg['date'] = msg_txt.get('Date') if 'Content-Transfer-Encoding' in fields: msg['encoding'] = msg_txt.get('Content-Transfer-Encoding') if 'References' in fields: msg['references'] = msg_txt.get('References') |
self._process_email(cr, uid, server, data[0][1], context) imap_server.store(num, '+FLAGS', '\\Seen') count += 1 logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (count, server.name)) | if self._process_email(cr, uid, server, data[0][1], context): imap_server.store(num, '+FLAGS', '\\Seen') count += 1 logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name)) | def fetch_mail(self, cr, uid, ids, context={}): fp = os.popen('ping www.google.com -c 1 -w 5',"r") if not fp.read(): logger.notifyChannel('imap', netsvc.LOG_WARNING, 'No address associated with hostname !') |
'period': fields.selection([('month','Monthly'), ('3months','3 Monthly')], 'Periods', required=True), 'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Your Bank and Cash Accounts',required=True), | 'period': fields.selection([('month','Monthly'), ('3months','3 Monthly')], 'Periods', required=True), 'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Your Bank and Cash Accounts'), | def _get_charts(self, cr, uid, context=None): modules = self.pool.get('ir.module.module') ids = modules.search(cr, uid, [('category_id','=','Account Charts')]) charts = list( sorted(((m.name, m.shortdesc) for m in modules.browse(cr, uid, ids)), key=itemgetter(1))) charts.insert(0,('configurable','Generic Chart Of Account')) return charts |
'date_start': time.strftime('%Y-01-01'), 'date_stop': time.strftime('%Y-12-31'), 'period': lambda *a: 'month', 'sale_tax': lambda *a: 0.0, 'purchase_tax': lambda *a: 0.0, | 'date_start': lambda *a: time.strftime('%Y-01-01'), 'date_stop': lambda *a: time.strftime('%Y-12-31'), 'period': 'month', 'sale_tax': 0.0, 'purchase_tax': 0.0, | def _get_default_charts(self, cr, uid, context=None): module_name = False company_id = self._default_company(cr, uid, context=context) company = self.pool.get('res.company').browse(cr, uid, company_id) address_id = self.pool.get('res.partner').address_get(cr, uid, [company.partner_id.id]) if address_id['default']: address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default']) code = address.country_id.code module_name = (code and 'l10n_' + code.lower()) or False if module_name: module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)]) if module_id: return module_name return 'configurable' |
'bank_account_id': fields.many2one('wizard.multi.charts.accounts', 'Bank Account', required=True), | 'bank_account_id': fields.many2one('account.installer', 'Bank Account', required=True), | def modules_to_install(self, cr, uid, ids, context=None): modules = super(account_installer, self).modules_to_install( cr, uid, ids, context=context) chart = self.read(cr, uid, ids, ['charts'], context=context)[0]['charts'] self.logger.notifyChannel( 'installer', netsvc.LOG_DEBUG, 'Installing chart of accounts %s'%chart) return modules | set([chart]) |
s.create_date as date, to_char(s.date_from,'YYYY/mm/dd') as date_from, to_char(s.date_to,'YYYY/mm/dd') as date_to, | date_trunc('seconds',s.create_date) as date, date_trunc('day',s.date_from) as date_from, date_trunc('day',s.date_to) as date_to, | def init(self, cr): tools.drop_view_if_exists(cr, 'hr_holidays_report') cr.execute(""" create or replace view hr_holidays_report as ( select min(s.id) as id, s.create_date as date, to_char(s.date_from,'YYYY/mm/dd') as date_from, to_char(s.date_to,'YYYY/mm/dd') as date_to, s.number_of_days_temp, s.employee_id, s.user_id as user_id, to_char(s.create_date, 'YYYY') as year, to_char(s.create_date, 'MM') as month, s.state from hr_holidays s group by s.create_date,s.state,s.date_from,s.date_to, s.number_of_days_temp,s.employee_id,s.user_id ) """) |
self.cr.execute('SELECT period_id, journal_id ' 'FROM account_journal_period ' 'WHERE id IN %s', (tuple(ids),)) | if (data['model'] == 'account.journal.period'): self.cr.execute('SELECT period_id, journal_id ' 'FROM account_journal_period ' 'WHERE id IN %s', (tuple(ids),)) else: self.cr.execute('SELECT period_id, journal_id ' 'FROM account_journal_period ') | def set_context(self, objects, data, ids, report_type=None): super(journal_print, self).set_context(objects, data, ids, report_type) self.cr.execute('SELECT period_id, journal_id ' 'FROM account_journal_period ' 'WHERE id IN %s', (tuple(ids),)) res = self.cr.fetchall() self.period_ids, self.journal_ids = zip(*res) |
def _compute_total(self, cr, uid, ids, name, args, context=None): position_pool = self.pool.get('account.fiscal.position') voucher_pool = self.pool.get('account.voucher') voucher_line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') tax_pool = self.pool.get('account.tax') res = {} for voucher in self.browse(cr, uid, ids): total = 0.0 for line in voucher.payment_ids: total += line.amount res[voucher.id] = total + voucher.tax_amount return res | def _compute_total(self, cr, uid, ids, name, args, context=None): position_pool = self.pool.get('account.fiscal.position') voucher_pool = self.pool.get('account.voucher') voucher_line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') tax_pool = self.pool.get('account.tax') res = {} for voucher in self.browse(cr, uid, ids): total = 0.0 for line in voucher.payment_ids: total += line.amount |
|
ids = move_line_pool.search(cr, uid, [('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context) | search_type = 'credit' account_type = False if ttype == 'receipt': search_type = 'debit' account_type = 'receivable' elif ttype == 'payment': search_type = 'credit' account_type = 'payable' ids = move_line_pool.search(cr, uid, [('account_id.type','=', account_type), ('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context) total = 0.0 | def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, journal_id=False, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) if journal_id: context.update({ 'journal_id':journal_id, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default |
'type':'dr', | def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, journal_id=False, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) if journal_id: context.update({ 'journal_id':journal_id, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default |
|
'type':'cr', | def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, journal_id=False, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) if journal_id: context.update({ 'journal_id':journal_id, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default |
|
res = {'payment_ids':res, 'account_id':account_id} | res = { 'payment_ids':res, 'account_id':account_id, 'amount':total } | def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, journal_id=False, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) if journal_id: context.update({ 'journal_id':journal_id, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default |
if inv.type == 'sale': | if inv.type in ('sale', 'receipt'): | def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue |
if inv.type in ('sale'): | if inv.type in ('sale', 'receipt'): | def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue |
'date_original': fields.date('Date', readonly="1"), 'date_due': fields.date('Due Date', readonly="1"), | 'date_original': fields.related('move_line_id','date', type='date', relation='account.move.line', string='Date', readonly="1"), 'date_due': fields.related('move_line_id','date_maturity', type='date', relation='account.move.line', string='Due Date', readonly="1"), | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Returns views and fields for current model where view will depend on {view_type}. @param cr: A database cursor @param user: ID of the user currently logged in @param view_id: list of fields, which required to read signatures @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx) @param context: context arguments, like lang, time zone @param toolbar: contains a list of reports, wizards, and links related to current model @return: Returns a dict that contains definition for fields, views, and toolbars """ data_pool = self.pool.get('ir.model.data') journal_pool = self.pool.get('account.journal') voucher_type = { 'sale':'view_sale_receipt_form', 'purchase':'view_purchase_receipt_form', 'payment':'view_vendor_payment_form', 'receipt':'view_vendor_receipt_form' } |
'amount_unreconciled': fields.float('Open Balance', readonly="1"), | 'amount_unreconciled': fields.related('move_line_id','balance', type='float', relation='account.move.line', string='Open Balance', readonly="1"), | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Returns views and fields for current model where view will depend on {view_type}. @param cr: A database cursor @param user: ID of the user currently logged in @param view_id: list of fields, which required to read signatures @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx) @param context: context arguments, like lang, time zone @param toolbar: contains a list of reports, wizards, and links related to current model @return: Returns a dict that contains definition for fields, views, and toolbars """ data_pool = self.pool.get('ir.model.data') journal_pool = self.pool.get('account.journal') voucher_type = { 'sale':'view_sale_receipt_form', 'purchase':'view_purchase_receipt_form', 'payment':'view_vendor_payment_form', 'receipt':'view_vendor_receipt_form' } |
'type': lambda *a: 'cr' | 'type': lambda *a: 'cr', 'name': lambda *a: 'Payment' | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Returns views and fields for current model where view will depend on {view_type}. @param cr: A database cursor @param user: ID of the user currently logged in @param view_id: list of fields, which required to read signatures @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx) @param context: context arguments, like lang, time zone @param toolbar: contains a list of reports, wizards, and links related to current model @return: Returns a dict that contains definition for fields, views, and toolbars """ data_pool = self.pool.get('ir.model.data') journal_pool = self.pool.get('account.journal') voucher_type = { 'sale':'view_sale_receipt_form', 'purchase':'view_purchase_receipt_form', 'payment':'view_vendor_payment_form', 'receipt':'view_vendor_receipt_form' } |
'name': case.partner_name or case.name, | 'name': case.partner_contact or case.name, | def _create_partner(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) case_obj = pool.get('crm.phonecall') partner_obj = pool.get('res.partner') contact_obj = pool.get('res.partner.address') partner_ids = [] partner_id = False contact_id = False for case in case_obj.browse(cr, uid, data['ids']): if data['form']['action'] == 'create': partner_id = partner_obj.create(cr, uid, { 'name': case.partner_name or case.name, 'user_id': case.user_id.id, 'comment': case.description, }) contact_id = contact_obj.create(cr, uid, { 'partner_id': partner_id, 'name': case.name, 'phone': case.phone, 'mobile': case.mobile, 'email': case.email_from }) |
'phone': case.phone, 'mobile': case.mobile, | 'phone': case.partner_phone, 'mobile': case.partner_mobile, | def _create_partner(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) case_obj = pool.get('crm.phonecall') partner_obj = pool.get('res.partner') contact_obj = pool.get('res.partner.address') partner_ids = [] partner_id = False contact_id = False for case in case_obj.browse(cr, uid, data['ids']): if data['form']['action'] == 'create': partner_id = partner_obj.create(cr, uid, { 'name': case.partner_name or case.name, 'user_id': case.user_id.id, 'comment': case.description, }) contact_id = contact_obj.create(cr, uid, { 'partner_id': partner_id, 'name': case.name, 'phone': case.phone, 'mobile': case.mobile, 'email': case.email_from }) |
inv_line['account_id'] = acc | def action_invoice(self, cr, uid, ids, context=None): """Create a invoice of order """ inv_ref = self.pool.get('account.invoice') inv_line_ref = self.pool.get('account.invoice.line') product_obj = self.pool.get('product.product') inv_ids = [] |
|
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): | def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): job_ids = [] | def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): for arg in args: if arg[0]=='address_id': self._order = 'sequence_partner' if arg[0]=='contact_id': self._order = 'sequence_contact' return super(res_partner_job,self).search(cr, user, args, offset, limit, order, context, count) |
if arg[0]=='contact_id': | elif arg[0] == 'contact_id': | def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): for arg in args: if arg[0]=='address_id': self._order = 'sequence_partner' if arg[0]=='contact_id': self._order = 'sequence_contact' return super(res_partner_job,self).search(cr, user, args, offset, limit, order, context, count) |
return super(res_partner_job,self).search(cr, user, args, offset, limit, order, context, count) | elif arg[0] == 'name': contact_obj = self.pool.get('res.partner.contact') search_arg = ['|', ('first_name', 'ilike', arg[2]), ('name', 'ilike', arg[2])] contact_ids = contact_obj.search(cr, user, search_arg, offset=offset, limit=limit, order=order, context=context, count=count) contacts = contact_obj.browse(cr, user, contact_ids, context=context) for contact in contacts: job_ids.extend([item.id for item in contact.job_ids]) res = super(res_partner_job,self).search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count) if job_ids: res = list(set(res + job_ids)) return res | def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): for arg in args: if arg[0]=='address_id': self._order = 'sequence_partner' if arg[0]=='contact_id': self._order = 'sequence_contact' return super(res_partner_job,self).search(cr, user, args, offset, limit, order, context, count) |
class many2many_domain(fields.many2many): def set(self, cr, obj, id, name, values, user=None, context=None): return super(many2many_domain, self).set(cr, obj, id, name, values, user=user, context=context) def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {} move_obj = obj.pool.get('stock.move') res = {} for i in ids: res[i] = [] valid_move_ids = move_obj.search(cr, user, self._domain) if valid_move_ids: cr.execute("SELECT production_id, move_id from mrp_production_move_ids where production_id in %s and move_id in %s", [tuple(ids), tuple(valid_move_ids)]) related_move_map = cr.fetchall() related_move_dict = dict((k, list(set([v[1] for v in itr]))) for k, itr in groupby(related_move_map, itemgetter(0))) res.update(related_move_dict) return res class one2many_domain(fields.one2many): def set(self, cr, obj, id, field, values, user=None, context=None): return super(one2many_domain, self).set(cr, obj, id, field, values, user=user, context=context) def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {} move_obj = obj.pool.get('stock.move') res = {} for i in ids: res[i] = [] move_ids = move_obj.search(cr, user, self._domain+[('production_id', 'in', tuple(ids))], context=context) related_move_dict = dict([(o.production_id.id, [o.id]) for o in move_obj.browse(cr, user, move_ids, context=context)]) res.update(related_move_dict) return res | def rounding(f, r): if not r: return f return round(f / r) * r |
|
'move_lines': many2many_domain('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Products to Consume', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}), 'move_lines2': many2many_domain('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Consumed Products', domain=[('state','in', ('done', 'cancel'))]), 'move_created_ids': one2many_domain('stock.move', 'production_id', 'Moves Created', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}), 'move_created_ids2': one2many_domain('stock.move', 'production_id', 'Moves Created', domain=[('state','in', ('done', 'cancel'))]), | 'move_lines': fields.many2many('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Products to Consume', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}), 'move_lines2': fields.many2many('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Consumed Products', domain=[('state','in', ('done', 'cancel'))]), 'move_created_ids': fields.one2many('stock.move', 'production_id', 'Moves Created', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}), 'move_created_ids2': fields.one2many('stock.move', 'production_id', 'Moves Created', domain=[('state','in', ('done', 'cancel'))]), | def _production_date(self, cr, uid, ids, prop, unknow_none, context={}): """ Finds production planned date. @param prop: Name of field. @param unknow_none: @return: Dictionary of values. """ result = {} for prod in self.browse(cr, uid, ids, context=context): result[prod.id] = prod.date_planned[:10] return result |
(_check_dates, 'Error! Task start-date must be lower then task end-date.', ['date_start', 'date_end']) | (_check_dates, 'Error! Task start-date must be lower then task end-date.', ['date_start', 'date_end']), (_check_recursion, _('Error ! You cannot create recursive tasks.'), ['parent_ids']) | def _is_template(self, cr, uid, ids, field_name, arg, context=None): res = {} for task in self.browse(cr, uid, ids, context=context): res[task.id] = True if task.project_id: if task.project_id.active == False or task.project_id.state == 'template': res[task.id] = False return res |
except Exception: | except Exception, e: | def get_childs(self, uri, filters=None): """ return the child objects as self.baseuris for the given URI """ self.parent.log_message('get childs: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri, allow_last=True) |
tt = timebox_obj.browse(cr, uid, timebox_obj.search(cr,uid,[])) | tt = timebox_obj.browse(cr, uid, timebox_obj.search(cr,uid,[]), context=context) | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(project_task,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) search_extended = False timebox_obj = self.pool.get('project.gtd.timebox') access_pool = self.pool.get('ir.model.access') if (res['type'] == 'search') and access_pool.check_groups(cr, uid, "project_gtd.group_project_getting"): tt = timebox_obj.browse(cr, uid, timebox_obj.search(cr,uid,[])) search_extended ='''<newline/><group col="%d" expand="%d" string="%s">''' % (len(tt)+7,1,_('Getting Things Done')) search_extended += '''<filter domain="[('timebox_id','=', False)]" context="{'set_editable':True,'set_visible':True,'gtd_visible':True,'user_invisible':True}" icon="gtk-new" help="Undefined Timebox" string="%s"/>''' % (_('Inbox'),) search_extended += '''<filter context="{'set_editable':True,'set_visible':True,'gtd_visible':True,'user_invisible':True}" icon="gtk-new" help="Getting things done" string="%s"/>''' % (_('GTD'),) search_extended += '''<separator orientation="vertical"/>''' for time in tt: if time.icon: icon = time.icon else : icon="" search_extended += '''<filter domain="[('timebox_id','=', ''' + str(time.id) + ''')]" icon="''' + icon + '''" string="''' + time.name + '''" context="{'gtd_visible':True, 'user_invisible': True}"/>''' search_extended += ''' <separator orientation="vertical"/> <field name="context_id" select="1" widget="selection"/> </group> </search> ''' if search_extended: res['arch'] = unicode(res['arch'], 'utf8').replace('</search>', search_extended) attrs_sel = self.pool.get('project.gtd.context').name_search(cr, uid, '', [], context=context) context_id_info = self.pool.get('project.task').fields_get(cr, uid, ['context_id']) context_id_info['context_id']['selection'] = attrs_sel res['fields'].update(context_id_info) return res |
context_id_info = self.pool.get('project.task').fields_get(cr, uid, ['context_id']) | context_id_info = self.pool.get('project.task').fields_get(cr, uid, ['context_id'], context=context) | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(project_task,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) search_extended = False timebox_obj = self.pool.get('project.gtd.timebox') access_pool = self.pool.get('ir.model.access') if (res['type'] == 'search') and access_pool.check_groups(cr, uid, "project_gtd.group_project_getting"): tt = timebox_obj.browse(cr, uid, timebox_obj.search(cr,uid,[])) search_extended ='''<newline/><group col="%d" expand="%d" string="%s">''' % (len(tt)+7,1,_('Getting Things Done')) search_extended += '''<filter domain="[('timebox_id','=', False)]" context="{'set_editable':True,'set_visible':True,'gtd_visible':True,'user_invisible':True}" icon="gtk-new" help="Undefined Timebox" string="%s"/>''' % (_('Inbox'),) search_extended += '''<filter context="{'set_editable':True,'set_visible':True,'gtd_visible':True,'user_invisible':True}" icon="gtk-new" help="Getting things done" string="%s"/>''' % (_('GTD'),) search_extended += '''<separator orientation="vertical"/>''' for time in tt: if time.icon: icon = time.icon else : icon="" search_extended += '''<filter domain="[('timebox_id','=', ''' + str(time.id) + ''')]" icon="''' + icon + '''" string="''' + time.name + '''" context="{'gtd_visible':True, 'user_invisible': True}"/>''' search_extended += ''' <separator orientation="vertical"/> <field name="context_id" select="1" widget="selection"/> </group> </search> ''' if search_extended: res['arch'] = unicode(res['arch'], 'utf8').replace('</search>', search_extended) attrs_sel = self.pool.get('project.gtd.context').name_search(cr, uid, '', [], context=context) context_id_info = self.pool.get('project.task').fields_get(cr, uid, ['context_id']) context_id_info['context_id']['selection'] = attrs_sel res['fields'].update(context_id_info) return res |
report_sxw.report_sxw('report.account.journal.period.print.wiz', 'account.journal.period', 'addons/account/report/wizard_account_journal.rml', parser=journal_print, header=False) | def _sum_credit(self, period_id, journal_id): self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 |
|
id = super(Wiki, self).create(cr, uid, vals, context) | id = super(wiki_wiki2, self).create(cr, uid, vals, context) | def create(self, cr, uid, vals, context=None): |
result = super(Wiki, self).write(cr, uid, ids, vals, context) | result = super(wiki_wiki2, self).write(cr, uid, ids, vals, context) | def write(self, cr, uid, ids, vals, context=None): |
self.query = obj_move._query_get(cr, uid, obj='l', context=data['form'].get('used_context',{})) self.init_query = obj_move._query_get(cr, uid, obj='l', context=data['form'].get('used_context_initial_bal', {})) | self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context',{})) self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context_initial_bal', {})) | def set_context(self, objects, data, ids, report_type=None): new_ids = ids obj_move = self.pool.get('account.move.line') self.sortby = data['form'].get('sortby', 'sort_date') self.query = obj_move._query_get(cr, uid, obj='l', context=data['form'].get('used_context',{})) self.init_query = obj_move._query_get(cr, uid, obj='l', context=data['form'].get('used_context_initial_bal', {})) self.init_balance = data['form']['initial_balance'] self.display_account = data['form']['display_account'] self.target_move = data['form'].get('target_move', 'all') ctx = self.context.copy() ctx['fiscalyear'] = data['form']['fiscalyear_id'] if data['form']['filter'] == 'filter_period': ctx['periods'] = data['form']['periods'] elif data['form']['filter'] == 'filter_date': ctx['date_from'] = data['form']['date_from'] ctx['date_to'] = data['form']['date_to'] ctx['state'] = data['form']['target_move'] self.context.update(ctx) if (data['model'] == 'ir.ui.menu'): new_ids = [data['form']['chart_account_id']] objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) return super(general_ledger, self).set_context(objects, data, new_ids, report_type=report_type) |
AND s.user_id = e.user_id) \ | AND s.user_id = r.user_id) \ | def _sheet(self, cursor, user, ids, name, args, context): sheet_obj = self.pool.get('hr_timesheet_sheet.sheet') cursor.execute("SELECT a.id, COALESCE(MAX(s.id), 0) \ FROM hr_timesheet_sheet_sheet s \ LEFT JOIN (hr_attendance a \ LEFT JOIN hr_employee e \ ON (a.employee_id = e.id)) \ ON (s.date_to >= date_trunc('day',a.name) \ AND s.date_from <= a.name \ AND s.user_id = e.user_id) \ WHERE a.id in (" + ",".join([str(x) for x in ids]) + ") \ GROUP BY a.id") res = dict(cursor.fetchall()) sheet_names = {} for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(), context=context): sheet_names[sheet_id] = name for line_id in {}.fromkeys(ids): sheet_id = res.get(line_id, False) if sheet_id: res[line_id] = (sheet_id, sheet_names[sheet_id]) else: res[line_id] = False return res |
'sequence' : lambda * a: 1, | def _get_in_visible_answer_type(self,cr, uid, context={}): return context.get('in_visible_answer_type', False) |
|
from account_period where date('%s') | from account_period where date(%s) | def compute_refund(self, cr, uid, ids, mode, context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: the account invoice refund’s ID or list of IDs |
(form['date'], self.pool.get('res.users').browse(cr, uid, uid,context=context).company_id.id,)) | (date, self.pool.get('res.users').browse(cr, uid, uid,context=context).company_id.id,)) | def compute_refund(self, cr, uid, ids, mode, context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: the account invoice refund’s ID or list of IDs |
limit 1 """, (form['date'],)) | limit 1 """, (date,)) | def compute_refund(self, cr, uid, ids, mode, context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: the account invoice refund’s ID or list of IDs |
'name': ((type1=='move_history_ids') and 'Upstream Traceability') or 'Downstream Traceability', | 'name': ((type1=='move_history_ids') and 'Donwstream Traceability') or 'Upstream Traceability', | def action_traceability(self, cr, uid, ids, context={}): """ It traces the information of a product @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: A dictionary of values """ |
if line.state == 'exception': for pick in order.picking_ids: for moves in pick.move_lines: if moves.state == 'cancel': move_obj.write(cr, uid, [move_id], {'product_qty': moves.product_qty}) proc_obj.write(cr, uid, [proc_id], {'product_qty': moves.product_qty, 'product_uos_qty': moves.product_qty}) | def action_ship_create(self, cr, uid, ids, *args): wf_service = netsvc.LocalService("workflow") picking_id = False company = self.pool.get('res.users').browse(cr, uid, uid).company_id for order in self.browse(cr, uid, ids, context={}): proc_ids = [] output_id = order.shop_id.warehouse_id.lot_output_id.id picking_id = False for line in order.order_line: proc_id = False date_planned = datetime.now() + relativedelta(days=line.delay or 0.0) date_planned = (date_planned - timedelta(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S') |
|
val['shipped'] = False | def action_ship_create(self, cr, uid, ids, *args): wf_service = netsvc.LocalService("workflow") picking_id = False company = self.pool.get('res.users').browse(cr, uid, uid).company_id for order in self.browse(cr, uid, ids, context={}): proc_ids = [] output_id = order.shop_id.warehouse_id.lot_output_id.id picking_id = False for line in order.order_line: proc_id = False date_planned = datetime.now() + relativedelta(days=line.delay or 0.0) date_planned = (date_planned - timedelta(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S') |
|
if len(obj.message_ids) >= action.trg_max_history: | history_ids = filter(lambda x: x.history, obj.message_ids) if len(history_ids) <= action.trg_max_history: | def do_check(self, cr, uid, action, obj, context={}): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values""" ok = super(base_action_rule, self).do_check(cr, uid, action, obj, context=context) |
vevent.add(field).value = str(data[map_field]) | vevent.add(field).value = str(data[map_field].encode('utf8')) | def create_ics(self, cr, uid, datas, name, ical, context=None): if not datas: model = context.get('model', None) war_str = "No data available" + (model and " for " + model) or "" raise osv.except_osv(_('Warning !'), _(war_str)) for data in datas: vevent = ical.add(name) for field in self.__attribute__.keys(): map_field = self.ical_get(field, 'field') map_type = self.ical_get(field, 'type') if map_field in data.keys(): if field == 'uid': model = context.get('model', None) if not model: continue uidval = openobjectid2uid(cr, data[map_field], model) model_obj = self.pool.get(model) r_ids = [] if model_obj._columns.get('recurrent_uid', None): cr.execute('select id from %s where recurrent_uid=%s' % (model_obj._table, data[map_field])) r_ids = map(lambda x: x[0], cr.fetchall()) if r_ids: rdata = self.pool.get(model).read(cr, uid, r_ids) rcal = self.export_cal(cr, uid, rdata, context=context) for revents in rcal.contents['vevent']: ical.contents['vevent'].append(revents) if data.get('recurrent_uid', None): uidval = openobjectid2uid(cr, data['recurrent_uid'], model) vevent.add('uid').value = uidval elif field == 'attendee' and data[map_field]: model = self.__attribute__[field].get('object', False) attendee_obj = self.pool.get('basic.calendar.attendee') vevent = attendee_obj.export_cal(cr, uid, model, \ data[map_field], vevent, context=context) elif field == 'valarm' and data[map_field]: model = self.__attribute__[field].get('object', False) alarm_obj = self.pool.get('basic.calendar.alarm') vevent = alarm_obj.export_cal(cr, uid, model, \ data[map_field][0], vevent, context=context) elif data[map_field]: if map_type in ("char", "text"): vevent.add(field).value = str(data[map_field]) elif map_type in ('datetime', 'date') and data[map_field]: if field in ('exdate'): vevent.add(field).value = [parser.parse(data[map_field])] else: vevent.add(field).value = parser.parse(data[map_field]) elif map_type == "timedelta": vevent.add(field).value = timedelta(hours=data[map_field]) elif map_type == "many2one": vevent.add(field).value = data.get(map_field)[1] elif map_type in ("float", "integer"): vevent.add(field).value = str(data.get(map_field)) elif map_type == "selection": if not self.ical_get(field, 'mapping'): vevent.add(field).value = (data[map_field]).upper() else: for key1, val1 in self.ical_get(field, 'mapping').items(): if val1 == data[map_field]: vevent.add(field).value = key1 return vevent |
vevent.add(field).value = data.get(map_field)[1] | vevent.add(field).value = (data.get(map_field)[1]).encode('utf8') | def create_ics(self, cr, uid, datas, name, ical, context=None): if not datas: model = context.get('model', None) war_str = "No data available" + (model and " for " + model) or "" raise osv.except_osv(_('Warning !'), _(war_str)) for data in datas: vevent = ical.add(name) for field in self.__attribute__.keys(): map_field = self.ical_get(field, 'field') map_type = self.ical_get(field, 'type') if map_field in data.keys(): if field == 'uid': model = context.get('model', None) if not model: continue uidval = openobjectid2uid(cr, data[map_field], model) model_obj = self.pool.get(model) r_ids = [] if model_obj._columns.get('recurrent_uid', None): cr.execute('select id from %s where recurrent_uid=%s' % (model_obj._table, data[map_field])) r_ids = map(lambda x: x[0], cr.fetchall()) if r_ids: rdata = self.pool.get(model).read(cr, uid, r_ids) rcal = self.export_cal(cr, uid, rdata, context=context) for revents in rcal.contents['vevent']: ical.contents['vevent'].append(revents) if data.get('recurrent_uid', None): uidval = openobjectid2uid(cr, data['recurrent_uid'], model) vevent.add('uid').value = uidval elif field == 'attendee' and data[map_field]: model = self.__attribute__[field].get('object', False) attendee_obj = self.pool.get('basic.calendar.attendee') vevent = attendee_obj.export_cal(cr, uid, model, \ data[map_field], vevent, context=context) elif field == 'valarm' and data[map_field]: model = self.__attribute__[field].get('object', False) alarm_obj = self.pool.get('basic.calendar.alarm') vevent = alarm_obj.export_cal(cr, uid, model, \ data[map_field][0], vevent, context=context) elif data[map_field]: if map_type in ("char", "text"): vevent.add(field).value = str(data[map_field]) elif map_type in ('datetime', 'date') and data[map_field]: if field in ('exdate'): vevent.add(field).value = [parser.parse(data[map_field])] else: vevent.add(field).value = parser.parse(data[map_field]) elif map_type == "timedelta": vevent.add(field).value = timedelta(hours=data[map_field]) elif map_type == "many2one": vevent.add(field).value = data.get(map_field)[1] elif map_type in ("float", "integer"): vevent.add(field).value = str(data.get(map_field)) elif map_type == "selection": if not self.ical_get(field, 'mapping'): vevent.add(field).value = (data[map_field]).upper() else: for key1, val1 in self.ical_get(field, 'mapping').items(): if val1 == data[map_field]: vevent.add(field).value = key1 return vevent |
vevent.add(field).value = (data[map_field]).upper() | vevent.add(field).value = (data[map_field].encode('utf8')).upper() | def create_ics(self, cr, uid, datas, name, ical, context=None): if not datas: model = context.get('model', None) war_str = "No data available" + (model and " for " + model) or "" raise osv.except_osv(_('Warning !'), _(war_str)) for data in datas: vevent = ical.add(name) for field in self.__attribute__.keys(): map_field = self.ical_get(field, 'field') map_type = self.ical_get(field, 'type') if map_field in data.keys(): if field == 'uid': model = context.get('model', None) if not model: continue uidval = openobjectid2uid(cr, data[map_field], model) model_obj = self.pool.get(model) r_ids = [] if model_obj._columns.get('recurrent_uid', None): cr.execute('select id from %s where recurrent_uid=%s' % (model_obj._table, data[map_field])) r_ids = map(lambda x: x[0], cr.fetchall()) if r_ids: rdata = self.pool.get(model).read(cr, uid, r_ids) rcal = self.export_cal(cr, uid, rdata, context=context) for revents in rcal.contents['vevent']: ical.contents['vevent'].append(revents) if data.get('recurrent_uid', None): uidval = openobjectid2uid(cr, data['recurrent_uid'], model) vevent.add('uid').value = uidval elif field == 'attendee' and data[map_field]: model = self.__attribute__[field].get('object', False) attendee_obj = self.pool.get('basic.calendar.attendee') vevent = attendee_obj.export_cal(cr, uid, model, \ data[map_field], vevent, context=context) elif field == 'valarm' and data[map_field]: model = self.__attribute__[field].get('object', False) alarm_obj = self.pool.get('basic.calendar.alarm') vevent = alarm_obj.export_cal(cr, uid, model, \ data[map_field][0], vevent, context=context) elif data[map_field]: if map_type in ("char", "text"): vevent.add(field).value = str(data[map_field]) elif map_type in ('datetime', 'date') and data[map_field]: if field in ('exdate'): vevent.add(field).value = [parser.parse(data[map_field])] else: vevent.add(field).value = parser.parse(data[map_field]) elif map_type == "timedelta": vevent.add(field).value = timedelta(hours=data[map_field]) elif map_type == "many2one": vevent.add(field).value = data.get(map_field)[1] elif map_type in ("float", "integer"): vevent.add(field).value = str(data.get(map_field)) elif map_type == "selection": if not self.ical_get(field, 'mapping'): vevent.add(field).value = (data[map_field]).upper() else: for key1, val1 in self.ical_get(field, 'mapping').items(): if val1 == data[map_field]: vevent.add(field).value = key1 return vevent |
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ | self.cr.execute("SELECT COALESCE(-sum(amount),0.0) FROM account_analytic_line \ | def _move_sum(self, account_id, date1, date2, option): if account_id not in self.acc_data_dict: account_analytic_obj = self.pool.get('account.analytic.account') ids = account_analytic_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account_id])]) self.acc_data_dict[account_id] = ids else: ids = self.acc_data_dict[account_id] |
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ | self.cr.execute("SELECT COALESCE(sum(amount),0.0) FROM account_analytic_line \ | def _move_sum(self, account_id, date1, date2, option): if account_id not in self.acc_data_dict: account_analytic_obj = self.pool.get('account.analytic.account') ids = account_analytic_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account_id])]) self.acc_data_dict[account_id] = ids else: ids = self.acc_data_dict[account_id] |
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ | self.cr.execute("SELECT COALESCE(sum(unit_amount),0.0) FROM account_analytic_line \ | def _move_sum(self, account_id, date1, date2, option): if account_id not in self.acc_data_dict: account_analytic_obj = self.pool.get('account.analytic.account') ids = account_analytic_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account_id])]) self.acc_data_dict[account_id] = ids else: ids = self.acc_data_dict[account_id] |
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ | self.cr.execute("SELECT COALESCE(sum(amount),0.0) FROM account_analytic_line \ | def _sum_all(self, accounts, date1, date2, option): ids = map(lambda x: x['id'], accounts) if not len(ids): return 0.0 |
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ | self.cr.execute("SELECT COALESCE(-sum(amount),0.0) FROM account_analytic_line \ | def _sum_all(self, accounts, date1, date2, option): ids = map(lambda x: x['id'], accounts) if not len(ids): return 0.0 |
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ | self.cr.execute("SELECT COALESCE(sum(unit_amount),0.0) FROM account_analytic_line \ | def _sum_all(self, accounts, date1, date2, option): ids = map(lambda x: x['id'], accounts) if not len(ids): return 0.0 |
self.write(cr, uid, ids, {'state': 'done', 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')}) | self.write(cr, uid, ids, {'state': 'done', 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), 'probability' : 100.0}) | def case_close(self, cr, uid, ids, *args): """Closes Case @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case Ids @param *args: Tuple Value for additional Params """ cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.__history(cr, uid, cases, _('Close')) self.write(cr, uid, ids, {'state': 'done', 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')}) # # We use the cache of cases to keep the old case state # self._action(cr, uid, cases, 'done') return True |
self.write(cr, uid, ids, {'state': 'cancel', 'active': True}) | self.write(cr, uid, ids, {'state': 'cancel', 'active': True, 'probability' : 0.0}) | def case_cancel(self, cr, uid, ids, *args): """Cancels Case @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case Ids @param *args: Tuple Value for additional Params """ cases = self.browse(cr, uid, ids) cases[0].state # to fill the browse record cache self.__history(cr, uid, cases, _('Cancel')) self.write(cr, uid, ids, {'state': 'cancel', 'active': True}) self._action(cr, uid, cases, 'cancel') return True |
'email_to': fields.char('Email TO', size=84), | 'email_to': fields.char('Email To', size=84), | def _note_get(self, cursor, user, ids, name, arg, context=None): """ Gives case History Description @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 case History’s IDs @param context: A standard dictionary for contextual values """ res = {} for hist in self.browse(cursor, user, ids, context or {}): res[hist.id] = (hist.email or '/') + ' (' + str(hist.date) + ')\n' res[hist.id] += (hist.description or '') return res |
ftp.login(user.get('login',''), user.get('password','')) | ftp.login(user.get('login',''), user.get('login','')) | def get_ftp_login(cr, uid, ormobj): ftp = get_plain_ftp() user = ormobj.pool.get('res.users').read(cr, uid, uid) ftp.login(user.get('login',''), user.get('password','')) ftp.cwd("/" + cr.dbname) return ftp |
'planned_hours': backlog.planned_hours, | 'planned_hours': backlog.expected_hours, | def do_create(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') task = self.pool.get('project.task') backlog_id = self.pool.get('scrum.product.backlog') ids_task = [] |
_order = "date desc" | _order = "date desc ,id desc" | def _currency(self, cursor, user, ids, name, args, context=None): res = {} res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') default_currency = res_users_obj.browse(cursor, user, user, context=context).company_id.currency_id for statement in self.browse(cursor, user, ids, context=context): currency = statement.journal_id.currency if not currency: currency = default_currency res[statement.id] = currency.id currency_names = {} for currency_id, currency_name in res_currency_obj.name_get(cursor, user, [x for x in res.values()], context=context): currency_names[currency_id] = currency_name for statement_id in res.keys(): currency_id = res[statement_id] res[statement_id] = (currency_id, currency_names[currency_id]) return res |
fnode = nodes.node_file(None, None, nctx, fbro) | if not fbro.parent_id: cr.execute("select db_datas from ir_attachment where id = %s" ,(fbro.id,)) res = cr.fetchone() datas = res[0] or '' size = len(datas) else: fnode = nodes.node_file(None, None, nctx, fbro) datas = fnode.get_data(cr, fbro) datas = base64.encodestring(datas or '') size = fnode.get_data_len(cr, fbro) | def _data_get(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} fbrl = self.browse(cr, uid, ids, context=context) nctx = nodes.get_node_context(cr, uid, context={}) # nctx will /not/ inherit the caller's context. Most of # it would be useless, anyway (like active_id, active_model, # bin_size etc.) result = {} bin_size = context.get('bin_size', False) for fbro in fbrl: fnode = nodes.node_file(None, None, nctx, fbro) if not bin_size: data = fnode.get_data(cr, fbro) result[fbro.id] = base64.encodestring(data or '') else: result[fbro.id] = fnode.get_data_len(cr, fbro) |
data = fnode.get_data(cr, fbro) result[fbro.id] = base64.encodestring(data or '') else: result[fbro.id] = fnode.get_data_len(cr, fbro) | result[fbro.id] = datas else: result[fbro.id] = size | def _data_get(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} fbrl = self.browse(cr, uid, ids, context=context) nctx = nodes.get_node_context(cr, uid, context={}) # nctx will /not/ inherit the caller's context. Most of # it would be useless, anyway (like active_id, active_model, # bin_size etc.) result = {} bin_size = context.get('bin_size', False) for fbro in fbrl: fnode = nodes.node_file(None, None, nctx, fbro) if not bin_size: data = fnode.get_data(cr, fbro) result[fbro.id] = base64.encodestring(data or '') else: result[fbro.id] = fnode.get_data_len(cr, fbro) |
work_times = resource_calendar_obj.interval_min_get(cr, uid, calendar_id, date_end, hours or 0.0, resource_id or False) | work_times = resource_calendar_obj.interval_min_get(cr, uid, calendar_id, date_end, hours or 0.0, resource_id and resource_id[0] or False) | def _check_date_start(self, cr, uid, task, date_end, context={}): """ Check And Compute date_end of task if change in date_start < older time. """ resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') calendar_id = task.project_id.resource_calendar_id and task.project_id.resource_calendar_id.id or False hours = task.planned_hours / task.occupation_rate resource_id = resource_obj.search(cr, uid, [('user_id', '=', task.user_id.id)], context=context) if resource_id: resource = resource_obj.browse(cr, uid, resource_id[0], context=context) if resource.calendar_id.id: calendar_id = resource.calendar_id and resource.calendar_id.id or False hours = task.planned_hours / (float(task.occupation_rate) * resource.time_efficiency) work_times = resource_calendar_obj.interval_min_get(cr, uid, calendar_id, date_end, hours or 0.0, resource_id or False) dt_start = work_times[0][0].strftime('%Y-%m-%d %H:%M:%S') self.write(cr, uid, [task.id], {'date_start' : dt_start,'date_end' : date_end.strftime('%Y-%m-%d %H:%M:%S')}) |
work_times = resource_calendar_obj.interval_get(cr, uid, calendar_id, date_start, hours or 0.0, resource.id or False) | work_times = resource_calendar_obj.interval_get(cr, uid, calendar_id, date_start, hours or 0.0, resource_id and resource_id[0] or False) | def _check_date_end(self, cr, uid, task, date_start, context={}): """ Check And Compute date_end of task if change in date_end > older time. """ resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') calendar_id = task.project_id.resource_calendar_id and task.project_id.resource_calendar_id.id or False hours = task.planned_hours / task.occupation_rate resource_id = resource_obj.search(cr,uid,[('user_id', '=', task.user_id.id)], context=context) if resource_id: resource = resource_obj.browse(cr, uid, resource_id[0], context=context) if resource.calendar_id.id: calendar_id = resource.calendar_id and resource.calendar_id.id or False hours = task.planned_hours / (float(task.occupation_rate) * resource.time_efficiency) work_times = resource_calendar_obj.interval_get(cr, uid, calendar_id, date_start, hours or 0.0, resource.id or False) dt_end = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S') self.write(cr, uid, [task.id], {'date_start': date_start.strftime('%Y-%m-%d %H:%M:%S'),'date_end' : dt_end}, context=context) |
return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom or False}, 'domain':{'product_uom':[]}} | return {'value': {'price_unit': 0.0, 'name': '', 'product_qty': 1.0, 'date_planned': False, 'notes': '', 'product_uom' : False}, 'domain':{'product_uom':[]}} | def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom, partner_id, date_order=False, fiscal_position=False, date_planned=False, name=False, price_unit=False, notes=False): if not pricelist: raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist or a supplier in the purchase form !\nPlease set one before choosing a product.')) if not partner_id: raise osv.except_osv(_('No Partner!'), _('You have to select a partner in the purchase form !\nPlease set one partner before choosing a product.')) if not product: return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom or False}, 'domain':{'product_uom':[]}} prod= self.pool.get('product.product').browse(cr, uid, product) lang=False if partner_id: lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang'] context={'lang':lang} context['partner_id'] = partner_id |
'product_qty': qty, | 'product_qty': qty or 1.0, | def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom, partner_id, date_order=False, fiscal_position=False, date_planned=False, name=False, price_unit=False, notes=False): if not pricelist: raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist or a supplier in the purchase form !\nPlease set one before choosing a product.')) if not partner_id: raise osv.except_osv(_('No Partner!'), _('You have to select a partner in the purchase form !\nPlease set one partner before choosing a product.')) if not product: return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom or False}, 'domain':{'product_uom':[]}} prod= self.pool.get('product.product').browse(cr, uid, product) lang=False if partner_id: lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang'] context={'lang':lang} context['partner_id'] = partner_id |
move_id = move_obj.create(cr, uid, {'journal_id': data.property_stock_journal.id}) | move_id = move_obj.create(cr, uid, {'journal_id': data.categ_id.property_stock_journal.id}) | def change_price(self, cr, uid, ids, context): """ @summary: 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') 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 |
'type_id': fields.many2one('crm.case.resource.type', 'Version', domain="[('object_id.model', '=', 'project.issue')]"), | 'type_id': fields.many2one('crm.case.resource.type', 'Version'), | def _get_data(self, cr, uid, ids, field_names, arg, context=None): if context is None: context = {} """ @param cr: the current row, from the database cursor, @param uid: the current users ID for security checks, @param ids: List of case and section Datas IDs @param context: A standard dictionary for contextual values """ |
cr.execute("select id from account_journal where name= '%s' and special_journal='t'"%(r[0])) | cr.execute("select id from account_journal where name= '%s' and special_journal='t'"%(r)) | def _get_v( self, cr, uid, ids,*a): """ Changed the Validation state of order @return: State """ |
cr.execute('select distinct product_id, location_id from stock_move where location_id in %s or location_dest_id in %s', (tuple(ids), tuple(ids))) res_products_by_location = sorted(cr.dictfetchall(), key=itemgetter('location_id')) | cr.execute('select distinct product_id, location_id from stock_move where location_id in %s', (tuple(ids), )) dict1 = cr.dictfetchall() cr.execute('select distinct product_id, location_dest_id as location_id from stock_move where location_dest_id in %s', (tuple(ids), )) dict2 = cr.dictfetchall() res_products_by_location = sorted(dict1+dict2, key=itemgetter('location_id')) | def _product_value(self, cr, uid, ids, field_names, arg, context=None): """Computes stock value (real and virtual) for a product, as well as stock qty (real and virtual). @param field_names: Name of field @return: Dictionary of values """ prod_id = context and context.get('product_id', False) |
if mline.date_from <= today and mline.date_to >= today: | if mline.date_to >= today: | def _membership_state(self, cr, uid, ids, name, args, context=None): res = {} for id in ids: res[id] = 'none' today = time.strftime('%Y-%m-%d') for id in ids: partner_data = self.browse(cr,uid,id) if partner_data.membership_cancel and today > partner_data.membership_cancel: res[id] = 'canceled' continue if partner_data.membership_stop and today > partner_data.membership_stop: res[id] = 'old' continue s = 4 if partner_data.member_lines: for mline in partner_data.member_lines: if mline.date_from <= today and mline.date_to >= today: if mline.account_invoice_line and mline.account_invoice_line.invoice_id: mstate = mline.account_invoice_line.invoice_id.state if mstate == 'paid': s = 0 break elif mstate == 'open' and s!=0: s = 1 elif mstate == 'cancel' and s!=0 and s!=1: s = 2 elif (mstate == 'draft' or mstate == 'proforma') and s!=0 and s!=1: s = 3 if s==4: for mline in partner_data.member_lines: if mline.date_from < today and mline.date_to < today and mline.date_from<=mline.date_to and (mline.account_invoice_line and mline.account_invoice_line.invoice_id.state) == 'paid': s = 5 else: s = 6 if s==0: res[id] = 'paid' elif s==1: res[id] = 'invoiced' elif s==2: res[id] = 'canceled' elif s==3: res[id] = 'waiting' elif s==5: res[id] = 'old' elif s==6: res[id] = 'none' if partner_data.free_member and s!=0: res[id] = 'free' if partner_data.associate_member: res_state = self._membership_state(cr, uid, [partner_data.associate_member.id], name, args, context) res[id] = res_state[partner_data.associate_member.id] return res |
state = obj_inv.browse(cr, uid, context['active_id']).state if obj_inv.browse(cr, uid, context['active_id']).state != 'draft': raise osv.except_osv(_('Error'), _('You can only change currency for Draft Invoice !')) pass | if context.get('active_id',False): state = obj_inv.browse(cr, uid, context['active_id']).state if obj_inv.browse(cr, uid, context['active_id']).state != 'draft': raise osv.except_osv(_('Error'), _('You can only change currency for Draft Invoice !')) pass | def view_init(self, cr , uid , fields_list, context=None): obj_inv = self.pool.get('account.invoice') if context is None: context = {} state = obj_inv.browse(cr, uid, context['active_id']).state if obj_inv.browse(cr, uid, context['active_id']).state != 'draft': raise osv.except_osv(_('Error'), _('You can only change currency for Draft Invoice !')) pass |
if self.path not in self.redirect_paths: | redir_path = self._find_redirect() if redir_path is False: | def send_head(self): """Common code for GET and HEAD commands. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.