rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
deb = head_mako_tpl.render( company=company, time=time, helper=helper, css=css, _debug=html, formatLang=self.formatLang, setLang=self.setLang, _=self.translate_call, ) | try : deb = head_mako_tpl.render( company=company, time=time, helper=helper, css=css, _debug=html, formatLang=self.formatLang, setLang=self.setLang, _=self.translate_call, ) except : raise Exception(exceptions.html_error_template().render()) | def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context) |
'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', string='Salesman'), | 'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', store=True, string='Salesman'), | def _number_packages(self, cr, uid, ids, field_name, arg, context=None): if context is None: context = {} res = {} for line in self.browse(cr, uid, ids, context=context): try: res[line.id] = int((line.product_uom_qty+line.product_packaging.qty-0.0001) / line.product_packaging.qty) except: res[line.id] = 1 return res |
if fbro.parent_id != vals['parent_id']: | if fbro.parent_id.id != vals['parent_id']: | def write(self, cr, uid, ids, vals, context=None): if not isinstance(ids, list): ids = [ids] res = self.search(cr, uid, [('id', 'in', ids)]) if not len(res): return False if not self._check_duplication(cr, uid, vals, ids, 'write'): raise osv.except_osv(_('ValidateError'), _('File name must be unique!')) if 'parent_id' in vals: # perhaps this file is changing directory nctx = nodes.get_node_context(cr,uid,context) dirobj = self.pool.get('document.directory') dbro = dirobj.browse(cr, uid, vals['parent_id'], context=context) ids2 = [] result = False for fbro in self.browse(cr, uid, ids, context=context): if fbro.parent_id != vals['parent_id']: fnode = nodes.node_file(None,None,nctx,fbro) res = fnode.move_to(cr, fbro, dbro, True) if isinstance(res, dict): vals2 = vals.copy() vals2.update(res) wid = res.get('id', fbro.id) result = super(document_file,self).write(cr,uid,wid,vals2,context=context) # TODO: how to handle/merge several results? elif res == True: ids2.append(fbro.id) elif res == False: pass ids = ids2 if len(ids): result = super(document_file,self).write(cr, uid, ids, vals, context=context) cr.commit() return result |
t.type, | t.type_id, | def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task_user') cr.execute(""" CREATE view report_project_task_user as SELECT (select 1 ) AS nbr, t.id as id, to_char(date_start, 'YYYY') as year, to_char(date_start, 'MM') as month, to_char(date_start, 'YYYY-MM-DD') as day, date_trunc('day',t.date_start) as date_start, date_trunc('day',t.date_end) as date_end, to_date(to_char(t.date_deadline, 'dd-MM-YYYY'),'dd-MM-YYYY') as date_deadline, |
t.type | t.type_id | def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task_user') cr.execute(""" CREATE view report_project_task_user as SELECT (select 1 ) AS nbr, t.id as id, to_char(date_start, 'YYYY') as year, to_char(date_start, 'MM') as month, to_char(date_start, 'YYYY-MM-DD') as day, date_trunc('day',t.date_start) as date_start, date_trunc('day',t.date_end) as date_end, to_date(to_char(t.date_deadline, 'dd-MM-YYYY'),'dd-MM-YYYY') as date_deadline, |
def onchange_type(self, cr, uid, ids, type, currency): | def onchange_type(self, cr, uid, ids, type, currency, context=None): | def onchange_type(self, cr, uid, ids, type, currency): obj_data = self.pool.get('ir.model.data') user_pool = self.pool.get('res.users') |
total_fixed = (total_fixed * 100) / inv.amount_total | total_fixed = (total_fixed * 100) / (inv.amount_total or 1.0) | def action_move_create(self, cr, uid, ids, *args): """Creates invoice related analytics and financial move lines""" ait_obj = self.pool.get('account.invoice.tax') cur_obj = self.pool.get('res.currency') context = {} for inv in self.browse(cr, uid, ids): if not inv.journal_id.sequence_id: raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal')) if not inv.invoice_line: raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.')) if inv.move_id: continue |
if res: return res[0] else: return False | return res and res[0] or False | def _get_def_cparent(self, cr, uid, context): acc_obj=self.pool.get('account.account') tmpl_obj=self.pool.get('account.account.template') #print "Searching for ",context tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']],['parent_id']) if not tids or not tids[0]['parent_id']: return False ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]],['code']) if not ptids or not ptids[0]['code']: raise osv.except_osv(_('Error !'), _('Cannot locate parent code for template account!')) res = acc_obj.search(cr,uid,[('code','=',ptids[0]['code'])]) if res: return res[0] else: return False |
fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout return _to_unicode(fp.read()) | pop = Popen(['antiword', fname], shell=False, stdout=PIPE) (data, _) = pop.communicate() return _to_unicode(data) | def _doIndexFile(self,fname): fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout return _to_unicode(fp.read()) |
fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout return _to_unicode( fp.read()) | pop = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE) (data, _) = pop.communicate() return _to_unicode(data) | def _doIndexFile(self,fname): fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout return _to_unicode( fp.read()) |
if curr_id: | if curr_id and company_id: | def onchange_currency_id(self, cr, uid, ids, curr_id, company_id): if curr_id: currency = self.pool.get('res.currency').browse(cr, uid, curr_id) if currency.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('Can not select currency that is not related to current company.\nPlease select accordingly !.')) return {} |
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line): | def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): | def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line): val={} dom={} if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr,uid,[('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr,uid,[line.id],{'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr,uid,inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id: val['journal_id']=False journal_ids=self.pool.get('account.journal').search(cr,uid,[('company_id','=',company_id)]) dom={'journal_id': [('id','in',journal_ids)]} else: journal_ids=self.pool.get('account.journal').search(cr,uid,[]) dom={'journal_id': [('id','in',journal_ids)]} return {'value' : val, 'domain': dom } |
period_obj = self.pool.get('account.period') | def _default_get(self, cr, uid, fields, context={}): # Compute simple values data = super(account_move_line, self).default_get(cr, uid, fields, context) # Starts: Manual entry from account.move form if context.get('lines',[]): |
|
data = super(ir_model, self).read(cr, uid, ids, fields=fields, \ | data = super(ir_model, self).read(cr, uid, new_ids, fields=fields, \ | def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'): """ Overrides orm read 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 IR Model’s IDs. @param context: A standard dictionary for contextual values """ if not context: context = {} data = super(ir_model, self).read(cr, uid, ids, fields=fields, \ context=context, load=load) if data: for val in data: val['id'] = base_calendar_id2real_id(val['id']) return isinstance(ids, (str, int, long)) and data[0] or data |
sql =""" select sum(pieces*number) as bal from singer_statement where starting_id = %d """%(data['id']) | sql =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d """%(data['id']) | def _get_bal(self,data): res = {} sql =""" select sum(pieces*number) as bal from singer_statement where starting_id = %d """%(data['id']) self.cr.execute(sql) res = self.cr.dictfetchall() if res : return res[0]['bal'] else : return False |
sql1 =""" select sum(pieces*number) as bal from singer_statement where starting_id = %d"""%(r['id']) | sql1 =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d"""%(r['id']) | def _get_net_total_starting(self,user): lst = [] res={} total_ending_bal = 0.0 total_starting_bal = 0.0 sql = """ SELECT abs.id,abs.balance_end_real as net_total FROM account_bank_statement as abs WHERE to_char(date_trunc('day',abs.date),'YYYY-MM-DD')::date = current_date and abs.state IN ('confirm','open') and abs.user_id = %d"""%(user.id) self.cr.execute(sql) res = self.cr.dictfetchall() for r in res : total_ending_bal += (r['net_total'] or 0.0) sql1 =""" select sum(pieces*number) as bal from singer_statement where starting_id = %d"""%(r['id']) self.cr.execute(sql1) data = self.cr.dictfetchall() if data[0]['bal']: total_starting_bal += data[0]['bal'] lst.append(total_ending_bal) lst.append(total_starting_bal) return lst |
partner_id = self.pool.get('account.move.line').read(cr, uid, context['active_id'], ['partner_id'])['partner_id'][0] self.pool.get('res.partner').write(cr, uid, partner_id, {'last_reconciliation_date': time.strftime('%Y-%m-%d')}, context) | partner_id = self.pool.get('account.move.line').read(cr, uid, context['active_id'], ['partner_id'])['partner_id'] if partner_id: self.pool.get('res.partner').write(cr, uid, partner_id[0], {'last_reconciliation_date': time.strftime('%Y-%m-%d')}, context) | def next_partner(self, cr, uid, ids, context=None): partner_id = self.pool.get('account.move.line').read(cr, uid, context['active_id'], ['partner_id'])['partner_id'][0] self.pool.get('res.partner').write(cr, uid, partner_id, {'last_reconciliation_date': time.strftime('%Y-%m-%d')}, context) #TODO: we have to find a way to update the context of the current tab (we could open a new tab with the context but it's not really handy) #TODO: remove that comments when the client side dev is done return {} |
res = res and res[0] or None | res = res and res[0] or 0.0 | def __pos_payment_user__total__(self, form): res=[] ids = form['user_id'] self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \ "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \ "and po.state='paid' and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date " \ "and po.user_id IN %s",(tuple(ids),)) res=self.cr.fetchone() res = res and res[0] or None |
journal_id, period_id = cr.fetchone() result['domain'] = str([('journal_id', '=', journal_id), ('period_id', '=', period_id)]) result['context'] = str({'journal_id': journal_id, 'period_id': period_id}) | res = cr.fetchone() if res: journal_id, period_id = res result['domain'] = str([('journal_id', '=', journal_id), ('period_id', '=', period_id)]) result['context'] = str({'journal_id': journal_id, 'period_id': period_id}) | def action_open_window(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') if context is None: context = {} |
current_period = self.pool.get('account.period').find(cr, uid)[0] | current_period = period_obj.find(cr, uid)[0] | def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): for arg in args: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = self.pool.get('account.period').find(cr, uid)[0] args.append(['period_id','in',[current_period]]) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] args.append(['period_id','in',ids]) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in args: args.remove(a) return super(account_entries_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order, context=context, count=count) |
current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] | current_year = fiscalyear_obj.find(cr, uid) ids = fiscalyear_obj.read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] | def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): for arg in args: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = self.pool.get('account.period').find(cr, uid)[0] args.append(['period_id','in',[current_period]]) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] args.append(['period_id','in',ids]) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in args: args.remove(a) return super(account_entries_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order, context=context, count=count) |
current_period = self.pool.get('account.period').find(cr, uid)[0] | current_period = period_obj.find(cr, uid)[0] | def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): todel=[] for arg in domain: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = self.pool.get('account.period').find(cr, uid)[0] domain.append(['period_id','in',[current_period]]) todel.append(arg) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] domain.append(['period_id','in',ids]) todel.append(arg) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in domain: domain.remove(a) return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context) |
current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] | current_year = fiscalyear_obj.find(cr, uid) ids = fiscalyear_obj.read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] | def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): todel=[] for arg in domain: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = self.pool.get('account.period').find(cr, uid)[0] domain.append(['period_id','in',[current_period]]) todel.append(arg) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = self.pool.get('account.fiscalyear').find(cr, uid) ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] domain.append(['period_id','in',ids]) todel.append(arg) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in domain: domain.remove(a) return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context) |
rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False | rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value_reference','res_id']) pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value_reference','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value_reference'].split(',')[1]) or False | def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False acc_id = False bank_id = False fiscal_position = False |
rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False | rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value_reference','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value_reference','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value_reference'].split(',')[1]) or False | def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not pay_res_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} account_obj = self.pool.get('account.account') if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = account_obj.browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configuration Error !'), _('Invoice line account company does not match with invoice company.')) else: continue if company_id and type: if type in ('out_invoice'): journal_type = 'sale' elif type in ('out_refund'): journal_type = 'sale_refund' elif type in ('in_refund'): journal_type = 'purchase_refund' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configuration Error !'), _('Can\'t find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Financial Accounting\Accounts\Journals.' % (journal_type))) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, []) |
if not name: result['name'] = res.partner_ref | result['name'] = res.partner_ref | def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos_obj = self.pool.get('account.fiscal.position') fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id) or False |
result[bom.id] += map(lambda x: x.id, bom2.bom_lines) print "name",name print "arg",arg print "result",result | result[bom.id] += map(lambda x: x.id, bom2.bom_lines) | def _child_compute(self, cr, uid, ids, name, arg, context={}): """ @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID of mrp.production object @param name: @param arg: |
'readonly': True, | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) pick_obj = self.pool.get('stock.picking') picking_ids = context.get('active_ids', False) _moves_arch_lst = """<form string="Deliver Products"> <separator colspan="4" string="Delivery Information"/> <group colspan="4" col="4"> <field name="date"/> </group> <separator colspan="4" string="Move Detail"/> """ _moves_fields = result['fields'] if picking_ids and view_type in ['form']: for pick in pick_obj.browse(cr, uid, picking_ids, context): for m in pick.move_lines: if m.state in ('done', 'cancel'): continue _moves_fields.update({ 'move%s_product_id'%(m.id) : { 'string': _('Product'), 'type' : 'many2one', 'relation': 'product.product', 'required' : True, 'readonly' : True, }, 'move%s_product_qty'%(m.id) : { 'string': _('Quantity'), 'type' : 'float', 'required': True, }, 'move%s_product_uom'%(m.id) : { 'string': _('Product UOM'), 'type' : 'many2one', 'relation': 'product.uom', 'required' : True, 'readonly' : True, }, 'move%s_prodlot_id'%(m.id): { 'string': _('Production Lot'), 'type': 'many2one', 'relation': 'stock.production.lot', 'readonly': True, } }) |
|
to_char(s.create_date, 'MM'),h.user_id,h.state, h.category_id, h.department_id | to_char(s.create_date, 'MM'), to_char(s.create_date, 'YYYY-MM-DD'), h.user_id,h.state, h.category_id, h.department_id | def init(self, cr): tools.drop_view_if_exists(cr, 'available_holidays_report') cr.execute(""" create or replace view available_holidays_report as ( select min(h.id) as id, date_trunc('day',h.create_date) as date, to_char(s.create_date, 'YYYY') as year, to_char(s.create_date, 'MM') as month, to_char(s.create_date, 'YYYY-MM-DD') as day, h.employee_id as employee_id, h.category_id as category_id, h.user_id as user_id, h.department_id, h.state as state, h.holiday_status_id as holiday_status_id, sum(number_of_days) as remaining_leave, (select sum(number_of_days_temp) from hr_holidays where type='remove' and employee_id=h.employee_id and holiday_status_id=h.holiday_status_id and state='validate') as taken_leaves, (select sum(number_of_days_temp) from hr_holidays where type='add' and employee_id=h.employee_id and holiday_status_id=h.holiday_status_id and state='validate') as max_leave from hr_holidays h left join hr_holidays_status s on (s.id = h.holiday_status_id) where h.state='validate' and s.active <> 'f' group by h.holiday_status_id, h.employee_id, date_trunc('day',h.create_date),to_char(s.create_date, 'YYYY'), to_char(s.create_date, 'MM'),h.user_id,h.state, h.category_id, h.department_id |
srctz = pytz.timezone('GMT') date_gmt = date_1.replace(tzinfo=srctz).astimezone(desttz).strftime('%Y-%m-%d %H:%M:%S') | date_gmt = date_1.replace(tzinfo=pytz.utc).astimezone(desttz).strftime('%Y-%m-%d %H:%M:%S') | 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 """ |
msg['subject'] = msg_txt.get('Subject') | msg['subject'] = ' '.join(map(lambda (x, y): unicode(x, y or 'ascii'), decode_header(msg_txt.get('Subject')))) | def _process_email(self, cr, uid, server, message, context={}): context.update({ 'server_id':server.id }) history_pool = self.pool.get('mail.server.history') msg_txt = email.message_from_string(message) message_id = msg_txt.get('Message-ID', False) msg = {} if not message_id: return False fields = msg_txt.keys() msg['id'] = message_id msg['message-id'] = message_id if 'Subject' in fields: msg['subject'] = msg_txt.get('Subject') if 'Content-Type' in fields: msg['content-type'] = msg_txt.get('Content-Type') if 'From' in fields: msg['from'] = msg_txt.get('From') if 'Delivered-To' in fields: msg['to'] = msg_txt.get('Delivered-To') if 'Cc' in fields: msg['cc'] = msg_txt.get('Cc') if 'Reply-To' in fields: msg['reply'] = msg_txt.get('Reply-To') if 'Date' in fields: msg['date'] = msg_txt.get('Date') if 'Content-Transfer-Encoding' in fields: msg['encoding'] = msg_txt.get('Content-Transfer-Encoding') if 'References' in fields: msg['references'] = msg_txt.get('References') |
query = "SELECT id FROM account_fiscalyear WHERE date_stop < '" + str(new_fyear.date_start) + "'" cr.execute(query) result = cr.dictfetchall() fy_ids = ','.join([str(x['id']) for x in result]) | def _data_save(self, cr, uid, data, context): if not data['form']['sure']: raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year cancelled, please check the box !')) pool = pooler.get_pool(cr.dbname) fy_id = data['form']['fy_id'] period_ids = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', fy_id)]) fy_period_set = ','.join(map(str, period_ids)) periods_fy2 = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fy2_id'])]) fy2_period_set = ','.join(map(str, periods_fy2)) period = pool.get('account.period').browse(cr, uid, data['form']['period_id'], context=context) new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'], context=context) old_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy_id'], context=context) new_journal = data['form']['journal_id'] new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context) if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id: raise wizard.except_wizard(_('UserError'), _('The journal must have default credit and debit account')) if not new_journal.centralisation: raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart')) move_ids = pool.get('account.move.line').search(cr, uid, [ ('journal_id','=',new_journal.id),('period_id.fiscalyear_id','=',new_fyear.id)]) if move_ids: raise wizard.except_wizard(_('UserError'), _('The opening journal must not have any entry in the new fiscal year !')) query_line = pool.get('account.move.line')._query_get(cr, uid, obj='account_move_line', context={'fiscalyear': fy_id}) cr.execute('select id from account_account WHERE active') ids = map(lambda x: x[0], cr.fetchall()) for account in pool.get('account.account').browse(cr, uid, ids, context={'fiscalyear': fy_id}): accnt_type_data = account.user_type if not accnt_type_data: continue if accnt_type_data.close_method=='none' or account.type == 'view': continue if accnt_type_data.close_method=='balance': if abs(account.balance)>0.0001: pool.get('account.move.line').create(cr, uid, { 'debit': account.balance>0 and account.balance, 'credit': account.balance<0 and -account.balance, 'name': data['form']['report_name'], 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, 'account_id': account.id }, {'journal_id': new_journal.id, 'period_id':period.id}) if accnt_type_data.close_method == 'unreconciled': offset = 0 limit = 100 while True: cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'AND reconcile_id is NULL ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, 'period_id': period.id, }) offset += limit #We have also to consider all move_lines that were reconciled #on another fiscal year, and report them too offset = 0 limit = 100 while True: #TODO: this query could be improved in order to work if there is more than 2 open FY # a.period_id IN ('+fy2_period_set+') is the problematic clause cr.execute('SELECT b.id, b.name, b.quantity, b.debit, b.credit, b.account_id, b.ref, ' \ 'b.amount_currency, b.currency_id, b.blocked, b.partner_id, ' \ 'b.date_maturity, b.date_created ' \ 'FROM account_move_line a, account_move_line b ' \ 'WHERE b.account_id = %s ' \ 'AND b.reconcile_id is NOT NULL ' \ 'AND a.reconcile_id = b.reconcile_id ' \ 'AND b.period_id IN ('+fy_period_set+') ' \ 'AND a.period_id IN ('+fy2_period_set+') ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, 'period_id': period.id, }) offset += limit if accnt_type_data.close_method=='detail': offset = 0 limit = 100 while True: cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move) offset += limit ids = pool.get('account.move.line').search(cr, uid, [('journal_id','=',new_journal.id), ('period_id.fiscalyear_id','=',new_fyear.id)]) context['fy_closing'] = True if ids: pool.get('account.move.line').reconcile(cr, uid, ids, context=context) new_period = data['form']['period_id'] ids = pool.get('account.journal.period').search(cr, uid, [('journal_id','=',new_journal.id),('period_id','=',new_period)]) if not ids: ids = [pool.get('account.journal.period').create(cr, uid, { 'name': (new_journal.name or '')+':'+(period.code or ''), 'journal_id': new_journal.id, 'period_id': period.id })] cr.execute('UPDATE account_fiscalyear ' \ 'SET end_journal_period_id = %s ' \ 'WHERE id = %s', (ids[0], old_fyear.id)) return {} |
|
obj='account_move_line', context={'fiscalyear': fy_id}) | obj='account_move_line', context={'fiscalyear': fy_ids}) | def _data_save(self, cr, uid, data, context): if not data['form']['sure']: raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year cancelled, please check the box !')) pool = pooler.get_pool(cr.dbname) fy_id = data['form']['fy_id'] period_ids = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', fy_id)]) fy_period_set = ','.join(map(str, period_ids)) periods_fy2 = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fy2_id'])]) fy2_period_set = ','.join(map(str, periods_fy2)) period = pool.get('account.period').browse(cr, uid, data['form']['period_id'], context=context) new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'], context=context) old_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy_id'], context=context) new_journal = data['form']['journal_id'] new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context) if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id: raise wizard.except_wizard(_('UserError'), _('The journal must have default credit and debit account')) if not new_journal.centralisation: raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart')) move_ids = pool.get('account.move.line').search(cr, uid, [ ('journal_id','=',new_journal.id),('period_id.fiscalyear_id','=',new_fyear.id)]) if move_ids: raise wizard.except_wizard(_('UserError'), _('The opening journal must not have any entry in the new fiscal year !')) query_line = pool.get('account.move.line')._query_get(cr, uid, obj='account_move_line', context={'fiscalyear': fy_id}) cr.execute('select id from account_account WHERE active') ids = map(lambda x: x[0], cr.fetchall()) for account in pool.get('account.account').browse(cr, uid, ids, context={'fiscalyear': fy_id}): accnt_type_data = account.user_type if not accnt_type_data: continue if accnt_type_data.close_method=='none' or account.type == 'view': continue if accnt_type_data.close_method=='balance': if abs(account.balance)>0.0001: pool.get('account.move.line').create(cr, uid, { 'debit': account.balance>0 and account.balance, 'credit': account.balance<0 and -account.balance, 'name': data['form']['report_name'], 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, 'account_id': account.id }, {'journal_id': new_journal.id, 'period_id':period.id}) if accnt_type_data.close_method == 'unreconciled': offset = 0 limit = 100 while True: cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'AND reconcile_id is NULL ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, 'period_id': period.id, }) offset += limit #We have also to consider all move_lines that were reconciled #on another fiscal year, and report them too offset = 0 limit = 100 while True: #TODO: this query could be improved in order to work if there is more than 2 open FY # a.period_id IN ('+fy2_period_set+') is the problematic clause cr.execute('SELECT b.id, b.name, b.quantity, b.debit, b.credit, b.account_id, b.ref, ' \ 'b.amount_currency, b.currency_id, b.blocked, b.partner_id, ' \ 'b.date_maturity, b.date_created ' \ 'FROM account_move_line a, account_move_line b ' \ 'WHERE b.account_id = %s ' \ 'AND b.reconcile_id is NOT NULL ' \ 'AND a.reconcile_id = b.reconcile_id ' \ 'AND b.period_id IN ('+fy_period_set+') ' \ 'AND a.period_id IN ('+fy2_period_set+') ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, 'period_id': period.id, }) offset += limit if accnt_type_data.close_method=='detail': offset = 0 limit = 100 while True: cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) result = cr.dictfetchall() if not result: break for move in result: move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, }) pool.get('account.move.line').create(cr, uid, move) offset += limit ids = pool.get('account.move.line').search(cr, uid, [('journal_id','=',new_journal.id), ('period_id.fiscalyear_id','=',new_fyear.id)]) context['fy_closing'] = True if ids: pool.get('account.move.line').reconcile(cr, uid, ids, context=context) new_period = data['form']['period_id'] ids = pool.get('account.journal.period').search(cr, uid, [('journal_id','=',new_journal.id),('period_id','=',new_period)]) if not ids: ids = [pool.get('account.journal.period').create(cr, uid, { 'name': (new_journal.name or '')+':'+(period.code or ''), 'journal_id': new_journal.id, 'period_id': period.id })] cr.execute('UPDATE account_fiscalyear ' \ 'SET end_journal_period_id = %s ' \ 'WHERE id = %s', (ids[0], old_fyear.id)) return {} |
'project_id':_get_project, | 'project_id':_get_project, 'probability':lambda *a:0.0, 'planned_cost':lambda *a:0.0, 'planned_revenue':lambda *a:0.0, | def onchange_stage_id(self, cr, uid, ids, stage_id, context={}): if not stage_id: return {'value':{}} stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context) if not stage.on_change: return {'value':{}} return {'value':{'probability':stage.probability}} |
for datas in self.read(cr, uid, ids): | for datas in self.read(cr, uid, ids, context=context): | def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Get rule string. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False elif datas.get('rrule_type') == 'custom': rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context) |
result[event] = False | result[datas['id']] = False | def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Get rule string. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False elif datas.get('rrule_type') == 'custom': rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context) |
rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom | rrule_custom = self.compute_rule_string(cr, uid, datas,\ context=context) result[datas['id']] = rrule_custom | def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Get rule string. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False elif datas.get('rrule_type') == 'custom': rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context) |
result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context) | result[datas['id']] = self.compute_rule_string(cr, uid, {'freq': datas.get('rrule_type').upper(), 'interval': 1}, context=context) | def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Get rule string. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids): if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False elif datas.get('rrule_type') == 'custom': rrule_custom = self.compute_rule_string(cr, uid, datas) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context) |
if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']] | fiscalyear_ids = [context['fiscalyear']] | def _query_get(self, cr, uid, obj='l', context=None): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') account_obj = self.pool.get('account.account') fiscalyear_ids = [] if context is None: context = {} initial_bal = context.get('initial_bal', False) company_clause = " " if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']] |
[res['base_pricelist_id']], prod_id, | [res['base_pricelist_id']], product_id, | def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst |
product.id, qty or 1.0, partner_id, {'uom': uom,'date': date_order })[pricelist] | product.id, qty or 1.0, partner_id, {'uom': uom,'date': date_order }) | def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True,date_order=False,packaging=False,fiscal_position=False, flag=False): |
new_list_price = product_uom_obj._compute_price(cr, uid, old_uom.id, list_price, uom) if(len(pricelists)>0 and pricelists[0]['visible_discount'] and list_price != 0): discount=(new_list_price-price) / new_list_price * 100 | new_list_price = get_real_price(list_price, product.id, pricelist) if(len(pricelists)>0 and pricelists[0]['visible_discount'] and list_price[pricelist] != 0): discount = (new_list_price - price) / new_list_price * 100 | def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True,date_order=False,packaging=False,fiscal_position=False, flag=False): |
_inherit = "project.projesct" | _inherit = "project.project" | def write(self, cr, uid, ids,vals,context=None): if context is None: context = {} if vals.get('project_id',False) or vals.get('name',False): vals_line = {} hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet') task_obj_l = self.browse(cr, uid, ids, context) if vals.get('project_id',False): project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id']) acc_id = project_obj.analytic_account_id.id |
'name':fields.char('Description', size=256, required=True), | 'name':fields.char('Memo', size=256, required=True), | def copy(self, cr, uid, id, default={}, context=None): res = { 'state':'draft', 'number':False, 'move_id':False, 'payment_ids':False } default.update(res) if 'date' not in default: default['date'] = time.strftime('%Y-%m-%d') return super(account_voucher, self).copy(cr, uid, id, default, context) |
att_val.update({ 'parent_ids': [(4, att.id)], 'ref': att.ref._name + ',' + str(att.ref.id) }) | if ref: att_val.update({ 'parent_ids': [(4, att.id)], 'ref': att.ref._name + ',' +str(att.ref.id) }) | def do_invite(self, cr, uid, ids, context={}): """ Invite attendee for meeting.. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of base calendar invite attendee’s IDs. @param context: A standard dictionary for contextual values @return: Dictionary of {}. """ for datas in self.read(cr, uid, ids): model = False model_field = False context_id = context and context.get('active_id', False) or False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context_id) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = [] mail_to = [] attendees = [] ref = {} |
'product_id': fields.many2one('product.product', 'Product', required=True), | 'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type', '<>', 'service')]), | def _stock_search(self, cr, uid, obj, name, args, context=None): """ Searches Ids of products @return: Ids of locations """ locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')]) cr.execute('''select prodlot_id, sum(qty) from stock_report_prodlots where location_id IN %s group by prodlot_id having sum(qty) '''+ str(args[0][1]) + str(args[0][2]),(tuple(locations),)) res = cr.fetchall() ids = [('id', 'in', map(lambda x: x[0], res))] return ids |
users = self.pool.get('res.users') users.write(cr, uid, users.search(cr, uid, [('action_id','=','Setup')], context=context), {'action_id': menu.id}, context=context) users.write(cr, uid, users.search(cr, uid, [('menu_id','=','Setup')], context=context), {'menu_id': menu.id}, context=context) | user = self.pool.get('res.users')\ .browse(cr, uid, uid, context=context) user.write({'action_id': menu.id, 'menu_id': menu.id}) | def set_default_menu(self, cr, uid, menu, context=None): users = self.pool.get('res.users') users.write(cr, uid, users.search(cr, uid, [('action_id','=','Setup')], context=context), {'action_id': menu.id}, context=context) users.write(cr, uid, users.search(cr, uid, [('menu_id','=','Setup')], context=context), {'menu_id': menu.id}, context=context) |
'A given user should only have menu item' | 'A given user should only have one menu item' | def get_default_menu(self, cr, uid, context=None): actions = self.pool.get('ir.actions.act_window') |
print p print p.property_account_receivable, p.property_account_receivable.company_id, p.property_account_payable, p.property_account_payable.company_id | def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): invoice_addr_id = False contact_addr_id = False partner_payment_term = False acc_id = False bank_id = False fiscal_position = False |
|
print '** la' | def move_line_id_payment_get(self, cr, uid, ids, *args): print '** la' if not ids: return [] result = self.move_line_id_payment_gets(cr, uid, ids, *args) return result.get(ids[0], []) |
|
print '** ICI' | def move_line_id_payment_gets(self, cr, uid, ids, *args): print '** ICI' res = {} if not ids: return res cr.execute('SELECT i.id, l.id '\ 'FROM account_move_line l '\ 'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\ 'WHERE i.id IN %s '\ 'AND l.account_id=i.account_id', (tuple(ids),)) for r in cr.fetchall(): res.setdefault(r[0], []) res[r[0]].append( r[1] ) return res |
|
'name': fields.char('Description',size=64,required=True), | 'name': fields.char('Description', size=1024, required=True), | def _get_log_ids(self, cr, uid, ids, field_names, arg, context={}): result = {} history_obj = False model_obj = self.pool.get('ir.model') if 'history_line' in field_names: history_obj = self.pool.get('crm.case.history') name = 'history_line' if 'log_ids' in field_names: history_obj = self.pool.get('crm.case.log') name = 'log_ids' if not history_obj: return result for case in self.browse(cr, uid, ids, context): model_ids = model_obj.search(cr, uid, [('model','=',case._name)]) history_ids = history_obj.search(cr, uid, [('model_id','=',model_ids[0]),('res_id','=',case.id)]) if history_ids: result[case.id] = {name:history_ids} else: result[case.id] = {name:[]} return result |
for lots in lots_obj.browse(cr, uid, record_ids): if lots.ach_uid: res['arch'] = """ <form title="Mapping Result"> <group col="2" colspan="2"> <label string="All objects are assigned to buyers !"/> <newline/> <button icon='gtk-cancel' special="cancel" string="Done" /> </group> </form> """ | try: for lots in lots_obj.browse(cr, uid, record_ids): if lots.ach_uid: res['arch'] = """ <form title="Mapping Result"> <group col="2" colspan="2"> <label string="All objects are assigned to buyers !"/> <newline/> <button icon='gtk-cancel' special="cancel" string="Done" /> </group> </form> """ except: return res | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Changes the view dynamically @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return: New arch of view. """ record_ids = context and context.get('active_ids', False) or False res = super(wiz_auc_lots_buyer_map, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) lots_obj = self.pool.get('auction.lots') if record_ids: for lots in lots_obj.browse(cr, uid, record_ids): if lots.ach_uid: res['arch'] = """ <form title="Mapping Result"> <group col="2" colspan="2"> <label string="All objects are assigned to buyers !"/> <newline/> <button icon='gtk-cancel' special="cancel" string="Done" /> </group> </form> """ return res |
if line.move_id.state <> 'draft': | if line.move_id.state <> 'draft' and (not line.journal_id.entry_posted): | def _update_check(self, cr, uid, ids, context={}): done = {} for line in self.browse(cr, uid, ids, context): if line.move_id.state <> 'draft': raise osv.except_osv(_('Error !'), _('You can not do this modification on a confirmed entry ! Please note that you can just change some non important fields !')) if line.reconcile_id: raise osv.except_osv(_('Error !'), _('You can not do this modification on a reconciled entry ! Please note that you can just change some non important fields !')) t = (line.journal_id.id, line.period_id.id) if t not in done: self._update_journal_check(cr, uid, line.journal_id.id, line.period_id.id, context) done[t] = True return True |
self.parent = self.context.get_dir_node(cr, dbro.parent_id.id) | self.parent = self.context.get_dir_node(cr, dbro.parent_id) | def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): """ Move directory. This operation is simple, since the present node is only used for static, simple directories. Note /may/ be called with ndir_node = None, to rename the document root. """ if ndir_node and (ndir_node.context != self.context): raise NotImplementedError("Cannot move directories between contexts") |
if ndir_node.context != self.context: | if ndir_node and ndir_node.context != self.context: | def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): if ndir_node.context != self.context: raise NotImplementedError("Cannot move files between contexts") |
self.parent = self.context.get_dir_node(cr, dbro.parent_id.id) | self.parent = self.context.get_dir_node(cr, dbro.parent_id) | def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): if ndir_node.context != self.context: raise NotImplementedError("Cannot move files between contexts") |
if self.parent != ndir_node: | if ndir_node and self.parent != ndir_node: | def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): if ndir_node.context != self.context: raise NotImplementedError("Cannot move files between contexts") |
'active': fields.boolean('Active', help="If the active field is set to\ true, it will allow you to hide the case without removing it."), | 'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the case without removing it."), | def _get_log_ids(self, cr, uid, ids, field_names, arg, context=None): """Gets id for case log from history of particular case @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Case IDs @param context: A standard dictionary for contextual values """ if not context: context = {} |
return all(procurement.move_id.state != 'cancel' for procurement in self.browse(cr, uid, ids)) | return all(procurement.move_id.state == 'cancel' for procurement in self.browse(cr, uid, ids)) | def check_move_cancel(self, cr, uid, ids, context={}): """ Checks if move is cancelled or not. @return: True or False. """ return all(procurement.move_id.state != 'cancel' for procurement in self.browse(cr, uid, ids)) |
scrpaed_location_ids = location_obj.search(cr, uid, [('scraped','=',True)]) | scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)]) | def default_get(self, cr, uid, fields, context=None): """ Get default values @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for default value @param context: A standard dictionary @return: default values of fields """ res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context) move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) location_obj = self.pool.get('stock.location') scrpaed_location_ids = location_obj.search(cr, uid, [('scraped','=',True)]) if 'product_id' in fields: res.update({'product_id': move.product_id.id}) if 'product_uom' in fields: res.update({'product_uom': move.product_uom.id}) if 'product_qty' in fields: res.update({'product_qty': move.product_qty}) if 'location_id' in fields: if scrpaed_location_ids: res.update({'location_id': scrpaed_location_ids[0]}) else: res.update({'location_id': False}) return res |
def _compute(self, cr, uid, ids, context=None): | def _compute(self, cr, uid, ids,field_name, arg, context=None): | def _compute(self, cr, uid, ids, context=None): res = {} if not ids: return res for phase in self.browse(cr, uid, ids, context=context): tot = 0.0 for task in phase.task_ids: tot += task.planned_hours res[phase.id] = { 'total_hours' : tot } return res |
res[phase.id] = { 'total_hours' : tot } | res[phase.id] = tot | def _compute(self, cr, uid, ids, context=None): res = {} if not ids: return res for phase in self.browse(cr, uid, ids, context=context): tot = 0.0 for task in phase.task_ids: tot += task.planned_hours res[phase.id] = { 'total_hours' : tot } return res |
def onchange_days(self, cr, uid, ids, project, context=None): result = {} for id in ids: project_id = self.browse(cr, uid, id, context=context) newdate = datetime.strptime(project_id.date_start, '%Y-%m-%d') + relativedelta(days=project_id.duration or 0.0) result['date_end'] = newdate.strftime('%Y-%m-%d') return {'value': result} | def onchange_days(self, cr, uid, ids, project, context=None): result = {} for id in ids: project_id = self.browse(cr, uid, id, context=context) newdate = datetime.strptime(project_id.date_start, '%Y-%m-%d') + relativedelta(days=project_id.duration or 0.0) result['date_end'] = newdate.strftime('%Y-%m-%d') return {'value': result} |
|
'date_start': time.strftime('%Y-01-01'), 'date_stop': time.strftime('%Y-12-31'), | 'date_start': lambda *a: time.strftime('%Y-01-01'), 'date_stop': lambda *a: time.strftime('%Y-12-31'), | def _get_default_charts(self, cr, uid, context=None): module_name = False company_id = self._default_company(cr, uid, context=context) company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) address_id = self.pool.get('res.partner').address_get(cr, uid, [company.partner_id.id]) if address_id['default']: address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default'], context=context) code = address.country_id.code module_name = (code and 'l10n_' + code.lower()) or False if module_name: module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)], context=context) if module_id: return module_name return 'configurable' |
'department_id': fields.related('employee_id','department_id', string="Department", readonly=True), | 'department_id': fields.related('employee_id','department_id', type='many2one', relation='hr.department', string="Department", readonly=True), | def _get_latest_contract(self, cr, uid, ids, field_name, args, context=None): res = {} obj_contract = self.pool.get('hr.contract') for emp in self.browse(cr, uid, ids, context=context): contract_ids = obj_contract.search(cr, uid, [('employee_id','=',emp.id),], order='date_start', context=context) if contract_ids: res[emp.id] = contract_ids[-1:][0] else: res[emp.id] = False return res |
vals = {} | vals = [] | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \ |
vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} | ref = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \ |
vals.update({'user_id': user_id, 'email': user.address_id.email}) | res = { 'user_id': user_id, 'email': user.address_id.email } res.update(ref) vals.append(res) | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \ |
vals.update({'email': datas['email']}) | vals.append({'email': datas['email']}) | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \ |
vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) | res = { 'partner_address_id': contact.id, 'email': contact.email } res.update(ref) vals.append(res) | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \ |
att_obj._send_mail(cr, uid, [att_id], mail_to, \ | att_obj._send_mail(cr, uid, attendees, mail_to, \ | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \ |
att_id = att_obj.create(cr, uid, vals) if model_field: obj.write(cr, uid, res_obj.id, {model_field: [(4, att_id)]}) | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \ |
|
value = {} | def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, context={}): if not start_date: return {} start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S") value = {} if end_date and not duration: end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S") diff = end - start duration = float(diff.days)* 24 + (float(diff.seconds) / 3600) value['duration'] = round(duration, 2) elif not end_date: end = start + timedelta(hours=duration) value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S") return {'value': value} |
|
loc_ids = location_obj.search(cr, uid,[('usage','=','internal')]) | def do_change_standard_price(self, cr, uid, ids, datas, context={}): """ Changes the Standard Price of Product and creates an account move accordingly. @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal @param context: A standard dictionary @return: """ location_obj = self.pool.get('stock.location') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line') |
|
'location_id': fields.dummy(string='Location', relation='stock.location', type='many2one', domain=[('usage','=','internal')]), | 'location_id': fields.dummy(string='Location', relation='stock.location', type='many2one'), | def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}): """ Finds the incoming and outgoing quantity of product. @return: Dictionary of values """ if not field_names: field_names = [] res = {} for id in ids: res[id] = {}.fromkeys(field_names, 0.0) for f in field_names: c = context.copy() if f == 'qty_available': c.update({ 'states': ('done',), 'what': ('in', 'out') }) if f == 'virtual_available': c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out') }) if f == 'incoming_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('in',) }) if f == 'outgoing_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('out',) }) stock = self.get_product_available(cr, uid, ids, context=c) for id in ids: res[id][f] = stock.get(id, 0.0) return res |
def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} | def onchange_planned(self, cr, uid, ids, planned = 0.0, effective = 0.0): return {'value':{'remaining_hours': planned - effective}} |
|
'name': product.partner_ref, | def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False, address_id=False): if not prod_id: return {} lang = False if address_id: addr_rec = self.pool.get('res.partner.address').browse(cr, uid, address_id) if addr_rec: lang = addr_rec.partner_id and addr_rec.partner_id.lang or False ctx = {'lang': lang} |
|
if not ids: result['name'] = product.partner_ref | def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False, address_id=False): if not prod_id: return {} lang = False if address_id: addr_rec = self.pool.get('res.partner.address').browse(cr, uid, address_id) if addr_rec: lang = addr_rec.partner_id and addr_rec.partner_id.lang or False ctx = {'lang': lang} |
|
wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.id, context) | wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.warehouse_id.id, context) | def make_procurement(self, cr, uid, ids, context=None): '''Create procurement''' for proc in self.browse(cr, uid, ids): wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.id, context) user = self.pool.get('res.users').browse(cr, uid, uid, context) procure_id = self.pool.get('mrp.procurement').create(cr, uid, { 'name':'INT:'+str(user.login), 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.qty, 'product_uom': proc.uom_id.id, 'location_id': wh.lot_stock_id.id, 'procure_method':'make_to_order', }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr) data_obj = self.pool.get('ir.model.data') id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view') id3 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_form_view') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'mrp.procurement', 'res_id' : procure_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window', } |
'bank': fields.many2one('res.bank', 'Bank'), | 'bank': fields.many2one('res.bank', 'Bank', required=True), | def _default_value(self, cursor, user, field, context=None): if field in ('country_id', 'state_id'): value = False else: value = '' if not context.get('address', False): return value for ham, spam, address in context['address']: if address.get('type', False) == 'default': return address.get(field, value) elif not address.get('type', False): value = address.get(field, value) return value |
a = repair.partner_id.property_account_receivable.id | if not repair.partner_id.property_account_receivable: raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name ) account_id = repair.partner_id.property_account_receivable.id | def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id}) |
'account_id': a, | 'account_id': account_id, | def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id}) |
'account_id': operation.product_id and operation.product_id.property_account_income and operation.product_id.property_account_income.id, | 'account_id': account_id, | def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id}) |
check = int(10 - math.ceil(total % 10.0)) | check = int(10 - math.ceil(total % 10.0)) %10 | def check_ean(eancode): if not eancode: return True if len(eancode) <> 13: return False try: int(eancode) except: return False oddsum=0 evensum=0 total=0 eanvalue=eancode reversevalue = eanvalue[::-1] finalean=reversevalue[1:] for i in range(len(finalean)): if is_pair(i): oddsum += int(finalean[i]) else: evensum += int(finalean[i]) total=(oddsum * 3) + evensum check = int(10 - math.ceil(total % 10.0)) if check != int(eancode[-1]): return False return True |
'base':fields.char('Based on', size=64, required=True, readonly=False, help='This will use to computer the % fields values, in general its on basic, but You can use all heads code field in small letter as a variable name i.e. hra, ma, lta, etc...., also you can use, static varible basic'), | 'base': fields.text('Based on', required=True, readonly=False, help='This will use to computer the % fields values, in general its on basic, but You can use all heads code field in small letter as a variable name i.e. hra, ma, lta, etc...., also you can use, static varible basic'), | def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res |
if line.category_id.register_id: ctr = { 'register_id':line.category_id.register_id.id, 'name':line.name, 'code':line.code, 'employee_id':slip.employee_id.id, 'period_id':period_id, 'emp_deduction':amount, } if line.category_id.contribute: ctr['comp_deduction'] = amount company = 0.0 employee = 0.0 if line.category_id.contribute and line.category_id.include_in_salary and line.category_id.amount_type == 'per': new_amount = (amount * (line.category_id.contribute_per / (1+line.category_id.contribute_per))) company = new_amount employee = amount - company elif line.category_id.contribute and line.category_id.include_in_salary and line.category_id.amount_type == 'fix': company = line.category_id.contribute_per employee = amount - company elif line.category_id.contribute and line.category_id.include_in_salary and line.category_id.amount_type == 'func': company = self.pool.get('hr.allounce.deduction.categoty').execute_function(cr, uid, line.category_id.id, line.slip_id.basic, context) employee = amount elif line.category_id.contribute and not line.category_id.include_in_salary and line.category_id.amount_type == 'per': company = amount * line.category_id.contribute_per employee = amount elif line.category_id.contribute and not line.category_id.include_in_salary and line.category_id.amount_type == 'fix': company = line.category_id.contribute_per employee = amount elif line.category_id.contribute and not line.category_id.include_in_salary and line.category_id.amount_type == 'func': company = self.pool.get('hr.allounce.deduction.categoty').execute_function(cr, uid, line.category_id.id, line.slip_id.basic, context) employee = amount ctr['emp_deduction'] = employee ctr['comp_deduction'] = company self.pool.get('hr.contibution.register.line').create(cr, uid, ctr) | def verify_sheet(self, cr, uid, ids, context={}): move_pool = self.pool.get('account.move') movel_pool = self.pool.get('account.move.line') exp_pool = self.pool.get('hr.expense.expense') for slip in self.browse(cr,uid,ids): total_deduct = 0.0 line_ids = [] partner = False partner_id = False if not slip.employee_id.address_home_id: raise osv.except_osv(_('Integrity Error !'), _('Please defined the Employee Home Address Along with Partners !!')) if not slip.employee_id.address_home_id.partner_id: raise osv.except_osv(_('Integrity Error !'), _('Please defined the Partner in Home Address !!')) partner = slip.employee_id.address_home_id.partner_id partner_id = slip.employee_id.address_home_id.partner_id.id period_id = False if slip.period_id: period_id = slip.period_id.id else: fiscal_year_ids = self.pool.get('account.fiscalyear').search(cr, uid, []) if not fiscal_year_ids: raise osv.except_osv(_('Warning !'), _('Please define fiscal year for perticular contract')) fiscal_year_objs = self.pool.get('account.fiscalyear').read(cr, uid, fiscal_year_ids, ['date_start','date_stop']) year_exist = False for fiscal_year in fiscal_year_objs: if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)): year_exist = True if not year_exist: raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s'%slip.date)) search_period = self.pool.get('account.period').search(cr,uid,[('date_start','<=',slip.date),('date_stop','>=',slip.date)]) if not search_period: raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s'%slip.date)) period_id = search_period[0] move = { #'name': slip.name, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'date': slip.date, 'ref':slip.number, 'narration': slip.name } move_id = move_pool.create(cr, uid, move) self.create_voucher(cr, uid, [slip.id], slip.name, move_id) line = { 'move_id':move_id, 'name': "By Basic Salary / " + slip.employee_id.name, 'date': slip.date, 'account_id': slip.employee_id.salary_account.id, 'debit': slip.basic, 'credit': 0.0, 'quantity':slip.working_days, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'analytic_account_id': False, 'ref':slip.number } #Setting Analysis Account for Basic Salary if slip.employee_id.analytic_account: line['analytic_account_id'] = slip.employee_id.analytic_account.id move_line_id = movel_pool.create(cr, uid, line) line_ids += [move_line_id] line = { 'move_id':move_id, 'name': "To Basic Paysble Salary / " + slip.employee_id.name, 'partner_id': partner_id, 'date': slip.date, 'account_id': slip.employee_id.employee_account.id, 'debit': 0.0, 'quantity':slip.working_days, 'credit': slip.basic, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, line)] for line in slip.line_ids: name = "[%s] - %s / %s" % (line.code, line.name, slip.employee_id.name) amount = line.total if line.type == 'leaves': continue rec = { 'move_id':move_id, 'name': name, 'date': slip.date, 'account_id': line.account_id.id, 'debit': 0.0, 'credit' : 0.0, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'analytic_account_id':False, 'ref':slip.number, 'quantity':1 } #Setting Analysis Account for Salary Slip Lines if line.analytic_account_id: rec['analytic_account_id'] = line.analytic_account_id.id else: rec['analytic_account_id'] = slip.deg_id.account_id.id if line.type == 'allounce' or line.type == 'otherpay': rec['debit'] = amount if not partner.property_account_payable: raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Payable Account!!')) ded_rec = { 'move_id':move_id, 'name': name, 'partner_id': partner_id, 'date': slip.date, 'account_id': partner.property_account_payable.id, 'debit': 0.0, 'quantity':1, 'credit' : amount, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, ded_rec)] elif line.type == 'deduction' or line.type == 'otherdeduct': if not partner.property_account_receivable: raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Receivable Account!!')) rec['credit'] = amount total_deduct += amount ded_rec = { 'move_id':move_id, 'name': name, 'partner_id': partner_id, 'date': slip.date, 'quantity':1, 'account_id': partner.property_account_receivable.id, 'debit': amount, 'credit' : 0.0, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, ded_rec)] line_ids += [movel_pool.create(cr, uid, rec)] if line.company_contrib > 0: company_contrib = line.company_contrib |
|
for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name | def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count |
|
if line.amount_type in ('fix', 'per'): value = line.amount elif line.amount_type == 'func': | if line.amount_type == 'func': | def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count |
count = 0 | def button_confirm_login(self, cr, uid, ids, context={}): for server in self.browse(cr, uid, ids, context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) count = 0 try: if server.type == 'imap': imap_server = None if server.is_ssl: imap_server = IMAP4_SSL(server.server, int(server.port)) else: imap_server = IMAP4(server.server, int(server.port)) |
|
"http://calendarserver.org/ns/" : ('getctag',), | "DAV:": ('principal-collection-set'), "http://cal.me.com/_namespace/" : ('user-state'), "http://calendarserver.org/ns/" : ( 'dropbox-home-URL', 'notification-URL', 'getctag',), | def _get_dav_getctag(self, cr): result = self.get_etag(cr) return str(result) |
def _get_caldav_calendar_data(self, cr): return self.get_data(cr) def _get_caldav_calendar_description(self, cr): uid = self.context.uid calendar_obj = self.context._dirobj.pool.get('basic.calendar') ctx = self.context.context.copy() ctx.update(self.dctx) calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx) return calendar.description def _get_caldav_calendar_home_set(self, cr): import xml.dom.minidom import urllib uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) calendar_obj = self.context._dirobj.pool.get('basic.calendar') calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx) huri = doc.createTextNode(urllib.quote('/%s/%s' % (cr.dbname, calendar.collection_id.name))) href = doc.documentElement href.tagName = 'D:href' href.appendChild(huri) return href def _get_caldav_calendar_user_address_set(self, cr): import xml.dom.minidom dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) user_obj = self.context._dirobj.pool.get('res.users') user = user_obj.browse(cr, uid, uid, context=ctx) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) href = doc.documentElement href.tagName = 'D:href' huri = doc.createTextNode('MAILTO:' + user.email) href.appendChild(huri) return href def _get_caldav_schedule_inbox_URL(self, cr): import xml.dom.minidom import urllib uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) calendar_obj = self.context._dirobj.pool.get('basic.calendar') calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx) res = '%s/%s' %(calendar.name, calendar.collection_id.name) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) href = doc.documentElement href.tagName = 'D:href' huri = doc.createTextNode(urllib.quote('/%s/%s' % (cr.dbname, res))) href.appendChild(huri) return href | def _get_ttag(self,cr): res = False if self.model and self.res_id: res = '%s_%d' % (self.model, self.res_id) elif self.calendar_id: res = '%d' % (self.calendar_id) return res |
|
def _get_caldav_schedule_outbox_URL(self, cr): return self._get_caldav_schedule_inbox_URL(cr) | def _get_caldav_schedule_outbox_URL(self, cr): return self._get_caldav_schedule_inbox_URL(cr) |
|
order_obj = self.pool.get('payment.order') | def search_entries(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line') mod_obj = self.pool.get('ir.model.data') if context is None: context = {} data = self.read(cr, uid, ids, [], context=context)[0] search_due_date = data['duedate'] |
|
self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context) | self.create_move_from_st_line(cr, uid, st_line, company_currency_id, st_line_number, context) | def button_confirm_bank(self, cr, uid, ids, context=None): done = [] obj_seq = self.pool.get('ir.sequence') if context is None: context = {} |
p.sale_id,sum(m.product_qty), m.state | p.sale_id,sum(m.product_qty), mp.state as mp_state | def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res |
p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': | p.sale_id = ANY(%s) GROUP BY mp.state, p.sale_id''') for oid, nbr, mp_state in cr.fetchall(): if mp_state == 'cancel': | def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res |
if state == 'done': | if mp_state == 'done': | def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res |
'user_id':fields.many2one('res.users', 'Responsible', readonly=True), | def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_report') cr.execute(""" create or replace view purchase_report as ( select min(l.id) as id, s.date_order as date, to_char(s.date_order, 'YYYY') as name, to_char(s.date_order, 'MM') as month, s.state, s.warehouse_id as warehouse_id, s.partner_id as partner_id, s.fiscal_position, s.create_uid as user_id, s.company_id as company_id, s.invoice_method, l.product_id, s.location_id as location_id, sum(l.product_qty*u.factor) as quantity, count(*) as nbr, sum(l.product_qty*l.price_unit) as price_total, (sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average from purchase_order s left join purchase_order_line l on (s.id=l.order_id) left join product_uom u on (u.id=l.product_uom) where l.product_id is not null group by s.company_id, s.create_uid, s.partner_id, s.location_id, l.product_id, s.date_order, to_char(s.date_order, 'YYYY'), to_char(s.date_order, 'MM'), s.state, s.warehouse_id, s.fiscal_position, s.invoice_method ) """) |
|
create_uid as user_id, | def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_order_qty_amount') cr.execute(""" create or replace view purchase_order_qty_amount as ( select min(id) as id, to_char(create_date, 'MM') as month, sum(product_qty) as total_qty, create_uid as user_id, sum(price_unit*product_qty) as total_amount from purchase_order_line where to_char(create_date,'YYYY') = to_char(current_date,'YYYY') group by to_char(create_date, 'MM'), create_uid |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.