bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def onchange_days(self, cr, uid, ids, project, context=None): result = {} for id in ids: project_id = self.browse(cr, uid, id, context=context) newdate = datetime.strptime(project_id.date_start, '%Y-%m-%d') + relativedelta(days=project_id.duration or 0.0) result['date_end'] = newdate.strftime('%Y-%m-%d') return {'value': result}
def onchange_days(self, cr, uid, ids, project, context=None): result = {} for id in ids: project_id = self.browse(cr, uid, id, context=context) newdate = datetime.strptime(project_id.date_start, '%Y-%m-%d') + relativedelta(days=project_id.duration or 0.0) result['date_end'] = newdate.strftime('%Y-%m-%d') return {'value': result}
469,000
def _get_default_charts(self, cr, uid, context=None): module_name = False company_id = self._default_company(cr, uid, context=context) company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) address_id = self.pool.get('res.partner').address_get(cr, uid, [company.partner_id.id]) if address_id['default']: address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default'], context=context) code = address.country_id.code module_name = (code and 'l10n_' + code.lower()) or False if module_name: module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)], context=context) if module_id: return module_name return 'configurable'
def _get_default_charts(self, cr, uid, context=None): module_name = False company_id = self._default_company(cr, uid, context=context) company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) address_id = self.pool.get('res.partner').address_get(cr, uid, [company.partner_id.id]) if address_id['default']: address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default'], context=context) code = address.country_id.code module_name = (code and 'l10n_' + code.lower()) or False if module_name: module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)], context=context) if module_id: return module_name return 'configurable'
469,001
def modules_to_install(self, cr, uid, ids, context=None): modules = super(account_installer, self).modules_to_install( cr, uid, ids, context=context) chart = self.read(cr, uid, ids, ['charts'], context=context)[0]['charts'] self.logger.notifyChannel( 'installer', netsvc.LOG_DEBUG, 'Installing chart of accounts %s'%chart) return modules | set([chart])
def modules_to_install(self, cr, uid, ids, context=None): modules = super(account_installer, self).modules_to_install( cr, uid, ids, context=context) chart = self.read(cr, uid, ids, ['charts'], context=context)[0]['charts'] self.logger.notifyChannel( 'installer', netsvc.LOG_DEBUG, 'Installing chart of accounts %s'%chart) return modules | set([chart])
469,002
def get(self, cr, obj, ids, name, user=None, context=None, values=None): context = context or {} values = values or {}
def get(self, cr, obj, ids, name, user=None, context=None, values=None): context = context or {} values = values or {}
469,003
def get(self, cr, obj, ids, name, user=None, context=None, values=None): context = context or {} values = values or {}
def get(self, cr, obj, ids, name, user=None, context=None, values=None): context = context or {} values = values or {}
469,004
def __init__(self, cr, uid, name, context=None): self.date_lst = [] self.date_lst_string = '' super(third_party_ledger, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, 'sum_credit_partner': self._sum_credit_partner, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self._get_account, 'get_filter': self._get_filter, 'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_fiscalyear': self._get_fiscalyear, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_journal': self._get_journal,
def __init__(self, cr, uid, name, context=None): self.date_lst = [] self.date_lst_string = '' super(third_party_ledger, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, 'sum_credit_partner': self._sum_credit_partner, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self._get_account, 'get_filter': self._get_filter, 'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_fiscalyear': self._get_fiscalyear, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_journal': self._get_journal,
469,005
def __init__(self, cr, uid, name, context=None): self.date_lst = [] self.date_lst_string = '' super(third_party_ledger, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, 'sum_credit_partner': self._sum_credit_partner, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self._get_account, 'get_filter': self._get_filter, 'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_fiscalyear': self._get_fiscalyear, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_journal': self._get_journal,
def __init__(self, cr, uid, name, context=None): self.date_lst = [] self.date_lst_string = '' super(third_party_ledger, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, 'sum_credit_partner': self._sum_credit_partner, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self._get_account, 'get_filter': self._get_filter, 'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_fiscalyear': self._get_fiscalyear, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_journal': self._get_journal,
469,006
def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field else: currency_total = self.tot_currency = 0.0 return currency_total
def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field else: currency_total = self.tot_currency = 0.0 return currency_total
469,007
def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field else: currency_total = self.tot_currency = 0.0 return currency_total
def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field else: currency_total = self.tot_currency = 0.0 return currency_total
469,008
def update_from_db(self, cr): # update the graph with values from the database (if exist) ## First, we set the default values for each package in graph additional_data = dict.fromkeys(self.keys(), {'id': 0, 'state': 'uninstalled', 'dbdemo': False, 'installed_version': None}) ## Then we get the values from the database cr.execute('SELECT name, id, state, demo AS dbdemo, latest_version AS installed_version' ' FROM ir_module_module' ' WHERE name in (%s)' % (','.join(['%s'] * len(self))), additional_data.keys() )
def update_from_db(self, cr): # update the graph with values from the database (if exist) ## First, we set the default values for each package in graph additional_data = dict.fromkeys(self.keys(), {'id': 0, 'state': 'uninstalled', 'dbdemo': False, 'installed_version': None}) ## Then we get the values from the database cr.execute('SELECT name, id, state, demo AS dbdemo, latest_version AS installed_version' ' FROM ir_module_module' ' WHERE name in %s',(tuple(additional_data),) )
469,009
def check_module_name(cr, mods, state): for mod in mods: id = modobj.search(cr, 1, ['&', ('state', '=', state), ('name', '=', mod)]) if id: getattr(modobj, states[state])(cr, 1, id) elif mod != 'all': logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: invalid module name!' % (mod))
def check_module_name(cr, mods, state): for mod in mods: id = modobj.search(cr, 1, ['&', ('state', '=', state), ('name', '=', mod)]) if id: getattr(modobj, states[state])(cr, 1, id) elif mod != 'all': logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: invalid module name!' % (mod))
469,010
def _get_latest_contract(self, cr, uid, ids, field_name, args, context=None): res = {} obj_contract = self.pool.get('hr.contract') for emp in self.browse(cr, uid, ids, context=context): contract_ids = obj_contract.search(cr, uid, [('employee_id','=',emp.id),], order='date_start', context=context) if contract_ids: res[emp.id] = contract_ids[-1:][0] else: res[emp.id] = False return res
def _get_latest_contract(self, cr, uid, ids, field_name, args, context=None): res = {} obj_contract = self.pool.get('hr.contract') for emp in self.browse(cr, uid, ids, context=context): contract_ids = obj_contract.search(cr, uid, [('employee_id','=',emp.id),], order='date_start', context=context) if contract_ids: res[emp.id] = contract_ids[-1:][0] else: res[emp.id] = False return res
469,011
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = [] mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
469,012
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': ref = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
469,013
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) res = { 'user_id': user_id, 'email': user.address_id.email } res.update(ref) vals.append(res) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
469,014
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.append({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
469,015
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): res = { 'partner_address_id': contact.id, 'email': contact.email } res.update(ref) vals.append(res) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
469,016
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
469,017
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = {} mail_to = [] if not model == 'calendar.attendee': vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) vals.update({'user_id': user_id, 'email': user.address_id.email}) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.update({'email': datas['email']}) mail_to.append(datas['email']) elif type == 'partner': add_obj = self.pool.get('res.partner.address') for contact in add_obj.browse(cr, uid, datas['contact_ids']): vals.update({ 'partner_address_id': contact.id, 'email': contact.email}) if contact.email: mail_to.append(contact.email) if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) if datas.get('send_mail'): if not mail_to: name = map(lambda x: x[1], filter(lambda x: type==x[0], \ self._columns['type'].selection)) raise osv.except_osv(_('Error!'), ("%s must have an email \
469,018
def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, context={}): if not start_date: return {} start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S") value = {} if end_date and not duration: end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S") diff = end - start duration = float(diff.days)* 24 + (float(diff.seconds) / 3600) value['duration'] = round(duration, 2) elif not end_date: end = start + timedelta(hours=duration) value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S") return {'value': value}
def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, context={}): if not start_date: return {} start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S") if end_date and not duration: end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S") diff = end - start duration = float(diff.days)* 24 + (float(diff.seconds) / 3600) value['duration'] = round(duration, 2) elif not end_date: end = start + timedelta(hours=duration) value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S") return {'value': value}
469,019
def do_change_standard_price(self, cr, uid, ids, datas, context={}): """ Changes the Standard Price of Product and creates an account move accordingly. @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal @param context: A standard dictionary @return: """ location_obj = self.pool.get('stock.location') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line')
def do_change_standard_price(self, cr, uid, ids, datas, context={}): """ Changes the Standard Price of Product and creates an account move accordingly. @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal @param context: A standard dictionary @return: """ location_obj = self.pool.get('stock.location') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line')
469,020
def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}): """ Finds the incoming and outgoing quantity of product. @return: Dictionary of values """ if not field_names: field_names = [] res = {} for id in ids: res[id] = {}.fromkeys(field_names, 0.0) for f in field_names: c = context.copy() if f == 'qty_available': c.update({ 'states': ('done',), 'what': ('in', 'out') }) if f == 'virtual_available': c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out') }) if f == 'incoming_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('in',) }) if f == 'outgoing_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('out',) }) stock = self.get_product_available(cr, uid, ids, context=c) for id in ids: res[id][f] = stock.get(id, 0.0) return res
def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}): """ Finds the incoming and outgoing quantity of product. @return: Dictionary of values """ if not field_names: field_names = [] res = {} for id in ids: res[id] = {}.fromkeys(field_names, 0.0) for f in field_names: c = context.copy() if f == 'qty_available': c.update({ 'states': ('done',), 'what': ('in', 'out') }) if f == 'virtual_available': c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out') }) if f == 'incoming_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('in',) }) if f == 'outgoing_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('out',) }) stock = self.get_product_available(cr, uid, ids, context=c) for id in ids: res[id][f] = stock.get(id, 0.0) return res
469,021
def onchange_planned(self, cr, uid, ids, planned = 0.0, effective = 0.0): return {'value':{'remaining_hours': planned - effective}}
def def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} onchange_planned(self, def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} cr, def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} uid, def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} ids, def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} planned def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} = def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} 0.0, def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} effective def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} = def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} 0.0): def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} return def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} {'value':{'remaining_hours': def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} planned def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} - def onchange_project(self, cr, uid, id, project_id): if not project_id: return {} data = self.pool.get('project.project').browse(cr, uid, [project_id]) partner_id=data and data[0].parent_id.partner_id if partner_id: return {'value':{'partner_id':partner_id.id}} return {} effective}}
469,022
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False, address_id=False): if not prod_id: return {} lang = False if address_id: addr_rec = self.pool.get('res.partner.address').browse(cr, uid, address_id) if addr_rec: lang = addr_rec.partner_id and addr_rec.partner_id.lang or False ctx = {'lang': lang}
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False, address_id=False): if not prod_id: return {} lang = False if address_id: addr_rec = self.pool.get('res.partner.address').browse(cr, uid, address_id) if addr_rec: lang = addr_rec.partner_id and addr_rec.partner_id.lang or False ctx = {'lang': lang}
469,023
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False, address_id=False): if not prod_id: return {} lang = False if address_id: addr_rec = self.pool.get('res.partner.address').browse(cr, uid, address_id) if addr_rec: lang = addr_rec.partner_id and addr_rec.partner_id.lang or False ctx = {'lang': lang}
defif not ids: result['name'] = product.partner_ref onchange_product_id(self,if not ids: result['name'] = product.partner_ref cr,if not ids: result['name'] = product.partner_ref uid,if not ids: result['name'] = product.partner_ref ids,if not ids: result['name'] = product.partner_ref prod_id=False,if not ids: result['name'] = product.partner_ref loc_id=False,if not ids: result['name'] = product.partner_ref loc_dest_id=False,if not ids: result['name'] = product.partner_ref address_id=False):if not ids: result['name'] = product.partner_ref ifif not ids: result['name'] = product.partner_ref notif not ids: result['name'] = product.partner_ref prod_id:if not ids: result['name'] = product.partner_ref returnif not ids: result['name'] = product.partner_ref {}if not ids: result['name'] = product.partner_ref langif not ids: result['name'] = product.partner_ref =if not ids: result['name'] = product.partner_ref Falseif not ids: result['name'] = product.partner_ref ifif not ids: result['name'] = product.partner_ref address_id:if not ids: result['name'] = product.partner_ref addr_recif not ids: result['name'] = product.partner_ref =if not ids: result['name'] = product.partner_ref self.pool.get('res.partner.address').browse(cr,if not ids: result['name'] = product.partner_ref uid,if not ids: result['name'] = product.partner_ref address_id)if not ids: result['name'] = product.partner_ref ifif not ids: result['name'] = product.partner_ref addr_rec:if not ids: result['name'] = product.partner_ref langif not ids: result['name'] = product.partner_ref =if not ids: result['name'] = product.partner_ref addr_rec.partner_idif not ids: result['name'] = product.partner_ref andif not ids: result['name'] = product.partner_ref addr_rec.partner_id.langif not ids: result['name'] = product.partner_ref orif not ids: result['name'] = product.partner_ref Falseif not ids: result['name'] = product.partner_ref ctxif not ids: result['name'] = product.partner_ref =if not ids: result['name'] = product.partner_ref {'lang':if not ids: result['name'] = product.partner_ref lang}
469,024
def make_procurement(self, cr, uid, ids, context=None): '''Create procurement''' for proc in self.browse(cr, uid, ids): wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.id, context) user = self.pool.get('res.users').browse(cr, uid, uid, context) procure_id = self.pool.get('mrp.procurement').create(cr, uid, { 'name':'INT:'+str(user.login), 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.qty, 'product_uom': proc.uom_id.id, 'location_id': wh.lot_stock_id.id, 'procure_method':'make_to_order', }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr) data_obj = self.pool.get('ir.model.data') id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view') id3 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_form_view') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'mrp.procurement', 'res_id' : procure_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window', }
def make_procurement(self, cr, uid, ids, context=None): '''Create procurement''' for proc in self.browse(cr, uid, ids): wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.warehouse_id.id, context) user = self.pool.get('res.users').browse(cr, uid, uid, context) procure_id = self.pool.get('mrp.procurement').create(cr, uid, { 'name':'INT:'+str(user.login), 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.qty, 'product_uom': proc.uom_id.id, 'location_id': wh.lot_stock_id.id, 'procure_method':'make_to_order', }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr) data_obj = self.pool.get('ir.model.data') id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view') id3 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_form_view') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'mrp.procurement', 'res_id' : procure_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window', }
469,025
def _default_value(self, cursor, user, field, context=None): if field in ('country_id', 'state_id'): value = False else: value = '' if not context.get('address', False): return value for ham, spam, address in context['address']: if address.get('type', False) == 'default': return address.get(field, value) elif not address.get('type', False): value = address.get(field, value) return value
def _default_value(self, cursor, user, field, context=None): if field in ('country_id', 'state_id'): value = False else: value = '' if not context.get('address', False): return value for ham, spam, address in context['address']: if address.get('type', False) == 'default': return address.get(field, value) elif not address.get('type', False): value = address.get(field, value) return value
469,026
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: if not repair.partner_id.property_account_receivable: raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name ) account_id = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
469,027
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': account_id, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
469,028
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: a = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': a, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id})
469,029
def check_ean(eancode): if not eancode: return True if len(eancode) <> 13: return False try: int(eancode) except: return False oddsum=0 evensum=0 total=0 eanvalue=eancode reversevalue = eanvalue[::-1] finalean=reversevalue[1:] for i in range(len(finalean)): if is_pair(i): oddsum += int(finalean[i]) else: evensum += int(finalean[i]) total=(oddsum * 3) + evensum check = int(10 - math.ceil(total % 10.0)) if check != int(eancode[-1]): return False return True
def check_ean(eancode): if not eancode: return True if len(eancode) <> 13: return False try: int(eancode) except: return False oddsum=0 evensum=0 total=0 eanvalue=eancode reversevalue = eanvalue[::-1] finalean=reversevalue[1:] for i in range(len(finalean)): if is_pair(i): oddsum += int(finalean[i]) else: evensum += int(finalean[i]) total=(oddsum * 3) + evensum check = int(10 - math.ceil(total % 10.0)) %10 if check != int(eancode[-1]): return False return True
469,030
def _name_get(d): name = d.get('name','') code = d.get('default_code',False) if code: name = '[%s] %s' % (code,name) if d.get('variants'): name = name + ' - %s' % (d['variants'],) return (d['id'], name)
def _name_get(d): name = d.get('name','') code = d.get('default_code',False) if code: name = '[%s] %s' % (code,name) if d.get('variants'): name = name + ' - %s' % (d['variants'],) return (d['id'], name)
469,031
def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res
def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res
469,032
def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res
def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res
469,033
def verify_sheet(self, cr, uid, ids, context={}): move_pool = self.pool.get('account.move') movel_pool = self.pool.get('account.move.line') exp_pool = self.pool.get('hr.expense.expense') for slip in self.browse(cr,uid,ids): total_deduct = 0.0 line_ids = [] partner = False partner_id = False if not slip.employee_id.address_home_id: raise osv.except_osv(_('Integrity Error !'), _('Please defined the Employee Home Address Along with Partners !!')) if not slip.employee_id.address_home_id.partner_id: raise osv.except_osv(_('Integrity Error !'), _('Please defined the Partner in Home Address !!')) partner = slip.employee_id.address_home_id.partner_id partner_id = slip.employee_id.address_home_id.partner_id.id period_id = False if slip.period_id: period_id = slip.period_id.id else: fiscal_year_ids = self.pool.get('account.fiscalyear').search(cr, uid, []) if not fiscal_year_ids: raise osv.except_osv(_('Warning !'), _('Please define fiscal year for perticular contract')) fiscal_year_objs = self.pool.get('account.fiscalyear').read(cr, uid, fiscal_year_ids, ['date_start','date_stop']) year_exist = False for fiscal_year in fiscal_year_objs: if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)): year_exist = True if not year_exist: raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s'%slip.date)) search_period = self.pool.get('account.period').search(cr,uid,[('date_start','<=',slip.date),('date_stop','>=',slip.date)]) if not search_period: raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s'%slip.date)) period_id = search_period[0] move = { #'name': slip.name, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'date': slip.date, 'ref':slip.number, 'narration': slip.name } move_id = move_pool.create(cr, uid, move) self.create_voucher(cr, uid, [slip.id], slip.name, move_id) line = { 'move_id':move_id, 'name': "By Basic Salary / " + slip.employee_id.name, 'date': slip.date, 'account_id': slip.employee_id.salary_account.id, 'debit': slip.basic, 'credit': 0.0, 'quantity':slip.working_days, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'analytic_account_id': False, 'ref':slip.number } #Setting Analysis Account for Basic Salary if slip.employee_id.analytic_account: line['analytic_account_id'] = slip.employee_id.analytic_account.id move_line_id = movel_pool.create(cr, uid, line) line_ids += [move_line_id] line = { 'move_id':move_id, 'name': "To Basic Paysble Salary / " + slip.employee_id.name, 'partner_id': partner_id, 'date': slip.date, 'account_id': slip.employee_id.employee_account.id, 'debit': 0.0, 'quantity':slip.working_days, 'credit': slip.basic, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, line)] for line in slip.line_ids: name = "[%s] - %s / %s" % (line.code, line.name, slip.employee_id.name) amount = line.total if line.type == 'leaves': continue rec = { 'move_id':move_id, 'name': name, 'date': slip.date, 'account_id': line.account_id.id, 'debit': 0.0, 'credit' : 0.0, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'analytic_account_id':False, 'ref':slip.number, 'quantity':1 } #Setting Analysis Account for Salary Slip Lines if line.analytic_account_id: rec['analytic_account_id'] = line.analytic_account_id.id else: rec['analytic_account_id'] = slip.deg_id.account_id.id if line.type == 'allounce' or line.type == 'otherpay': rec['debit'] = amount if not partner.property_account_payable: raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Payable Account!!')) ded_rec = { 'move_id':move_id, 'name': name, 'partner_id': partner_id, 'date': slip.date, 'account_id': partner.property_account_payable.id, 'debit': 0.0, 'quantity':1, 'credit' : amount, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, ded_rec)] elif line.type == 'deduction' or line.type == 'otherdeduct': if not partner.property_account_receivable: raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Receivable Account!!')) rec['credit'] = amount total_deduct += amount ded_rec = { 'move_id':move_id, 'name': name, 'partner_id': partner_id, 'date': slip.date, 'quantity':1, 'account_id': partner.property_account_receivable.id, 'debit': amount, 'credit' : 0.0, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, ded_rec)] line_ids += [movel_pool.create(cr, uid, rec)] if line.company_contrib > 0: company_contrib = line.company_contrib
def verify_sheet(self, cr, uid, ids, context={}): move_pool = self.pool.get('account.move') movel_pool = self.pool.get('account.move.line') exp_pool = self.pool.get('hr.expense.expense') for slip in self.browse(cr,uid,ids): total_deduct = 0.0 line_ids = [] partner = False partner_id = False if not slip.employee_id.address_home_id: raise osv.except_osv(_('Integrity Error !'), _('Please defined the Employee Home Address Along with Partners !!')) if not slip.employee_id.address_home_id.partner_id: raise osv.except_osv(_('Integrity Error !'), _('Please defined the Partner in Home Address !!')) partner = slip.employee_id.address_home_id.partner_id partner_id = slip.employee_id.address_home_id.partner_id.id period_id = False if slip.period_id: period_id = slip.period_id.id else: fiscal_year_ids = self.pool.get('account.fiscalyear').search(cr, uid, []) if not fiscal_year_ids: raise osv.except_osv(_('Warning !'), _('Please define fiscal year for perticular contract')) fiscal_year_objs = self.pool.get('account.fiscalyear').read(cr, uid, fiscal_year_ids, ['date_start','date_stop']) year_exist = False for fiscal_year in fiscal_year_objs: if ((fiscal_year['date_start'] <= slip.date) and (fiscal_year['date_stop'] >= slip.date)): year_exist = True if not year_exist: raise osv.except_osv(_('Warning !'), _('Fiscal Year is not defined for slip date %s'%slip.date)) search_period = self.pool.get('account.period').search(cr,uid,[('date_start','<=',slip.date),('date_stop','>=',slip.date)]) if not search_period: raise osv.except_osv(_('Warning !'), _('Period is not defined for slip date %s'%slip.date)) period_id = search_period[0] move = { #'name': slip.name, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'date': slip.date, 'ref':slip.number, 'narration': slip.name } move_id = move_pool.create(cr, uid, move) self.create_voucher(cr, uid, [slip.id], slip.name, move_id) line = { 'move_id':move_id, 'name': "By Basic Salary / " + slip.employee_id.name, 'date': slip.date, 'account_id': slip.employee_id.salary_account.id, 'debit': slip.basic, 'credit': 0.0, 'quantity':slip.working_days, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'analytic_account_id': False, 'ref':slip.number } #Setting Analysis Account for Basic Salary if slip.employee_id.analytic_account: line['analytic_account_id'] = slip.employee_id.analytic_account.id move_line_id = movel_pool.create(cr, uid, line) line_ids += [move_line_id] line = { 'move_id':move_id, 'name': "To Basic Paysble Salary / " + slip.employee_id.name, 'partner_id': partner_id, 'date': slip.date, 'account_id': slip.employee_id.employee_account.id, 'debit': 0.0, 'quantity':slip.working_days, 'credit': slip.basic, 'journal_id': slip.journal_id.id, 'period_id': period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, line)] for line in slip.line_ids: name = "[%s] - %s / %s" % (line.code, line.name, slip.employee_id.name) amount = line.total if line.type == 'leaves': continue rec = { 'move_id':move_id, 'name': name, 'date': slip.date, 'account_id': line.account_id.id, 'debit': 0.0, 'credit' : 0.0, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'analytic_account_id':False, 'ref':slip.number, 'quantity':1 } #Setting Analysis Account for Salary Slip Lines if line.analytic_account_id: rec['analytic_account_id'] = line.analytic_account_id.id else: rec['analytic_account_id'] = slip.deg_id.account_id.id if line.type == 'allounce' or line.type == 'otherpay': rec['debit'] = amount if not partner.property_account_payable: raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Payable Account!!')) ded_rec = { 'move_id':move_id, 'name': name, 'partner_id': partner_id, 'date': slip.date, 'account_id': partner.property_account_payable.id, 'debit': 0.0, 'quantity':1, 'credit' : amount, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, ded_rec)] elif line.type == 'deduction' or line.type == 'otherdeduct': if not partner.property_account_receivable: raise osv.except_osv(_('Integrity Error !'), _('Please Configure Partners Receivable Account!!')) rec['credit'] = amount total_deduct += amount ded_rec = { 'move_id':move_id, 'name': name, 'partner_id': partner_id, 'date': slip.date, 'quantity':1, 'account_id': partner.property_account_receivable.id, 'debit': amount, 'credit' : 0.0, 'journal_id' : slip.journal_id.id, 'period_id' :period_id, 'ref':slip.number } line_ids += [movel_pool.create(cr, uid, ded_rec)] line_ids += [movel_pool.create(cr, uid, rec)] if line.company_contrib > 0: company_contrib = line.company_contrib
469,034
def _get_leaves(self, cr, user, slip, employee, context={}): """ Compute leaves for an employee @param cr: cursor to database @param user: id of current user @param slip: object of the hr.payroll.slip model @param employee: object of the hr.employee model @param context: context arguments, like lang, time zone @return: return a result """ result = []
def_get_leaves(self,cr,user,slip,employee,context={}):"""Computeleavesforanemployee@paramcr:cursortodatabase@paramuser:idofcurrentuser@paramslip:objectofthehr.payroll.slipmodel@paramemployee:objectofthehr.employeemodel@paramcontext:contextarguments,likelang,timezone@return:returnaresult"""result=[]
469,035
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
469,036
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name get_days(start, for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name end, for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name month, for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name year, for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name calc_day): for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name count for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name = for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name 0 for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name import for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name datetime for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name for for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name day for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name in for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name range(start, for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name end): for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name if for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name datetime.date(year, for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name month, for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name day).weekday() for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name == for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name calc_day: for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name count for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name += for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name 1 for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name return for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name count for cline in line.category_id.contribute_ids: print 'XXXXXXXXXXXXXXX : ', cline.name
469,037
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
469,038
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
469,039
def check_duplicate(self, cr, uid, ids):
def check_duplicate(self, cr, uid, ids):
469,040
def button_confirm_login(self, cr, uid, ids, context={}): for server in self.browse(cr, uid, ids, context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) count = 0 try: if server.type == 'imap': imap_server = None if server.is_ssl: imap_server = IMAP4_SSL(server.server, int(server.port)) else: imap_server = IMAP4(server.server, int(server.port))
def button_confirm_login(self, cr, uid, ids, context={}): for server in self.browse(cr, uid, ids, context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) try: if server.type == 'imap': imap_server = None if server.is_ssl: imap_server = IMAP4_SSL(server.server, int(server.port)) else: imap_server = IMAP4(server.server, int(server.port))
469,041
def _get_dav_getctag(self, cr): result = self.get_etag(cr) return str(result)
def _get_dav_getctag(self, cr): result = self.get_etag(cr) return str(result)
469,042
def _get_ttag(self,cr): res = False if self.model and self.res_id: res = '%s_%d' % (self.model, self.res_id) elif self.calendar_id: res = '%d' % (self.calendar_id) return res
def _get_ttag(self,cr): res = False if self.model and self.res_id: res = '%s_%d' % (self.model, self.res_id) elif self.calendar_id: res = '%d' % (self.calendar_id) return res
469,043
def _get_caldav_schedule_outbox_URL(self, cr): return self._get_caldav_schedule_inbox_URL(cr)
def _get_caldav_schedule_outbox_URL(self, cr): return self._get_caldav_schedule_inbox_URL(cr)
469,044
def search_entries(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line') mod_obj = self.pool.get('ir.model.data') if context is None: context = {} data = self.read(cr, uid, ids, [], context=context)[0] search_due_date = data['duedate']
def search_entries(self, cr, uid, ids, context=None): line_obj = self.pool.get('account.move.line') mod_obj = self.pool.get('ir.model.data') if context is None: context = {} data = self.read(cr, uid, ids, [], context=context)[0] search_due_date = data['duedate']
469,045
def button_confirm_bank(self, cr, uid, ids, context=None): done = [] obj_seq = self.pool.get('ir.sequence') if context is None: context = {}
def button_confirm_bank(self, cr, uid, ids, context=None): done = [] obj_seq = self.pool.get('ir.sequence') if context is None: context = {}
469,046
def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res
def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), mp.state as mp_state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res
469,047
def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res
def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY mp.state, p.sale_id''') for oid, nbr, mp_state in cr.fetchall(): if mp_state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res
469,048
def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res
def _picked_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} if not ids: return {} res = {} for id in ids: res[id] = [0.0, 0.0] cr.execute('''SELECT p.sale_id,sum(m.product_qty), m.state FROM stock_move m LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE p.sale_id = ANY(%s) GROUP BY m.state, p.sale_id''',(ids,)) for oid, nbr, state in cr.fetchall(): if state == 'cancel': continue if mp_state == 'done': res[oid][0] += nbr or 0.0 res[oid][1] += nbr or 0.0 else: res[oid][1] += nbr or 0.0 for r in res: if not res[r][1]: res[r] = 0.0 else: res[r] = 100.0 * res[r][0] / res[r][1] for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 return res
469,049
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_report') cr.execute(""" create or replace view purchase_report as ( select min(l.id) as id, s.date_order as date, to_char(s.date_order, 'YYYY') as name, to_char(s.date_order, 'MM') as month, s.state, s.warehouse_id as warehouse_id, s.partner_id as partner_id, s.fiscal_position, s.create_uid as user_id, s.company_id as company_id, s.invoice_method, l.product_id, s.location_id as location_id, sum(l.product_qty*u.factor) as quantity, count(*) as nbr, sum(l.product_qty*l.price_unit) as price_total, (sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average from purchase_order s left join purchase_order_line l on (s.id=l.order_id) left join product_uom u on (u.id=l.product_uom) where l.product_id is not null group by s.company_id, s.create_uid, s.partner_id, s.location_id, l.product_id, s.date_order, to_char(s.date_order, 'YYYY'), to_char(s.date_order, 'MM'), s.state, s.warehouse_id, s.fiscal_position, s.invoice_method ) """)
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_report') cr.execute(""" create or replace view purchase_report as ( select min(l.id) as id, s.date_order as date, to_char(s.date_order, 'YYYY') as name, to_char(s.date_order, 'MM') as month, s.state, s.warehouse_id as warehouse_id, s.partner_id as partner_id, s.fiscal_position, s.create_uid as user_id, s.company_id as company_id, s.invoice_method, l.product_id, s.location_id as location_id, sum(l.product_qty*u.factor) as quantity, count(*) as nbr, sum(l.product_qty*l.price_unit) as price_total, (sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average from purchase_order s left join purchase_order_line l on (s.id=l.order_id) left join product_uom u on (u.id=l.product_uom) where l.product_id is not null group by s.company_id, s.create_uid, s.partner_id, s.location_id, l.product_id, s.date_order, to_char(s.date_order, 'YYYY'), to_char(s.date_order, 'MM'), s.state, s.warehouse_id, s.fiscal_position, s.invoice_method ) """)
469,050
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_order_qty_amount') cr.execute(""" create or replace view purchase_order_qty_amount as ( select min(id) as id, to_char(create_date, 'MM') as month, sum(product_qty) as total_qty, create_uid as user_id, sum(price_unit*product_qty) as total_amount from purchase_order_line where to_char(create_date,'YYYY') = to_char(current_date,'YYYY') group by to_char(create_date, 'MM'), create_uid
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_order_qty_amount') cr.execute(""" create or replace view purchase_order_qty_amount as ( select min(id) as id, to_char(create_date, 'MM') as month, sum(product_qty) as total_qty, sum(price_unit*product_qty) as total_amount from purchase_order_line where to_char(create_date,'YYYY') = to_char(current_date,'YYYY') group by to_char(create_date, 'MM'), create_uid
469,051
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_order_qty_amount') cr.execute(""" create or replace view purchase_order_qty_amount as ( select min(id) as id, to_char(create_date, 'MM') as month, sum(product_qty) as total_qty, create_uid as user_id, sum(price_unit*product_qty) as total_amount from purchase_order_line where to_char(create_date,'YYYY') = to_char(current_date,'YYYY') group by to_char(create_date, 'MM'), create_uid
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_order_qty_amount') cr.execute(""" create or replace view purchase_order_qty_amount as ( select min(id) as id, to_char(create_date, 'MM') as month, sum(product_qty) as total_qty, create_uid as user_id, sum(price_unit*product_qty) as total_amount from purchase_order_line where to_char(create_date,'YYYY') = to_char(current_date,'YYYY') group by to_char(create_date, 'MM'), create_uid
469,052
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
469,053
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
469,054
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
469,055
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
469,056
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
469,057
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
469,058
def _balance(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} c = context.copy() c['initital_bal'] = True sql = [ """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2""", """WHERE l2.account_id = l1.account_id""", """AND""", """l1.id <= l2.id""", """AND""", """l2.id IN %s""", """AND""", self._query_get(cr, uid, obj='l1', context=c), """ GROUP BY l2.id""", ]
def _balance(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} c = context.copy() c['initital_bal'] = True sql = [ """SELECT l2.id, SUM(l1.debit-l1.credit) FROM account_move_line l1, account_move_line l2""", """WHERE l2.account_id = l1.account_id""", """AND""", """l1.id <= l2.id""", """AND""", """l2.id IN %s""", """AND""", self._query_get(cr, uid, obj='l1', context=c), """ GROUP BY l2.id""", ]
469,059
def get_memory(self, cr, obj, ids, name, user=None, context=None, values=None): if not context: context = {} if not values: values = [] res = {} for i in ids: val = None for v in values: if v['id'] == i: val = v[name] break
def get_memory(self, cr, obj, ids, name, user=None, context=None, values=None): if not context: context = {} if not values: values = [] res = {} for i in ids: val = None for v in values: if v['id'] == i: val = v[name] break
469,060
def _eval_xml(self, node, pool, cr, uid, idref, context=None): if context is None: context = {} if node.tag in ('field','value'): t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res elif node.tag == "getitem": for n in node: res=_eval_xml(self,n,pool,cr,uid,idref) if not res: raise LookupError elif node.get('type') in ("int", "list"): return res[int(node.get('index'))] else: return res[node.get('index','').encode("utf8")] elif node.tag == "function": args = [] a_eval = node.get('eval','') if a_eval: idref['ref'] = lambda x: self.id_get(cr, False, x) args = unsafe_eval(a_eval, idref) for n in node: return_val = _eval_xml(self,n, pool, cr, uid, idref, context) if return_val is not None: args.append(return_val) model = pool.get(node.get('model','')) method = node.get('name','') res = getattr(model, method)(cr, uid, *args) return res elif node.tag == "test": return node.text
def_eval_xml(self,node,pool,cr,uid,idref,context=None):ifcontextisNone:context={}ifnode.tagin('field','value'):t=node.get('type','char')f_model=node.get('model','').encode('utf-8')ifnode.get('search'):f_search=node.get("search",'').encode('utf-8')f_use=node.get("use",'id').encode('utf-8')f_name=node.get("name",'').encode('utf-8')q=unsafe_eval(f_search,idref)ids=pool.get(f_model).search(cr,uid,q)iff_use!='id':ids=map(lambdax:x[f_use],pool.get(f_model).read(cr,uid,ids,[f_use]))_cols=pool.get(f_model)._columnsif(f_namein_cols)and_cols[f_name]._type=='many2many':returnidsf_val=Falseiflen(ids):f_val=ids[0]ifisinstance(f_val,tuple):f_val=f_val[0]returnf_vala_eval=node.get('eval','')ifa_eval:idref2=dict(idref,time=time,DateTime=datetime,timedelta=timedelta,version=release.major_version,ref=lambdax:self.id_get(cr,False,x),pytz=pytz)iflen(f_model):idref2['obj']=_obj(self.pool,cr,uid,f_model,context=context)try:returnunsafe_eval(a_eval,idref2)exceptException:logger=logging.getLogger('init')logger.warning('couldnoteval(%s)for%sin%s'%(a_eval,node.get('name'),context),exc_info=True)return""ift=='xml':def_process(s,idref):m=re.findall('[^%]%\((.*?)\)[ds]',s)foridinm:ifnotidinidref:idref[id]=self.id_get(cr,False,id)returns%idrefreturn'<?xmlversion="1.0"?>\n'\+_process("".join([etree.tostring(n,encoding='utf-8')forninnode]),idref)iftin('char','int','float'):d=node.textift=='int':d=d.strip()ifd=='None':returnNoneelse:returnint(d.strip())elift=='float':returnfloat(d.strip())returndeliftin('list','tuple'):res=[]forninnode.findall('./value'):res.append(_eval_xml(self,n,pool,cr,uid,idref))ift=='tuple':returntuple(res)returnreselifnode.tag=="getitem":forninnode:res=_eval_xml(self,n,pool,cr,uid,idref)ifnotres:raiseLookupErrorelifnode.get('type')in("int","list"):returnres[int(node.get('index'))]else:returnres[node.get('index','').encode("utf8")]elifnode.tag=="function":args=[]a_eval=node.get('eval','')ifa_eval:idref['ref']=lambdax:self.id_get(cr,False,x)args=unsafe_eval(a_eval,idref)forninnode:return_val=_eval_xml(self,n,pool,cr,uid,idref,context)ifreturn_valisnotNone:args.append(return_val)model=pool.get(node.get('model',''))method=node.get('name','')res=getattr(model,method)(cr,uid,*args)returnreselifnode.tag=="test":returnnode.text
469,061
def _eval_xml(self, node, pool, cr, uid, idref, context=None): if context is None: context = {} if node.tag in ('field','value'): t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res elif node.tag == "getitem": for n in node: res=_eval_xml(self,n,pool,cr,uid,idref) if not res: raise LookupError elif node.get('type') in ("int", "list"): return res[int(node.get('index'))] else: return res[node.get('index','').encode("utf8")] elif node.tag == "function": args = [] a_eval = node.get('eval','') if a_eval: idref['ref'] = lambda x: self.id_get(cr, False, x) args = unsafe_eval(a_eval, idref) for n in node: return_val = _eval_xml(self,n, pool, cr, uid, idref, context) if return_val is not None: args.append(return_val) model = pool.get(node.get('model','')) method = node.get('name','') res = getattr(model, method)(cr, uid, *args) return res elif node.tag == "test": return node.text
def _eval_xml(self, node, pool, cr, uid, idref, context=None): if context is None: context = {} if node.tag in ('field','value'): t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res elif node.tag == "getitem": for n in node: res=_eval_xml(self,n,pool,cr,uid,idref) if not res: raise LookupError elif node.get('type') in ("int", "list"): return res[int(node.get('index'))] else: return res[node.get('index','').encode("utf8")] elif node.tag == "function": args = [] a_eval = node.get('eval','') if a_eval: idref['ref'] = lambda x: self.id_get(cr, False, x) args = unsafe_eval(a_eval, idref) for n in node: return_val = _eval_xml(self,n, pool, cr, uid, idref, context) if return_val is not None: args.append(return_val) model = pool.get(node.get('model','')) method = node.get('name','') res = getattr(model, method)(cr, uid, *args) return res elif node.tag == "test": return node.text
469,062
def _eval_xml(self, node, pool, cr, uid, idref, context=None): if context is None: context = {} if node.tag in ('field','value'): t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res elif node.tag == "getitem": for n in node: res=_eval_xml(self,n,pool,cr,uid,idref) if not res: raise LookupError elif node.get('type') in ("int", "list"): return res[int(node.get('index'))] else: return res[node.get('index','').encode("utf8")] elif node.tag == "function": args = [] a_eval = node.get('eval','') if a_eval: idref['ref'] = lambda x: self.id_get(cr, False, x) args = unsafe_eval(a_eval, idref) for n in node: return_val = _eval_xml(self,n, pool, cr, uid, idref, context) if return_val is not None: args.append(return_val) model = pool.get(node.get('model','')) method = node.get('name','') res = getattr(model, method)(cr, uid, *args) return res elif node.tag == "test": return node.text
def _eval_xml(self, node, pool, cr, uid, idref, context=None): if context is None: context = {} if node.tag in ('field','value'): t = node.get('type','char') f_model = node.get('model', '').encode('utf-8') if node.get('search'): f_search = node.get("search",'').encode('utf-8') f_use = node.get("use",'id').encode('utf-8') f_name = node.get("name",'').encode('utf-8') q = unsafe_eval(f_search, idref) ids = pool.get(f_model).search(cr, uid, q) if f_use != 'id': ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use])) _cols = pool.get(f_model)._columns if (f_name in _cols) and _cols[f_name]._type=='many2many': return ids f_val = False if len(ids): f_val = ids[0] if isinstance(f_val, tuple): f_val = f_val[0] return f_val a_eval = node.get('eval','') if a_eval: idref2 = dict(idref, time=time, DateTime=datetime, timedelta=timedelta, version=release.major_version, ref=lambda x: self.id_get(cr, False, x), pytz=pytz) if len(f_model): idref2['obj'] = _obj(self.pool, cr, uid, f_model, context=context) try: return unsafe_eval(a_eval, idref2) except Exception: logger = logging.getLogger('init') logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True) return "" if t == 'xml': def _process(s, idref): m = re.findall('[^%]%\((.*?)\)[ds]', s) for id in m: if not id in idref: idref[id]=self.id_get(cr, False, id) return s % idref return '<?xml version="1.0"?>\n'\ +_process("".join([etree.tostring(n, encoding='utf-8') for n in node]), idref) if t in ('char', 'int', 'float'): d = node.text if t == 'int': d = d.strip() if d == 'None': return None else: return int(d.strip()) elif t == 'float': return float(d.strip()) return d elif t in ('list','tuple'): res=[] for n in node.findall('./value'): res.append(_eval_xml(self,n,pool,cr,uid,idref)) if t=='tuple': return tuple(res) return res elif node.tag == "getitem": for n in node: res=_eval_xml(self,n,pool,cr,uid,idref) if not res: raise LookupError elif node.get('type') in ("int", "list"): return res[int(node.get('index'))] else: return res[node.get('index','').encode("utf8")] elif node.tag == "function": args = [] a_eval = node.get('eval','') if a_eval: idref['ref'] = lambda x: self.id_get(cr, False, x) args = unsafe_eval(a_eval, idref) for n in node: return_val = _eval_xml(self,n, pool, cr, uid, idref, context) if return_val is not None: args.append(return_val) model = pool.get(node.get('model','')) method = node.get('name','') res = getattr(model, method)(cr, uid, *args) return res elif node.tag == "test": return node.text
469,063
def get_context(self, data_node, node, eval_dict): data_node_context = (len(data_node) and data_node.get('context','').encode('utf8')) if data_node_context: context = unsafe_eval(data_node_context, eval_dict) else: context = {}
def get_context(self, data_node, node, eval_dict): data_node_context = (len(data_node) and data_node.get('context','').encode('utf8')) if data_node_context: context = unsafe_eval(data_node_context, eval_dict) else: context = {}
469,064
def get_context(self, data_node, node, eval_dict): data_node_context = (len(data_node) and data_node.get('context','').encode('utf8')) if data_node_context: context = unsafe_eval(data_node_context, eval_dict) else: context = {}
def get_context(self, data_node, node, eval_dict): data_node_context = (len(data_node) and data_node.get('context','').encode('utf8')) if data_node_context: context = unsafe_eval(data_node_context, eval_dict) else: context = {}
469,065
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form'
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form'
469,066
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form'
def_tag_act_window(self,cr,rec,data_node=None):name=rec.get('name','').encode('utf-8')xml_id=rec.get('id','').encode('utf8')self._test_xml_id(xml_id)type=rec.get('type','').encode('utf-8')or'ir.actions.act_window'view_id=Falseifrec.get('view'):view_id=self.id_get(cr,'ir.actions.act_window',rec.get('view','').encode('utf-8'))domain=rec.get('domain','').encode('utf-8')or'{}'context=rec.get('context','').encode('utf-8')or'{}'res_model=rec.get('res_model','').encode('utf-8')src_model=rec.get('src_model','').encode('utf-8')view_type=rec.get('view_type','').encode('utf-8')or'form'view_mode=rec.get('view_mode','').encode('utf-8')or'tree,form'
469,067
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form'
def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) type = rec.get('type','').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.get('view'): view_id = self.id_get(cr, 'ir.actions.act_window', rec.get('view','').encode('utf-8')) domain = rec.get('domain','').encode('utf-8') or '{}' context = rec.get('context','').encode('utf-8') or '{}' res_model = rec.get('res_model','').encode('utf-8') src_model = rec.get('src_model','').encode('utf-8') view_type = rec.get('view_type','').encode('utf-8') or 'form' view_mode = rec.get('view_mode','').encode('utf-8') or 'tree,form'
469,068
def ref(str_id): return self.id_get(cr, None, str_id)
def ref(str_id): return self.id_get(cr, None, str_id)
469,069
def _tag_record(self, cr, rec, data_node=None): rec_model = rec.get("model").encode('ascii') model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.get("id",'').encode('ascii') rec_context = rec.get("context", None) if rec_context: rec_context = unsafe_eval(rec_context) self._test_xml_id(rec_id) if self.isnoupdate(data_node) and self.mode != 'init': # check if the xml record has an id string if rec_id: if '.' in rec_id: module,rec_id2 = rec_id.split('.') else: module = self.module rec_id2 = rec_id id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2) # check if the resource already existed at the last update if id: # if it existed, we don't update the data, but we need to # know the id of the existing record anyway self.idref[rec_id] = int(id) return None else: # if the resource didn't exist if not self.nodeattr2bool(rec, 'forcecreate', True): # we don't want to create it, so we skip it return None # else, we let the record to be created
def _tag_record(self, cr, rec, data_node=None): rec_model = rec.get("model").encode('ascii') model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.get("id",'').encode('ascii') rec_context = rec.get("context", None) if rec_context: rec_context = unsafe_eval(rec_context) self._test_xml_id(rec_id) if self.isnoupdate(data_node) and self.mode != 'init': # check if the xml record has an id string if rec_id: if '.' in rec_id: module,rec_id2 = rec_id.split('.') else: module = self.module rec_id2 = rec_id id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2) # check if the resource already existed at the last update if id: # if it existed, we don't update the data, but we need to # know the id of the existing record anyway self.idref[rec_id] = int(id) return None else: # if the resource didn't exist if not self.nodeattr2bool(rec, 'forcecreate', True): # we don't want to create it, so we skip it return None # else, we let the record to be created
469,070
def _tag_record(self, cr, rec, data_node=None): rec_model = rec.get("model").encode('ascii') model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.get("id",'').encode('ascii') rec_context = rec.get("context", None) if rec_context: rec_context = unsafe_eval(rec_context) self._test_xml_id(rec_id) if self.isnoupdate(data_node) and self.mode != 'init': # check if the xml record has an id string if rec_id: if '.' in rec_id: module,rec_id2 = rec_id.split('.') else: module = self.module rec_id2 = rec_id id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2) # check if the resource already existed at the last update if id: # if it existed, we don't update the data, but we need to # know the id of the existing record anyway self.idref[rec_id] = int(id) return None else: # if the resource didn't exist if not self.nodeattr2bool(rec, 'forcecreate', True): # we don't want to create it, so we skip it return None # else, we let the record to be created
def _tag_record(self, cr, rec, data_node=None): rec_model = rec.get("model").encode('ascii') model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.get("id",'').encode('ascii') rec_context = rec.get("context", None) if rec_context: rec_context = unsafe_eval(rec_context) self._test_xml_id(rec_id) if self.isnoupdate(data_node) and self.mode != 'init': # check if the xml record has an id string if rec_id: if '.' in rec_id: module,rec_id2 = rec_id.split('.') else: module = self.module rec_id2 = rec_id id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2) # check if the resource already existed at the last update if id: # if it existed, we don't update the data, but we need to # know the id of the existing record anyway self.idref[rec_id] = int(id) return None else: # if the resource didn't exist if not self.nodeattr2bool(rec, 'forcecreate', True): # we don't want to create it, so we skip it return None # else, we let the record to be created
469,071
def _tag_record(self, cr, rec, data_node=None): rec_model = rec.get("model").encode('ascii') model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.get("id",'').encode('ascii') rec_context = rec.get("context", None) if rec_context: rec_context = unsafe_eval(rec_context) self._test_xml_id(rec_id) if self.isnoupdate(data_node) and self.mode != 'init': # check if the xml record has an id string if rec_id: if '.' in rec_id: module,rec_id2 = rec_id.split('.') else: module = self.module rec_id2 = rec_id id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2) # check if the resource already existed at the last update if id: # if it existed, we don't update the data, but we need to # know the id of the existing record anyway self.idref[rec_id] = int(id) return None else: # if the resource didn't exist if not self.nodeattr2bool(rec, 'forcecreate', True): # we don't want to create it, so we skip it return None # else, we let the record to be created
def _tag_record(self, cr, rec, data_node=None): rec_model = rec.get("model").encode('ascii') model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.get("id",'').encode('ascii') rec_context = rec.get("context", None) if rec_context: rec_context = unsafe_eval(rec_context) self._test_xml_id(rec_id) if self.isnoupdate(data_node) and self.mode != 'init': # check if the xml record has an id string if rec_id: if '.' in rec_id: module,rec_id2 = rec_id.split('.') else: module = self.module rec_id2 = rec_id id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, module, rec_id2) # check if the resource already existed at the last update if id: # if it existed, we don't update the data, but we need to # know the id of the existing record anyway self.idref[rec_id] = int(id) return None else: # if the resource didn't exist if not self.nodeattr2bool(rec, 'forcecreate', True): # we don't want to create it, so we skip it return None # else, we let the record to be created
469,072
def _lang_get(self, cr, uid, context={}): obj = self.pool.get('res.lang') ids = obj.search(cr, uid, [], context=context) res = obj.read(cr, uid, ids, ['code', 'name'], context) return [(r['code'], r['name']) for r in res] + [('','')]
def _lang_get(self, cr, uid, context={}): obj = self.pool.get('res.lang') ids = obj.search(cr, uid, [], context=context) res = obj.read(cr, uid, ids, ['code', 'name'], context) return [(r['code'], r['name']) for r in res] + [('','')]
469,073
def _get_level(self, cr, uid, ids, field_name, arg, context={}): res={} accounts = self.browse(cr, uid, ids) for account in accounts: level = 0 if account.parent_id : obj = self.browse(cr, uid, account.parent_id.id) level = obj.level + 1 res[account.id] = level return res
def _get_level(self, cr, uid, ids, field_name, arg, context={}): res={} accounts = self.browse(cr, uid, ids) for account in accounts: level = 0 if account.parent_id : obj = self.browse(cr, uid, account.parent_id.id) level = obj.level + 1 res[account.id] = level return res
469,074
def unlink(self, cr, user, ids, context=None): for field in self.browse(cr, user, ids, context): if field.state <> 'manual': raise except_orm(_('Error'), _("You can not remove the field '%s' !") %(field.name,)) # # MAY BE ADD A ALTER TABLE DROP ? # return super(ir_model_fields, self).unlink(cr, user, ids, context)
def unlink(self, cr, user, ids, context=None): for field in self.browse(cr, user, ids, context): if field.state <> 'manual': raise except_orm(_('Error'), _("You cannot remove the field '%s' !") %(field.name,)) # # MAY BE ADD A ALTER TABLE DROP ? # return super(ir_model_fields, self).unlink(cr, user, ids, context)
469,075
def _makeInvoices(self, cr, uid, context={}): invoices = {} invoice_ids = [] create_ids=[] tax_ids=[] inv_create = 0 inv_reject = 0 inv_rej_reason = "" list_inv = [] obj_event_reg = self.pool.get('event.registration') obj_lines = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') data_event_reg = obj_event_reg.browse(cr,uid, context['active_ids'], context=context)
def _makeInvoices(self, cr, uid, context={}): invoices = {} invoice_ids = [] create_ids=[] tax_ids=[] inv_create = 0 inv_reject = 0 inv_rej_reason = "" list_inv = [] obj_event_reg = self.pool.get('event.registration') obj_lines = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') data_event_reg = obj_event_reg.browse(cr,uid, context['active_ids'], context=context)
469,076
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') project_obj = self.pool.get('project.project') task_obj = self.pool.get('project.task') uom_obj = self.pool.get('product.uom') vals_line = {} context = kwargs.get('context', {}) #TOFIX: after loading project_timesheet module, it's fail yml of other project* modules. #Temporary: pass context['withoutemployee'] = True in all yml. if 'withoutemployee' in context and context['withoutemployee']: return super(project_work,self).create(cr, uid, vals, context=context) obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] #calculate quantity based on employee's product's uom vals_line['unit_amount'] = vals['hours'] user_uom, default_uom = project_obj._get_user_and_default_uom_ids(cr, uid) if result['product_uom_id'] != default_uom: vals_line['unit_amount'] = uom_obj._compute_qty(cr, uid, default_uom, vals['hours'], result['product_uom_id']) acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 0.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=context)
def create(self, cr, uid, vals, *args, **kwargs): obj_timesheet = self.pool.get('hr.analytic.timesheet') project_obj = self.pool.get('project.project') task_obj = self.pool.get('project.task') uom_obj = self.pool.get('product.uom') vals_line = {} context = kwargs.get('context', {}) #TOFIX: after loading project_timesheet module, it's fail yml of other project* modules. #Temporary: pass context['withoutemployee'] = True in all yml. if 'withoutemployee' in context and context['withoutemployee']: return super(project_work,self).create(cr, uid, vals, context=context) obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] vals_line['date'] = vals['date'][:10] #calculate quantity based on employee's product's uom vals_line['unit_amount'] = vals['hours'] user_uom, default_uom = project_obj._get_user_and_default_uom_ids(cr, uid) if result['product_uom_id'] != default_uom: vals_line['unit_amount'] = uom_obj._compute_qty(cr, uid, default_uom, vals['hours'], result['product_uom_id']) acc_id = obj_task.project_id.analytic_account_id.id vals_line['account_id'] = acc_id res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 0.0 vals_line['product_uom_id'] = result['product_uom_id'] amount = vals_line['unit_amount'] prod_id = vals_line['product_id'] unit = False timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=context)
469,077
def create_planning(self,cr, uid, ids, context=None): if context is None: context = {} product_obj = self.pool.get('product.product') planning_obj = self.pool.get('stock.planning') mod_obj = self.pool.get('ir.model.data') prod_categ_obj = self.pool.get('product.category') template_obj = self.pool.get('product.template') planning_lines = [] for f in self.browse(cr, uid, ids, context=context): if f.forecasted_products: cr.execute("SELECT product_id \ FROM stock_sale_forecast \ WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id2.id, f.warehouse_id2.id)) products_id1 = [x for x, in cr.fetchall()] else: categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or [] prod_categ_ids = prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)]) templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)]) products_id1 = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)]) if len(products_id1)==0: raise osv.except_osv(_('Error !'), _('No forecasts for selected period or no products in selected category !'))
def create_planning(self,cr, uid, ids, context=None): if context is None: context = {} product_obj = self.pool.get('product.product') planning_obj = self.pool.get('stock.planning') mod_obj = self.pool.get('ir.model.data') prod_categ_obj = self.pool.get('product.category') template_obj = self.pool.get('product.template') planning_lines = [] for f in self.browse(cr, uid, ids, context=context): if f.forecasted_products: cr.execute("SELECT product_id \ FROM stock_sale_forecast \ WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id.id, f.warehouse_id.id)) products_id1 = [x for x, in cr.fetchall()] else: categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or [] prod_categ_ids = prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)]) templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)]) products_id1 = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)]) if len(products_id1)==0: raise osv.except_osv(_('Error !'), _('No forecasts for selected period or no products in selected category !'))
469,078
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
def _amount_all(self, cr, uid, ids, field_name, arg, context=None): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
469,079
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
469,080
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur = order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
469,081
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val+= c['amount'] val1 += line.price_subtotal res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
def _amount_all(self, cr, uid, ids, field_name, arg, context): res = {} cur_obj=self.pool.get('res.currency') for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, 'amount_total': 0.0, } val = val1 = 0.0 cur=order.pricelist_id.currency_id for line in order.order_line: for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']: val += c['amount'] res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1) res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] return res
469,082
def search_message(self, cr, uid, message, context=None): #@param message: string of mail which is read from EML File #@return model,res_id references = [] dictcreate = dict(message) msg = dictcreate.get('message') msg = self.pool.get('email.server.tools').parse_message(msg) message_id = msg.get('message-id') refs = msg.get('references') references = refs.split() msg_pool = self.pool.get('mailgate.message') model = '' res_id = 0 if message_id: msg_ids = msg_pool.search(cr, uid, [('message_id','=',message_id)]) if msg_ids and len(msg_ids): msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id else: if references : msg_ids = msg_pool.search(cr, uid, [('message_id','in',references)]) msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id return (model,res_id)
def search_message(self, cr, uid, message, context=None): #@param message: string of mail which is read from EML File #@return model,res_id references = [] dictcreate = dict(message) msg = dictcreate.get('message') msg = self.pool.get('email.server.tools').parse_message(msg) message_id = msg.get('message-id') refs = msg.get('references',False) references = False if refs: references = refs.split() msg_pool = self.pool.get('mailgate.message') model = '' res_id = 0 if message_id: msg_ids = msg_pool.search(cr, uid, [('message_id','=',message_id)]) if msg_ids and len(msg_ids): msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id else: if references : msg_ids = msg_pool.search(cr, uid, [('message_id','in',references)]) msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id return (model,res_id)
469,083
def search_message(self, cr, uid, message, context=None): #@param message: string of mail which is read from EML File #@return model,res_id references = [] dictcreate = dict(message) msg = dictcreate.get('message') msg = self.pool.get('email.server.tools').parse_message(msg) message_id = msg.get('message-id') refs = msg.get('references') references = refs.split() msg_pool = self.pool.get('mailgate.message') model = '' res_id = 0 if message_id: msg_ids = msg_pool.search(cr, uid, [('message_id','=',message_id)]) if msg_ids and len(msg_ids): msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id else: if references : msg_ids = msg_pool.search(cr, uid, [('message_id','in',references)]) msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id return (model,res_id)
def search_message(self, cr, uid, message, context=None): #@param message: string of mail which is read from EML File #@return model,res_id references = [] dictcreate = dict(message) msg = dictcreate.get('message') msg = self.pool.get('email.server.tools').parse_message(msg) message_id = msg.get('message-id') refs = msg.get('references') references = refs.split() msg_pool = self.pool.get('mailgate.message') model = '' res_id = 0 if message_id: msg_ids = msg_pool.search(cr, uid, [('message_id','=',message_id)]) if msg_ids and len(msg_ids): if msg_ids and len(msg_ids): msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id else: if references : msg_ids = msg_pool.search(cr, uid, [('message_id','in',references)]) if msg_ids and len(msg_ids): msg = msg_pool.browse(cr, uid, msg_ids[0]) model = msg.model res_id = msg.res_id return (model,res_id)
469,084
def _debit_credit_bal_qtty(self, cr, uid, ids, name, arg, context=None): res = {} if context is None: context = {} child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) for i in child_ids: res[i] = {} for n in name: res[i][n] = 0.0
def _debit_credit_bal_qtty(self, cr, uid, ids, name, arg, context=None): res = {} if context is None: context = {} child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) for i in child_ids: res[i] = {} for n in name: res[i][n] = 0.0
469,085
def doIndex(self, content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None if content_type and self.mimes.has_key(content_type): mime = content_type fobj = self.mimes[content_type] elif filename: bname,ext = os.path.splitext(filename) if self.exts.has_key(ext): fobj = self.exts[ext] mime = fobj._getDefMime(ext) if content_type and not fobj: mime,fobj = mime_match(content_type, self.mimes) if not fobj: try: if realfname : fname = realfname else: bname,ext = os.path.splitext(filename) fd, fname = tempfile.mkstemp(suffix=ext) os.write(fd, content) os.close(fd) fp = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE).stdout result = fp.read() fp.close() mime2 = result.split(';')[0] self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. mime,fobj = mime_match(mime2, self.mimes) if not mime: mime = mime2 except Exception: self.__logger.exception('Cannot determine mime type') try: if fobj: res = (mime, fobj.indexContent(content,filename,fname or realfname) ) else: self.__logger.debug("Have no object, return (%s, None)", mime) res = (mime, None ) except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname) res = None # If we created a tmp file, unlink it now if not realfname and fname: try: os.unlink(fname) except Exception: self.__logger.exception("Could not unlink %s", fname) return res
def doIndex(self, content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None if content_type and self.mimes.has_key(content_type): mime = content_type fobj = self.mimes[content_type] elif filename: try: bname,ext = os.path.splitext(filename or 'test.tmp') except Exception: bname, ext = filename, 'tmp' if self.exts.has_key(ext): fobj = self.exts[ext] mime = fobj._getDefMime(ext) if content_type and not fobj: mime,fobj = mime_match(content_type, self.mimes) if not fobj: try: if realfname : fname = realfname else: try: bname,ext = os.path.splitext(filename or 'test.tmp') except Exception: bname, ext = filename, 'tmp' fd, fname = tempfile.mkstemp(suffix=ext) os.write(fd, content) os.close(fd) fp = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE).stdout result = fp.read() fp.close() mime2 = result.split(';')[0] self.__logger.debug('File gave us: %s', mime2) # Note that the temporary file still exists now. mime,fobj = mime_match(mime2, self.mimes) if not mime: mime = mime2 except Exception: self.__logger.exception('Cannot determine mime type') try: if fobj: res = (mime, fobj.indexContent(content,filename,fname or realfname) ) else: self.__logger.debug("Have no object, return (%s, None)", mime) res = (mime, None ) except Exception: self.__logger.exception("Could not index file %s (%s)", filename, fname or realfname) res = None # If we created a tmp file, unlink it now if not realfname and fname: try: os.unlink(fname) except Exception: self.__logger.exception("Could not unlink %s", fname) return res
469,086
def __compute(self, cr, uid, ids, field_names, arg=None, context=None, query='', query_params=()): """ compute the balance, debit and/or credit for the provided account ids Arguments: `ids`: account ids `field_names`: the fields to compute (a list of any of 'balance', 'debit' and 'credit') `arg`: unused fields.function stuff `query`: additional query filter (as a string) `query_params`: parameters for the provided query string (__compute will handle their escaping) as a tuple """ mapping = { 'balance': "COALESCE(SUM(l.debit),0) " \ "- COALESCE(SUM(l.credit), 0) as balance", 'debit': "COALESCE(SUM(l.debit), 0) as debit", 'credit': "COALESCE(SUM(l.credit), 0) as credit" } #get all the necessary accounts children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context) #compute for each account the balance/debit/credit from the move lines accounts = {} if children_and_consolidated: aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
def __compute(self, cr, uid, ids, field_names, arg=None, context=None, query='', query_params=()): """ compute the balance, debit and/or credit for the provided account ids Arguments: `ids`: account ids `field_names`: the fields to compute (a list of any of 'balance', 'debit' and 'credit') `arg`: unused fields.function stuff `query`: additional query filter (as a string) `query_params`: parameters for the provided query string (__compute will handle their escaping) as a tuple """ mapping = { 'balance': "COALESCE(SUM(l.debit),0) " \ "- COALESCE(SUM(l.credit), 0) as balance", 'debit': "COALESCE(SUM(l.debit), 0) as debit", 'credit': "COALESCE(SUM(l.credit), 0) as credit" } #get all the necessary accounts children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context) #compute for each account the balance/debit/credit from the move lines accounts = {} if children_and_consolidated: aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
469,087
def _default_company(self, cr, uid, context={}): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) if user.company_id: return user.company_id.id return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
def _default_company(self, cr, uid, context={}): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) if user.company_id: return user.company_id.id return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
469,088
def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None): res = {} res['value'] = {} res['value']["sale_tax"] = False res['value']["purchase_tax"] = False if chart_template_id: ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" , "=", chart_template_id)], order="sequence") if len(ids) > 0: id=ids[0] res['value']["sale_tax"] = id res['value']["purchase_tax"] = id return res
def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None): res = {} res['value'] = {} res['value']["sale_tax"] = False res['value']["purchase_tax"] = False if chart_template_id: sale_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" , "=", chart_template_id), ('type_tax_use', 'in', ('sale','all'))], order="sequence") purchase_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" , "=", chart_template_id), ('type_tax_use', 'in', ('purchase','all'))], order="sequence") res['value']["sale_tax"] = sale_tax_ids and sale_tax_ids[0] or False res['value']["purchase_tax"] = purchase_tax_ids and purchase_tax_ids[0] or False return res
469,089
def make_sscc(self, cr, uid, context=None): sequence = self.pool.get('ir.sequence').get(cr, uid, 'stock.lot.tracking') return sequence + str(self.checksum(sequence))
def make_sscc(self, cr, uid, context=None): sequence = self.pool.get('ir.sequence').get(cr, uid, 'stock.lot.tracking') return sequence + str(self.checksum(sequence))
469,090
def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) new_id = super(stock_picking, self).create(cr, user, vals, context) return new_id
def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) new_id = super(stock_picking, self).create(cr, user, vals, context) return new_id
469,091
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
469,092
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id') prodlot_ids[move.id] = prodlot_id if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
469,093
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
469,094
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
469,095
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
469,096
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
469,097
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
469,098
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
defdo_partial(self,cr,uid,ids,partial_datas,context=None):"""Makespartialpickingandmovesdone.@parampartial_datas:Dictionarycontainingdetailsofpartialpickinglikepartner_id,address_id,delivery_date,deliverymoveswithproduct_id,product_qty,uom@return:Dictionaryofvalues"""ifcontextisNone:context={}else:context=dict(context)res={}move_obj=self.pool.get('stock.move')product_obj=self.pool.get('product.product')currency_obj=self.pool.get('res.currency')users_obj=self.pool.get('res.users')uom_obj=self.pool.get('product.uom')price_type_obj=self.pool.get('product.price.type')sequence_obj=self.pool.get('ir.sequence')wf_service=netsvc.LocalService("workflow")partner_id=partial_datas.get('partner_id',False)address_id=partial_datas.get('address_id',False)delivery_date=partial_datas.get('delivery_date',False)forpickinself.browse(cr,uid,ids,context=context):new_picking=Nonenew_moves=[]complete,too_many,too_few=[],[],[]move_product_qty={}formoveinpick.move_lines:ifmove.statein('done','cancel'):continuepartial_data=partial_datas.get('move%s'%(move.id),False)assertpartial_data,_('DonotFoundPartialdataofStockMoveLine:%s'%(move.id))product_qty=partial_data.get('product_qty',0.0)move_product_qty[move.id]=product_qtyproduct_uom=partial_data.get('product_uom',False)product_price=partial_data.get('product_price',0.0)product_currency=partial_data.get('product_currency',False)prodlot_id=partial_data.get('prodlot_id',False)ifmove.product_qty==product_qty:complete.append(move)elifmove.product_qty>product_qty:too_few.append(move)else:too_many.append(move)
469,099