bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def action_done(self, cr, uid, ids, context=None): track_flag = False for move in self.browse(cr, uid, ids): if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting', 'confirmed'): self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) else: pass # self.action_done(cr, uid, [move.move_dest_id.id]) if move.move_dest_id.auto_validate: self.action_done(cr, uid, [move.move_dest_id.id], context=context)
def action_done(self, cr, uid, ids, context=None): track_flag = False for move in self.browse(cr, uid, ids): if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting', 'confirmed'): self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) else: pass # self.action_done(cr, uid, [move.move_dest_id.id]) if move.move_dest_id.auto_validate: self.action_done(cr, uid, [move.move_dest_id.id], context=context)
468,800
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.period_ids = [] self.journal_ids = [] self.localcontext.update( { 'time': time, 'lines': self.lines, 'periods': self.periods, 'sum_debit_period': self._sum_debit_period, 'sum_credit_period': self._sum_credit_period, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_fiscalyear': self._get_fiscalyear, 'get_account': self._get_account, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_sortby': self._get_sortby, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_filter': self._get_filter, 'get_journal': self._get_journal, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_currency ':self.get_currency })
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.period_ids = [] self.journal_ids = [] self.localcontext.update( { 'time': time, 'lines': self.lines, 'periods': self.periods, 'sum_debit_period': self._sum_debit_period, 'sum_credit_period': self._sum_credit_period, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_fiscalyear': self._get_fiscalyear, 'get_account': self._get_account, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_sortby': self._get_sortby, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_filter': self._get_filter, 'get_journal': self._get_journal, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_currency ':self.get_currency })
468,801
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.period_ids = [] self.journal_ids = [] self.localcontext.update( { 'time': time, 'lines': self.lines, 'periods': self.periods, 'sum_debit_period': self._sum_debit_period, 'sum_credit_period': self._sum_credit_period, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_fiscalyear': self._get_fiscalyear, 'get_account': self._get_account, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_sortby': self._get_sortby, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_filter': self._get_filter, 'get_journal': self._get_journal, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_currency ':self.get_currency })
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.period_ids = [] self.journal_ids = [] self.localcontext.update( { 'time': time, 'lines': self.lines, 'periods': self.periods, 'sum_debit_period': self._sum_debit_period, 'sum_credit_period': self._sum_credit_period, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_fiscalyear': self._get_fiscalyear, 'get_account': self._get_account, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_sortby': self._get_sortby, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_filter': self._get_filter, 'get_journal': self._get_journal, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_currency ':self._get_currency })
468,802
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()
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()
468,803
def _get_account(self, data): if data['model']=='account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).company_id.name return super(journal_print ,self)._get_account(data)
def _get_account(self, data): if data['model']=='account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).company_id.name return super(journal_print ,self)._get_account(data)
468,804
def _get_fiscalyear(self, data): if data['model']=='account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).fiscalyear_id.name return super(journal_print ,self)._get_fiscalyear(data)
def _get_fiscalyear(self, data): if data['model']=='account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).fiscalyear_id.name return super(journal_print ,self)._get_fiscalyear(data)
468,805
def _get_currency(self, data): if data['model']=='account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).journal_id.currency or False return data['form']['amount_currency']
def _get_currency(self, data): if data['model']=='account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).journal_id.currency or False return data['form']['amount_currency']
468,806
def find_child(obj): self.list[obj.code]=str(obj.amount) if obj.child_ids: for child in obj.child_ids: find_child(child) return True
def find_child(obj): self.list[str(obj.code)]=str(obj.amount) if obj.child_ids: for child in obj.child_ids: find_child(child) return True
468,807
def rg(ids, table, parent): if not ids: return [] ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context) return ids + rg(ids2, table, parent)
def rg(ids, table, parent): if not ids: return [] ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context) return ids + rg(ids2, table, parent)
468,808
def _balance_search(self, cursor, user, obj, name, args): if not len(args): return [] where = ' and '.join(map(lambda x: '(abs(sum(debit-credit))'+x[1]+str(x[2])+')',args)) cursor.execute('select id, sum(debit-credit) from account_move_line \ group by id,debit,credit having '+where) res = cursor.fetchall() if not len(res): return [('id', '=', '0')] return [('id', 'in', [x[0] for x in res])]
def _balance_search(self, cursor, user, obj, name, args, domain=None, context=None): if context is None: context = {} if not len(args): return [] where = ' and '.join(map(lambda x: '(abs(sum(debit-credit))'+x[1]+str(x[2])+')',args)) cursor.execute('select id, sum(debit-credit) from account_move_line \ group by id,debit,credit having '+where) res = cursor.fetchall() if not len(res): return [('id', '=', '0')] return [('id', 'in', [x[0] for x in res])]
468,809
def handle_one_request(self): """Handle a single HTTP request. Dispatch to the correct handler. """ self.request.setblocking(True) self.raw_requestline = self.rfile.readline() if not self.raw_requestline: self.close_connection = 1 # self.log_message("no requestline, connection closed?") return if not self.parse_rawline(): self.log_message("Could not parse rawline.") return # self.parse_request(): # Do NOT parse here. the first line should be the only if self.path == '*' and self.command == 'OPTIONS': # special handling of path='*', must not use any vdir at all. if not self.parse_request(): return self.do_OPTIONS() return for vdir in self.server.vdirs: p = vdir.matches(self.path) if p == False: continue npath = self.path[len(p):] if not npath.startswith('/'): npath = '/' + npath
def handle_one_request(self): """Handle a single HTTP request. Dispatch to the correct handler. """ self.request.setblocking(True) self.raw_requestline = self.rfile.readline() if not self.raw_requestline: self.close_connection = 1 # self.log_message("no requestline, connection closed?") return if not self.parse_rawline(): self.log_message("Could not parse rawline.") return # self.parse_request(): # Do NOT parse here. the first line should be the only if self.path == '*' and self.command == 'OPTIONS': # special handling of path='*', must not use any vdir at all. if not self.parse_request(): return self.do_OPTIONS() return for vdir in self.server.vdirs: p = vdir.matches(self.path) if p == False: continue npath = self.path[len(p):] if not npath.startswith('/'): npath = '/' + npath
468,810
def _ref_lines(self,form): result = [] res = {} acc_id = [] final = [] acc_pool = self.pool.get('account.analytic.account') line_pool = self.pool.get('account.analytic.line')
def _ref_lines(self,form): result = [] res = {} acc_id = [] final = [] acc_pool = self.pool.get('account.analytic.account') line_pool = self.pool.get('account.analytic.line')
468,811
def _lines(self,form,ids={}): if not ids: ids = self.ids
def _lines(self,form,ids={}): if not ids: ids = self.ids
468,812
def unlink(self, cr, uid, ids, context=None): for pick in self.browse(cr, uid, ids, context=context): if pick.state in ['done','cancel']: raise osv.except_osv(_('Error'), _('You cannot remove the picking which is in %s state !')%(pick.state,)) elif pick.state in ['confirmed','assigned']: ids2 = [move.id for move in pick.move_lines] context.update({'call_unlink':True}) self.pool.get('stock.move').action_cancel(cr, uid, ids2, context) else: continue return super(stock_picking, self).unlink(cr, uid, ids, context=context)
def unlink(self, cr, uid, ids, context=None): for pick in self.browse(cr, uid, ids, context=context): if pick.state in ['done','cancel']: raise osv.except_osv(_('Error'), _('You cannot remove the picking which is in %s state !')%(pick.state,)) elif pick.state in ['confirmed','assigned', 'draft']: ids2 = [move.id for move in pick.move_lines] context.update({'call_unlink':True}) self.pool.get('stock.move').action_cancel(cr, uid, ids2, context) else: continue return super(stock_picking, self).unlink(cr, uid, ids, context=context)
468,813
def unlink(self, cr, uid, ids, context=None): for pick in self.browse(cr, uid, ids, context=context): if pick.state in ['done','cancel']: raise osv.except_osv(_('Error'), _('You cannot remove the picking which is in %s state !')%(pick.state,)) elif pick.state in ['confirmed','assigned']: ids2 = [move.id for move in pick.move_lines] context.update({'call_unlink':True}) self.pool.get('stock.move').action_cancel(cr, uid, ids2, context) else: continue return super(stock_picking, self).unlink(cr, uid, ids, context=context)
def unlink(self, cr, uid, ids, context=None): for pick in self.browse(cr, uid, ids, context=context): if pick.state in ['done','cancel']: raise osv.except_osv(_('Error'), _('You cannot remove the picking which is in %s state !')%(pick.state,)) elif pick.state in ['confirmed','assigned']: ids2 = [move.id for move in pick.move_lines] ctx = context.copy() ctx.update({'call_unlink':True}) if pick.state != 'draft': move_obj.action_cancel(cr, uid, ids2, ctx) move_obj.unlink(cr, uid, ids2, ctx) return super(stock_picking, self).unlink(cr, uid, ids, context=context)
468,814
def create_xml(self, cr, uid, ids, context=None): obj_fyear = self.pool.get('account.fiscalyear') obj_tax_code = self.pool.get('account.tax.code') obj_acc_period = self.pool.get('account.period') obj_user = self.pool.get('res.users') mod_obj = self.pool.get('ir.model.data')
def create_xml(self, cr, uid, ids, context=None): obj_fyear = self.pool.get('account.fiscalyear') obj_tax_code = self.pool.get('account.tax.code') obj_acc_period = self.pool.get('account.period') obj_user = self.pool.get('res.users') mod_obj = self.pool.get('ir.model.data')
468,815
def create_xml(self, cr, uid, ids, context=None): obj_fyear = self.pool.get('account.fiscalyear') obj_tax_code = self.pool.get('account.tax.code') obj_acc_period = self.pool.get('account.period') obj_user = self.pool.get('res.users') mod_obj = self.pool.get('ir.model.data')
def create_xml(self, cr, uid, ids, context=None): obj_fyear = self.pool.get('account.fiscalyear') obj_tax_code = self.pool.get('account.tax.code') obj_acc_period = self.pool.get('account.period') obj_user = self.pool.get('res.users') mod_obj = self.pool.get('ir.model.data')
468,816
# TODO def unlink(...
# TODO def unlink(...
468,817
def _do_assign(self, cr, uid, data, context): task_obj = pooler.get_pool(cr.dbname).get('project.task') task = task_obj.browse(cr, uid, data['id'], context) newname = data['form']['prefix'] or '' task_obj.copy(cr, uid, data['id'], { 'name': data['form']['name'], 'user_id': data['form']['user_id'], 'planned_hours': data['form']['planned_hours'], 'remaining_hours': data['form']['planned_hours'], 'parent_id': data['id'], 'state': 'open', 'description': data['form']['new_task_description'] or '', 'child_ids': [], 'work_ids': [] }) task_obj.write(cr, uid, data['id'], { 'remaining_hours': data['form']['planned_hours_me'], 'name': newname }) if data['form']['state']=='pending': task_obj.do_pending(cr, uid, [data['id']]) else: task_obj.do_close(cr, uid, [data['id']]) return {}
def _do_assign(self, cr, uid, data, context): task_obj = pooler.get_pool(cr.dbname).get('project.task') task = task_obj.browse(cr, uid, data['id'], context) newname = data['form']['prefix'] or '' task_obj.copy(cr, uid, data['id'], { 'name': data['form']['name'], 'user_id': data['form']['user_id'], 'planned_hours': data['form']['planned_hours'], 'remaining_hours': data['form']['planned_hours'], 'parent_id': data['id'], 'state': 'open', 'description': data['form']['new_task_description'] or '', 'child_ids': [], 'work_ids': [] }) task_obj.write(cr, uid, [data['id']], { 'remaining_hours': data['form']['planned_hours_me'], 'name': newname }) if data['form']['state']=='pending': task_obj.do_pending(cr, uid, [data['id']]) else: task_obj.do_close(cr, uid, [data['id']]) return {}
468,818
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """
468,819
def compute_refund(self, cr, uid, ids, mode='refund', context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: the account invoice refund’s ID or list of IDs
def compute_refund(self, cr, uid, ids, mode='refund', context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: the account invoice refund’s ID or list of IDs
468,820
# def ref() added because , if context has ref('id') eval wil use this ref
# def ref() added because , if context has ref('id') eval wil use this ref
468,821
def ref(str_id): return self.id_get(cr, None, str_id)
def ref(str_id): return self.id_get(cr, None, str_id)
468,822
def list_web(self, cr, uid, context=False): """ list_web(cr, uid, context) -> [module_name] Lists all the currently installed modules with a web component.
def list_web(self, cr, uid, context=None): """ list_web(cr, uid, context) -> [module_name] Lists all the currently installed modules with a web component.
468,823
def get_web(self, cr, uid, names, context=False): """ get_web(cr, uid, [module_name], context) -> [{name, depends, content}]
def _web_dependencies(self, cr, uid, module, context=None): for dependency in module.dependencies_id: (parent,) = self.browse(cr, uid, self.search(cr, uid, [('name', '=', dependency.name)], context=context), context=context) if parent.web: yield parent.name else: self._web_dependencies( cr, uid, parent, context=context) def get_web(self, cr, uid, names, context=None): """ get_web(cr, uid, [module_name], context) -> [{name, depends, content}]
468,824
def get_web(self, cr, uid, names, context=False): """ get_web(cr, uid, [module_name], context) -> [{name, depends, content}]
def get_web(self, cr, uid, names, context=False): """ get_web(cr, uid, [module_name], context) -> [{name, depends, content}]
468,825
def login(db, login, password): print 'login' pool = pooler.get_pool(db) user_obj = pool.get('res.users') res = user_obj.login(db, login, password) print 'login end' return res
def login(db, login, password): pool = pooler.get_pool(db) user_obj = pool.get('res.users') res = user_obj.login(db, login, password) print 'login end' return res
468,826
def login(db, login, password): print 'login' pool = pooler.get_pool(db) user_obj = pool.get('res.users') res = user_obj.login(db, login, password) print 'login end' return res
def login(db, login, password): print 'login' pool = pooler.get_pool(db) user_obj = pool.get('res.users') return user_obj.login(db, login, password)
468,827
def _employee_get(obj, cr, uid, context=None): if context is None: context = {} ids = obj.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if ids: return ids[0] return False
def _employee_get(obj, cr, uid, context=None): if context is None: context = {} ids = obj.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if ids: return ids[0] return False
468,828
def holidays_validate2(self, cr, uid, ids, *args): vals = {'state':'validate1'} self.check_holidays(cr, uid, ids) ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)]) if ids2: vals['manager_id'] = ids2[0] else: raise osv.except_osv(_('Warning !'),_('No user related to the selected employee.')) return self.write(cr, uid, ids, vals)
def holidays_validate2(self, cr, uid, ids, *args): vals = {'state':'validate1'} self.check_holidays(cr, uid, ids) ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) if ids2: vals['manager_id'] = ids2[0] else: raise osv.except_osv(_('Warning !'),_('No user related to the selected employee.')) return self.write(cr, uid, ids, vals)
468,829
def holidays_validate(self, cr, uid, ids, *args): obj_emp = self.pool.get('hr.employee') data_holiday = self.browse(cr, uid, ids) self.check_holidays(cr, uid, ids) vals = {'state':'validate'} ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) if ids2: if data_holiday[0].state == 'validate1': vals['manager_id2'] = ids2[0] else: vals['manager_id'] = ids2[0] else: raise osv.except_osv(_('Warning !'), _('No user related to the selected employee.')) self.write(cr, uid, ids, vals) for record in data_holiday: if record.holiday_type == 'employee' and record.type == 'remove': vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': record.employee_id.calendar_id.id, 'company_id': record.employee_id.company_id.id, 'resource_id': record.employee_id.resource_id.id, 'holiday_id': record.id } self._create_resource_leave(cr, uid, vals) elif record.holiday_type == 'category' and record.type == 'remove': emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)]) for emp in obj_emp.browse(cr, uid, emp_ids): vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': emp.calendar_id.id, 'company_id': emp.company_id.id, 'resource_id': emp.resource_id.id, 'holiday_id':record.id } self._create_resource_leave(cr, uid, vals) return True
def holidays_validate(self, cr, uid, ids, *args): obj_emp = self.pool.get('hr.employee') data_holiday = self.browse(cr, uid, ids) self.check_holidays(cr, uid, ids) vals = {'state':'validate'} ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) if ids2: if data_holiday[0].state == 'validate1': vals['manager_id2'] = ids2[0] else: vals['manager_id'] = ids2[0] else: raise osv.except_osv(_('Warning !'), _('No user related to the selected employee.')) self.write(cr, uid, ids, vals) for record in data_holiday: if record.holiday_type == 'employee' and record.type == 'remove': vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': record.employee_id.calendar_id.id, 'company_id': record.employee_id.company_id.id, 'resource_id': record.employee_id.resource_id.id, 'holiday_id': record.id } for leave_id in self.search(cr, uid, [('category_holiday_id', '=', record.id)]): wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr) elif record.holiday_type == 'category' and record.type == 'remove': emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)]) for emp in obj_emp.browse(cr, uid, emp_ids): vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': emp.calendar_id.id, 'company_id': emp.company_id.id, 'resource_id': emp.resource_id.id, 'holiday_id':record.id } for leave_id in self.search(cr, uid, [('category_holiday_id', '=', record.id)]): wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr) return True
468,830
def holidays_confirm(self, cr, uid, ids, *args): obj_hr_holiday_status = self.pool.get('hr.holidays.status') for record in self.browse(cr, uid, ids): user_id = False leave_asked = record.number_of_days_temp if record.holiday_type == 'employee' and record.type == 'remove': if record.employee_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days( cr, uid, [record.holiday_status_id.id], record.employee_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for employee %s while there are too few remaining leave days.') % (record.employee_id.name)) nb = -(record.number_of_days_temp) elif record.holiday_type == 'category' and record.type == 'remove': if record.category_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days_cat( cr, uid, [record.holiday_status_id.id], record.category_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for category %s while there are too few remaining leave days.') % (record.category_id.name)) nb = -(record.number_of_days_temp) else: nb = record.number_of_days_temp
def holidays_confirm(self, cr, uid, ids, *args): obj_hr_holiday_status = self.pool.get('hr.holidays.status') for record in self.browse(cr, uid, ids): user_id = False leave_asked = record.number_of_days_temp if record.holiday_type == 'employee' and record.type == 'remove': if record.employee_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days( cr, uid, [record.holiday_status_id.id], record.employee_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for employee %s while there are too few remaining leave days.') % (record.employee_id.name)) nb = -(record.number_of_days_temp) elif record.holiday_type == 'category' and record.type == 'remove': if record.category_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days_cat( cr, uid, [record.holiday_status_id.id], record.category_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for category %s while there are too few remaining leave days.') % (record.category_id.name)) nb = -(record.number_of_days_temp) else: nb = record.number_of_days_temp
468,831
def holidays_refuse(self, cr, uid, ids, *args): vals = {'state': 'refuse'} ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)]) if ids2: vals['manager_id'] = ids2[0] self.write(cr, uid, ids, vals) return True
def holidays_refuse(self, cr, uid, ids, *args): vals = {'state': 'refuse'} ids2 = obj_emp.search(cr, uid, [('user_id','=', uid)]) if ids2: vals['manager_id'] = ids2[0] self.write(cr, uid, ids, vals) return True
468,832
def holidays_cancel(self, cr, uid, ids, *args): self._update_user_holidays(cr, uid, ids) self.write(cr, uid, ids, {'state': 'cancel'}) self._remove_resouce_leave(cr, uid, ids) return True
def holidays_cancel(self, cr, uid, ids, *args): self._update_user_holidays(cr, uid, ids) self.write(cr, uid, ids, {'state': 'cancel'}) leave_ids = self._get_category_leave_ids(cr, uid, ids) if leave_ids: self.unlink(cr, uid, leave_ids) return True
468,833
def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {}
def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {}
468,834
def _check_date(self, cr, uid, ids): if ids: cr.execute('select number_of_days_temp from hr_holidays where id in ('+','.join(map(str, ids))+')') res = cr.fetchall() if res and res[0][0] < 0: return False return True
def _check_date(self, cr, uid, ids): if ids: cr.execute('select number_of_days_temp from hr_holidays where id in ('+','.join(map(str, ids))+')') res = cr.fetchall() if res and res[0][0] and res[0][0] < 0: return False return True
468,835
def __str__(self): return self._str
def __str__(self): return self._str
468,836
def _check_has_start(self, cr, uid, ids, context=None): for campaign in self.browse(cr, uid, ids, context=context): if not any(a.start for a in campaign.activity_ids): return False return True
def _check_has_start(self, cr, uid, ids, context=None): for campaign in self.browse(cr, uid, ids, context=context): if not any(a.start for a in campaign.activity_ids): return False return True
468,837
def state_running_set(self, cr, uid, ids, *args): # TODO check that all subcampaigns are running campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no activitity in the campaign") activity_ids = [ act_id.id for act_id in campaign.activity_ids] if not activity_ids: raise osv.except_osv(_("Error"), _("The campaign cannot be started : there are no activities in it")) act_obj = self.pool.get('marketing.campaign.activity') act_ids = act_obj.search(cr, uid, [('id', 'in', activity_ids), ('type', '=', 'email')]) for activity in act_obj.browse(cr, uid, act_ids): if not activity.email_template_id.enforce_from_account : raise osv.except_osv(_("Error"), _("The campaign cannot be started: an email account is missing in the email activity '%s'")%activity.name) if activity.email_template_id.enforce_from_account.state != 'approved' : raise osv.except_osv(_("Error"), _("The campaign cannot be started: the email account is not approved in the email activity '%s'")%activity.name) self.write(cr, uid, ids, {'state': 'running'}) return True
def state_running_set(self, cr, uid, ids, *args): # TODO check that all subcampaigns are running campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids: raise osv.except_osv(_("Error"), _("The campaign cannot be started: there are no activities in it")) has_start = False has_signal_without_from = False for activity in campaign.activity_ids: if activity.start: has_start = True if activity.signal and len(activity.from_ids) == 0: has_signal_without_from = True if activity.type != 'email': continue if not activity.email_template_id.enforce_from_account: raise osv.except_osv(_("Error"), _("The campaign cannot be started: an email account is missing in the email activity '%s'")%activity.name) if activity.email_template_id.enforce_from_account.state != 'approved' : raise osv.except_osv(_("Error"), _("The campaign cannot be started: the email account is not approved in the email activity '%s'")%activity.name) self.write(cr, uid, ids, {'state': 'running'}) return True
468,838
def state_running_set(self, cr, uid, ids, *args): # TODO check that all subcampaigns are running campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no activitity in the campaign") activity_ids = [ act_id.id for act_id in campaign.activity_ids] if not activity_ids: raise osv.except_osv(_("Error"), _("The campaign cannot be started : there are no activities in it")) act_obj = self.pool.get('marketing.campaign.activity') act_ids = act_obj.search(cr, uid, [('id', 'in', activity_ids), ('type', '=', 'email')]) for activity in act_obj.browse(cr, uid, act_ids): if not activity.email_template_id.enforce_from_account : raise osv.except_osv(_("Error"), _("The campaign cannot be started: an email account is missing in the email activity '%s'")%activity.name) if activity.email_template_id.enforce_from_account.state != 'approved' : raise osv.except_osv(_("Error"), _("The campaign cannot be started: the email account is not approved in the email activity '%s'")%activity.name) self.write(cr, uid, ids, {'state': 'running'}) return True
def state_running_set(self, cr, uid, ids, *args): # TODO check that all subcampaigns are running campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no activitity in the campaign") activity_ids = [ act_id.id for act_id in campaign.activity_ids] if not activity_ids: raise osv.except_osv(_("Error"), _("The campaign cannot be started : there are no activities in it")) act_obj = self.pool.get('marketing.campaign.activity') act_ids = act_obj.search(cr, uid, [('id', 'in', activity_ids), ('type', '=', 'email')]) for activity in act_obj.browse(cr, uid, act_ids): if not activity.email_template_id.enforce_from_account : raise osv.except_osv(_("Error"), _("The campaign cannot be started: an email account is missing in the email activity '%s'")%activity.name) if activity.email_template_id.enforce_from_account.state != 'approved': raise osv.except_osv(_("Error"), _("The campaign cannot be started: the email account is not approved in the email activity '%s'")%activity.name) self.write(cr, uid, ids, {'state': 'running'}) return True
468,839
def state_running_set(self, cr, uid, ids, *args): # TODO check that all subcampaigns are running campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no activitity in the campaign") activity_ids = [ act_id.id for act_id in campaign.activity_ids] if not activity_ids: raise osv.except_osv(_("Error"), _("The campaign cannot be started : there are no activities in it")) act_obj = self.pool.get('marketing.campaign.activity') act_ids = act_obj.search(cr, uid, [('id', 'in', activity_ids), ('type', '=', 'email')]) for activity in act_obj.browse(cr, uid, act_ids): if not activity.email_template_id.enforce_from_account : raise osv.except_osv(_("Error"), _("The campaign cannot be started: an email account is missing in the email activity '%s'")%activity.name) if activity.email_template_id.enforce_from_account.state != 'approved' : raise osv.except_osv(_("Error"), _("The campaign cannot be started: the email account is not approved in the email activity '%s'")%activity.name) self.write(cr, uid, ids, {'state': 'running'}) return True
def state_running_set(self, cr, uid, ids, *args): # TODO check that all subcampaigns are running campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no activitity in the campaign") activity_ids = [ act_id.id for act_id in campaign.activity_ids] if not activity_ids: raise osv.except_osv(_("Error"), _("The campaign cannot be started : there are no activities in it")) act_obj = self.pool.get('marketing.campaign.activity') act_ids = act_obj.search(cr, uid, [('id', 'in', activity_ids), ('type', '=', 'email')]) for activity in act_obj.browse(cr, uid, act_ids): if not activity.email_template_id.enforce_from_account : raise osv.except_osv(_("Error"), _("The campaign cannot be started: an email account is missing in the email activity '%s'")%activity.name) if activity.email_template_id.enforce_from_account.state != 'approved' : raise osv.except_osv(_("Error"), _("The campaign cannot be started: the email account is not approved in the email activity '%s'")%activity.name) self.write(cr, uid, ids, {'state': 'running'}) return True
468,840
def _wo_check(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context) journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context) cur_obj = pool.get('res.currency') # Here we need that: # The invoice total amount in company's currency <> paid amount in company currency # (according to the correct day rate, invoicing rate and payment rate are may be different) # => Ask to a write-off of the difference. This could happen even if both amount are equal, # because if the currency rate # Get the amount in company currency for the invoice (according to move lines) inv_amount_company_currency = invoice.move_id.amount
def _wo_check(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context) journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context) cur_obj = pool.get('res.currency') # Here we need that: # The invoice total amount in company's currency <> paid amount in company currency # (according to the correct day rate, invoicing rate and payment rate are may be different) # => Ask to a write-off of the difference. This could happen even if both amount are equal, # because if the currency rate # Get the amount in company currency for the invoice (according to move lines) inv_amount_company_currency = invoice.move_id.amount
468,841
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'project_vs_remaining_hours') cr.execute(""" create or replace view project_vs_remaining_hours as ( select min(pt.id) as id, a.name as project, sum(pt.remaining_hours) as remaining_hours, a.state, pu.uid from project_task as pt, project_project as p, account_analytic_account as a, project_user_rel as pu where pt.project_id=p.id and p.category_id = a.id and pu.project_id=p.id group by a.name,a.state,pu.uid ) """)
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'project_vs_remaining_hours') cr.execute(""" create or replace view project_vs_remaining_hours as ( select min(pt.id) as id, aaa.name as project, CASE WHEN pu.uid is null THEN aaa.user_id ELSE pu.uid END as uid, sum(pt.remaining_hours) as remaining_hours, aaa.state from project_task pt left join project_project as pp ON (pt.project_id=pp.id) left join account_analytic_account as aaa ON (pp.category_id=aaa.id) left join project_user_rel as pu ON (pu.project_id=pp.id) where pt.create_uid=aaa.user_id group by aaa.name,aaa.state,pu.uid,aaa.user_id ) """)
468,842
def get_memory(self, cr, obj, ids, name, user=None, context=None, values=None): result = {} for id in ids: result[id] = obj.datas[id][name] return result
def get_memory(self, cr, obj, ids, name, user=None, context=None, values=None): result = {} for id in ids: result[id] = obj.datas[id].get(name, False) return result
468,843
def set_context(self, objects, data, ids, report_type = None): new_ids = ids if (data['model'] == 'ir.ui.menu'): new_ids = 'active_ids' in data['form'] and data['form']['active_ids'] or [] objects = self.pool.get('account.journal.period').browse(self.cr, self.uid, new_ids) self.query_get_clause = data['form']['query_line'] or '' super(journal_print, self).set_context(objects, data, new_ids, report_type)
def set_context(self, objects, data, ids, report_type=None): new_ids = ids if (data['model'] == 'ir.ui.menu'): new_ids = 'active_ids' in data['form'] and data['form']['active_ids'] or [] objects = self.pool.get('account.journal.period').browse(self.cr, self.uid, new_ids) self.query_get_clause = data['form']['query_line'] or '' super(journal_print, self).set_context(objects, data, new_ids, report_type)
468,844
def set_context(self, objects, data, ids, report_type = None): new_ids = ids if (data['model'] == 'ir.ui.menu'): new_ids = 'active_ids' in data['form'] and data['form']['active_ids'] or [] objects = self.pool.get('account.journal.period').browse(self.cr, self.uid, new_ids) self.query_get_clause = data['form']['query_line'] or '' super(journal_print, self).set_context(objects, data, new_ids, report_type)
def set_context(self, objects, data, ids, report_type = None): new_ids = ids if (data['model'] == 'ir.ui.menu'): new_ids = 'active_ids' in data['form'] and data['form']['active_ids'] or [] objects = self.pool.get('account.journal.period').browse(self.cr, self.uid, new_ids) self.query_get_clause = data['form']['query_line'] or '' super(journal_print, self).set_context(objects, data, new_ids, report_type)
468,845
def __init__(self, cr, uid, name, context={}): super(journal_print, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self.get_account })
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self.get_account })
468,846
def lines(self, period_id, journal_id, sort_selection='date', *args): obj_jperiod = self.pool.get('account.journal.period') obj_mline = self.pool.get('account.move.line') self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft')) self.cr.commit() self.cr.execute('SELECT id FROM account_move_line l WHERE '+self.query_get_clause+' AND period_id=%s AND journal_id=%s ORDER BY %s', (period_id, journal_id, sort_selection)) ids = map(lambda x: x[0], self.cr.fetchall()) return obj_mline.browse(self.cr, self.uid, ids)
def lines(self, period_id, journal_id=[]): obj_jperiod = self.pool.get('account.journal.period') obj_mline = self.pool.get('account.move.line') self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft')) self.cr.commit() self.cr.execute('SELECT id FROM account_move_line l WHERE '+self.query_get_clause+' AND period_id=%s AND journal_id=%s ORDER BY %s', (period_id, journal_id, sort_selection)) ids = map(lambda x: x[0], self.cr.fetchall()) return obj_mline.browse(self.cr, self.uid, ids)
468,847
def lines(self, period_id, journal_id, sort_selection='date', *args): obj_jperiod = self.pool.get('account.journal.period') obj_mline = self.pool.get('account.move.line') self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft')) self.cr.commit() self.cr.execute('SELECT id FROM account_move_line l WHERE '+self.query_get_clause+' AND period_id=%s AND journal_id=%s ORDER BY %s', (period_id, journal_id, sort_selection)) ids = map(lambda x: x[0], self.cr.fetchall()) return obj_mline.browse(self.cr, self.uid, ids)
def lines(self, period_id, journal_id, sort_selection='date', *args): obj_jperiod = self.pool.get('account.journal.period') obj_mline = self.pool.get('account.move.line') self.cr.execute('update account_journal_period set state=%s where journal_id IN %s and period_id=%s and state=%s', ('printed', self.journal_ids, period_id, 'draft')) self.cr.commit() self.cr.execute('SELECT id FROM account_move_line l WHERE '+self.query_get_clause+' AND period_id=%s AND journal_id=%s ORDER BY %s', (period_id, journal_id, sort_selection)) ids = map(lambda x: x[0], self.cr.fetchall()) return obj_mline.browse(self.cr, self.uid, ids)
468,848
def lines(self, period_id, journal_id, sort_selection='date', *args): obj_jperiod = self.pool.get('account.journal.period') obj_mline = self.pool.get('account.move.line') self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft')) self.cr.commit() self.cr.execute('SELECT id FROM account_move_line l WHERE '+self.query_get_clause+' AND period_id=%s AND journal_id=%s ORDER BY %s', (period_id, journal_id, sort_selection)) ids = map(lambda x: x[0], self.cr.fetchall()) return obj_mline.browse(self.cr, self.uid, ids)
def lines(self, period_id, journal_id, sort_selection='date', *args): obj_jperiod = self.pool.get('account.journal.period') obj_mline = self.pool.get('account.move.line') self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft')) self.cr.commit() self.cr.execute('SELECT id FROM account_move_line l WHERE period_id=%s AND journal_id IN %s ' + self.query_get_clause + ' ORDER BY '+ self.sort_selection + '' ,(period_id, self.journal_ids )) ids = map(lambda x: x[0], self.cr.fetchall()) return obj_mline.browse(self.cr, self.uid, ids)
468,849
def _sum_debit(self, period_id, journal_id): self.cr.execute('SELECT SUM(debit) FROM account_move_line l WHERE '+self.query_get_clause+' AND period_id=%s AND journal_id=%s', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0
def _sum_debit(self, period_id, journal_id=[]): self.cr.execute('SELECT SUM(debit) FROM account_move_line l WHERE period_id=%s AND journal_id IN %s '+ self.query_get_clause +'', (period_id, self.journal_ids)) return self.cr.fetchone()[0] or 0.0
468,850
def _sum_credit(self, period_id, journal_id): self.cr.execute('SELECT SUM(credit) FROM account_move_line l WHERE '+self.query_get_clause+' AND period_id=%s AND journal_id=%s', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, period_id, journal_id=[]): self.cr.execute('SELECT SUM(credit) FROM account_move_line l WHERE period_id=%s AND journal_id IN %s '+ self.query_get_clause +'', (period_id, self.journal_ids)) return self.cr.fetchone()[0] or 0.0
468,851
def _sum_credit(self, period_id, journal_id): self.cr.execute('SELECT SUM(credit) FROM account_move_line l WHERE '+self.query_get_clause+' AND period_id=%s AND journal_id=%s', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, period_id, journal_id): self.cr.execute('SELECT SUM(credit) FROM account_move_line l WHERE '+self.query_get_clause+' AND period_id=%s AND journal_id=%s', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0
468,852
def get_start_period(self, form): return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr,self.uid,form['period_from']).name
def get_start_period(self, form): return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr,self.uid,form['period_from']).name
468,853
def get_end_period(self, form): return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr,self.uid,form['period_to']).name
def get_end_period(self, form): return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr,self.uid,form['period_to']).name
468,854
def get_account(self, form): return pooler.get_pool(self.cr.dbname).get('account.account').browse(self.cr,self.uid,form['chart_account_id']).name
def get_account(self, form): return pooler.get_pool(self.cr.dbname).get('account.account').browse(self.cr,self.uid,form['chart_account_id']).name
468,855
def get_account(self, form): return pooler.get_pool(self.cr.dbname).get('account.account').browse(self.cr,self.uid,form['chart_account_id']).name
defget_account(self,form):returnpooler.get_pool(self.cr.dbname).get('account.account').browse(self.cr,self.uid,form['chart_account_id']).name
468,856
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None,\ toolbar=False, submenu=False): """ Overrides orm field_view_get. @return: Dictionary of Fields, arch and toolbar. """
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None,\ toolbar=False, submenu=False): """ Overrides orm field_view_get. @return: Dictionary of Fields, arch and toolbar. """
468,857
def generate_random_pass(): pass_chars = RANDOM_PASS_CHARACTERS[:] random.shuffle(pass_chars) return ''.join(pass_chars[0:10])
def generate_random_pass(): pass_chars = RANDOM_PASS_CHARACTERS[:] random.shuffle(pass_chars) return ''.join(pass_chars[0:10])
468,858
def _get_currency(self, cr, uid, context): user = self.pool.get('res.users').browse(cr, uid, uid) if user.company_id: return user.company_id.currency_id.id else: return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
def _get_currency(self, cr, uid, context): user = self.pool.get('res.users').browse(cr, uid, uid) if user.company_id: return user.company_id.currency_id.id else: return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
468,859
def open_voucher(self, dbcr, uid, ids, context={}): cr = 0.0 dr = 0.0 total = 0.0 new_line = [] position_pool = self.pool.get('account.fiscal.position') voucher_pool = self.pool.get('account.voucher') voucher_line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') tax_pool = self.pool.get('account.tax')
def open_voucher(self, dbcr, uid, ids, context={}): cr = 0.0 dr = 0.0 total = 0.0 new_line = [] position_pool = self.pool.get('account.fiscal.position') voucher_pool = self.pool.get('account.voucher') voucher_line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') tax_pool = self.pool.get('account.tax')
468,860
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {} if self._context: context = context.copy() context.update(self._context) if not values: values = {}
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {} if self._context: context = context.copy() context.update(self._context) if not values: values = {}
468,861
def add_reply(self, cursor, user, ids, context=None): for case in self.browse(cursor, user, ids, context=context): if case.email_last: description = email_last self.write(cursor, user, case.id, { 'description': '> ' + description.replace('\n','\n> '), }, context=context) return True
def add_reply(self, cursor, user, ids, context=None): for case in self.browse(cursor, user, ids, context=context): if case.email_last: description = case.email_last self.write(cursor, user, case.id, { 'description': '> ' + description.replace('\n','\n> '), }, context=context) return True
468,862
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False):
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False):
468,863
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False):
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False):
468,864
def create_picking(self, cr, uid, ids, context={}): """Create a picking for each order and validate it.""" picking_obj = self.pool.get('stock.picking')
def create_picking(self, cr, uid, ids, context={}): """Create a picking for each order and validate it.""" picking_obj = self.pool.get('stock.picking')
468,865
def create_picking(self, cr, uid, ids, context={}): """Create a picking for each order and validate it.""" picking_obj = self.pool.get('stock.picking')
def create_picking(self, cr, uid, ids, context={}): """Create a picking for each order and validate it.""" picking_obj = self.pool.get('stock.picking')
468,866
args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def or curr_c.account_receivable.id
args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def or curr_c.account_receivable.id
468,867
order_account = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def or curr_c.account_receivable.id
order_account = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def or curr_c.account_receivable.id
468,868
def price_get_multi_old(self, cr, uid, product_map, context=None): """multi products 'price_get' @param context: { 'date': Date of the pricelist (%Y-%m-%d), @return: a dict with product_id as key and the product price as value } """
def price_get_multi_old(self, cr, uid, product_map, context=None): """multi products 'price_get' @param context: { 'date': Date of the pricelist (%Y-%m-%d), @return: a dict with product_id as key and the product price as value } """
468,869
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
468,870
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
468,871
def create_entries(self, cr, uid, ids, context=None): account_model_obj = self.pool.get('account.model') account_period_obj = self.pool.get('account.period') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') mod_obj = self.pool.get('ir.model.data') if context is None: context = {}
def create_entries(self, cr, uid, ids, context=None): account_model_obj = self.pool.get('account.model') account_period_obj = self.pool.get('account.period') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') mod_obj = self.pool.get('ir.model.data') if context is None: context = {}
468,872
def do_create(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') analytic_account_obj = self.pool.get('account.analytic.account') res_partner_obj = self.pool.get('res.partner') account_payment_term_obj = self.pool.get('account.payment.term') invoices = []
def do_create(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') analytic_account_obj = self.pool.get('account.analytic.account') res_partner_obj = self.pool.get('res.partner') account_payment_term_obj = self.pool.get('account.payment.term') invoices = []
468,873
def do_create(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') analytic_account_obj = self.pool.get('account.analytic.account') res_partner_obj = self.pool.get('res.partner') account_payment_term_obj = self.pool.get('account.payment.term') invoices = []
def do_create(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') analytic_account_obj = self.pool.get('account.analytic.account') res_partner_obj = self.pool.get('res.partner') account_payment_term_obj = self.pool.get('account.payment.term') invoices = []
468,874
def do_create(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') analytic_account_obj = self.pool.get('account.analytic.account') res_partner_obj = self.pool.get('res.partner') account_payment_term_obj = self.pool.get('account.payment.term') invoices = []
def do_create(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') analytic_account_obj = self.pool.get('account.analytic.account') res_partner_obj = self.pool.get('res.partner') account_payment_term_obj = self.pool.get('account.payment.term') invoices = []
468,875
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <peter@fry-it.com> ## download here: http://www.peterbe.com/plog/html2plaintext """ from an HTML text, convert the HTML to plain text. If @body_id is provided then this is the tag where the body (not necessarily <body>) starts. """ try: from BeautifulSoup import BeautifulSoup, SoupStrainer, Comment except: return html urls = [] if body_id is not None: strainer = SoupStrainer(id=body_id) else: strainer = SoupStrainer('body') soup = BeautifulSoup(html, parseOnlyThese=strainer, fromEncoding=encoding) for link in soup.findAll('a'): title = link.renderContents() for url in [x[1] for x in link.attrs if x[0]=='href']: urls.append(dict(url=url, tag=str(link), title=title)) html = soup.__str__() url_index = [] i = 0 for d in urls: if d['title'] == d['url'] or 'http://'+d['title'] == d['url']: html = html.replace(d['tag'], d['url']) else: i += 1 html = html.replace(d['tag'], '%s [%s]' % (d['title'], i)) url_index.append(d['url']) html = html.replace('<strong>','*').replace('</strong>','*') html = html.replace('<b>','*').replace('</b>','*') html = html.replace('<h3>','*').replace('</h3>','*') html = html.replace('<h2>','**').replace('</h2>','**') html = html.replace('<h1>','**').replace('</h1>','**') html = html.replace('<em>','/').replace('</em>','/') # the only line breaks we respect is those of ending tags and # breaks html = html.replace('\n',' ') html = html.replace('<br>', '\n') html = html.replace('<tr>', '\n') html = html.replace('</p>', '\n\n') html = re.sub('<br\s*/>', '\n', html) html = html.replace(' ' * 2, ' ') # for all other tags we failed to clean up, just remove then and # complain about them on the stderr def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' ' html = re.sub('<.*?>', desperate_fixer, html) # lstrip all lines html = '\n'.join([x.lstrip() for x in html.splitlines()]) for i, url in enumerate(url_index): if i == 0: html += '\n\n' html += '[%s] %s\n' % (i+1, url) return html
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <peter@fry-it.com> ## download here: http://www.peterbe.com/plog/html2plaintext """ from an HTML text, convert the HTML to plain text. If @body_id is provided then this is the tag where the body (not necessarily <body>) starts. """ try: from BeautifulSoup import BeautifulSoup, SoupStrainer, Comment except: return html urls = [] if body_id is not None: strainer = SoupStrainer(id=body_id) else: strainer = SoupStrainer('body') soup = BeautifulSoup(html, parseOnlyThese=strainer, fromEncoding=encoding) for link in soup.findAll('a'): title = link.renderContents() for url in [x[1] for x in link.attrs if x[0]=='href']: urls.append(dict(url=ustr(url), tag=ustr(link), title=ustr(title))) html = ustr(soup.__str__()) url_index = [] i = 0 for d in urls: if d['title'] == d['url'] or 'http://'+d['title'] == d['url']: html = html.replace(d['tag'], d['url']) else: i += 1 html = html.replace(d['tag'], '%s [%s]' % (d['title'], i)) url_index.append(d['url']) html = html.replace('<strong>','*').replace('</strong>','*') html = html.replace('<b>','*').replace('</b>','*') html = html.replace('<h3>','*').replace('</h3>','*') html = html.replace('<h2>','**').replace('</h2>','**') html = html.replace('<h1>','**').replace('</h1>','**') html = html.replace('<em>','/').replace('</em>','/') # the only line breaks we respect is those of ending tags and # breaks html = html.replace('\n',' ') html = html.replace('<br>', '\n') html = html.replace('<tr>', '\n') html = html.replace('</p>', '\n\n') html = re.sub('<br\s*/>', '\n', html) html = html.replace(' ' * 2, ' ') # for all other tags we failed to clean up, just remove then and # complain about them on the stderr def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' ' html = re.sub('<.*?>', desperate_fixer, html) # lstrip all lines html = '\n'.join([x.lstrip() for x in html.splitlines()]) for i, url in enumerate(url_index): if i == 0: html += '\n\n' html += '[%s] %s\n' % (i+1, url) return html
468,876
def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' '
def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' '
468,877
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
468,878
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
468,879
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
468,880
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
468,881
def _number_packages(self, cr, uid, ids, field_name, arg, context=None): if context is None: context = {} res = {} for line in self.browse(cr, uid, ids, context=context): try: res[line.id] = int((line.product_uom_qty+line.product_packaging.qty-0.0001) / line.product_packaging.qty) except: res[line.id] = 1 return res
def _number_packages(self, cr, uid, ids, field_name, arg, context=None): if context is None: context = {} res = {} for line in self.browse(cr, uid, ids, context=context): try: res[line.id] = int((line.product_uom_qty+line.product_packaging.qty-0.0001) / line.product_packaging.qty) except: res[line.id] = 1 return res
468,882
def _check_duplication(self, cr, uid, vals, ids=[], op='create'): name = vals.get('name', False) parent_id = vals.get('parent_id', False) res_model = vals.get('res_model', False) res_id = vals.get('res_id', 0) if op == 'write': for file in self.browse(cr, uid, ids): if not name: name = file.name if not parent_id: parent_id = file.parent_id and file.parent_id.id or False if not res_model: res_model = file.res_model and file.res_model or False if not res_id: res_id = file.res_id and file.res_id or 0 res = self.search(cr, uid, [('id', '<>', file.id), ('name', '=', name), ('parent_id', '=', parent_id), ('res_model', '=', res_model), ('res_id', '=', res_id)]) if len(res): return False if op == 'create': res = self.search(cr, uid, [('name', '=', name), ('parent_id', '=', parent_id), ('res_id', '=', res_id), ('res_model', '=', res_model)]) if len(res): return False return True
def _check_duplication(self, cr, uid, vals, ids=[], op='create'): name = vals.get('name', False) parent_id = vals.get('parent_id', False) res_model = vals.get('res_model', False) res_id = vals.get('res_id', 0) if op == 'write': for file in self.browse(cr, uid, ids): if not name: name = file.name if not parent_id: parent_id = file.parent_id and file.parent_id.id or False if not res_model: res_model = file.res_model and file.res_model or False if not res_id: res_id = file.res_id and file.res_id or 0 res = self.search(cr, uid, [('id', '<>', file.id), ('name', '=', name), ('parent_id', '=', parent_id), ('res_model', '=', res_model), ('res_id', '=', res_id)]) if len(res): return False if op == 'create': res = self.search(cr, uid, [('name', '=', name), ('parent_id', '=', parent_id), ('res_id', '=', res_id), ('res_model', '=', res_model)]) if len(res): return False return True
468,883
def write(self, cr, uid, ids, vals, context=None): if not isinstance(ids, list): ids = [ids] res = self.search(cr, uid, [('id', 'in', ids)]) if not len(res): return False if not self._check_duplication(cr, uid, vals, ids, 'write'): raise osv.except_osv(_('ValidateError'), _('File name must be unique!')) if 'parent_id' in vals: # perhaps this file is changing directory nctx = nodes.get_node_context(cr,uid,context) dirobj = self.pool.get('document.directory') dbro = dirobj.browse(cr, uid, vals['parent_id'], context=context) ids2 = [] result = False for fbro in self.browse(cr, uid, ids, context=context): if fbro.parent_id != vals['parent_id']: fnode = nodes.node_file(None,None,nctx,fbro) res = fnode.move_to(cr, fbro, dbro, True) if isinstance(res, dict): vals2 = vals.copy() vals2.update(res) wid = res.get('id', fbro.id) result = super(document_file,self).write(cr,uid,wid,vals2,context=context) # TODO: how to handle/merge several results? elif res == True: ids2.append(fbro.id) elif res == False: pass ids = ids2 if len(ids): result = super(document_file,self).write(cr, uid, ids, vals, context=context) cr.commit() return result
def write(self, cr, uid, ids, vals, context=None): if not isinstance(ids, list): ids = [ids] res = self.search(cr, uid, [('id', 'in', ids)]) if not len(res): return False if not self._check_duplication(cr, uid, vals, ids, 'write'): raise osv.except_osv(_('ValidateError'), _('File name must be unique!')) if 'parent_id' in vals: # perhaps this file is changing directory nctx = nodes.get_node_context(cr,uid,context) dirobj = self.pool.get('document.directory') dbro = dirobj.browse(cr, uid, vals['parent_id'], context=context) ids2 = [] result = False for fbro in self.browse(cr, uid, ids, context=context): if fbro.parent_id.id != vals['parent_id']: fnode = nodes.node_file(None,None,nctx,fbro) res = fnode.move_to(cr, fbro, dbro, True) if isinstance(res, dict): vals2 = vals.copy() vals2.update(res) wid = res.get('id', fbro.id) result = super(document_file,self).write(cr,uid,wid,vals2,context=context) # TODO: how to handle/merge several results? elif res == True: ids2.append(fbro.id) elif res == False: pass ids = ids2 if len(ids): result = super(document_file,self).write(cr, uid, ids, vals, context=context) cr.commit() return result
468,884
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task_user') cr.execute(""" CREATE view report_project_task_user as SELECT (select 1 ) AS nbr, t.id as id, to_char(date_start, 'YYYY') as year, to_char(date_start, 'MM') as month, to_char(date_start, 'YYYY-MM-DD') as day, date_trunc('day',t.date_start) as date_start, date_trunc('day',t.date_end) as date_end, to_date(to_char(t.date_deadline, 'dd-MM-YYYY'),'dd-MM-YYYY') as date_deadline,
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task_user') cr.execute(""" CREATE view report_project_task_user as SELECT (select 1 ) AS nbr, t.id as id, to_char(date_start, 'YYYY') as year, to_char(date_start, 'MM') as month, to_char(date_start, 'YYYY-MM-DD') as day, date_trunc('day',t.date_start) as date_start, date_trunc('day',t.date_end) as date_end, to_date(to_char(t.date_deadline, 'dd-MM-YYYY'),'dd-MM-YYYY') as date_deadline,
468,885
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task_user') cr.execute(""" CREATE view report_project_task_user as SELECT (select 1 ) AS nbr, t.id as id, to_char(date_start, 'YYYY') as year, to_char(date_start, 'MM') as month, to_char(date_start, 'YYYY-MM-DD') as day, date_trunc('day',t.date_start) as date_start, date_trunc('day',t.date_end) as date_end, to_date(to_char(t.date_deadline, 'dd-MM-YYYY'),'dd-MM-YYYY') as date_deadline,
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task_user') cr.execute(""" CREATE view report_project_task_user as SELECT (select 1 ) AS nbr, t.id as id, to_char(date_start, 'YYYY') as year, to_char(date_start, 'MM') as month, to_char(date_start, 'YYYY-MM-DD') as day, date_trunc('day',t.date_start) as date_start, date_trunc('day',t.date_end) as date_end, to_date(to_char(t.date_deadline, 'dd-MM-YYYY'),'dd-MM-YYYY') as date_deadline,
468,886
def onchange_type(self, cr, uid, ids, type, currency): obj_data = self.pool.get('ir.model.data') user_pool = self.pool.get('res.users')
def onchange_type(self, cr, uid, ids, type, currency, context=None): obj_data = self.pool.get('ir.model.data') user_pool = self.pool.get('res.users')
468,887
def onchange_type(self, cr, uid, ids, type, currency): obj_data = self.pool.get('ir.model.data') user_pool = self.pool.get('res.users')
defonchange_type(self,cr,uid,ids,type,currency):obj_data=self.pool.get('ir.model.data')user_pool=self.pool.get('res.users')
468,888
def set_context(self, objects, data, ids, report_type = None): ## self.borne_date = self.get_min_date(data['form']) ## new_ids = [] if (data['model'] == 'account.account'): new_ids = ids else: new_ids.append(data['form']['Account_list'])
def set_context(self, objects, data, ids, report_type = None): ## self.borne_date = self.get_min_date(data['form']) ## new_ids = [] if (data['model'] == 'account.account'): new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or [] else: new_ids.append(data['form']['Account_list'])
468,889
def __init__(self, cr, uid, name, context): super(general_ledger, self).__init__(cr, uid, name, context=context) cr.sql_log=1 self.date_borne = {} self.query = "" self.child_ids = "" self.tot_currency = 0.0 self.period_sql = "" self.sold_accounts = {} self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_account': self._sum_debit_account, 'sum_credit_account': self._sum_credit_account, 'sum_solde_account': self._sum_solde_account, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'sum_solde': self._sum_solde, 'get_children_accounts': self.get_children_accounts, 'sum_currency_amount_account': self._sum_currency_amount_account }) self.context = context
def __init__(self, cr, uid, name, context): super(general_ledger, self).__init__(cr, uid, name, context=context) self.date_borne = {} self.query = "" self.child_ids = "" self.tot_currency = 0.0 self.period_sql = "" self.sold_accounts = {} self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_account': self._sum_debit_account, 'sum_credit_account': self._sum_credit_account, 'sum_solde_account': self._sum_solde_account, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'sum_solde': self._sum_solde, 'get_children_accounts': self.get_children_accounts, 'sum_currency_amount_account': self._sum_currency_amount_account }) self.context = context
468,890
def action_move_create(self, cr, uid, ids, *args): """Creates invoice related analytics and financial move lines""" ait_obj = self.pool.get('account.invoice.tax') cur_obj = self.pool.get('res.currency') context = {} for inv in self.browse(cr, uid, ids): if not inv.journal_id.sequence_id: raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal')) if not inv.invoice_line: raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.')) if inv.move_id: continue
def action_move_create(self, cr, uid, ids, *args): """Creates invoice related analytics and financial move lines""" ait_obj = self.pool.get('account.invoice.tax') cur_obj = self.pool.get('res.currency') context = {} for inv in self.browse(cr, uid, ids): if not inv.journal_id.sequence_id: raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal')) if not inv.invoice_line: raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.')) if inv.move_id: continue
468,891
def _get_def_cparent(self, cr, uid, context): acc_obj=self.pool.get('account.account') tmpl_obj=self.pool.get('account.account.template') #print "Searching for ",context tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']],['parent_id']) if not tids or not tids[0]['parent_id']: return False ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]],['code']) if not ptids or not ptids[0]['code']: raise osv.except_osv(_('Error !'), _('Cannot locate parent code for template account!')) res = acc_obj.search(cr,uid,[('code','=',ptids[0]['code'])]) if res: return res[0] else: return False
def _get_def_cparent(self, cr, uid, context): acc_obj=self.pool.get('account.account') tmpl_obj=self.pool.get('account.account.template') #print "Searching for ",context tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']],['parent_id']) if not tids or not tids[0]['parent_id']: return False ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]],['code']) if not ptids or not ptids[0]['code']: raise osv.except_osv(_('Error !'), _('Cannot locate parent code for template account!')) res = acc_obj.search(cr,uid,[('code','=',ptids[0]['code'])]) if res: return res[0] else: return False
468,892
def stop(self): self.running = False if os.name != 'nt': try: self.server.socket.shutdown( getattr(socket, 'SHUT_RDWR', 2) except socket.error, e: if e.errno != 57: raise # OSX, socket shutdowns both sides if any side closes it # causing an error 57 'Socket is not connected' on shutdown # of the other side (or something), see # http://bugs.python.org/issue4397 netsvc.Logger().notifyChannel( 'server', netsvc.LOG_DEBUG, '"%s" when shutting down server socket, ' 'this is normal under OS X'%e) self.server.socket.close()
def stop(self): self.running = False if os.name != 'nt': try: self.server.socket.shutdown( getattr(socket, 'SHUT_RDWR', 2)) except socket.error, e: if e.errno != 57: raise # OSX, socket shutdowns both sides if any side closes it # causing an error 57 'Socket is not connected' on shutdown # of the other side (or something), see # http://bugs.python.org/issue4397 netsvc.Logger().notifyChannel( 'server', netsvc.LOG_DEBUG, '"%s" when shutting down server socket, ' 'this is normal under OS X'%e) self.server.socket.close()
468,893
def _doIndexFile(self,fname): fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout return _to_unicode(fp.read())
def _doIndexFile(self,fname): pop = Popen(['antiword', fname], shell=False, stdout=PIPE) (data, _) = pop.communicate() return _to_unicode(data)
468,894
def _doIndexFile(self,fname): fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout return _to_unicode( fp.read())
def _doIndexFile(self,fname): fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout return _to_unicode( fp.read())
468,895
def onchange_currency_id(self, cr, uid, ids, curr_id, company_id): if curr_id: currency = self.pool.get('res.currency').browse(cr, uid, curr_id) if currency.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('Can not select currency that is not related to current company.\nPlease select accordingly !.')) return {}
def onchange_currency_id(self, cr, uid, ids, curr_id, company_id): if curr_id and company_id: currency = self.pool.get('res.currency').browse(cr, uid, curr_id) if currency.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('Can not select currency that is not related to current company.\nPlease select accordingly !.')) return {}
468,896
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line): val={} dom={} if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr,uid,[('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr,uid,[line.id],{'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr,uid,inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id: val['journal_id']=False journal_ids=self.pool.get('account.journal').search(cr,uid,[('company_id','=',company_id)]) dom={'journal_id': [('id','in',journal_ids)]} else: journal_ids=self.pool.get('account.journal').search(cr,uid,[]) dom={'journal_id': [('id','in',journal_ids)]} return {'value' : val, 'domain': dom }
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val={} dom={} if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr,uid,[('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr,uid,[line.id],{'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr,uid,inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id: val['journal_id']=False journal_ids=self.pool.get('account.journal').search(cr,uid,[('company_id','=',company_id)]) dom={'journal_id': [('id','in',journal_ids)]} else: journal_ids=self.pool.get('account.journal').search(cr,uid,[]) dom={'journal_id': [('id','in',journal_ids)]} return {'value' : val, 'domain': dom }
468,897
def _default_get(self, cr, uid, fields, context={}): # Compute simple values data = super(account_move_line, self).default_get(cr, uid, fields, context) # Starts: Manual entry from account.move form if context.get('lines',[]):
def _default_get(self, cr, uid, fields, context={}): # Compute simple values data = super(account_move_line, self).default_get(cr, uid, fields, context) # Starts: Manual entry from account.move form if context.get('lines',[]):
468,898
def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0, skip=0): line = datas[position] row = {} warning = [] data_res_id = False nbrmax = position+1
def process_liness(self, datas, prefix, current_module, model_name, fields_def, position=0, skip=0): line = datas[position] row = {} warning = [] data_res_id = False nbrmax = position+1
468,899