bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0, skip=0): line = datas[position] row = {} warning = [] data_res_id = False nbrmax = position+1
def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0, skip=0): line = datas[position] row = {} warning = [] data_res_id = False nbrmax = position+1
468,900
def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0, skip=0): line = datas[position] row = {} warning = [] data_res_id = False nbrmax = position+1
def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0, skip=0): line = datas[position] row = {} warning = [] data_res_id = False nbrmax = position+1
468,901
fields_def = self.fields_get(cr, uid, context=context)
fields_def = self.fields_get(cr, uid, context=context)
468,902
fields_def = self.fields_get(cr, uid, context=context)
fields_def = self.fields_get(cr, uid, context=context)
468,903
def _get_source(self, cr, uid, name, types, lang, source=None): """ Returns the translation for the given combination of name, type, language and source. All values passed to this method should be unicode (not byte strings), especially ``source``.
def _get_source(self, cr, uid, name, types, lang, source=None): """ Returns the translation for the given combination of name, type, language and source. All values passed to this method should be unicode (not byte strings), especially ``source``.
468,904
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
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, new_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
468,905
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
def _get_bal(self,data): res = {} sql =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d """%(data['id']) self.cr.execute(sql) res = self.cr.dictfetchall() if res : return res[0]['bal'] else : return False
468,906
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
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 account_cashbox_line 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
468,907
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 {}
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'] if partner_id: self.pool.get('res.partner').write(cr, uid, partner_id[0], {'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 {}
468,908
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
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
468,909
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 = {}
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 = {}
468,910
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)
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 = period_obj.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)
468,911
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)
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 = fiscalyear_obj.find(cr, uid) ids = fiscalyear_obj.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)
468,912
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)
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 = period_obj.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)
468,913
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)
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 = fiscalyear_obj.find(cr, uid) ids = fiscalyear_obj.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)
468,914
def read_group(self, cr, user, ids, fields, groupby, context=None): context = context or {} result = [] if not ids:return
def read_group(self, cr, user, ids, fields, groupby, context=None): context = context or {} result = [] if not ids:return
468,915
def read_group(self, cr, user, ids, fields, groupby, context=None): context = context or {} result = [] if not ids:return
def read_group(self, cr, user, ids, fields, groupby, context=None): context = context or {} result = [] if not ids:return
468,916
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
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
468,917
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, [])
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_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 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, [])
468,918
def copy(self, cr, uid, id, default={}, context=None): default.update({ 'state':'draft', 'number':False, 'move_id':False, 'move_name':False, 'internal_number': False, }) if 'date_invoice' not in default: default.update({ 'date_invoice':False }) if 'date_due' not in default: default.update({ 'date_due':False }) return super(account_invoice, self).copy(cr, uid, id, default, context)
def copy(self, cr, uid, id, default={}, context=None): default.update({ 'state':'draft', 'number':False, 'move_id':False, 'move_name':False, 'internal_number': False, }) if 'date_invoice' not in default: default.update({ 'date_invoice':False }) if 'date_due' not in default: default.update({ 'date_due':False }) return super(account_invoice, self).copy(cr, uid, id, default, context)
468,919
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference or ''
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference or ''
468,920
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference or ''
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference or ''
468,921
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference or ''
def action_number(self, cr, uid, ids, *args): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference or ''
468,922
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
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
468,923
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:
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:
468,924
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:
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:
468,925
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, } })
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', } })
468,926
def upgrade_graph(graph, cr, module_list, force=None): if force is None: force = [] packages = [] len_graph = len(graph) for module in module_list: mod_path = get_module_path(module) terp_file = get_module_resource(module, '__terp__.py') if not mod_path or not terp_file: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable' % (module)) cr.execute("update ir_module_module set state=%s where name=%s", ('uninstallable', module)) continue if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'): try: info = eval(tools.file_open(terp_file).read()) except: logger.notifyChannel('init', netsvc.LOG_ERROR, 'module %s: eval file %s' % (module, terp_file)) raise if info.get('installable', True): packages.append((module, info.get('depends', []), info)) dependencies = dict([(p, deps) for p, deps, data in packages]) current, later = set([p for p, dep, data in packages]), set() while packages and current > later: package, deps, data = packages[0] # if all dependencies of 'package' are already in the graph, add 'package' in the graph if reduce(lambda x, y: x and y in graph, deps, True): if not package in current: packages.pop(0) continue later.clear() current.remove(package) graph.addNode(package, deps) node = Node(package, graph) node.data = data for kind in ('init', 'demo', 'update'): if package in tools.config[kind] or 'all' in tools.config[kind] or kind in force: setattr(node, kind, True) else: later.add(package) packages.append((package, deps, data)) packages.pop(0) graph.update_from_db(cr) for package in later: unmet_deps = filter(lambda p: p not in graph, dependencies[package]) logger.notifyChannel('init', netsvc.LOG_ERROR, 'module %s: Unmet dependencies: %s' % (package, ', '.join(unmet_deps))) result = len(graph) - len_graph if result != len(module_list): logger.notifyChannel('init', netsvc.LOG_WARNING, 'Not all modules have loaded.') return result
def upgrade_graph(graph, cr, module_list, force=None): if force is None: force = [] packages = [] len_graph = len(graph) for module in module_list: mod_path = get_module_path(module) terp_file = get_module_resource(module, '__terp__.py') if not mod_path or not terp_file: logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable' % (module)) raise osv.osv.except_osv('Error!',"Module '%s' was not found" % (module,)) if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'): try: info = eval(tools.file_open(terp_file).read()) except: logger.notifyChannel('init', netsvc.LOG_ERROR, 'module %s: eval file %s' % (module, terp_file)) raise if info.get('installable', True): packages.append((module, info.get('depends', []), info)) dependencies = dict([(p, deps) for p, deps, data in packages]) current, later = set([p for p, dep, data in packages]), set() while packages and current > later: package, deps, data = packages[0] # if all dependencies of 'package' are already in the graph, add 'package' in the graph if reduce(lambda x, y: x and y in graph, deps, True): if not package in current: packages.pop(0) continue later.clear() current.remove(package) graph.addNode(package, deps) node = Node(package, graph) node.data = data for kind in ('init', 'demo', 'update'): if package in tools.config[kind] or 'all' in tools.config[kind] or kind in force: setattr(node, kind, True) else: later.add(package) packages.append((package, deps, data)) packages.pop(0) graph.update_from_db(cr) for package in later: unmet_deps = filter(lambda p: p not in graph, dependencies[package]) logger.notifyChannel('init', netsvc.LOG_ERROR, 'module %s: Unmet dependencies: %s' % (package, ', '.join(unmet_deps))) result = len(graph) - len_graph if result != len(module_list): logger.notifyChannel('init', netsvc.LOG_WARNING, 'Not all modules have loaded.') return result
468,927
def load_modules(db, force_demo=False, status=None, update_module=False): if not status: status = {} cr = db.cursor() if cr: cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='ir_module_module'") if len(cr.fetchall())==0: logger.notifyChannel("init", netsvc.LOG_INFO, "init db") tools.init_db(cr)
defload_modules(db,force_demo=False,status=None,update_module=False):ifnotstatus:status={}cr=db.cursor()ifcr:cr.execute("SELECTrelnameFROMpg_classWHERErelkind='r'ANDrelname='ir_module_module'")iflen(cr.fetchall())==0:logger.notifyChannel("init",netsvc.LOG_INFO,"initdb")tools.init_db(cr)
468,928
def load_modules(db, force_demo=False, status=None, update_module=False): if not status: status = {} cr = db.cursor() if cr: cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='ir_module_module'") if len(cr.fetchall())==0: logger.notifyChannel("init", netsvc.LOG_INFO, "init db") tools.init_db(cr)
defif not_loaded: return load_modules(db,if not_loaded: return force_demo=False,if not_loaded: return status=None,if not_loaded: return update_module=False):if not_loaded: return ifif not_loaded: return notif not_loaded: return status:if not_loaded: return statusif not_loaded: return =if not_loaded: return {}if not_loaded: return if not_loaded: return crif not_loaded: return =if not_loaded: return db.cursor()if not_loaded: return ifif not_loaded: return cr:if not_loaded: return cr.execute("SELECTif not_loaded: return relnameif not_loaded: return FROMif not_loaded: return pg_classif not_loaded: return WHEREif not_loaded: return relkind='r'if not_loaded: return ANDif not_loaded: return relname='ir_module_module'")if not_loaded: return ifif not_loaded: return len(cr.fetchall())==0:if not_loaded: return logger.notifyChannel("init",if not_loaded: return netsvc.LOG_INFO,if not_loaded: return "initif not_loaded: return db")if not_loaded: return tools.init_db(cr)
468,929
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): raise _('The search method is not implemented on this object !')
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): raise _('The search method is not implemented on this object !')
468,930
def name_get(self, cr, user, ids, context=None): raise _('The name_get method is not implemented on this object !')
def name_get(self, cr, user, ids, context=None): raise _('The name_get method is not implemented on this object !')
468,931
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): raise _('The name_search method is not implemented on this object !')
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): raise _('The name_search method is not implemented on this object !')
468,932
def copy(self, cr, uid, id, default=None, context=None): raise _('The copy method is not implemented on this object !')
def copy(self, cr, uid, id, default=None, context=None): raise _('The copy method is not implemented on this object !')
468,933
def exists(self, cr, uid, id, context=None): raise _('The exists method is not implemented on this object !')
def exists(self, cr, uid, id, context=None): raise _('The exists method is not implemented on this object !')
468,934
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
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
468,935
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 """
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 """
468,936
def _next_action_note(self, cr, uid, ids, context=None): next = self._next_action(cr, uid) if next: # if the next one is also an old-style extension, you never know... if next.note: return next.note return "Click 'Continue' to configure the next addon..." return "Your database is now fully configured.\n\n"\ "Click 'Continue' and enjoy your OpenERP experience..."
def _next_action_note(self, cr, uid, ids, context=None): next = self._next_action(cr, uid) if next: # if the next one is also an old-style extension, you never know... if next.note: return next.note return "Click 'Continue' to configure the next addon..." return "Your database is now fully configured.\n\n"\ "Click 'Continue' and enjoy your OpenERP experience..."
468,937
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')
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')
468,938
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')
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'] = ' '.join(map(lambda (x, y): unicode(x, y or 'ascii'), decode_header(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')
468,939
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
468,940
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
468,941
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: print 'false 1',model,fields,e return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) print 'false 2' return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas)
468,942
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 {}
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)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]) 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))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]) 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)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]) new_journal = data['form']['journal_id'] new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context)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]) 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'))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]) 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 = "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]) 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}):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]) 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 += limitquery = "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]) #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))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]) 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'] = Truequery = "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]) 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))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]) return {}
468,943
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 {}
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_ids}) 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 {}
468,944
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
468,945
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
468,946
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}}
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}}
468,947
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)
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, context=context): 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)
468,948
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)
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[datas['id']] = 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)
468,949
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)
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,\ context=context) result[datas['id']] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq':\ datas.get('rrule_type').upper(), \ 'interval': 1}, context=context)
468,950
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)
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)
468,951
def get_min_max_date(self, cr, uid, ids, field_name, arg, context=None): """ Finds minimum and maximum dates for picking. @return: Dictionary of values """ res = {} for id in ids: res[id] = {'min_date': False, 'max_date': False} if not ids: return res cr.execute("""select picking_id, min(date_expected), max(date_expected) from stock_move where picking_id IN %s group by picking_id""",(tuple(ids),)) for pick, dt1, dt2 in cr.fetchall(): res[pick]['min_date'] = dt1 res[pick]['max_date'] = dt2 return res
def get_min_max_date(self, cr, uid, ids, field_name, arg, context=None): """ Finds minimum and maximum dates for picking. @return: Dictionary of values """ res = {} for id in ids: res[id] = {'min_date': False, 'max_date': False} if not ids: return res cr.execute("""select picking_id, min(date_expected), max(date_expected) from stock_move where picking_id IN %s group by picking_id""",(tuple(ids),)) for pick, dt1, dt2 in cr.fetchall(): res[pick]['min_date'] = dt1 res[pick]['max_date'] = dt2 return res
468,952
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']]
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']]
468,953
def create(self, cr, uid, vals, context=None, check=True): account_obj = self.pool.get('account.account') tax_obj = self.pool.get('account.tax') move_obj = self.pool.get('account.move') cur_obj = self.pool.get('res.currency') journal_obj = self.pool.get('account.journal') if context is None: context = {} if vals.get('move_id', False): company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False) if company_id: vals['company_id'] = company_id[0] self._check_date(cr, uid, vals, context, check) if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals: context['journal_id'] = vals['journal_id'] if 'period_id' in vals: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = move_obj.browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
def create(self, cr, uid, vals, context=None, check=True): account_obj = self.pool.get('account.account') tax_obj = self.pool.get('account.tax') move_obj = self.pool.get('account.move') cur_obj = self.pool.get('res.currency') journal_obj = self.pool.get('account.journal') if context is None: context = {} if vals.get('move_id', False): company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False) if company_id: vals['company_id'] = company_id[0] self._check_date(cr, uid, vals, context, check) if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals: context['journal_id'] = vals['journal_id'] if 'period_id' in vals: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = move_obj.browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
468,954
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Returns views and fields for current model where view will depend on {view_type}. @param cr: A database cursor @param user: ID of the user currently logged in @param view_id: list of fields, which required to read signatures @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx) @param context: context arguments, like lang, time zone @param toolbar: contains a list of reports, wizards, and links related to current model
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Returns views and fields for current model where view will depend on {view_type}. @param cr: A database cursor @param user: ID of the user currently logged in @param view_id: list of fields, which required to read signatures @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx) @param context: context arguments, like lang, time zone @param toolbar: contains a list of reports, wizards, and links related to current model
468,955
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
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
468,956
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
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
468,957
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):
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):
468,958
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):
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):
468,959
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):
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):
468,960
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
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
468,961
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)
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)
468,962
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 = {}
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 = {}
468,963
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 = {}
defdo_invite(self,cr,uid,ids,context={}):"""Inviteattendeeformeeting..@paramcr:thecurrentrow,fromthedatabasecursor,@paramuid:thecurrentuser’sIDforsecuritychecks,@paramids:Listofbasecalendarinviteattendee’sIDs.@paramcontext:Astandarddictionaryforcontextualvalues@return:Dictionaryof{}."""fordatasinself.read(cr,uid,ids):model=Falsemodel_field=Falsecontext_id=contextandcontext.get('active_id',False)orFalseifnotcontextornotcontext.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={}
468,964
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context={}): """ send mail. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of calendar attendee’s IDs. @param context: A standard dictionary for contextual values @return: True """ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.name for att in self.browse(cr, uid, ids, context=context): sign = att.sent_by_uid and att.sent_by_uid.signature or '' sign = '<br>'.join(sign and sign.split('\n') or []) res_obj = att.ref if res_obj and len(res_obj): res_obj = res_obj[0] sub = '[%s Invitation][%d] %s' % (company, att.id, res_obj.name) att_infos = [] other_invitaion_ids = self.search(cr, uid, [('ref', '=', att.ref)]) for att2 in self.browse(cr, uid, other_invitaion_ids): att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ att2.email) + ' - Status: ' + att2.state.title()) body_vals = {'name': res_obj.name, 'start_date': res_obj.date, 'end_date': res_obj.date_deadline or False, 'description': res_obj.description or '-', 'location': res_obj.location or '-', 'attendees': '<br>'.join(att_infos), 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', 'sign': sign, 'company': company } body = html_invitation % body_vals if mail_to and email_from: tools.email_send( email_from, mail_to, sub, body, subtype='html', reply_to=email_from ) return True
def_send_mail(self,cr,uid,ids,mail_to,email_from=tools.config.get('email_from',False),context={}):"""sendmail.@paramcr:thecurrentrow,fromthedatabasecursor,@paramuid:thecurrentuser’sIDforsecuritychecks,@paramids:Listofcalendarattendee’sIDs.@paramcontext:Astandarddictionaryforcontextualvalues@return:True"""company=self.pool.get('res.users').browse(cr,uid,uid,context=context).company_id.nameforattinself.browse(cr,uid,ids,context=context):sign=att.sent_by_uidandatt.sent_by_uid.signatureor''sign='<br>'.join(signandsign.split('\n')or[])res_obj=att.refifres_objandlen(res_obj):res_obj=res_obj[0]sub='[%sInvitation][%d]%s'%(company,att.id,res_obj.name)att_infos=[]other_invitaion_ids=self.search(cr,uid,[('ref','=',att.ref)])foratt2inself.browse(cr,uid,other_invitaion_ids):att_infos.append(((att2.user_idandatt2.user_id.name)or\(att2.partner_idandatt2.partner_id.name)or\att2.email)+'-Status:'+att2.state.title())body_vals={'name':res_obj.name,'start_date':res_obj.date,'end_date':res_obj.date_deadlineorFalse,'description':res_obj.descriptionor'-','location':res_obj.locationor'-','attendees':'<br>'.join(att_infos),'user':res_obj.user_idandres_obj.user_id.nameor'OpenERPUser','sign':sign,'company':company}body=html_invitation%body_valsifmail_toandemail_from:tools.email_send(email_from,mail_to,sub,body,subtype='html',reply_to=email_from)returnTrue
468,965
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
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
468,966
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)
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)
468,967
def get_default_menu(self, cr, uid, context=None): actions = self.pool.get('ir.actions.act_window')
def get_default_menu(self, cr, uid, context=None): actions = self.pool.get('ir.actions.act_window')
468,968
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
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
468,969
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], [])
def move_line_id_payment_get(self, cr, uid, ids, *args): if not ids: return [] result = self.move_line_id_payment_gets(cr, uid, ids, *args) return result.get(ids[0], [])
468,970
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
def move_line_id_payment_gets(self, cr, uid, ids, *args): 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
468,971
def rg(ids, table, parent): if not ids: return [] ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context) return ids + rg(ids2, table, parent)
def rg(ids, table, parent): if not ids: return [] ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context) return ids + rg(ids2, table, parent)
468,972
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
if isinstance(right, basestring): c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
468,973
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
468,974
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: self.__exp[i] = ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
468,975
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
def _get_expression(field_obj,cr, uid, left, right, operator, context=None): if context is None: context = {} c = context.copy() c['active_test'] = False dict_op = {'not in':'!=','in':'='} if isinstance(right,tuple): right = list(right) if (not isinstance(right,list)) and operator in ['not in','in']: operator = dict_op[operator] res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c) if not res_ids: return ('id','=',0) else: right = map(lambda x: x[0], res_ids) return (left, 'in', right)
468,976
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
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
468,977
def _lang_get(self, cr, uid, context={}): obj = self.pool.get('res.lang') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['code', 'name'], context) res = [(r['code'], r['name']) for r in res] return res
def _lang_get(self, cr, uid, context={}): obj = self.pool.get('res.lang') ids = obj.search(cr, uid, [('translatable','=',True)]) res = obj.read(cr, uid, ids, ['code', 'name'], context) res = [(r['code'], r['name']) for r in res] return res
468,978
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
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: 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 return res
468,979
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
def _update_check(self, cr, uid, ids, context={}): done = {} for line in self.browse(cr, uid, ids, context): if line.move_id.state <> 'draft' and (not line.journal_id.entry_posted): 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
468,980
def _get_company(self,cr, uid, context={}, uid2=False): if not uid2: uid2 = uid user = self.pool.get('res.users').browse(cr, uid, uid2, context) return user.company_id.id
def _get_company(self,cr, uid, context={}, uid2=False): if not uid2: uid2 = uid user = self.pool.get('res.users').browse(cr, uid, uid2, context) return user.company_id.id
468,981
def context_get(self, cr, uid, context=None): user = self.browse(cr, uid, uid, context) result = {} for k in self._columns.keys(): if k.startswith('context_'): res = getattr(user,k) if isinstance(res, browse_record): res = res.id result[k[8:]] = res return result
def context_get(self, cr, uid, context=None): user = self.browse(cr, uid, uid, context) result = {} for k in self._columns.keys(): if k.startswith('context_'): res = getattr(user,k) or False if isinstance(res, browse_record): res = res.id result[k[8:]] = res return result
468,982
def context_get(self, cr, uid, context=None): user = self.browse(cr, uid, uid, context) result = {} for k in self._columns.keys(): if k.startswith('context_'): res = getattr(user,k) if isinstance(res, browse_record): res = res.id result[k[8:]] = res return result
def context_get(self, cr, uid, context=None): user = self.browse(cr, uid, uid, context) result = {} for k in self._columns.keys(): if k.startswith('context_'): res = getattr(user,k) if isinstance(res, browse_record): res = res.id result[k[8:]] = res return result
468,983
def context_get(self, cr, uid, context=None): user = self.browse(cr, uid, uid, context) result = {} for k in self._columns.keys(): if k.startswith('context_'): res = getattr(user,k) if isinstance(res, browse_record): res = res.id result[k[8:]] = res return result
defcontext_get(self,cr,uid,context=None):user=self.browse(cr,uid,uid,context)result={}forkinself._columns.keys():ifk.startswith('context_'):res=getattr(user,k)ifisinstance(res,browse_record):res=res.idresult[k[8:]]=resreturnresult
468,984
def login(self, db, login, password): if not password: return False cr = pooler.get_db(db).cursor() cr.execute('select id from res_users where login=%s and password=%s and active', (tools.ustr(login), tools.ustr(password))) res = cr.fetchone() cr.close() if res: return res[0] else: return False
def login(self, db, login, password): if not password: return False cr = pooler.get_db(db).cursor() cr.execute('select id from res_users where login=%s and password=%s and active', (tools.ustr(login), tools.ustr(password))) res = cr.fetchone() cr.close() if res: return res[0] else: return False
468,985
def check(self, db, uid, passwd): if not passwd: return False cached_pass = self._uid_cache.get(db, {}).get(uid) if (cached_pass is not None) and cached_pass == passwd: return True cr = pooler.get_db(db).cursor() cr.execute('select count(1) from res_users where id=%s and password=%s and active=%s', (int(uid), passwd, True)) res = cr.fetchone()[0] cr.close() if not bool(res): raise security.ExceptionNoTb('AccessDenied') if res: if self._uid_cache.has_key(db): ulist = self._uid_cache[db] ulist[uid] = passwd else: self._uid_cache[db] = {uid:passwd} return bool(res)
def check(self, db, uid, passwd): if not passwd: return False cached_pass = self._uid_cache.get(db, {}).get(uid) if (cached_pass is not None) and cached_pass == passwd: return True cr = pooler.get_db(db).cursor() cr.execute('select count(1) from res_users where id=%s and password=%s and active=%s', (int(uid), passwd, True)) res = cr.fetchone()[0] cr.close() if not bool(res): raise security.ExceptionNoTb('AccessDenied') if res: if self._uid_cache.has_key(db): ulist = self._uid_cache[db] ulist[uid] = passwd else: self._uid_cache[db] = {uid:passwd} return bool(res)
468,986
def access(self, db, uid, passwd, sec_level, ids): if not passwd: return False cr = pooler.get_db(db).cursor() cr.execute('select id from res_users where id=%s and password=%s', (uid, passwd)) res = cr.fetchone() cr.close() if not res: raise security.ExceptionNoTb('Bad username or password') return res[0]
def access(self, db, uid, passwd, sec_level, ids): if not passwd: return False cr = pooler.get_db(db).cursor() cr.execute('select id from res_users where id=%s and password=%s', (uid, passwd)) res = cr.fetchone() cr.close() if not res: raise security.ExceptionNoTb('Bad username or password') return res[0]
468,987
def access(self, db, uid, passwd, sec_level, ids): if not passwd: return False cr = pooler.get_db(db).cursor() cr.execute('select id from res_users where id=%s and password=%s', (uid, passwd)) res = cr.fetchone() cr.close() if not res: raise security.ExceptionNoTb('Bad username or password') return res[0]
def access(self, db, uid, passwd, sec_level, ids): if not passwd: return False cr = pooler.get_db(db).cursor() cr.execute('select id from res_users where id=%s and password=%s', (uid, passwd)) res = cr.fetchone() cr.close() if not res: raise security.ExceptionNoTb('Bad username or password') return res[0]
468,988
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")
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")
468,989
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")
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): if ndir_node and ndir_node.context != self.context: raise NotImplementedError("Cannot move files between contexts")
468,990
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")
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")
468,991
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")
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")
468,992
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 = {}
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 = {}
468,993
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))
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))
468,994
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 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, [('scrap_location','=',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
468,995
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 _compute(self, cr, uid, ids,field_name, arg, 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
468,996
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 _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] = tot return res
468,997
def create(self, cr, uid, ids, datas, context=None): if not context: context={} self.context = context pool = pooler.get_pool(cr.dbname) model = pool.get(datas['model']) model_id = pool.get('ir.model').search(cr, uid, [('model','=',model._name)]) if model_id: model_desc = pool.get('ir.model').browse(cr, uid, model_id[0], context).name self.title = model_desc else: model_desc = model._description self.title = model_desc
def create(self, cr, uid, ids, datas, context=None): if not context: context={} self.context = context pool = pooler.get_pool(cr.dbname) model = pool.get(datas['model']) model_id = pool.get('ir.model').search(cr, uid, [('model','=',model._name)]) if model_id: model_desc = pool.get('ir.model').browse(cr, uid, model_id[0], context).name self.title = model_desc else: model_desc = model._description self.title = model_desc
468,998
def get_id(self, xml_id): if not xml_id: raise YamlImportException("The xml_id should be a non empty string.") if isinstance(xml_id, types.IntType): id = xml_id elif xml_id in self.id_map: id = self.id_map[xml_id] else: if '.' in xml_id: module, checked_xml_id = xml_id.split('.', 1) else: module = self.module checked_xml_id = xml_id ir_id = self.pool.get('ir.model.data')._get_id(self.cr, self.uid, module, checked_xml_id) obj = self.pool.get('ir.model.data').read(self.cr, self.uid, ir_id, ['res_id']) id = int(obj['res_id']) self.id_map[xml_id] = id return id
def get_id(self, xml_id): if not xml_id: raise YamlImportException("The xml_id should be a non empty string.") if isinstance(xml_id, types.IntType): id = xml_id elif xml_id in self.id_map: id = self.id_map[xml_id] else: if '.' in xml_id: module, checked_xml_id = xml_id.split('.', 1) else: module = self.module checked_xml_id = xml_id ir_id = self.pool.get('ir.model.data')._get_id(self.cr, self.uid, module, checked_xml_id) obj = self.pool.get('ir.model.data').read(self.cr, self.uid, ir_id, ['res_id']) or {} id = int(obj['res_id']) self.id_map[xml_id] = id return id
468,999