rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
visibility = False if vals.get('category_id', False): category_pool = self.pool.get('idea.category') category = category_pool.browse(cr, user, vals.get('category_id'), context) visibility = category.visibility vals.update({ 'visibility':visibility }) | def write(self, cr, user, ids, vals, context=None): """ Update redord(s) exist in {ids}, with new value provided in {vals} |
|
rcal = self.export_cal(cr, uid, r_ids, 'vevent', context=context) | r_datas = model_obj.read(cr, uid, r_ids, context=context) rcal = CalDAV.export_cal(self, cr, uid, r_datas, 'vevent', context=context) for revents in rcal.contents.get('vevent', []): ical.contents['vevent'].append(revents) | def create_ics(self, cr, uid, datas, name, ical, context=None): """ create 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 """ |
data_ids = mod_obj.search(cr, uid, line_domain, context=context) | data_ids = mod_obj.search(cr, uid, line_domain, order="id", context=context) | def get_calendar_objects(self, cr, uid, ids, parent=None, domain=None, context=None): if not context: context = {} if not domain: domain = [] res = [] ctx_res_id = context.get('res_id', None) ctx_model = context.get('model', None) for cal in self.browse(cr, uid, ids): for line in cal.line_ids: if ctx_model and ctx_model != line.object_id.model: continue if line.name in ('valarm', 'attendee'): continue line_domain = eval(line.domain or '[]') line_domain += domain if ctx_res_id: line_domain += [('id','=',ctx_res_id)] mod_obj = self.pool.get(line.object_id.model) data_ids = mod_obj.search(cr, uid, line_domain, context=context) for data in mod_obj.browse(cr, uid, data_ids, context): ctx = parent and parent.context or None node = res_node_calendar('%s.ics' %data.id, parent, ctx, data, line.object_id.model, data.id) res.append(node) return res |
def get_children(self,uri, filters=None): | def get_childs(self,uri, filters=None): | def get_children(self,uri, filters=None): """ return the child objects as self.baseuris for the given URI """ self.parent.log_message('get children: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri, allow_last=True) |
fp = Popen(['file','-b',fname], shell=False, stdout=PIPE).stdout | fp = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE).stdout | def doIndex(self,content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None if content_type and self.mimes.has_key(content_type): mime = content_type fobj = self.mimes[content_type] elif filename: bname,ext = os.path.splitext(filename) if self.exts.has_key(ext): fobj = self.exts[ext] mime = fobj._getDefMime(ext) if content_type and not fobj: mime,fobj = mime_match(content_type, self.mimes) if not fobj: try: if realfname : fname = realfname else: bname,ext = os.path.splitext(filename) fd, fname = tempfile.mkstemp(suffix=ext) os.write(fd, content) os.close(fd) #fp = Popen(['file','-b','--mime-type',fname], shell=False, stdout=PIPE).stdout fp = Popen(['file','-b',fname], shell=False, stdout=PIPE).stdout result = fp.read() fp.close() mime2 = result.strip() self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. mime,fobj = mime_match(mime2, self.mimes) if not mime: mime = mime2 except Exception: self.__logger.exception('Cannot determine mime type') try: if fobj: res = (mime, fobj.indexContent(content,filename,fname or realfname) ) else: self.__logger.debug("Have no object, return (%s, None)", mime) res = (mime, None ) except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname) res = None # If we created a tmp file, unlink it now if not realfname and fname: try: os.unlink(fname) except Exception: self.__logger.exception("Could not unlink %s", fname) return res |
mime2 = result.strip() | mime2 = result.split(';')[0] | def doIndex(self,content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None if content_type and self.mimes.has_key(content_type): mime = content_type fobj = self.mimes[content_type] elif filename: bname,ext = os.path.splitext(filename) if self.exts.has_key(ext): fobj = self.exts[ext] mime = fobj._getDefMime(ext) if content_type and not fobj: mime,fobj = mime_match(content_type, self.mimes) if not fobj: try: if realfname : fname = realfname else: bname,ext = os.path.splitext(filename) fd, fname = tempfile.mkstemp(suffix=ext) os.write(fd, content) os.close(fd) #fp = Popen(['file','-b','--mime-type',fname], shell=False, stdout=PIPE).stdout fp = Popen(['file','-b',fname], shell=False, stdout=PIPE).stdout result = fp.read() fp.close() mime2 = result.strip() self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. mime,fobj = mime_match(mime2, self.mimes) if not mime: mime = mime2 except Exception: self.__logger.exception('Cannot determine mime type') try: if fobj: res = (mime, fobj.indexContent(content,filename,fname or realfname) ) else: self.__logger.debug("Have no object, return (%s, None)", mime) res = (mime, None ) except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname) res = None # If we created a tmp file, unlink it now if not realfname and fname: try: os.unlink(fname) except Exception: self.__logger.exception("Could not unlink %s", fname) return res |
'planned_hours': fields.float('Planned Hours', required=True, help='Estimated time to do the task, usually set by the project manager when the task is in draft state.'), | 'planned_hours': fields.float('Planned Hours', help='Estimated time to do the task, usually set by the project manager when the task is in draft state.'), | 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 |
('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in model !'), ('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in model !'), | ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in model (Credit Or Debit Must Be "0")!'), ('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in model (Credit + Debit Must Be greater "0")!'), | def generate(self, cr, uid, ids, datas={}, context={}): move_ids = [] for model in self.browse(cr, uid, ids, context): period_id = self.pool.get('account.period').find(cr,uid, context=context) if not period_id: raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] move_id = self.pool.get('account.move').create(cr, uid, { 'ref': model.ref, 'period_id': period_id, 'journal_id': model.journal_id.id, }) move_ids.append(move_id) for line in model.lines_id: val = { 'move_id': move_id, 'journal_id': model.journal_id.id, 'period_id': period_id } val.update({ 'name': line.name, 'quantity': line.quantity, 'debit': line.debit, 'credit': line.credit, 'account_id': line.account_id.id, 'move_id': move_id, 'ref': line.ref, 'partner_id': line.partner_id.id, 'date': time.strftime('%Y-%m-%d'), 'date_maturity': time.strftime('%Y-%m-%d') }) c = context.copy() c.update({'journal_id': model.journal_id.id,'period_id': period_id}) self.pool.get('account.move.line').create(cr, uid, val, context=c) return move_ids |
result = obj_model.read(cr, uid, [vals['res_id']], context=context) | result = obj_model.read(cr, uid, [vals['res_id']], ['name', 'partner_id', 'address_id'], context=context) | def create(self, cr, uid, vals, context=None): if not context: context = {} vals['title'] = vals['name'] vals['parent_id'] = context.get('parent_id', False) or vals.get('parent_id', False) if not vals['parent_id']: vals['parent_id'] = self.pool.get('document.directory')._get_root_directory(cr,uid, context) if not vals.get('res_id', False) and context.get('default_res_id', False): vals['res_id'] = context.get('default_res_id', False) if not vals.get('res_model', False) and context.get('default_res_model', False): vals['res_model'] = context.get('default_res_model', False) if vals.get('res_id', False) and vals.get('res_model', False): obj_model = self.pool.get(vals['res_model']) result = obj_model.read(cr, uid, [vals['res_id']], context=context) if len(result): obj = result[0] if obj.get('name', False): vals['title'] = (obj.get('name', ''))[:60] if obj_model._name == 'res.partner': vals['partner_id'] = obj['id'] elif obj.get('address_id', False): if isinstance(obj['address_id'], tuple) or isinstance(obj['address_id'], list): address_id = obj['address_id'][0] else: address_id = obj['address_id'] address = self.pool.get('res.partner.address').read(cr, uid, [address_id], context=context) if len(address): vals['partner_id'] = address[0]['partner_id'][0] or False elif obj.get('partner_id', False): if isinstance(obj['partner_id'], tuple) or isinstance(obj['partner_id'], list): vals['partner_id'] = obj['partner_id'][0] else: vals['partner_id'] = obj['partner_id'] |
if not ids: raise osv.except_osv(_('Invalid !'), _('Please save voucher before selection partner !')) line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) voucher_id = ids[0] | voucher_id = ids and ids[0] or False | def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, 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') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) 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 ttype not in ('payment', 'receipt'): return default if not ids: raise osv.except_osv(_('Invalid !'), _('Please save voucher before selection partner !')) line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) voucher_id = ids[0] ids = move_pool.search(cr, uid, [('reconcile_id','=', False), ('state','=','posted'), ('partner_id','=',partner_id)], context=context) for move in move_pool.browse(cr, uid, ids): rs = { 'ref':move.ref or '/', 'move_id':move.id, 'voucher_id':voucher_id, } if ttype == 'payment': rs.update({ 'account_id':move.partner_id.property_account_payable.id, 'type':'dr', 'amount':move.amount }) elif ttype == 'receipt': rs.update({ 'account_id':move.partner_id.property_account_receivable.id, 'type':'cr', 'amount':move.amount }) line_id = line_pool.create(cr, uid, rs) res += [line_id] return { 'value':{'payment_ids':res}, 'context':context, } |
result[id] = price | result[id] = price result['item_id'] = {id: item_id} | def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None): ''' context = { 'uom': Unit of Measure (int), 'partner': Partner ID (int), 'date': Date of the pricelist (%Y-%m-%d), } ''' context = context or {} currency_obj = self.pool.get('res.currency') product_obj = self.pool.get('product.product') supplierinfo_obj = self.pool.get('product.supplierinfo') price_type_obj = self.pool.get('product.price.type') |
'type': 'other', | 'type': 'liquidity', | 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') obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id company_id = obj_multi.company_id.id |
vals_journal['type'] = 'cash' | vals_journal['type'] = line.account_type == 'cash' and 'cash' or 'bank' | 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') obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id company_id = obj_multi.company_id.id |
consumed_products[consumed_product.product_id.id] = 0 consumed_products[consumed_product.product_id.id] -= consumed_product.product_qty | consumed_products[consumed_product.product_id.id] = consumed_product.product_qty check[consumed_product.product_id.id] = 0 for f in production.product_lines: if f.product_id.id == consumed_product.product_id.id: if (len(production.move_lines2) - scraped) > len(production.product_lines): check[consumed_product.product_id.id] += consumed_product.product_qty consumed = check[consumed_product.product_id.id] rest_consumed = produced_qty * f.product_qty / production.product_qty - consumed consumed_products[consumed_product.product_id.id] = rest_consumed | def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product based on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = [] |
rest_qty = production_qty * f.product_qty / production.product_qty - consumed_qty if rest_qty > 0: stock_mov_obj.action_consume(cr, uid, [raw_product.id], rest_qty, production.location_src_id.id, context=context) | if consumed_qty == 0: consumed_qty = production_qty * f.product_qty / production.product_qty if consumed_qty > 0: stock_mov_obj.action_consume(cr, uid, [raw_product.id], consumed_qty, production.location_src_id.id, context=context) | def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product based on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = [] |
vals_line['amount'] = 00.0 | vals_line['amount'] = 0.0 | def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context']) |
timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context']) | timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=context) | def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context']) |
prod_id, amount, unit, context=kwargs['context']) if amount_unit: vals_line['amount'] = (-1) * vals['hours']* (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj_timesheet.write(cr, uid, [timeline_id], vals_line, {}) | prod_id, amount, unit, context=context) if amount_unit and 'amount' in amount_unit.get('value',{}): updv = { 'amount': amount_unit['value']['amount'] * (-1.0) } obj_timesheet.write(cr, uid, [timeline_id], updv, context=context) | def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') task_obj = self.pool.get('project.task') vals_line = {} obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context']) |
vals_line = {} | def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context) |
|
task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: | if isinstance(ids, (long, int)): ids = [ids,] for task in self.browse(cr, uid, ids, context=context): line_id = task.hr_analytic_timesheet_id if not line_id: continue vals_line = {} | def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context) |
vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] | for fld in ('product_id', 'general_account_id', 'journal_id', 'product_uom_id'): if result.get(fld, False): vals_line[fld] = result[fld] | def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context) |
unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context) | amount_unit = obj.on_change_unit_amount(cr, uid, line_id.id, prod_id=prod_id, unit_amount=vals_line['unit_amount'], unit=False, context=context) if amount_unit and 'amount' in amount_unit.get('value',{}): vals_line['amount'] = amount_unit['value']['amount'] * (-1.0) obj.write(cr, uid, [line_id.id], vals_line, context=context) | def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} vals_line = {} obj = self.pool.get('hr.analytic.timesheet') timesheet_obj = self.pool.get('hr.analytic.timesheet') task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: vals_line['user_id'] = vals['user_id'] result = self.get_user_related_details(cr, uid, vals['user_id']) vals_line['product_id'] = result['product_id'] vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['product_uom_id'] = result['product_uom_id'] if 'date' in vals: vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] # Compute based on pricetype unit = False amount_unit=obj.on_change_unit_amount(cr, uid, line_id, vals_line['product_id'], vals_line['unit_amount'], unit, context=context) if amount_unit: vals_line['amount'] = (-1) * vals['hours'] * (amount_unit.get('value',{}).get('amount',0.0) or 0.0) obj.write(cr, uid, [line_id], vals_line, context=context) |
pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id'] | hat_obj = self.pool.get('hr.analytic.timesheet') hat_ids = [] for task in self.browse(cr, uid, ids): if task.hr_analytic_timesheet_id: hat_ids.append(task.hr_analytic_timesheet_id) | def unlink(self, cr, uid, ids, *args, **kwargs): pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id'] |
list_avail_ids = pool_analytic_timesheet.search(cr, uid, []) if timesheet_id in list_avail_ids: obj = pool_analytic_timesheet.unlink(cr, uid, [timesheet_id], *args, **kwargs) | if hat_ids: hat_obj.unlink(cr, uid, hat_ids, *args, **kwargs) | def unlink(self, cr, uid, ids, *args, **kwargs): pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id'] |
'hr_analytic_timesheet_id':fields.integer('Related Timeline Id') | 'hr_analytic_timesheet_id':fields.many2one('hr.analytic.timesheet','Related Timeline Id', ondelete='set null'), | def unlink(self, cr, uid, ids, *args, **kwargs): pool_analytic_timesheet = self.pool.get('hr.analytic.timesheet') for work_id in ids: timesheet_id = self.read(cr, uid, work_id, ['hr_analytic_timesheet_id'])['hr_analytic_timesheet_id'] |
def _lang_get(self, cr, uid, context={}): | def _lang_get(self, cr, uid, context=None): | def _lang_get(self, cr, uid, context={}): """ Get language for language selection field. @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 @return: list of dictionary which contain code and name and id. """ obj = self.pool.get('res.lang') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['code', 'name'], context=context) res = [((r['code']).replace('_', '-').lower(), r['name']) for r in res] return res |
def _tz_get(self, cr, uid, context={}): | def _tz_get(self, cr, uid, context=None): | def _tz_get(self, cr, uid, context={}): return [(x.lower(), x) for x in pytz.all_timezones] |
def onchange_allday(self, cr, uid, ids, allday, context={}): | def onchange_allday(self, cr, uid, ids, allday, context=None): | def onchange_allday(self, cr, uid, ids, allday, context={}): """Sets duration as 24 Hours if event is selcted for all day @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 calendar event’s IDs. @param allday: Value of allday boolean @param context: A standard dictionary for contextual values """ if not allday or not ids: return {} event = self.browse(cr, uid, ids, context=context)[0] value = { 'duration': 24 } return {'value': value} |
def browse(self, cr, uid, ids, context=None, list_class=None, fields_process={}): | def browse(self, cr, uid, ids, context=None, list_class=None, fields_process=None): | def browse(self, cr, uid, ids, context=None, list_class=None, fields_process={}): """ Overrides orm browse method. @param self: the object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm meeting's ids @param context: A standard dictionary for contextual values @return: the object list. """ if isinstance(ids, (str, int, long)): select = [ids] else: select = ids select = map(lambda x: base_calendar_id2real_id(x), select) res = super(calendar_event, self).browse(cr, uid, select, context, \ list_class, fields_process) if isinstance(ids, (str, int, long)): return res and res[0] or False |
WHERE date>=%s AND date<=%s AND amount>0 AND general_account_id = %s", (date1, date2, a['id'])) | WHERE date>=%s AND date<=%s AND amount<0 AND general_account_id = %s", (date1, date2, a['id'])) | def _lines_p(self, date1, date2): res = [] acc_obj = self.pool.get('account.account') |
WHERE date>=%s AND date<=%s AND amount<0 AND general_account_id = %s", (date1, date2, a['id'])) | WHERE date>=%s AND date<=%s AND amount>0 AND general_account_id = %s", (date1, date2, a['id'])) | def _lines_p(self, date1, date2): res = [] acc_obj = self.pool.get('account.account') |
'confirmed': "is scheduled for the '" + datetime.strptime(pick.min_date, '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d') + "'.", | 'confirmed': "is scheduled for the '" + msg , | def log_picking(self, cr, uid, ids, context=None): """ This function will create log messages for picking. @param cr: the database cursor @param uid: the current user's ID for security checks, @param ids: List of Picking Ids @param context: A standard dictionary for contextual values """ for pick in self.browse(cr, uid, ids, context=context): type_list = { 'out':'Picking List', 'in':'Reception', 'internal': 'Internal picking', 'delivery': 'Delivery order' } message = type_list.get(pick.type, _('Document')) + " '" + (pick.name or 'n/a') + "' " state_list = { 'confirmed': "is scheduled for the '" + datetime.strptime(pick.min_date, '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d') + "'.", 'assigned': 'is ready to process.', 'cancel': 'is Cancelled.', 'done': 'is processed.', 'draft':'is draft.', } message += state_list[pick.state] self.log(cr, uid, pick.id, message) return True |
if not view_id and context.get('invoice_type', False): | if not view_id: | def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): if not view_id and context.get('invoice_type', False): mod_obj = self.pool.get('ir.model.data') if context.get('invoice_type') in ('out_invoice', 'out_refund'): result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form') else: result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form') result = result and result[1] or False view_id = result res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) doc = etree.XML(res['arch']) nodes = doc.xpath("//field[@name='partner_id']") if context.get('type', 'sale') in ('purchase', 'payment'): for node in nodes: node.set('domain', "[('supplier', '=', True)]") res['arch'] = etree.tostring(doc) return res |
if context.get('invoice_type') in ('out_invoice', 'out_refund'): | if context.get('invoice_type', False) in ('out_invoice', 'out_refund') or context.get('line_type', False) == 'customer': | def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): if not view_id and context.get('invoice_type', False): mod_obj = self.pool.get('ir.model.data') if context.get('invoice_type') in ('out_invoice', 'out_refund'): result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form') else: result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form') result = result and result[1] or False view_id = result res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) doc = etree.XML(res['arch']) nodes = doc.xpath("//field[@name='partner_id']") if context.get('type', 'sale') in ('purchase', 'payment'): for node in nodes: node.set('domain', "[('supplier', '=', True)]") res['arch'] = etree.tostring(doc) return res |
xml_id = 'action_invoice_tree5' | xml_id = 'action_invoice_tree1' | def _create_invoice(obj, cr, uid, data, context): if data['form'].get('new_picking', False): data['id'] = data['form']['new_picking'] data['ids'] = [data['form']['new_picking']] pool = pooler.get_pool(cr.dbname) picking_obj = pooler.get_pool(cr.dbname).get('stock.picking') mod_obj = pool.get('ir.model.data') act_obj = pool.get('ir.actions.act_window') type = data['form']['type'] context['date_inv'] = data['form']['invoice_date'] res = picking_obj.action_invoice_create(cr, uid, data['ids'], journal_id = data['form']['journal_id'], group=data['form']['group'], type=type, context= context) invoice_ids = res.values() if not invoice_ids: raise wizard.except_wizard(_('Error'), _('Invoice is not created')) if type == 'out_invoice': xml_id = 'action_invoice_tree5' elif type == 'in_invoice': xml_id = 'action_invoice_tree8' elif type == 'out_refund': xml_id = 'action_invoice_tree10' else: xml_id = 'action_invoice_tree12' result = mod_obj._get_id(cr, uid, 'account', xml_id) id = mod_obj.read(cr, uid, result, ['res_id']) result = act_obj.read(cr, uid, id['res_id']) result['res_id'] = invoice_ids return result |
xml_id = 'action_invoice_tree8' | xml_id = 'action_invoice_tree2' | def _create_invoice(obj, cr, uid, data, context): if data['form'].get('new_picking', False): data['id'] = data['form']['new_picking'] data['ids'] = [data['form']['new_picking']] pool = pooler.get_pool(cr.dbname) picking_obj = pooler.get_pool(cr.dbname).get('stock.picking') mod_obj = pool.get('ir.model.data') act_obj = pool.get('ir.actions.act_window') type = data['form']['type'] context['date_inv'] = data['form']['invoice_date'] res = picking_obj.action_invoice_create(cr, uid, data['ids'], journal_id = data['form']['journal_id'], group=data['form']['group'], type=type, context= context) invoice_ids = res.values() if not invoice_ids: raise wizard.except_wizard(_('Error'), _('Invoice is not created')) if type == 'out_invoice': xml_id = 'action_invoice_tree5' elif type == 'in_invoice': xml_id = 'action_invoice_tree8' elif type == 'out_refund': xml_id = 'action_invoice_tree10' else: xml_id = 'action_invoice_tree12' result = mod_obj._get_id(cr, uid, 'account', xml_id) id = mod_obj.read(cr, uid, result, ['res_id']) result = act_obj.read(cr, uid, id['res_id']) result['res_id'] = invoice_ids return result |
xml_id = 'action_invoice_tree10' | xml_id = 'action_invoice_tree3' | def _create_invoice(obj, cr, uid, data, context): if data['form'].get('new_picking', False): data['id'] = data['form']['new_picking'] data['ids'] = [data['form']['new_picking']] pool = pooler.get_pool(cr.dbname) picking_obj = pooler.get_pool(cr.dbname).get('stock.picking') mod_obj = pool.get('ir.model.data') act_obj = pool.get('ir.actions.act_window') type = data['form']['type'] context['date_inv'] = data['form']['invoice_date'] res = picking_obj.action_invoice_create(cr, uid, data['ids'], journal_id = data['form']['journal_id'], group=data['form']['group'], type=type, context= context) invoice_ids = res.values() if not invoice_ids: raise wizard.except_wizard(_('Error'), _('Invoice is not created')) if type == 'out_invoice': xml_id = 'action_invoice_tree5' elif type == 'in_invoice': xml_id = 'action_invoice_tree8' elif type == 'out_refund': xml_id = 'action_invoice_tree10' else: xml_id = 'action_invoice_tree12' result = mod_obj._get_id(cr, uid, 'account', xml_id) id = mod_obj.read(cr, uid, result, ['res_id']) result = act_obj.read(cr, uid, id['res_id']) result['res_id'] = invoice_ids return result |
xml_id = 'action_invoice_tree12' | xml_id = 'action_invoice_tree4' | def _create_invoice(obj, cr, uid, data, context): if data['form'].get('new_picking', False): data['id'] = data['form']['new_picking'] data['ids'] = [data['form']['new_picking']] pool = pooler.get_pool(cr.dbname) picking_obj = pooler.get_pool(cr.dbname).get('stock.picking') mod_obj = pool.get('ir.model.data') act_obj = pool.get('ir.actions.act_window') type = data['form']['type'] context['date_inv'] = data['form']['invoice_date'] res = picking_obj.action_invoice_create(cr, uid, data['ids'], journal_id = data['form']['journal_id'], group=data['form']['group'], type=type, context= context) invoice_ids = res.values() if not invoice_ids: raise wizard.except_wizard(_('Error'), _('Invoice is not created')) if type == 'out_invoice': xml_id = 'action_invoice_tree5' elif type == 'in_invoice': xml_id = 'action_invoice_tree8' elif type == 'out_refund': xml_id = 'action_invoice_tree10' else: xml_id = 'action_invoice_tree12' result = mod_obj._get_id(cr, uid, 'account', xml_id) id = mod_obj.read(cr, uid, result, ['res_id']) result = act_obj.read(cr, uid, id['res_id']) result['res_id'] = invoice_ids return result |
partner_id = partner_rec.id or False | partner_id = partner.id or False | def make_po(self, cr, uid, ids, context={}): """ Make purchase order from procurement @return: New created Purchase Orders procurement wise """ res = {} company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id partner_obj = self.pool.get('res.partner') uom_obj = self.pool.get('product.uom') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') acc_pos_obj = self.pool.get('account.fiscal.position') po_obj = self.pool.get('purchase.order') for procurement in self.browse(cr, uid, ids): res_id = procurement.move_id.id partner_list = sorted([(partner_id.sequence, partner_id) for partner_id in procurement.product_id.seller_ids if partner_id]) partner_rec = partner_list and partner_list[0] and partner_list[0][1] or False partner = partner_rec.name or False partner_id = partner_rec.id or False address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] pricelist_id = partner.property_product_pricelist_purchase.id |
self.log(cr, uid, lead.id, | leads.log(cr, uid, lead.id, | def action_apply(self, cr, uid, ids, context=None): """ This converts lead to opportunity and opens Opportunity view @param ids: ids of the leads to convert to opportunities |
avg(extract('epoch' from (date_closed-c.create_date)))/3600 as delay_close | avg(extract('epoch' from (date_closed-c.create_date)))/(3600*24) as delay_close | def init(self, cr): """ Display Est.Revenue , Average Probability ,Est.Revenue Probability @param cr: the current row, from the database cursor """ |
self.write(cr, uid, [t.id], {'state': 'open', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S'),}) | data = {'state': 'open'} if not t.date_start: data['date_start'] = time.strftime('%Y-%m-%d %H:%M:%S') self.write(cr, uid, [t.id], data) | def do_open(self, cr, uid, ids, *args): tasks= self.browse(cr,uid,ids) for t in tasks: self.write(cr, uid, [t.id], {'state': 'open', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S'),}) message = _('Task ') + " '" + t.name + "' "+ _("is Open.") self.log(cr, uid, t.id, message) return True |
new_ids = [] if (data['model'] == 'account.account'): new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] else: new_ids.append(data['form']['chart_account_id']) | new_ids = ids if (data['model'] == 'ir.ui.menu'): new_ids = [data['form']['chart_account_id']] | def set_context(self, objects, data, ids, report_type=None): self.borne_date = self.get_min_date(data['form']) new_ids = [] if (data['model'] == 'account.account'): new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] else: new_ids.append(data['form']['chart_account_id']) objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) super(general_ledger, self).set_context(objects, data, new_ids, report_type) |
update_val['product_uos_qty'] = uos_qty_rest | update_val['product_uos_qty'] = uos_qty_rest if location_dest_id: update_val.update({'location_dest_id': location_dest_id}) if location_id: update_val.update({'location_id': location_id}) | def consume_moves(self, cr, uid, ids, quantity, location_id=False, location_dest_id=False, consume=True, context=None): if not context: context = {} if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !')) |
class report_products_to_received_planned(osv.osv): _name = "report.products.to.received.planned" _description = "Received Products vs Planned" _auto = False _columns = { 'date':fields.date('Date'), 'qty': fields.float('Actual Qty', digits_compute=dp.get_precision('Product UoM')), 'planned_qty': fields.float('Planned Qty', digits_compute=dp.get_precision('Product UoM')), } def init(self, cr): tools.drop_view_if_exists(cr, 'report_products_to_received_planned') cr.execute(""" create or replace view report_products_to_received_planned as ( select stock.create_date as date, min(stock.id) as id, sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock.picking_id and picking.type = 'in' where stock.create_date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) group by stock.create_date union select stock.date as date , min(stock.id) as id, 0 as actual_qty, sum(stock.product_qty) as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock.picking_id and picking.type = 'in' where stock.date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) group by stock.date ) """) report_products_to_received_planned() class report_delivery_products_planned(osv.osv): _name = "report.delivery.products.planned" _description = "Delivered products vs Planned" _auto = False _columns = { 'date':fields.date('Date'), 'qty': fields.float('Actual Qty', digits_compute=dp.get_precision('Product UoM')), 'planned_qty': fields.float('Planned Qty', digits_compute=dp.get_precision('Product UoM')), } def init(self, cr): tools.drop_view_if_exists(cr, 'report_delivery_products_planned') cr.execute(""" create or replace view report_delivery_products_planned as ( select stock.create_date as date, min(stock.id) as id, sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock.picking_id and picking.type = 'out' where stock.create_date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) group by stock.create_date union select stock.date as date, min(stock.id), 0 as actual_qty, sum(stock.product_qty) as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock.picking_id and picking.type = 'out' where stock.date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) group by stock.date ) """) report_delivery_products_planned() | def action_move(self, cr, uid, ids, context=None): move_obj = self.pool.get('stock.move') picking_obj = self.pool.get('stock.picking') account_move_obj = self.pool.get('account.move') for act in self.read(cr, uid, ids): move_lines = move_obj.browse(cr, uid, act['move_ids']) for line in move_lines: if line.picking_id: picking_obj.write(cr, uid, [line.picking_id.id], {'move_lines': [(1, line.id, {'picking_id': act['picking_id']})]}) picking_obj.write(cr, uid, [act['picking_id']], {'move_lines': [(1, line.id, {'picking_id': act['picking_id']})]}) old_picking = picking_obj.read(cr, uid, [line.picking_id.id])[0] if not len(old_picking['move_lines']): picking_obj.write(cr, uid, [old_picking['id']], {'state': 'done'}) else: raise osv.except_osv(_('UserError'), _('You can not create new moves.')) return {'type': 'ir.actions.act_window_close'} |
|
FROM res_partner,account_move_line AS l, account_account\ | FROM res_partner,account_move_line AS l, account_account, account_move am\ | def _get_lines(self, form): res = [] self.cr.execute('SELECT DISTINCT res_partner.id AS id,\ res_partner.name AS name \ FROM res_partner,account_move_line AS l, account_account\ WHERE (l.account_id=account_account.id) \ AND ((reconcile_id IS NULL)\ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND (l.partner_id=res_partner.id)\ AND ' + self.query + ' \ ORDER BY res_partner.name', (self.date_from,)) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): self.total_account.append(0) # # Build a string like (1,2,3) for easy use in SQL query partner_ids = [x['id'] for x in partners] if not partner_ids: return [] # This dictionary will store the debit-credit for all partners, using partner_id as key. move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
ORDER BY res_partner.name', (self.date_from,)) | ORDER BY res_partner.name', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from,)) | def _get_lines(self, form): res = [] self.cr.execute('SELECT DISTINCT res_partner.id AS id,\ res_partner.name AS name \ FROM res_partner,account_move_line AS l, account_account\ WHERE (l.account_id=account_account.id) \ AND ((reconcile_id IS NULL)\ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND (l.partner_id=res_partner.id)\ AND ' + self.query + ' \ ORDER BY res_partner.name', (self.date_from,)) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): self.total_account.append(0) # # Build a string like (1,2,3) for easy use in SQL query partner_ids = [x['id'] for x in partners] if not partner_ids: return [] # This dictionary will store the debit-credit for all partners, using partner_id as key. move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] | def _get_lines(self, form): res = [] self.cr.execute('SELECT DISTINCT res_partner.id AS id,\ res_partner.name AS name \ FROM res_partner,account_move_line AS l, account_account\ WHERE (l.account_id=account_account.id) \ AND ((reconcile_id IS NULL)\ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND (l.partner_id=res_partner.id)\ AND ' + self.query + ' \ ORDER BY res_partner.name', (self.date_from,)) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): self.total_account.append(0) # # Build a string like (1,2,3) for easy use in SQL query partner_ids = [x['id'] for x in partners] if not partner_ids: return [] # This dictionary will store the debit-credit for all partners, using partner_id as key. move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
|
GROUP BY l.partner_id ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from)) | AND (l.date <= %s)\ GROUP BY l.partner_id ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from, self.date_from,)) | def _get_lines(self, form): res = [] self.cr.execute('SELECT DISTINCT res_partner.id AS id,\ res_partner.name AS name \ FROM res_partner,account_move_line AS l, account_account\ WHERE (l.account_id=account_account.id) \ AND ((reconcile_id IS NULL)\ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND (l.partner_id=res_partner.id)\ AND ' + self.query + ' \ ORDER BY res_partner.name', (self.date_from,)) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): self.total_account.append(0) # # Build a string like (1,2,3) for easy use in SQL query partner_ids = [x['id'] for x in partners] if not partner_ids: return [] # This dictionary will store the debit-credit for all partners, using partner_id as key. move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
GROUP BY l.partner_id', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids),self.date_from)) | AND (l.date <= %s)\ GROUP BY l.partner_id', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids),self.date_from, self.date_from,)) | def _get_lines(self, form): res = [] self.cr.execute('SELECT DISTINCT res_partner.id AS id,\ res_partner.name AS name \ FROM res_partner,account_move_line AS l, account_account\ WHERE (l.account_id=account_account.id) \ AND ((reconcile_id IS NULL)\ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND (l.partner_id=res_partner.id)\ AND ' + self.query + ' \ ORDER BY res_partner.name', (self.date_from,)) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): self.total_account.append(0) # # Build a string like (1,2,3) for easy use in SQL query partner_ids = [x['id'] for x in partners] if not partner_ids: return [] # This dictionary will store the debit-credit for all partners, using partner_id as key. move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
self.cr.execute('SELECT l.partner_id, SUM(l.debit-l.credit)\ FROM account_move_line AS l, account_account, account_move am \ WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)\ AND (am.state IN %s)\ AND (account_account.type IN %s)\ AND (l.partner_id IN %s)\ AND ((l.reconcile_id IS NULL)\ OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND '+ self.query + '\ AND account_account.active\ AND ' + dates_query + '\ GROUP BY l.partner_id', args_list) | args_list += (self.date_from,) self.cr.execute('''SELECT l.partner_id, SUM(l.debit-l.credit) FROM account_move_line AS l, account_account, account_move am WHERE (l.account_id = account_account.id) AND (l.move_id=am.id) AND (am.state IN %s) AND (account_account.type IN %s) AND (l.partner_id IN %s) AND ((l.reconcile_id IS NULL) OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND ''' + self.query + ''' AND account_account.active AND ''' + dates_query + ''' AND (l.date <= %s) GROUP BY l.partner_id''', args_list) | def _get_lines(self, form): res = [] self.cr.execute('SELECT DISTINCT res_partner.id AS id,\ res_partner.name AS name \ FROM res_partner,account_move_line AS l, account_account\ WHERE (l.account_id=account_account.id) \ AND ((reconcile_id IS NULL)\ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND (l.partner_id=res_partner.id)\ AND ' + self.query + ' \ ORDER BY res_partner.name', (self.date_from,)) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): self.total_account.append(0) # # Build a string like (1,2,3) for easy use in SQL query partner_ids = [x['id'] for x in partners] if not partner_ids: return [] # This dictionary will store the debit-credit for all partners, using partner_id as key. move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
if values['total']: res.append(values) | res.append(values) | def _get_lines(self, form): res = [] self.cr.execute('SELECT DISTINCT res_partner.id AS id,\ res_partner.name AS name \ FROM res_partner,account_move_line AS l, account_account\ WHERE (l.account_id=account_account.id) \ AND ((reconcile_id IS NULL)\ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND (l.partner_id=res_partner.id)\ AND ' + self.query + ' \ ORDER BY res_partner.name', (self.date_from,)) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): self.total_account.append(0) # # Build a string like (1,2,3) for easy use in SQL query partner_ids = [x['id'] for x in partners] if not partner_ids: return [] # This dictionary will store the debit-credit for all partners, using partner_id as key. move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
AND account_account.active ',(tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from)) | AND (l.date <= %s)\ AND account_account.active ',(tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from,)) | def _get_lines_with_out_partner(self, form): res = [] move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
args_list += (self.date_from,) | def _get_lines_with_out_partner(self, form): res = [] move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
|
def _sheet_search(self, cursor, user, obj, name, args): | def _sheet_search(self, cursor, user, obj, name, args, context={}): | def _sheet_search(self, cursor, user, obj, name, args): if not len(args): return [] sheet_obj = self.pool.get('hr_timesheet_sheet.sheet') |
AND s.user_id = e.user_id) ' + \ | AND s.user_id = r.user_id) ' + \ | def _sheet_search(self, cursor, user, obj, name, args): if not len(args): return [] sheet_obj = self.pool.get('hr_timesheet_sheet.sheet') |
return True | def process_wi_email(self, cr, uid, activity, workitem, context=None): print 'Sending Email Init', activity.name return self.pool.get('email.template').generate_mail(cr, uid, activity.email_template_id.id, [workitem.res_id], context=context) |
|
return pooler.get_pool(cr.dbname).get('decimal.precision').precision_get(cr, 1, application) | res = pooler.get_pool(cr.dbname).get('decimal.precision').precision_get(cr, 1, application) return (16, res) | def change_digit(cr): return pooler.get_pool(cr.dbname).get('decimal.precision').precision_get(cr, 1, application) |
"AND debit > 0", | "AND debit > 0 " \ "ORDER BY date_maturity", | def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', False) and form.get('max_amount') or 0.0 power = form['power'] allow_write_off = form['allow_write_off'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: params = (account_id,) if not allow_write_off: query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL AND state <> 'draft' GROUP BY partner_id HAVING ABS(SUM(debit-credit)) = 0.0 AND count(*)>0""" else: query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL AND state <> 'draft' GROUP BY partner_id HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0""" params += (max_amount,) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query, params) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if allow_write_off: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) else: move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) |
"AND credit > 0", | "AND credit > 0 " \ "ORDER BY date_maturity", | def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', False) and form.get('max_amount') or 0.0 power = form['power'] allow_write_off = form['allow_write_off'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: params = (account_id,) if not allow_write_off: query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL AND state <> 'draft' GROUP BY partner_id HAVING ABS(SUM(debit-credit)) = 0.0 AND count(*)>0""" else: query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL AND state <> 'draft' GROUP BY partner_id HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0""" params += (max_amount,) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query, params) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if allow_write_off: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) else: move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) |
success = self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_in') | self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_in') | def sign_in(self, cr, uid, data, context=None): if context is None: context = {} emp_id = data['emp_id'] if 'last_time' in data: if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'): raise osv.except_osv(_('UserError'), _('The sign-out date must be in the past')) self.pool.get('hr.attendance').create(cr, uid, {'name': data['last_time'], 'action': 'sign_out', 'employee_id': emp_id}, context=context) try: success = self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_in') except: raise osv.except_osv(_('UserError'), _('A sign-in must be right after a sign-out !')) return {} # To do: Return Success message |
success = self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_out') | self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_out') | def sign_out(self, cr, uid, data, context=None): emp_id = data['emp_id'] if 'last_time' in data: if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'): raise osv.except_osv(_('UserError'), _('The Sign-in date must be in the past')) self.pool.get('hr.attendance').create(cr, uid, {'name':data['last_time'], 'action':'sign_in', 'employee_id':emp_id}, context=context) try: success = self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_out') except: raise osv.except_osv(_('UserError'), _('A sign-out must be right after a sign-in !')) return {} # To do: Return Success message |
'res.partner':(_get_partners, ['free_member', 'membership_state'], 10) | 'res.partner':(_get_partners, ['free_member', 'membership_state','associate_member'], 10) | def _get_partners(self, cr, uid, ids, context={}): ids2 = ids while ids2: ids2 = self.search(cr, uid, [('associate_member','in',ids2)], context=context) ids+=ids2 return ids |
data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) | value = {} if case.section_id.id : domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] else : domain = [('type', '=', stage_type)] | def stage_change(self, cr, uid, ids, context=None, order='sequence'): if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False next_stage_id = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} |
data = {'stage_id': next_stage.id} | value.update({'stage_id': next_stage.id}) | def stage_change(self, cr, uid, ids, context=None, order='sequence'): if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False next_stage_id = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} |
data.update({'probability': next_stage.probability}) self.write(cr, uid, [case.id], data, context=context) | value.update({'probability': next_stage.probability}) self.write(cr, uid, [case.id], value, context=context) | def stage_change(self, cr, uid, ids, context=None, order='sequence'): if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False next_stage_id = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} |
if debit < 0: credit = -debit debit = 0.0 if credit < 0: debit = -credit credit = 0.0 | def _get_payment_term_lines(term_id, amount): term_pool = self.pool.get('account.payment.term') if term_id and amount: terms = term_pool.compute(cr, uid, term_id, amount) return terms return False |
|
if inv.tax_amount > 0: | if inv.tax_amount: | def _get_payment_term_lines(term_id, amount): term_pool = self.pool.get('account.payment.term') if term_id and amount: terms = term_pool.compute(cr, uid, term_id, amount) return terms return False |
if inv.journal_id.type in ('sale','purchase_refund'): | if inv.journal_id.type in ('sale','purchase_refund') and amount > 0: | def _get_payment_term_lines(term_id, amount): term_pool = self.pool.get('account.payment.term') if term_id and amount: terms = term_pool.compute(cr, uid, term_id, amount) return terms return False |
return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id': False}, context) | return super(wiki_wiki2, self).copy_data(cr, uid, id, {'wiki_id': False}, context) | def copy_data(self, cr, uid, id, default=None, context=None): |
employee_ids=employee_obj.search(cr, uid, [('parent_id','=',employee.id)], context=context) | def onchange_employee_id(self, cr, uid, ids, employee_id, context=None): if context is None: context = {} evaluation_plan_id=False if employee_id: employee_obj=self.pool.get('hr.employee') for employee in employee_obj.browse(cr, uid, [employee_id], context=context): if employee and employee.evaluation_plan_id and employee.evaluation_plan_id.id: evaluation_plan_id=employee.evaluation_plan_id.id employee_ids=employee_obj.search(cr, uid, [('parent_id','=',employee.id)], context=context) return {'value': {'plan_id':evaluation_plan_id}} |
|
apprai_id = [] | def button_plan_in_progress(self, cr, uid, ids, context=None): hr_eval_inter_obj = self.pool.get('hr.evaluation.interview') if context is None: context = {} apprai_id = [] for evaluation in self.browse(cr, uid, ids, context=context): wait = False for phase in evaluation.plan_id.phase_ids: childs = [] if phase.action == "bottom-up": childs = evaluation.employee_id.child_ids elif phase.action in ("top-down", "final"): if evaluation.employee_id.parent_id: childs = [evaluation.employee_id.parent_id] elif phase.action == "self": childs = [evaluation.employee_id] for child in childs: |
|
def msg_new(self, cr, uid, msg, model): print ' MSG NEW' , model | def msg_new(self, cr, uid, msg, model): | def msg_new(self, cr, uid, msg, model): print ' MSG NEW' , model message = self.msg_body_get(msg) res_model = self.pool.get(model) res_id = res_model.msg_new(cr, uid, msg) if res_id: attachments = message['attachment'] |
warning += [_("Relation not found: %s on '%s'") % (line[i], relation)] | warning += [_("Relation not found: %s on '%s'") % (word, relation)] | def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0): line = datas[position] row = {} translate = {} todo = [] warning = [] data_id = False data_res_id = False is_xml_id = False is_db_id = False ir_model_data_obj = self.pool.get('ir.model.data') # # Import normal fields # for i in range(len(fields)): if i >= len(line): raise Exception(_('Please check that all your lines have %d columns.') % (len(fields),)) if not line[i]: continue |
_("Relation not found: %s on '%s'") % (line[i], relation)) | _("Relation not found: %s on '%s'") % (word, relation)) | def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0): line = datas[position] row = {} translate = {} todo = [] warning = [] data_id = False data_res_id = False is_xml_id = False is_db_id = False ir_model_data_obj = self.pool.get('ir.model.data') # # Import normal fields # for i in range(len(fields)): if i >= len(line): raise Exception(_('Please check that all your lines have %d columns.') % (len(fields),)) if not line[i]: continue |
'title': 'Bad Lot Assignation !', 'message': 'You are moving %.2f products but only %.2f available in this lot.' % (product_qty, prodlot.stock_available or 0.0) | 'title': _('Bad Lot Assignation !'), 'message': _('You are moving %.2f products but only %.2f available in this lot.') % (product_qty, prodlot.stock_available or 0.0) | def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, context=None): """ On change of production lot gives a warning message. @param prodlot_id: Changed production lot id @param product_qty: Quantity of product @param loc_id: Location id @param product_id: Product id @return: Warning message """ if not prodlot_id or not loc_id: return {} ctx = context and context.copy() or {} ctx['location_id'] = loc_id prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, ctx) location = self.pool.get('stock.location').browse(cr, uid, loc_id) warning = {} if (location.usage == 'internal') and (product_qty > (prodlot.stock_available or 0.0)): warning = { 'title': 'Bad Lot Assignation !', 'message': 'You are moving %.2f products but only %.2f available in this lot.' % (product_qty, prodlot.stock_available or 0.0) } return {'warning': warning} |
required=True, | required=False, | 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 |
data_id = data_pool.search(cr, uid, [('model','=','account.account'), ('name','=','chart0')]) if data_id: data = data_pool.browse(cr, uid, data_id[0]) account_id = data.res_id acc_ids = obj_acc._get_children_and_consol(cr, uid, [account_id]) if acc_ids: cr.execute("update account_account set active='f' where id in " + str(tuple(acc_ids))) | def execute(self, cr, uid, ids, context=None): if context is None: context = {} data_pool = self.pool.get('ir.model.data') obj_acc = self.pool.get('account.account') super(account_installer, self).execute(cr, uid, ids, context=context) record = self.browse(cr, uid, ids, context=context)[0] company_id = self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id for res in self.read(cr, uid, ids): if record.charts == 'configurable': mod_obj = self.pool.get('ir.model.data') fp = tools.file_open(opj('account','configurable_account_chart.xml')) tools.convert_xml_import(cr, 'account', fp, {}, 'init',True, None) fp.close() self.generate_configurable_chart(cr, uid, ids, context=context) obj_tax = self.pool.get('account.tax') obj_product = self.pool.get('product.product') ir_values = self.pool.get('ir.values') s_tax = (res.get('sale_tax',0.0))/100 p_tax = (res.get('purchase_tax',0.0))/100 tax_val = {} default_tax = [] |
|
self.rpc(self.model, 'history', [id], 'Receive', True, msg['From'], message['body'], False, False, {'model' : self.model}) | self.rpc(self.model, 'history', [id], 'Receive', True, msg_to, message['body'], msg_from, False, {'model' : self.model}) | def msg_new(self, msg): message = self.msg_body_get(msg) msg_subject = self._decode_header(msg['Subject']) msg_from = self._decode_header(msg['From']) msg_cc = self._decode_header(msg['Cc'] or '') data = { 'name': msg_subject, 'email_from': msg_from, 'email_cc': msg_cc, 'user_id': False, 'description': message['body'], 'state' : 'draft', } data.update(self.partner_get(msg_from)) |
self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], body['body']) | self.rpc(self.model, 'history', [id], 'Send', True, self._decode_header(msg['From']), body['body']) | def msg_user(self, msg, id): body = self.msg_body_get(msg) |
self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], message['body']) | self.rpc(self.model, 'history', [id], 'Send', True, self._decode_header(msg['From']), message['body']) | def msg_partner(self, msg, id): message = self.msg_body_get(msg) body = message['body'] act = 'case_open' self.rpc(self.model, act, [id]) #body2 = '\n'.join(map(lambda l: '> '+l, (body or '').split('\n'))) #data = { # 'description':body, #} #self.rpc(self.model, 'write', [id], data) attachments = message['attachment'] for attach in attachments or []: data_attach = { 'name': str(attach), 'datas': binascii.b2a_base64(str(attachments[attach])), 'datas_fname': str(attach), 'description': 'Mail attachment', 'res_model': self.model, 'res_id': id } self.rpc('ir.attachment', 'create', data_attach) self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], message['body']) return id |
if not context.get('allow_write_off', False): | if not allow_write_off: | def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', 0.0) power = form['power'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: if not context.get('allow_write_off', False): query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0) else: query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if not context.get('allow_write_off', False): move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) else: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) |
HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0) | HAVING ABS(SUM(debit-credit)) = %s AND count(*)>0"%(account_id, 0.0) | def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', 0.0) power = form['power'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: if not context.get('allow_write_off', False): query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0) else: query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if not context.get('allow_write_off', False): move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) else: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) |
HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0) | HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0"%(account_id, max_amount or 0.0) | def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', 0.0) power = form['power'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: if not context.get('allow_write_off', False): query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0) else: query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if not context.get('allow_write_off', False): move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) else: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) |
if not context.get('allow_write_off', False): | if allow_write_off: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) else: | def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', 0.0) power = form['power'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: if not context.get('allow_write_off', False): query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0) else: query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if not context.get('allow_write_off', False): move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) else: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) |
else: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) | def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', 0.0) power = form['power'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: if not context.get('allow_write_off', False): query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0) else: query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if not context.get('allow_write_off', False): move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) else: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) |
|
'nodestroy':True, | def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', 0.0) power = form['power'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: if not context.get('allow_write_off', False): query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0) else: query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if not context.get('allow_write_off', False): move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) else: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) |
|
'alert_date': fields.datetime('Alert Date', help="The date signifying an alert to notify about the production lot."), | 'alert_date': fields.datetime('Alert Date', help="The date an alert should be notified about the production lot."), | def calc_date(self, cr, uid, context=None): """Compute the limit date for a given date""" if context is None: context = {} if not context.get('product_id', False): date = False else: product = pooler.get_pool(cr.dbname).get('product.product').browse( cr, uid, context['product_id']) duration = getattr(product, dtype) # set date to False when no expiry time specified on the product date = duration and (datetime.datetime.today() + datetime.timedelta(days=duration)) return date and date.strftime('%Y-%m-%d %H:%M:%S') |
'alert_time': fields.integer('Product Alert Time', help="The number of days after which, needs an alert to notify about the production lot."), | 'alert_time': fields.integer('Product Alert Time', help="The number of days after which an alert should be notified about the production lot."), | def create(self, cr, uid, vals, context=None): newid = super(stock_production_lot, self).create(cr, uid, vals, context=context) obj = self.browse(cr, uid, newid, context=context) towrite = [] for f in ('life_date','use_date','removal_date','alert_date'): if not getattr(obj, f): towrite.append(f) context = context or {} context['product_id'] = obj.product_id.id self.write(cr, uid, [obj.id], self.default_get(cr, uid, towrite, context=context)) return newid |
sum(planned_revenue) as amount_revenue, sum(planned_cost) as amount_costs, sum(planned_revenue*probability/100)::decimal(16,2) as amount_revenue_prob, avg(probability)::decimal(16,2) as probability, | def init(self, cr): tools.drop_view_if_exists(cr, 'project_issue_report') cr.execute(""" create or replace view project_issue_report as ( select min(c.id) as id, to_char(c.create_date, 'YYYY') as name, to_char(c.create_date, 'MM') as month, c.state, c.user_id, c.section_id, c.categ_id, c.stage_id, count(*) as nbr, sum(planned_revenue) as amount_revenue, sum(planned_cost) as amount_costs, sum(planned_revenue*probability/100)::decimal(16,2) as amount_revenue_prob, avg(probability)::decimal(16,2) as probability, to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close from project_issue c group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id,c.categ_id,c.stage_id )""") |
|
for inv in self.browse(cr,uid,ids): move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context) self.write(cr, uid, [inv.id], {'state':'done'}, context=context) | for inv in self.browse(cr, uid, ids, context=context): move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context) self.write(cr, uid, [inv.id], {'state':'done'}, context=context) | def action_done(self, cr, uid, ids, context=None): move_obj = self.pool.get('stock.move') for inv in self.browse(cr,uid,ids): move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context) self.write(cr, uid, [inv.id], {'state':'done'}, context=context) return True |
c['location'] = loc_id for prod in product_product_obj.browse(cr, uid, product_ids, context=c): for f in field_names: if f == 'stock_real': result[loc_id][f] += prod.qty_available elif f == 'stock_virtual': result[loc_id][f] += prod.virtual_available elif f == 'stock_real_value': amount = prod.qty_available * prod.standard_price amount = currency_obj.round(cr, uid, currency, amount) result[loc_id][f] += amount elif f == 'stock_virtual_value': amount = prod.virtual_available * prod.standard_price amount = currency_obj.round(cr, uid, currency, amount) result[loc_id][f] += amount | if loc_id in ids: c['location'] = loc_id for prod in product_product_obj.browse(cr, uid, product_ids, context=c): for f in field_names: if f == 'stock_real': result[loc_id][f] += prod.qty_available elif f == 'stock_virtual': result[loc_id][f] += prod.virtual_available elif f == 'stock_real_value': amount = prod.qty_available * prod.standard_price amount = currency_obj.round(cr, uid, currency, amount) result[loc_id][f] += amount elif f == 'stock_virtual_value': amount = prod.virtual_available * prod.standard_price amount = currency_obj.round(cr, uid, currency, amount) result[loc_id][f] += amount | 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 """ result = dict([(i, {}.fromkeys(field_names, 0.0)) for i in ids]) |
repeated_move_line_ids.append(move_line_id) | repeated_move_line_ids += move_line_id | def _search_invoices(obj, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) line_obj = pool.get('account.move.line') statement_obj = pool.get('account.bank.statement') journal_obj = pool.get('account.journal') statement = statement_obj.browse(cr, uid, data['id'], context=context) args_move_line = [] repeated_move_line_ids = [] # Creating a group that is unique for importing move lines(move lines, once imported into statement lines, should not appear again) for st_line in statement.line_ids: args_move_line = [] args_move_line.append(('name','=', st_line.name)) args_move_line.append(('ref','=',st_line.ref)) if st_line.partner_id: args_move_line.append(('partner_id','=',st_line.partner_id.id)) args_move_line.append(('account_id','=',st_line.account_id.id)) move_line_id = line_obj.search(cr, uid, args_move_line,context=context) if move_line_id: repeated_move_line_ids.append(move_line_id) journal_ids = data['form']['journal_id'][0][2] if journal_ids == []: journal_ids = journal_obj.search(cr, uid, [('type', 'in', ('sale','cash','purchase'))], context=context) args = [ ('reconcile_id', '=', False), ('journal_id', 'in', journal_ids), ('account_id.reconcile', '=', True)] if repeated_move_line_ids: args.append(('id','not in',repeated_move_line_ids)) line_ids = line_obj.search(cr, uid, args, #order='date DESC, id DESC', #doesn't work context=context) FORM.string = '''<?xml version="1.0"?> |
c.type_id as type_id, | c.type_action as type_action, | def init(self, cr): |
c.priority,c.type_id,c.date_deadline,c.date_closed | c.priority,c.type_action,c.date_deadline,c.date_closed | def init(self, cr): |
m.exdate, m.exrule from " + self._table + \ | m.exdate, m.exrule, m.recurrent_id, m.recurrent_uid from " + self._table + \ | def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """ |
result.append(idval) count += 1 | if not data['recurrent_id']: result.append(idval) count += 1 else: ex_id = real_id2base_calendar_id(data['recurrent_uid'], data['recurrent_id']) recur_dict.append(ex_id) | def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """ |
ids = result | ids = list(set(result)-set(recur_dict)) | def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """ |
attrs.append("attrs='{'readonly':[('state','=','valid')]}'") | attrs.append('''attrs="{'readonly':[('state','=','valid')]}"''') | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): journal_pool = self.pool.get('account.journal') |
linktopartner = "http:\\\\"+web_server+":"+str(web_server_port)+"\\openerp\\form\\view?model=res.partner&id="+str(vals) win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, linktopartner) | linktopartner = "http://"+web_server+":"+str(web_server_port)+"/openerp/form/view?model=res.partner&id="+str(vals) win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, str(linktopartner)) | def OpenPartnerForm(txtProcessor,*args): import win32con b = check() if not b: return #Acquiring control of the text box partner_link = txtProcessor.GetControl() #Reading Current Selected Email. ex = txtProcessor.window.manager.outlook.ActiveExplorer() assert ex.Selection.Count == 1 mail = ex.Selection.Item(1) partner_text = "" try: partner_text = ustr(mail.SenderName).encode('iso-8859-1') sender_mail = ustr(mail.SenderEmailAddress).encode('iso-8859-1') except Exception: win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, "< Error in reading email.>") pass vals = NewConn.SearchPartner(sender_mail) if vals == True: win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, "< Their is contact related to "+str(partner_text)+" email address, but no partner is linked to contact>") txtProcessor.init_done=True return if vals == None: win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, "< No Partner found linked to "+str(partner_text)+" email address.>") txtProcessor.init_done=True return global web_server global web_server_port if web_server.strip() == "" or web_server.strip() == "http:\\\\": win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, " <Invalid Server Address>") txtProcessor.init_done=True return try: linktopartner = "http:\\\\"+web_server+":"+str(web_server_port)+"\\openerp\\form\\view?model=res.partner&id="+str(vals) win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, linktopartner) except Exception,e: win32ui.MessageBox("Error While Opening Partner.\n"+str(e),"Open Partner", flag_error) webbrowser.open_new(linktopartner) txtProcessor.init_done=True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.