bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def create_xml(self, cr, uid, ids, datas, context=None): obj_emp = pooler.get_pool(cr.dbname).get('hr.employee') start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d') end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d') first_monday = start_date - relativedelta(days=start_date.date().weekday()) last_monday = end_date + relativedelta(days=7 - end_date.date().weekday()) if last_monday < first_monday: first_monday, last_monday = last_monday, first_monday
def create_xml(self, cr, uid, ids, datas, context=None): obj_emp = pooler.get_pool(cr.dbname).get('hr.employee') start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d') end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d') first_monday = start_date - relativedelta(days=start_date.date().weekday()) last_monday = end_date + relativedelta(days=7 - end_date.date().weekday()) if last_monday < first_monday: first_monday, last_monday = last_monday, first_monday
467,600
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') content = '' sale_order = self.pool.get('sale.order') so_ref = procurement.name.split(':')[0] order_ids = sale_order.search(cr, uid, [('name','=',so_ref)], context)
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') content = '' sale_order = self.pool.get('sale.order') so_ref = procurement.name.split(':')[0] order_ids = sale_order.search(cr, uid, [('name','=',so_ref)], context)
467,601
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') content = '' sale_order = self.pool.get('sale.order') so_ref = procurement.name.split(':')[0] order_ids = sale_order.search(cr, uid, [('name','=',so_ref)], context)
def action_produce_assign_service(self, cr, uid, ids, context={}): for procurement in self.browse(cr, uid, ids): sline = self.pool.get('sale.order.line') content = '' sale_order = self.pool.get('sale.order') so_ref = procurement.name.split(':')[0] order_ids = sale_order.search(cr, uid, [('name','=',so_ref)], context)
467,602
def create(self, cr, uid, vals, context=None, check=True): if not context: context={} account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals and 'journal_id' not in context: context['journal_id'] = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
def create(self, cr, uid, vals, context=None, check=True): if not context: context={} account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals and 'journal_id' not in context: context['journal_id'] = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
467,603
def create(self, cr, uid, vals, context=None, check=True): if not context: context={} account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals and 'journal_id' not in context: context['journal_id'] = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
def create(self, cr, uid, vals, context=None, check=True): if not context: context={} account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals and 'journal_id' not in context: context['journal_id'] = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
467,604
def case_close(self, cr, uid, ids, *args): """Overrides close for crm_case for setting probability and close date @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case Ids @param *args: Tuple Value for additional Params """ res = super(crm_opportunity, self).case_close(cr, uid, ids, args) stage_id = super(crm_opportunity, self).stage_next(cr, uid, ids, context={'force_domain': [('probability', '=', 100)]}) if not stage_id: raise osv.except_osv(_('Warning !'), _('There is no stage for won oppportunities defined for this Sale Team.')) value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value'] value.update({'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id})
def case_close(self, cr, uid, ids, *args): """Overrides close for crm_case for setting probability and close date @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case Ids @param *args: Tuple Value for additional Params """ res = super(crm_opportunity, self).case_close(cr, uid, ids, args) stage_id = super(crm_opportunity, self).stage_next(cr, uid, ids, context={'force_domain': [('probability', '=', 100)]}) if not stage_id: raise osv.except_osv(_('Warning !'), _('There is no stage for won opportunities defined for this Sale Team.')) value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value'] value.update({'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id})
467,605
def case_mark_lost(self, cr, uid, ids, *args): """Mark the case as lost: state = done and probability = 0% @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case Ids @param *args: Tuple Value for additional Params """ res = super(crm_opportunity, self).case_close(cr, uid, ids, args) stage_id = super(crm_opportunity, self).stage_next(cr, uid, ids, context={'force_domain': [('probability', '=', 0)]}) if not stage_id: raise osv.except_osv(_('Warning !'), _('There is no stage for lost oppportunities defined for this Sale Team.')) value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value'] value.update({'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id})
def case_mark_lost(self, cr, uid, ids, *args): """Mark the case as lost: state = done and probability = 0% @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case Ids @param *args: Tuple Value for additional Params """ res = super(crm_opportunity, self).case_close(cr, uid, ids, args) stage_id = super(crm_opportunity, self).stage_next(cr, uid, ids, context={'force_domain': [('probability', '=', 0)]}) if not stage_id: raise osv.except_osv(_('Warning !'), _('There is no stage for lost opportunities defined for this Sale Team.')) value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value'] value.update({'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id})
467,606
def write(self, cr, uid, ids, vals, context={}): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') uom_obj = self.pool.get('product.uom') if not context: context = {} if context.get('scheduler',False): return super(project_phase, self).write(cr, uid, ids, vals, context=context) # Consider calendar and efficiency if the phase is performed by a resource # otherwise consider the project's working calendar phase = self.browse(cr, uid, ids[0], context=context) calendar_id = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False resource_id = resource_obj.search(cr, uid, [('user_id', '=', phase.responsible_id.id)],context=context) if resource_id: cal_id = resource_obj.browse(cr, uid, resource_id[0], context=context).calendar_id.id if cal_id: calendar_id = cal_id default_uom_id = uom_obj.search(cr, uid, [('name', '=', 'Hour')])[0] avg_hours = uom_obj._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id)
def write(self, cr, uid, ids, vals, context={}): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') uom_obj = self.pool.get('product.uom') if not context: context = {} if context.get('scheduler',False): return super(project_phase, self).write(cr, uid, ids, vals, context=context) # Consider calendar and efficiency if the phase is performed by a resource # otherwise consider the project's working calendar phase = self.browse(cr, uid, ids[0], context=context) calendar_id = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False resource_id = resource_obj.search(cr, uid, [('user_id', '=', phase.responsible_id.id)],context=context) if resource_id: cal_id = resource_obj.browse(cr, uid, resource_id[0], context=context).calendar_id.id if cal_id: calendar_id = cal_id default_uom_id = uom_obj.search(cr, uid, [('name', '=', 'Hour')])[0] avg_hours = uom_obj._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id)
467,607
def write(self, cr, uid, ids, vals, context={}): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') uom_obj = self.pool.get('product.uom') if not context: context = {} if context.get('scheduler',False): return super(project_phase, self).write(cr, uid, ids, vals, context=context) # Consider calendar and efficiency if the phase is performed by a resource # otherwise consider the project's working calendar phase = self.browse(cr, uid, ids[0], context=context) calendar_id = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False resource_id = resource_obj.search(cr, uid, [('user_id', '=', phase.responsible_id.id)],context=context) if resource_id: cal_id = resource_obj.browse(cr, uid, resource_id[0], context=context).calendar_id.id if cal_id: calendar_id = cal_id default_uom_id = uom_obj.search(cr, uid, [('name', '=', 'Hour')])[0] avg_hours = uom_obj._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id)
def write(self, cr, uid, ids, vals, context={}): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') uom_obj = self.pool.get('product.uom') if not context: context = {} if context.get('scheduler',False): return super(project_phase, self).write(cr, uid, ids, vals, context=context) # Consider calendar and efficiency if the phase is performed by a resource # otherwise consider the project's working calendar phase = self.browse(cr, uid, ids[0], context=context) calendar_id = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False resource_id = resource_obj.search(cr, uid, [('user_id', '=', phase.responsible_id.id)],context=context) if resource_id: cal_id = resource_obj.browse(cr, uid, resource_id[0], context=context).calendar_id.id if cal_id: calendar_id = cal_id default_uom_id = uom_obj.search(cr, uid, [('name', '=', 'Hour')])[0] avg_hours = uom_obj._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id)
467,608
def onchange_planned(self, cr, uid, ids, project, user_id=False, planned=0.0, effective=0.0, date_start=None, occupation_rate=0.0): result = {} resource = False resource_obj = self.pool.get('resource.resource') project_pool = self.pool.get('project.project') resource_calendar = self.pool.get('resource.calendar') if not project: return {'value' : result} if date_start: hrs = float(planned / float(occupation_rate)) calendar_id = project_pool.browse(cr, uid, project).resource_calendar_id.id dt_start = mx.DateTime.strptime(date_start, '%Y-%m-%d %H:%M:%S') resource_id = resource_obj.search(cr, uid, [('user_id','=',user_id)]) if resource_id: resource_data = resource_obj.browse(cr, uid, resource_id)[0] resource = resource_data.id hrs = planned / (float(occupation_rate) * resource_data.time_efficiency) if resource_data.calendar_id.id: calendar_id = resource_data.calendar_id.id work_times = resource_calendar.interval_get(cr, uid, calendar_id, dt_start, hrs or 0.0, resource or False) result['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S') result['remaining_hours'] = planned - effective return {'value' : result}
def onchange_planned(self, cr, uid, ids, project, user_id=False, planned=0.0, effective=0.0, date_start=None, occupation_rate=0.0): result = {} resource = False resource_obj = self.pool.get('resource.resource') project_pool = self.pool.get('project.project') resource_calendar = self.pool.get('resource.calendar') if not project: return {'value' : result} if date_start: hrs = float(planned / float(occupation_rate)) calendar_id = project_pool.browse(cr, uid, project).resource_calendar_id.id dt_start = mx.DateTime.strptime(date_start, '%Y-%m-%d %H:%M:%S') resource_id = resource_obj.search(cr, uid, [('user_id','=',user_id)]) if resource_id: resource_data = resource_obj.browse(cr, uid, resource_id)[0] resource = resource_data.id hrs = planned / (float(occupation_rate) * resource_data.time_efficiency) if resource_data.calendar_id.id: calendar_id = resource_data.calendar_id.id work_times = resource_calendar.interval_get(cr, uid, calendar_id, dt_start, hrs or 0.0, resource or False) if work_times: result['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S') result['remaining_hours'] = planned - effective return {'value' : result}
467,609
def write(self, cr, uid, ids, vals, context={}): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') if not context: context = {} if context.get('scheduler',False): return super(task, self).write(cr, uid, ids, vals, context=context)
def write(self, cr, uid, ids, vals, context={}): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') if not context: context = {} if context.get('scheduler',False): return super(task, self).write(cr, uid, ids, vals, context=context)
467,610
def write(self, cr, uid, ids, vals, context={}): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') if not context: context = {} if context.get('scheduler',False): return super(task, self).write(cr, uid, ids, vals, context=context)
def write(self, cr, uid, ids, vals, context={}): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') if not context: context = {} if context.get('scheduler',False): return super(task, self).write(cr, uid, ids, vals, context=context)
467,611
def _get_move_lines(self, cr, uid, ids, context={}): result = [] for move in self.pool.get('account.move').browse(cr, uid, ids, context=context): for line in move.line_id: result.append(line.id) return result
def _get_move_lines(self, cr, uid, ids, context={}): result = [] for move in self.pool.get('account.move').browse(cr, uid, ids, context=context): for line in move.line_id: result.append(line.id) return result
467,612
def _if_account(self, cr, uid, ids, context=None): chart = self.read(cr, uid, ids, ['charts'], context=context)[0]['charts'] self.logger.notifyChannel( 'installer', netsvc.LOG_DEBUG, 'Addon "account" selected, installing chart of accounts %s'%chart) return [chart]
def _if_account(self, cr, uid, ids, context=None): chart = self.read(cr, uid, ids, ['charts'], context=context)[0]['charts'] self.logger.notifyChannel( 'installer', netsvc.LOG_DEBUG, 'Addon "account" selected, installing chart of accounts %s'%chart) return [chart]
467,613
def unlink(self, cr, uid, ids, context=None): purchase_orders = self.read(cr, uid, ids, ['state']) unlink_ids = [] for s in purchase_orders: if s['state'] in ['draft','cancel']: unlink_ids.append(s['id']) else: raise osv.except_osv(_('Invalid action !'), _('Cannot delete Purchase Order(s) which are in %s State!' % s['state']))
def unlink(self, cr, uid, ids, context=None): purchase_orders = self.read(cr, uid, ids, ['state']) unlink_ids = [] for s in purchase_orders: if s['state'] in ['draft','cancel']: unlink_ids.append(s['id']) else: raise osv.except_osv(_('Invalid action !'), _('Cannot delete Purchase Order(s) which are in %s State!' % s['state']))
467,614
def get_value(cursor, user, recid, message=None, template=None, context=None): """ Evaluates an expression and returns its value @param cursor: Database Cursor @param user: ID of current user @param recid: ID of the target record under evaluation @param message: The expression to be evaluated @param template: BrowseRecord object of the current template @param context: OpenERP Context @return: Computed message (unicode) or u"" """ pool = pooler.get_pool(cursor.dbname) if message is None: message = {} #Returns the computed expression if message: try: message = tools.ustr(message) object = pool.get(template.model_int_name).browse(cursor, user, recid, context) env = { 'user':pool.get('res.users').browse(cursor, user, user, context), 'db':cursor.dbname } if template.template_language == 'mako': templ = MakoTemplate(message, input_encoding='utf-8') reply = MakoTemplate(message).render_unicode(object=object, peobject=object, env=env, format_exceptions=True) elif template.template_language == 'django': templ = DjangoTemplate(message) env['object'] = object env['peobject'] = object reply = templ.render(Context(env)) return reply or False except Exception: logging.exception("can't render %r", message) return u"" else: return message
def get_value(cursor, user, recid, message=None, template=None, context=None): """ Evaluates an expression and returns its value @param cursor: Database Cursor @param user: ID of current user @param recid: ID of the target record under evaluation @param message: The expression to be evaluated @param template: BrowseRecord object of the current template @param context: OpenERP Context @return: Computed message (unicode) or u"" """ pool = pooler.get_pool(cursor.dbname) if message is None: message = {} #Returns the computed expression if message: try: message = tools.ustr(message) object = pool.get(template.model_int_name).browse(cursor, user, recid, context) env = { 'user':pool.get('res.users').browse(cursor, user, user, context), 'db':cursor.dbname } if template.template_language == 'mako': templ = MakoTemplate(message, input_encoding='utf-8') reply = MakoTemplate(message).render_unicode(object=object, peobject=object, env=env, format_exceptions=True) elif template.template_language == 'django': templ = DjangoTemplate(message) env['object'] = object env['peobject'] = object reply = templ.render(Context(env)) return reply or False except Exception: logging.exception("can't render %r", message) return u"" else: return message
467,615
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
467,616
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
467,617
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
467,618
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
467,619
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
467,620
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
467,621
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
467,622
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
467,623
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
def change_model(self, cursor, user, ids, object_name, context=None): if object_name: mod_name = self.pool.get('ir.model').read( cursor, user, object_name, ['model'], context)['model'] else: mod_name = False return { 'value':{'model_int_name':mod_name} }
467,624
def delete_action(self, cr, uid, ids, context): self.unlink_action(cr, uid, ids, context) return True
def delete_action(self, cr, uid, ids, context): self.unlink_action(cr, uid, ids, context) return True
467,625
def unlink(self, cr, uid, ids, context=None): self.unlink_action(cr, uid, ids, context) return super(email_template, self).unlink(cr, uid, ids, context)
def unlink(self, cr, uid, ids, context=None): self.unlink_action(cr, uid, ids, context) return super(email_template, self).unlink(cr, uid, ids, context)
467,626
def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} default = default.copy() old = self.read(cr, uid, id, ['name'], context=context) new_name = _("Copy of template ") + old.get('name', 'No Name') check = self.search(cr, uid, [('name', '=', new_name)], context=context) if check: new_name = new_name + '_' + random.choice('abcdefghij') + random.choice('lmnopqrs') + random.choice('tuvwzyz') default.update({'name':new_name}) return super(email_template, self).copy(cr, uid, id, default, context)
def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} default = default.copy() old = self.read(cr, uid, id, ['name'], context=context) new_name = _("Copy of template ") + old.get('name', 'No Name') check = self.search(cr, uid, [('name', '=', new_name)], context=context) if check: new_name = new_name + '_' + random.choice('abcdefghij') + random.choice('lmnopqrs') + random.choice('tuvwzyz') default.update({'name':new_name}) return super(email_template, self).copy(cr, uid, id, default, context)
467,627
def build_expression(self, field_name, sub_field_name, null_value, template_language='mako'): """ Returns a template expression based on data provided @param field_name: field name @param sub_field_name: sub field name (M2O) @param null_value: default value if the target value is empty @param template_language: name of template engine @return: computed expression """
def build_expression(self, field_name, sub_field_name, null_value, template_language='mako'): """ Returns a template expression based on data provided @param field_name: field name @param sub_field_name: sub field name (M2O) @param null_value: default value if the target value is empty @param template_language: name of template engine @return: computed expression """
467,628
def build_expression(self, field_name, sub_field_name, null_value, template_language='mako'): """ Returns a template expression based on data provided @param field_name: field name @param sub_field_name: sub field name (M2O) @param null_value: default value if the target value is empty @param template_language: name of template engine @return: computed expression """
def build_expression(self, field_name, sub_field_name, null_value, template_language='mako'): """ Returns a template expression based on data provided @param field_name: field name @param sub_field_name: sub field name (M2O) @param null_value: default value if the target value is empty @param template_language: name of template engine @return: computed expression """
467,629
def onchange_model_object_field(self, cr, uid, ids, model_object_field, template_language, context=None): if not model_object_field: return {} result = {} field_obj = self.pool.get('ir.model.fields').browse(cr, uid, model_object_field, context) #Check if field is relational if field_obj.ttype in ['many2one', 'one2many', 'many2many']: res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_obj.relation)], context=context) if res_ids: result['sub_object'] = res_ids[0] result['copyvalue'] = self.build_expression(False, False, False, template_language) result['sub_model_object_field'] = False result['null_value'] = False else: #Its a simple field... just compute placeholder result['sub_object'] = False result['copyvalue'] = self.build_expression(field_obj.name, False, False, template_language ) result['sub_model_object_field'] = False result['null_value'] = False return {'value':result}
def onchange_model_object_field(self, cr, uid, ids, model_object_field, template_language, context=None): if not model_object_field: return {} result = {} field_obj = self.pool.get('ir.model.fields').browse(cr, uid, model_object_field, context) #Check if field is relational if field_obj.ttype in ['many2one', 'one2many', 'many2many']: res_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', field_obj.relation)], context=context) if res_ids: result['sub_object'] = res_ids[0] result['copyvalue'] = self.build_expression(False, False, False, template_language) result['sub_model_object_field'] = False result['null_value'] = False else: #Its a simple field... just compute placeholder result['sub_object'] = False result['copyvalue'] = self.build_expression(field_obj.name, False, False, template_language ) result['sub_model_object_field'] = False result['null_value'] = False return {'value':result}
467,630
def _add_attachment(self, cursor, user, mailbox_id, name, data, filename, context=None): """ Add an attachment to a given mailbox entry. :param data: base64 encoded attachment data to store """ attachment_obj = self.pool.get('ir.attachment') attachment_data = { 'name': (name or '') + _(' (Email Attachment)'), 'datas': data, 'datas_fname': filename, 'description': name or _('No Description'), 'res_model':'email_template.mailbox', 'res_id': mailbox_id, } attachment_id = attachment_obj.create(cursor, user, attachment_data, context) if attachment_id: self.pool.get('email_template.mailbox').write( cursor, user, mailbox_id, { 'attachments_ids':[(4, attachment_id)], 'mail_type':'multipart/mixed' }, context)
def _add_attachment(self, cursor, user, mailbox_id, name, data, filename, context=None): """ Add an attachment to a given mailbox entry. :param data: base64 encoded attachment data to store """ attachment_obj = self.pool.get('ir.attachment') attachment_data = { 'name': (name or '') + _(' (Email Attachment)'), 'datas': data, 'datas_fname': filename, 'description': name or _('No Description'), 'res_model':'email_template.mailbox', 'res_id': mailbox_id, } attachment_id = attachment_obj.create(cursor, user, attachment_data, context) if attachment_id: self.pool.get('email_template.mailbox').write( cursor, user, mailbox_id, { 'attachments_ids':[(4, attachment_id)], 'mail_type':'multipart/mixed' }, context)
467,631
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None): """ Generate report to be attached and attach it to the email, and add any directly attached files as well. @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @param mail: Browse record of email object @return: True """ if template.report_template: reportname = 'report.' + \ self.pool.get('ir.actions.report.xml').read( cursor, user, template.report_template.id, ['report_name'], context)['report_name'] service = netsvc.LocalService(reportname) data = {} data['model'] = template.model_int_name (result, format) = service.create(cursor, user, [record_id], data, context) fname = tools.ustr(get_value(cursor, user, record_id, template.file_name, template, context) or 'Report') ext = '.' + format if not fname.endswith(ext): fname += ext self._add_attachment(cursor, user, mail.id, mail.subject, base64.b64encode(result), fname, context)
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None): """ Generate report to be attached and attach it to the email, and add any directly attached files as well. @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @param mail: Browse record of email object @return: True """ if template.report_template: reportname = 'report.' + \ self.pool.get('ir.actions.report.xml').read( cursor, user, template.report_template.id, ['report_name'], context)['report_name'] service = netsvc.LocalService(reportname) data = {} data['model'] = template.model_int_name (result, format) = service.create(cursor, user, [record_id], data, context) fname = tools.ustr(get_value(cursor, user, record_id, template.file_name, template, context) or 'Report') ext = '.' + format if not fname.endswith(ext): fname += ext self._add_attachment(cursor, user, mail.id, mail.subject, base64.b64encode(result), fname, context)
467,632
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None): """ Generate report to be attached and attach it to the email, and add any directly attached files as well. @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @param mail: Browse record of email object @return: True """ if template.report_template: reportname = 'report.' + \ self.pool.get('ir.actions.report.xml').read( cursor, user, template.report_template.id, ['report_name'], context)['report_name'] service = netsvc.LocalService(reportname) data = {} data['model'] = template.model_int_name (result, format) = service.create(cursor, user, [record_id], data, context) fname = tools.ustr(get_value(cursor, user, record_id, template.file_name, template, context) or 'Report') ext = '.' + format if not fname.endswith(ext): fname += ext self._add_attachment(cursor, user, mail.id, mail.subject, base64.b64encode(result), fname, context)
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None): """ Generate report to be attached and attach it to the email, and add any directly attached files as well. @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @param mail: Browse record of email object @return: True """ if template.report_template: reportname = 'report.' + \ self.pool.get('ir.actions.report.xml').read( cursor, user, template.report_template.id, ['report_name'], context)['report_name'] service = netsvc.LocalService(reportname) data = {} data['model'] = template.model_int_name (result, format) = service.create(cursor, user, [record_id], data, context) fname = tools.ustr(get_value(cursor, user, record_id, template.file_name, template, context) or 'Report') ext = '.' + format if not fname.endswith(ext): fname += ext self._add_attachment(cursor, user, mail.id, mail.subject, base64.b64encode(result), fname, context)
467,633
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None): """ Generate report to be attached and attach it to the email, and add any directly attached files as well. @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @param mail: Browse record of email object @return: True """ if template.report_template: reportname = 'report.' + \ self.pool.get('ir.actions.report.xml').read( cursor, user, template.report_template.id, ['report_name'], context)['report_name'] service = netsvc.LocalService(reportname) data = {} data['model'] = template.model_int_name (result, format) = service.create(cursor, user, [record_id], data, context) fname = tools.ustr(get_value(cursor, user, record_id, template.file_name, template, context) or 'Report') ext = '.' + format if not fname.endswith(ext): fname += ext self._add_attachment(cursor, user, mail.id, mail.subject, base64.b64encode(result), fname, context)
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None): """ Generate report to be attached and attach it to the email, and add any directly attached files as well. @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @param mail: Browse record of email object @return: True """ if template.report_template: reportname = 'report.' + \ self.pool.get('ir.actions.report.xml').read( cursor, user, template.report_template.id, ['report_name'], context)['report_name'] service = netsvc.LocalService(reportname) data = {} data['model'] = template.model_int_name (result, format) = service.create(cursor, user, [record_id], data, context) fname = tools.ustr(get_value(cursor, user, record_id, template.file_name, template, context) or 'Report') ext = '.' + format if not fname.endswith(ext): fname += ext self._add_attachment(cursor, user, mail.id, mail.subject, base64.b64encode(result), fname, context)
467,634
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None): """ Generate report to be attached and attach it to the email, and add any directly attached files as well. @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @param mail: Browse record of email object @return: True """ if template.report_template: reportname = 'report.' + \ self.pool.get('ir.actions.report.xml').read( cursor, user, template.report_template.id, ['report_name'], context)['report_name'] service = netsvc.LocalService(reportname) data = {} data['model'] = template.model_int_name (result, format) = service.create(cursor, user, [record_id], data, context) fname = tools.ustr(get_value(cursor, user, record_id, template.file_name, template, context) or 'Report') ext = '.' + format if not fname.endswith(ext): fname += ext self._add_attachment(cursor, user, mail.id, mail.subject, base64.b64encode(result), fname, context)
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None): """ Generate report to be attached and attach it to the email, and add any directly attached files as well. @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @param mail: Browse record of email object @return: True """ if template.report_template: reportname = 'report.' + \ self.pool.get('ir.actions.report.xml').read( cursor, user, template.report_template.id, ['report_name'], context)['report_name'] service = netsvc.LocalService(reportname) data = {} data['model'] = template.model_int_name (result, format) = service.create(cursor, user, [record_id], data, context) fname = tools.ustr(get_value(cursor, user, record_id, template.file_name, template, context) or 'Report') ext = '.' + format if not fname.endswith(ext): fname += ext self._add_attachment(cursor, user, mail.id, mail.subject, base64.b64encode(result), fname, context)
467,635
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None): """ Generates an email from the template for record record_id of target object @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @return: ID of created object """ if context is None: context = {} #If account to send from is in context select it, else use enforced account if 'account_id' in context.keys(): from_account = self.pool.get('email_template.account').read( cursor, user, context.get('account_id'), ['name', 'email_id'], context ) else: from_account = { 'id':template.from_account.id, 'name':template.from_account.name, 'email_id':template.from_account.email_id } lang = get_value(cursor, user, record_id, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.browse(cursor, user, template.id, context=ctx) # determine name of sender, either it is specified in email_id or we # use the account name email_id = from_account['email_id'].strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: # we should keep it all, name is probably specified in the address email_from = from_account['email_id'] else: email_from = tools.ustr(from_account['name']) + "<" + tools.ustr('email_id') + ">",
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None): """ Generates an email from the template for record record_id of target object @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @return: ID of created object """ if context is None: context = {} #If account to send from is in context select it, else use enforced account if 'account_id' in context.keys(): from_account = self.pool.get('email_template.account').read( cursor, user, context.get('account_id'), ['name', 'email_id'], context ) else: from_account = { 'id':template.from_account.id, 'name':template.from_account.name, 'email_id':template.from_account.email_id } lang = get_value(cursor, user, record_id, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.browse(cursor, user, template.id, context=ctx) # determine name of sender, either it is specified in email_id or we # use the account name email_id = from_account['email_id'].strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: # we should keep it all, name is probably specified in the address email_from = from_account['email_id'] else: email_from = tools.ustr(from_account['name']) + "<" + tools.ustr('email_id') + ">",
467,636
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None): """ Generates an email from the template for record record_id of target object @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @return: ID of created object """ if context is None: context = {} #If account to send from is in context select it, else use enforced account if 'account_id' in context.keys(): from_account = self.pool.get('email_template.account').read( cursor, user, context.get('account_id'), ['name', 'email_id'], context ) else: from_account = { 'id':template.from_account.id, 'name':template.from_account.name, 'email_id':template.from_account.email_id } lang = get_value(cursor, user, record_id, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.browse(cursor, user, template.id, context=ctx) # determine name of sender, either it is specified in email_id or we # use the account name email_id = from_account['email_id'].strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: # we should keep it all, name is probably specified in the address email_from = from_account['email_id'] else: email_from = tools.ustr(from_account['name']) + "<" + tools.ustr('email_id') + ">",
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None): """ Generates an email from the template for record record_id of target object @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @return: ID of created object """ if context is None: context = {} #If account to send from is in context select it, else use enforced account if 'account_id' in context.keys(): from_account = self.pool.get('email_template.account').read( cursor, user, context.get('account_id'), ['name', 'email_id'], context ) else: from_account = { 'id':template.from_account.id, 'name':template.from_account.name, 'email_id':template.from_account.email_id } lang = get_value(cursor, user, record_id, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.browse(cursor, user, template.id, context=ctx) # determine name of sender, either it is specified in email_id or we # use the account name email_id = from_account['email_id'].strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: # we should keep it all, name is probably specified in the address email_from = from_account['email_id'] else: email_from = tools.ustr(from_account['name']) + "<" + tools.ustr('email_id') + ">",
467,637
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None): """ Generates an email from the template for record record_id of target object @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @return: ID of created object """ if context is None: context = {} #If account to send from is in context select it, else use enforced account if 'account_id' in context.keys(): from_account = self.pool.get('email_template.account').read( cursor, user, context.get('account_id'), ['name', 'email_id'], context ) else: from_account = { 'id':template.from_account.id, 'name':template.from_account.name, 'email_id':template.from_account.email_id } lang = get_value(cursor, user, record_id, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.browse(cursor, user, template.id, context=ctx) # determine name of sender, either it is specified in email_id or we # use the account name email_id = from_account['email_id'].strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: # we should keep it all, name is probably specified in the address email_from = from_account['email_id'] else: email_from = tools.ustr(from_account['name']) + "<" + tools.ustr('email_id') + ">",
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None): """ Generates an email from the template for record record_id of target object @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @return: ID of created object """ if context is None: context = {} #If account to send from is in context select it, else use enforced account if 'account_id' in context.keys(): from_account = self.pool.get('email_template.account').read( cursor, user, context.get('account_id'), ['name', 'email_id'], context ) else: from_account = { 'id':template.from_account.id, 'name':template.from_account.name, 'email_id':template.from_account.email_id } lang = get_value(cursor, user, record_id, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.browse(cursor, user, template.id, context=ctx) # determine name of sender, either it is specified in email_id or we # use the account name email_id = from_account['email_id'].strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: # we should keep it all, name is probably specified in the address email_from = from_account['email_id'] else: email_from = tools.ustr(from_account['name']) + "<" + tools.ustr('email_id') + ">",
467,638
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None): """ Generates an email from the template for record record_id of target object @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @return: ID of created object """ if context is None: context = {} #If account to send from is in context select it, else use enforced account if 'account_id' in context.keys(): from_account = self.pool.get('email_template.account').read( cursor, user, context.get('account_id'), ['name', 'email_id'], context ) else: from_account = { 'id':template.from_account.id, 'name':template.from_account.name, 'email_id':template.from_account.email_id } lang = get_value(cursor, user, record_id, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.browse(cursor, user, template.id, context=ctx) # determine name of sender, either it is specified in email_id or we # use the account name email_id = from_account['email_id'].strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: # we should keep it all, name is probably specified in the address email_from = from_account['email_id'] else: email_from = tools.ustr(from_account['name']) + "<" + tools.ustr('email_id') + ">",
def _generate_mailbox_item_from_template(self, cursor, user, template, record_id, context=None): """ Generates an email from the template for record record_id of target object @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @return: ID of created object """ if context is None: context = {} #If account to send from is in context select it, else use enforced account if 'account_id' in context.keys(): from_account = self.pool.get('email_template.account').read( cursor, user, context.get('account_id'), ['name', 'email_id'], context ) else: from_account = { 'id':template.from_account.id, 'name':template.from_account.name, 'email_id':template.from_account.email_id } lang = get_value(cursor, user, record_id, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.browse(cursor, user, template.id, context=ctx) # determine name of sender, either it is specified in email_id or we # use the account name email_id = from_account['email_id'].strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: # we should keep it all, name is probably specified in the address email_from = from_account['email_id'] else: email_from = tools.ustr(from_account['name']) + "<" + tools.ustr('email_id') + ">",
467,639
def generate_mail(self, cursor, user, template_id, record_ids, context=None): if context is None: context = {} template = self.browse(cursor, user, template_id, context=context) if not template: raise Exception("The requested template could not be loaded") result = True mailbox_obj = self.pool.get('email_template.mailbox') for record_id in record_ids: mailbox_id = self._generate_mailbox_item_from_template( cursor, user, template, record_id, context) mail = mailbox_obj.browse( cursor, user, mailbox_id, context=context ) if template.report_template or template.attachment_ids: self.generate_attach_reports( cursor, user, template, record_id, mail, context )
def generate_mail(self, cursor, user, template_id, record_ids, context=None): if context is None: context = {} template = self.browse(cursor, user, template_id, context=context) if not template: raise Exception("The requested template could not be loaded") result = True mailbox_obj = self.pool.get('email_template.mailbox') for record_id in record_ids: mailbox_id = self._generate_mailbox_item_from_template( cursor, user, template, record_id, context) mail = mailbox_obj.browse( cursor, user, mailbox_id, context=context ) if template.report_template or template.attachment_ids: self.generate_attach_reports( cursor, user, template, record_id, mail, context )
467,640
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: OpenERP Context """ return self.pool.get('email.template').read( cursor, user, context['template_id'], ['object_name'], context)['object_name']
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: OpenERP Context """ return self.pool.get('email.template').read( cursor, user, context['template_id'], ['object_name'], context)['object_name']
467,641
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: OpenERP Context """ return self.pool.get('email.template').read( cursor, user, context['template_id'], ['object_name'], context)['object_name']
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: OpenERP Context """ return self.pool.get('email.template').read( cursor, user, context['template_id'], ['object_name'], context)['object_name']
467,642
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: OpenERP Context """ return self.pool.get('email.template').read( cursor, user, context['template_id'], ['object_name'], context)['object_name']
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: OpenERP Context """ return self.pool.get('email.template').read( cursor, user, context['template_id'], ['object_name'], context)['object_name']
467,643
def on_change_ref(self, cr, uid, ids, rel_model_ref, context=None): if context is None: context = {} if not rel_model_ref: return {} vals = {} if context == {}: context = self.context template = self.pool.get('email.template').browse(cr, uid, context['template_id'], context) #Search translated template lang = get_value(cr, uid, rel_model_ref, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.pool.get('email.template').browse(cr, uid, context['template_id'], ctx) vals['to'] = get_value(cr, uid, rel_model_ref, template.def_to, template, context) vals['cc'] = get_value(cr, uid, rel_model_ref, template.def_cc, template, context) vals['bcc'] = get_value(cr, uid, rel_model_ref, template.def_bcc, template, context) vals['reply_to'] = get_value(cr, uid, rel_model_ref, template.reply_to, template, context) if template.message_id: vals['message_id'] = get_value(cr, uid, rel_model_ref, template.message_id, template, context) elif template.track_campaign_item: vals['message_id'] = tools.misc.generate_tracking_message_id(rel_model_ref) vals['subject'] = get_value(cr, uid, rel_model_ref, template.def_subject, template, context) vals['body_text'] = get_value(cr, uid, rel_model_ref, template.def_body_text, template, context) vals['body_html'] = get_value(cr, uid, rel_model_ref, template.def_body_html, template, context) vals['report'] = get_value(cr, uid, rel_model_ref, template.file_name, template, context) return {'value':vals}
def on_change_ref(self, cr, uid, ids, rel_model_ref, context=None): if context is None: context = {} if not rel_model_ref: return {} vals = {} if context == {}: context = self.context template = self.pool.get('email.template').browse(cr, uid, context['template_id'], context) #Search translated template lang = get_value(cr, uid, rel_model_ref, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.pool.get('email.template').browse(cr, uid, context['template_id'], ctx) vals['to'] = get_value(cr, uid, rel_model_ref, template.def_to, template, context) vals['cc'] = get_value(cr, uid, rel_model_ref, template.def_cc, template, context) vals['bcc'] = get_value(cr, uid, rel_model_ref, template.def_bcc, template, context) vals['reply_to'] = get_value(cr, uid, rel_model_ref, template.reply_to, template, context) if template.message_id: vals['message_id'] = get_value(cr, uid, rel_model_ref, template.message_id, template, context) elif template.track_campaign_item: vals['message_id'] = tools.misc.generate_tracking_message_id(rel_model_ref) vals['subject'] = get_value(cr, uid, rel_model_ref, template.def_subject, template, context) vals['body_text'] = get_value(cr, uid, rel_model_ref, template.def_body_text, template, context) vals['body_html'] = get_value(cr, uid, rel_model_ref, template.def_body_html, template, context) vals['report'] = get_value(cr, uid, rel_model_ref, template.file_name, template, context) return {'value':vals}
467,644
def msg_user(self, msg, id): body = self.msg_body_get(msg)
def msg_user(self, msg, id): body = self.msg_body_get(msg)
467,645
def msg_partner(self, msg, id): message = self.msg_body_get(msg) body = message['body'] act = 'case_open' self.rpc(self.model, act, [id]) #body2 = '\n'.join(map(lambda l: '> '+l, (body or '').split('\n'))) #data = { # 'description':body, #} #self.rpc(self.model, 'write', [id], data) attachments = message['attachment'] for attach in attachments or []: data_attach = { 'name': str(attach), 'datas': binascii.b2a_base64(str(attachments[attach])), 'datas_fname': str(attach), 'description': 'Mail attachment', 'res_model': self.model, 'res_id': id } self.rpc('ir.attachment', 'create', data_attach) self.rpc(self.model, 'history', [id], 'Send', True, self._decode_header(msg['From']), message['body']) return id
def msg_partner(self, msg, id): message = self.msg_body_get(msg) body = message['body'] act = 'case_open' self.rpc(self.model, act, [id]) #body2 = '\n'.join(map(lambda l: '> '+l, (body or '').split('\n'))) #data = { # 'description':body, #} #self.rpc(self.model, 'write', [id], data) attachments = message['attachment'] for attach in attachments or []: data_attach = { 'name': str(attach), 'datas': binascii.b2a_base64(str(attachments[attach])), 'datas_fname': str(attach), 'description': 'Mail attachment', 'res_model': self.model, 'res_id': id } self.rpc('ir.attachment', 'create', data_attach) self.rpc(self.model, 'history', [id], 'Send', True, self._decode_header(msg['To']), message['body'], self._decode_header(msg['From']), False, {'model' : self.model}) return id
467,646
def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Gets Recurrence rule string according to value type RECUR of iCalendar from the values given. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids, context=context): event = datas['id'] if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False cr.execute("UPDATE %s set exrule=Null where id=%s" % (self._table, event)) elif datas.get('rrule_type') == 'custom': if datas.get('interval', 0) < 0: raise osv.except_osv('Warning!', 'Interval can not be Negative') if datas.get('count', 0) < 0: raise osv.except_osv('Warning!', 'Count can not be Negative') rrule_custom = self.compute_rule_string(cr, uid, datas, \ context=context) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq': datas.get('rrule_type').upper(), 'interval': 1}, context=context)
def _get_rulestring(self, cr, uid, ids, name, arg, context=None): """ Gets Recurrence rule string according to value type RECUR of iCalendar from the values given. @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ result = {} for datas in self.read(cr, uid, ids, context=context): event = datas['id'] if datas.get('rrule_type'): if datas.get('rrule_type') == 'none': result[event] = False cr.execute("UPDATE %s set exrule=Null where id=%s" % (self._table, event)) elif datas.get('rrule_type') == 'custom': if datas.get('interval', 0) < 0: raise osv.except_osv('Warning!', 'Interval can not be Negative') if datas.get('count', 0) < 0: raise osv.except_osv('Warning!', 'Count can not be Negative') rrule_custom = self.compute_rule_string(cr, uid, datas, \ context=context) result[event] = rrule_custom else: result[event] = self.compute_rule_string(cr, uid, {'freq': datas.get('rrule_type').upper(), 'interval': 1}, context=context)
467,647
def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: if not line.location_src_id: self.write(cr, uid, procurement.id, {'message': _('No source location defined to generate the picking !')}) return (line.type_proc=='move') and (line.location_src_id) return False
def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False
467,648
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False): if not prod_id: return {} product = self.pool.get('product.product').browse(cr, uid, [prod_id])[0] uos_id = product.uos_id and product.uos_id.id or False result = { 'name': product.partner_ref, 'product_uom': product.uom_id.id, 'product_uos': uos_id, 'product_qty': 1.00, 'product_uos_qty' : self.pool.get('stock.move').onchange_quantity(cr, uid, ids, prod_id, 1.00, product.uom_id.id, uos_id)['value']['product_uos_qty'] }
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 {} product = self.pool.get('product.product').browse(cr, uid, [prod_id])[0] uos_id = product.uos_id and product.uos_id.id or False result = { 'name': product.partner_ref, 'product_uom': product.uom_id.id, 'product_uos': uos_id, 'product_qty': 1.00, 'product_uos_qty' : self.pool.get('stock.move').onchange_quantity(cr, uid, ids, prod_id, 1.00, product.uom_id.id, uos_id)['value']['product_uos_qty'] }
467,649
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False): if not prod_id: return {} product = self.pool.get('product.product').browse(cr, uid, [prod_id])[0] uos_id = product.uos_id and product.uos_id.id or False result = { 'name': product.partner_ref, 'product_uom': product.uom_id.id, 'product_uos': uos_id, 'product_qty': 1.00, 'product_uos_qty' : self.pool.get('stock.move').onchange_quantity(cr, uid, ids, prod_id, 1.00, product.uom_id.id, uos_id)['value']['product_uos_qty'] }
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_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} product = self.pool.get('product.product').browse(cr, uid, [prod_id], context=ctx)[0] uos_id = product.uos_id and product.uos_id.id or False result = { 'name': product.partner_ref, 'product_uom': product.uom_id.id, 'product_uos': uos_id, 'product_qty': 1.00, 'product_uos_qty' : self.pool.get('stock.move').onchange_quantity(cr, uid, ids, prod_id, 1.00, product.uom_id.id, uos_id)['value']['product_uos_qty'] }
467,650
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(str(msg)) subject = "[%s] %s" %(res_id, self._decode_header(message['Subject'])) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(tools.ustr(msg).encode('utf-8')) subject = "[%s] %s" %(res_id, message['Subject']) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
467,651
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(str(msg)) subject = "[%s] %s" %(res_id, self._decode_header(message['Subject'])) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(str(msg)) subject = "[%s] %s" %(res_id, self._decode_header(message['Subject'])) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
467,652
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(str(msg)) subject = "[%s] %s" %(res_id, self._decode_header(message['Subject'])) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(str(msg)) subject = "[%s] %s" %(res_id, self._decode_header(message['Subject'])) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
467,653
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(str(msg)) subject = "[%s] %s" %(res_id, self._decode_header(message['Subject'])) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(str(msg)) subject = "[%s] %s" %(res_id, self._decode_header(message['Subject'])) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
467,654
def process_report(self, node): values = {} for dest, f in (('name','string'), ('model','model'), ('report_name','name')): values[dest] = getattr(node, f) assert values[dest], "Attribute %s of report is empty !" % (f,) for field,dest in (('rml','report_rml'),('file','report_file'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')): if getattr(node, field): values[dest] = getattr(node, field) if node.auto: values['auto'] = eval(node.auto) if node.sxw: sxw_content = misc.file_open(node.sxw).read() values['report_sxw_content'] = sxw_content if node.header: values['header'] = eval(node.header) values['multi'] = node.multi and eval(node.multi) xml_id = node.id self.validate_xml_id(xml_id)
def process_report(self, node): values = {} for dest, f in (('name','string'), ('model','model'), ('report_name','name')): values[dest] = getattr(node, f) assert values[dest], "Attribute %s of report is empty !" % (f,) for field,dest in (('rml','report_rml'),('file','report_rml'),('xml','report_xml'),('xsl','report_xsl'),('attachment','attachment'),('attachment_use','attachment_use')): if getattr(node, field): values[dest] = getattr(node, field) if node.auto: values['auto'] = eval(node.auto) if node.sxw: sxw_content = misc.file_open(node.sxw).read() values['report_sxw_content'] = sxw_content if node.header: values['header'] = eval(node.header) values['multi'] = node.multi and eval(node.multi) xml_id = node.id self.validate_xml_id(xml_id)
467,655
def _data_set(self, cr, uid, id, name, value, arg, context): if not value: return True fbro = self.browse(cr, uid, id, context=context) nctx = nodes.get_node_context(cr, uid, context) fnode = nodes.node_file(None, None, nctx, fbro) res = fnode.set_data(cr, base64.decodestring(value), fbro) return res
def _data_set(self, cr, uid, id, name, value, arg, context): if not value: return True fbro = self.browse(cr, uid, id, context=context) nctx = nodes.get_node_context(cr, uid, context) fnode = nodes.node_file(None, None, nctx, fbro) res = fnode.set_data(cr, base64.decodestring(value), fbro) return res
467,656
def doc_createXElement(xdoc, tagName): e = xElement(tagName) e.ownerDocument = xdoc return e
def doc_createXElement(xdoc, tagName): e = xElement(tagName) e.ownerDocument = xdoc return e
467,657
def _create_record(self, cr, uid, doc, model, data, record_id, noupdate=False): data_pool = self.pool.get('ir.model.data') model_pool = self.pool.get(model) record = doc.createElement('record') record.setAttribute("id", record_id) record.setAttribute("model", model) record_list = [record] lids = data_pool.search(cr, uid, [('model','=',model)]) res = data_pool.read(cr, uid, lids[:1], ['module']) if res: self.depends[res[0]['module']]=True fields = model_pool.fields_get(cr, uid) for key,val in data.items(): if not (val or (fields[key]['type']=='boolean')): continue if fields[key]['type'] in ('integer','float'): field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", val and str(val) or 'False' ) record.appendChild(field) elif fields[key]['type'] in ('boolean',): field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", val and '1' or '0' ) record.appendChild(field) elif fields[key]['type'] in ('many2one',): field = doc.createElement('field') field.setAttribute("name", key) if type(val) in (type(''),type(u'')): id = val else: id,update = self._get_id(cr, uid, fields[key]['relation'], val) noupdate = noupdate or update if not id: relation_pool = self.pool.get(fields[key]['relation']) field.setAttribute("model", fields[key]['relation']) fld_nm = relation_pool._rec_name name = relation_pool.read(cr, uid, val,[fld_nm])[fld_nm] or False field.setAttribute("search", str([(str(fld_nm) ,'=', name)])) else: field.setAttribute("ref", id) record.appendChild(field) elif fields[key]['type'] in ('one2many',): for valitem in (val or []): if valitem[0] in (0,1): if key in model_pool._columns: fname = model_pool._columns[key]._fields_id else: fname = model_pool._inherit_fields[key][2]._fields_id if valitem[0] == 0: newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) valitem[1]=newid else: newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1]) if not newid: newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) valitem[1]=newid self.ids[(fields[key]['relation'], valitem[1])] = newid childrecord, update = self._create_record(cr, uid, doc, fields[key]['relation'],valitem[2], newid) noupdate = noupdate or update record_list += childrecord else: pass elif fields[key]['type'] in ('many2many',): res = [] for valitem in (val or []): if valitem[0]==6: for id2 in valitem[2]: id,update = self._get_id(cr, uid, fields[key]['relation'], id2) self.ids[(fields[key]['relation'],id2)] = id noupdate = noupdate or update res.append(id) field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", "[(6,0,["+','.join(map(lambda x: "ref('%s')" % (x,), res))+'])]') record.appendChild(field) else: field = doc_createXElement(doc, 'field') field.setAttribute("name", key) field.appendChild(doc.createTextNode(val)) record.appendChild(field)
def _create_record(self, cr, uid, doc, model, data, record_id, noupdate=False): data_pool = self.pool.get('ir.model.data') model_pool = self.pool.get(model) record = doc.createElement('record') record.setAttribute("id", record_id) record.setAttribute("model", model) record_list = [record] lids = data_pool.search(cr, uid, [('model','=',model)]) res = data_pool.read(cr, uid, lids[:1], ['module']) if res: self.depends[res[0]['module']]=True fields = model_pool.fields_get(cr, uid) for key,val in data.items(): if not (val or (fields[key]['type']=='boolean')): continue if fields[key]['type'] in ('integer','float'): field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", val and str(val) or 'False' ) record.appendChild(field) elif fields[key]['type'] in ('boolean',): field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", val and '1' or '0' ) record.appendChild(field) elif fields[key]['type'] in ('many2one',): field = doc.createElement('field') field.setAttribute("name", key) if type(val) in (type(''),type(u'')): id = val else: id,update = self._get_id(cr, uid, fields[key]['relation'], val) noupdate = noupdate or update if not id: relation_pool = self.pool.get(fields[key]['relation']) field.setAttribute("model", fields[key]['relation']) fld_nm = relation_pool._rec_name name = relation_pool.read(cr, uid, val,[fld_nm])[fld_nm] or False field.setAttribute("search", str([(str(fld_nm) ,'=', name)])) else: field.setAttribute("ref", id) record.appendChild(field) elif fields[key]['type'] in ('one2many',): for valitem in (val or []): if valitem[0] in (0,1): if key in model_pool._columns: model_pool._columns[key]._fields_id else: fname = model_pool._inherit_fields[key][2]._fields_id if valitem[0] == 0: newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) valitem[1]=newid else: newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1]) if not newid: newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) valitem[1]=newid self.ids[(fields[key]['relation'], valitem[1])] = newid childrecord, update = self._create_record(cr, uid, doc, fields[key]['relation'],valitem[2], newid) noupdate = noupdate or update record_list += childrecord else: pass elif fields[key]['type'] in ('many2many',): res = [] for valitem in (val or []): if valitem[0]==6: for id2 in valitem[2]: id,update = self._get_id(cr, uid, fields[key]['relation'], id2) self.ids[(fields[key]['relation'],id2)] = id noupdate = noupdate or update res.append(id) field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", "[(6,0,["+','.join(map(lambda x: "ref('%s')" % (x,), res))+'])]') record.appendChild(field) else: field = doc_createXElement(doc, 'field') field.setAttribute("name", key) field.appendChild(doc.createTextNode(val)) record.appendChild(field)
467,658
def _create_record(self, cr, uid, doc, model, data, record_id, noupdate=False): data_pool = self.pool.get('ir.model.data') model_pool = self.pool.get(model) record = doc.createElement('record') record.setAttribute("id", record_id) record.setAttribute("model", model) record_list = [record] lids = data_pool.search(cr, uid, [('model','=',model)]) res = data_pool.read(cr, uid, lids[:1], ['module']) if res: self.depends[res[0]['module']]=True fields = model_pool.fields_get(cr, uid) for key,val in data.items(): if not (val or (fields[key]['type']=='boolean')): continue if fields[key]['type'] in ('integer','float'): field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", val and str(val) or 'False' ) record.appendChild(field) elif fields[key]['type'] in ('boolean',): field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", val and '1' or '0' ) record.appendChild(field) elif fields[key]['type'] in ('many2one',): field = doc.createElement('field') field.setAttribute("name", key) if type(val) in (type(''),type(u'')): id = val else: id,update = self._get_id(cr, uid, fields[key]['relation'], val) noupdate = noupdate or update if not id: relation_pool = self.pool.get(fields[key]['relation']) field.setAttribute("model", fields[key]['relation']) fld_nm = relation_pool._rec_name name = relation_pool.read(cr, uid, val,[fld_nm])[fld_nm] or False field.setAttribute("search", str([(str(fld_nm) ,'=', name)])) else: field.setAttribute("ref", id) record.appendChild(field) elif fields[key]['type'] in ('one2many',): for valitem in (val or []): if valitem[0] in (0,1): if key in model_pool._columns: fname = model_pool._columns[key]._fields_id else: fname = model_pool._inherit_fields[key][2]._fields_id if valitem[0] == 0: newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) valitem[1]=newid else: newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1]) if not newid: newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) valitem[1]=newid self.ids[(fields[key]['relation'], valitem[1])] = newid childrecord, update = self._create_record(cr, uid, doc, fields[key]['relation'],valitem[2], newid) noupdate = noupdate or update record_list += childrecord else: pass elif fields[key]['type'] in ('many2many',): res = [] for valitem in (val or []): if valitem[0]==6: for id2 in valitem[2]: id,update = self._get_id(cr, uid, fields[key]['relation'], id2) self.ids[(fields[key]['relation'],id2)] = id noupdate = noupdate or update res.append(id) field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", "[(6,0,["+','.join(map(lambda x: "ref('%s')" % (x,), res))+'])]') record.appendChild(field) else: field = doc_createXElement(doc, 'field') field.setAttribute("name", key) field.appendChild(doc.createTextNode(val)) record.appendChild(field)
def _create_record(self, cr, uid, doc, model, data, record_id, noupdate=False): data_pool = self.pool.get('ir.model.data') model_pool = self.pool.get(model) record = doc.createElement('record') record.setAttribute("id", record_id) record.setAttribute("model", model) record_list = [record] lids = data_pool.search(cr, uid, [('model','=',model)]) res = data_pool.read(cr, uid, lids[:1], ['module']) if res: self.depends[res[0]['module']]=True fields = model_pool.fields_get(cr, uid) for key,val in data.items(): if not (val or (fields[key]['type']=='boolean')): continue if fields[key]['type'] in ('integer','float'): field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", val and str(val) or 'False' ) record.appendChild(field) elif fields[key]['type'] in ('boolean',): field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", val and '1' or '0' ) record.appendChild(field) elif fields[key]['type'] in ('many2one',): field = doc.createElement('field') field.setAttribute("name", key) if type(val) in (type(''),type(u'')): id = val else: id,update = self._get_id(cr, uid, fields[key]['relation'], val) noupdate = noupdate or update if not id: relation_pool = self.pool.get(fields[key]['relation']) field.setAttribute("model", fields[key]['relation']) fld_nm = relation_pool._rec_name name = relation_pool.read(cr, uid, val,[fld_nm])[fld_nm] or False field.setAttribute("search", str([(str(fld_nm) ,'=', name)])) else: field.setAttribute("ref", id) record.appendChild(field) elif fields[key]['type'] in ('one2many',): for valitem in (val or []): if valitem[0] in (0,1): if key in model_pool._columns: fname = model_pool._columns[key]._fields_id else: model_pool._inherit_fields[key][2]._fields_id if valitem[0] == 0: newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) valitem[1]=newid else: newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1]) if not newid: newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) valitem[1]=newid self.ids[(fields[key]['relation'], valitem[1])] = newid childrecord, update = self._create_record(cr, uid, doc, fields[key]['relation'],valitem[2], newid) noupdate = noupdate or update record_list += childrecord else: pass elif fields[key]['type'] in ('many2many',): res = [] for valitem in (val or []): if valitem[0]==6: for id2 in valitem[2]: id,update = self._get_id(cr, uid, fields[key]['relation'], id2) self.ids[(fields[key]['relation'],id2)] = id noupdate = noupdate or update res.append(id) field = doc.createElement('field') field.setAttribute("name", key) field.setAttribute("eval", "[(6,0,["+','.join(map(lambda x: "ref('%s')" % (x,), res))+'])]') record.appendChild(field) else: field = doc_createXElement(doc, 'field') field.setAttribute("name", key) field.appendChild(doc.createTextNode(val)) record.appendChild(field)
467,659
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
467,660
def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') res={} for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount for payment in order.payments: res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0) for line in order.lines: if order.price_type!='tax_excluded': res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_inv(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) else: res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) return res
def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') res={} for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount for payment in order.payments: res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0) for line in order.lines: if order.price_type!='tax_excluded': res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_inv(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) else: res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) return res
467,661
def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') res={} for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount for payment in order.payments: res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0) for line in order.lines: if order.price_type!='tax_excluded': res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_inv(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) else: res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) return res
def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') res={} for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount for payment in order.payments: res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0) for line in order.lines: if order.price_type!='tax_excluded': res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_inv(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty)['taxes'], res[order.id]['amount_tax']) else: res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty)['taxes'], res[order.id]['amount_tax']) return res
467,662
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
467,663
def _amount_line_ttc(self, cr, uid, ids, field_name, arg, context): res = {} account_tax_obj = self.pool.get('account.tax') for line in self.browse(cr, uid, ids): tax_amount = 0.0 taxes = [t for t in line.product_id.taxes_id] computed_taxes = account_tax_obj.compute(cr, uid, taxes, line.price_unit, line.qty) for tax in computed_taxes: tax_amount += tax['amount'] price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) if line.discount!=0.0: res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0) else: res[line.id]=line.price_unit*line.qty res[line.id] = res[line.id] + tax_amount return res
def _amount_line_ttc(self, cr, uid, ids, field_name, arg, context): res = {} account_tax_obj = self.pool.get('account.tax') for line in self.browse(cr, uid, ids): tax_amount = 0.0 taxes = [t for t in line.product_id.taxes_id] computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit, line.qty)['taxes'] for tax in computed_taxes: tax_amount += tax['amount'] price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) if line.discount!=0.0: res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0) else: res[line.id]=line.price_unit*line.qty res[line.id] = res[line.id] + tax_amount return res
467,664
def get_id(self, cr, uid, sequence_id, test='id=%s', context=None): try: cr.execute('SELECT id, number_next, prefix, suffix, padding FROM ir_sequence WHERE '+test+' AND active=%s FOR UPDATE', (sequence_id, True)) res = cr.dictfetchone() if res: cr.execute('UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s AND active=%s', (res['id'], True)) if res['number_next']: return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix']) else: return self._process(res['prefix']) + self._process(res['suffix']) finally: cr.commit() return False
def get_id(self, cr, uid, sequence_id, test='id=%s', context=None): cr.execute('SELECT id, number_next, prefix, suffix, padding FROM ir_sequence WHERE '+test+' AND active=%s FOR UPDATE', (sequence_id, True)) res = cr.dictfetchone() if res: cr.execute('UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s AND active=%s', (res['id'], True)) if res['number_next']: return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix']) else: return self._process(res['prefix']) + self._process(res['suffix']) return False
467,665
def _get_default_uom_id(self, cr, uid): model_data_obj = self.pool.get('ir.model.data') model_data_id = model_data_obj._get_id(cr, uid, 'product', 'uom_hour') return model_data_obj.read(cr, uid, [model_data_id], ['res_id'])[0]['res_id']
def _get_default_uom_id(self, cr, uid): model_data_obj = self.pool.get('ir.model.data') model_data_id = model_data_obj._get_id(cr, uid, 'product', 'uom_hour') return model_data_obj.read(cr, uid, [model_data_id], ['res_id'])[0]['res_id']
467,666
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if not hasattr(self, "_auto") or self._auto: cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname='%s'" % self._table) if not cr.rowcount: cr.execute("CREATE TABLE \"%s\" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITH OIDS" % self._table) create = True cr.commit() if self._parent_store: cr.execute("""SELECT c.relname FROM pg_class c, pg_attribute a WHERE c.relname=%s AND a.attname=%s AND c.oid=a.attrelid """, (self._table, 'parent_left')) if not cr.rowcount: if 'parent_left' not in self._columns: logger.notifyChannel('orm', netsvc.LOG_ERROR, 'create a column parent_left on object %s: fields.integer(\'Left Parent\', select=1)' % (self._table, )) if 'parent_right' not in self._columns: logger.notifyChannel('orm', netsvc.LOG_ERROR, 'create a column parent_right on object %s: fields.integer(\'Right Parent\', select=1)' % (self._table, )) if self._columns[self._parent_name].ondelete<>'cascade': logger.notifyChannel('orm', netsvc.LOG_ERROR, "the columns %s on object must be set as ondelete='cascasde'" % (self._name, self._parent_name)) cr.execute('ALTER TABLE "%s" ADD COLUMN "parent_left" INTEGER' % (self._table,)) cr.execute('ALTER TABLE "%s" ADD COLUMN "parent_right" INTEGER' % (self._table,)) cr.commit() store_compute = True
def _auto_init(self, cr, context={}): store_compute = False logger = netsvc.Logger() create = False todo_end = [] self._field_create(cr, context=context) if not hasattr(self, "_auto") or self._auto: cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname='%s'" % self._table) if not cr.rowcount: cr.execute("CREATE TABLE \"%s\" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITH OIDS" % self._table) create = True cr.commit() if self._parent_store: cr.execute("""SELECT c.relname FROM pg_class c, pg_attribute a WHERE c.relname=%s AND a.attname=%s AND c.oid=a.attrelid """, (self._table, 'parent_left')) if not cr.rowcount: if 'parent_left' not in self._columns: logger.notifyChannel('orm', netsvc.LOG_ERROR, 'create a column parent_left on object %s: fields.integer(\'Left Parent\', select=1)' % (self._table, )) if 'parent_right' not in self._columns: logger.notifyChannel('orm', netsvc.LOG_ERROR, 'create a column parent_right on object %s: fields.integer(\'Right Parent\', select=1)' % (self._table, )) if self._columns[self._parent_name].ondelete<>'cascade': logger.notifyChannel('orm', netsvc.LOG_ERROR, "The column %s on object %s must be set as ondelete='cascade'" % (self._parent_name, self._name)) cr.execute('ALTER TABLE "%s" ADD COLUMN "parent_left" INTEGER' % (self._table,)) cr.execute('ALTER TABLE "%s" ADD COLUMN "parent_right" INTEGER' % (self._table,)) cr.commit() store_compute = True
467,667
def action_invoice_create(self, cr, uid, ids, journal_id=False, group=False, type='out_invoice', context=None): """ Creates invoice based on the invoice state selected for picking. @param journal_id: Id of journal @param group: Whether to create a group invoice or not @param type: Type invoice to be created @return: Ids of created invoices for the pickings """ if context is None: context = {}
def action_invoice_create(self, cr, uid, ids, journal_id=False, group=False, type='out_invoice', context=None): """ Creates invoice based on the invoice state selected for picking. @param journal_id: Id of journal @param group: Whether to create a group invoice or not @param type: Type invoice to be created @return: Ids of created invoices for the pickings """ if context is None: context = {}
467,668
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
467,669
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
467,670
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s ( # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s ( # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
467,671
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
467,672
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s ( # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s ( # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
467,673
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
467,674
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
467,675
def validate(self, cr, uid, ids, context={}): if context and ('__last_update' in context): del context['__last_update']
def validate(self, cr, uid, ids, context={}): if context and ('__last_update' in context): del context['__last_update']
467,676
def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}): res = super(product_product, self)._product_available(cr, uid, ids, field_names, arg, context) for f in field_names: c = context.copy() if f=='stock_value': c.update({ 'states':('done',), 'what':('in', '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={}): res = super(product_product, self)._product_available(cr, uid, ids, field_names, arg, context) for f in field_names: c = context.copy() if f=='stock_value': c.update({ 'states':('done',), 'what':('in', '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
467,677
def _check_allow_negative_stock(self, cr, uid, ids): for product in self.browse(cr, uid, ids): if product.qty_available < 0.0: allow_negative = product.allow_negative_stock if not allow_negative: allow_neagtive = product.categ_id.allow_negative_stock if allow_negative != True : return False return True
def _check_allow_negative_stock(self, cr, uid, ids): for product in self.browse(cr, uid, ids): if product.qty_available < 0.0: allow_negative = product.allow_negative_stock if not allow_negative: allow_neagtive = product.categ_id.allow_negative_stock if allow_negative != True : return False return True
467,678
def product_id_change(self, cr, uid, ids, pricelist, price_unit_id, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sale form !\nPlease set one customer before choosing a product.')) warning = {} product_uom_obj = self.pool.get('product.uom') partner_obj = self.pool.get('res.partner') product_obj = self.pool.get('product.product') if partner_id: lang = partner_obj.browse(cr, uid, partner_id).lang context = {'lang': lang, 'partner_id': partner_id}
def product_id_change(self, cr, uid, ids, pricelist, price_unit_id, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sale form !\nPlease set one customer before choosing a product.')) warning = {} product_uom_obj = self.pool.get('product.uom') partner_obj = self.pool.get('res.partner') product_obj = self.pool.get('product.product') if partner_id: lang = partner_obj.browse(cr, uid, partner_id).lang context = {'lang': lang, 'partner_id': partner_id}
467,679
def __init__(self, model, name, string, **kwargs): self.model = model self.name = name self.string = string super(Function, self).__init__(**kwargs)
def __init__(self, model, name, string, **kwargs): self.model = model self.name = name self.string = string super(Function, self).__init__(**kwargs)
467,680
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): res = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag) purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price res['value'].update({'purchase_price':purchase_price}) return res
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): res = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag) if product: purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price res['value'].update({'purchase_price':purchase_price}) return res
467,681
def create(self, cr, uid, vals, context=None, check=True): account_obj = self.pool.get('account.account') tax_obj = self.pool.get('account.tax') move_obj = self.pool.get('account.move') cur_obj = self.pool.get('res.currency') journal_obj = self.pool.get('account.journal') if context is None: context = {} company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False) if company_id: vals['company_id'] = company_id[0] self._check_date(cr, uid, vals, context, check) if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals: context['journal_id'] = vals['journal_id'] if 'period_id' in vals: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = move_obj.browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
def create(self, cr, uid, vals, context=None, check=True): account_obj = self.pool.get('account.account') tax_obj = self.pool.get('account.tax') move_obj = self.pool.get('account.move') cur_obj = self.pool.get('res.currency') journal_obj = self.pool.get('account.journal') if context is None: context = {} if vals.get('move_id', False): company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False) if company_id: vals['company_id'] = company_id[0] self._check_date(cr, uid, vals, context, check) if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals: context['journal_id'] = vals['journal_id'] if 'period_id' in vals: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = move_obj.browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id
467,682
def _append_node(name, text): n = etree.SubElement(config, name) n.text = text
def _append_node(name, text): n = etree.SubElement(config, name) n.text = text
467,683
def process_record(self, node): import osv record, fields = node.items()[0] model = self.get_model(record.model) if isinstance(model, osv.osv.osv_memory): record_dict=self.create_osv_memory_record(record, fields) else: self.validate_xml_id(record.id) if self.isnoupdate(record) and self.mode != 'init': id = self.pool.get('ir.model.data')._update_dummy(self.cr, self.uid, record.model, self.module, record.id) # check if the resource already existed at the last update if id: self.id_map[record] = int(id) return None else: if not self._coerce_bool(record.forcecreate): return None
def process_record(self, node): import osv record, fields = node.items()[0] model = self.get_model(record.model) if isinstance(model, osv.osv.osv_memory): record_dict=self.create_osv_memory_record(record, fields) else: self.validate_xml_id(record.id) if self.isnoupdate(record) and self.mode != 'init': id = self.pool.get('ir.model.data')._update_dummy(self.cr, self.uid, record.model, self.module, record.id) # check if the resource already existed at the last update if id: self.id_map[record] = int(id) return None else: if not self._coerce_bool(record.forcecreate): return None
467,684
def get_module_resource(module, *args): """Return the full path of a resource of the given module. @param module: the module @param args: the resource path components @return: absolute path to the resource """ a = get_module_path(module) res = a and opj(a, *args) or False if zipfile.is_zipfile( a +'.zip') : zip = zipfile.ZipFile( a + ".zip") files = [opj(a,'/'.join(f.split('/')[1:])) for f in zip.namelist()] if res in files: return res else: if os.path.isfile(res): return res return False
def get_module_resource(module, *args): """Return the full path of a resource of the given module. @param module: the module @param args: the resource path components @return: absolute path to the resource """ a = get_module_path(module) res = a and opj(a, *args) or False if zipfile.is_zipfile( a +'.zip') : zip = zipfile.ZipFile( a + ".zip") files = ['/'.join(f.split('/')[1:]) for f in zip.namelist()] res = '/'.join(args) if res in files: return res else: if os.path.isfile(res): return res return False
467,685
def get_module_resource(module, *args): """Return the full path of a resource of the given module. @param module: the module @param args: the resource path components @return: absolute path to the resource """ a = get_module_path(module) res = a and opj(a, *args) or False if zipfile.is_zipfile( a +'.zip') : zip = zipfile.ZipFile( a + ".zip") files = [opj(a,'/'.join(f.split('/')[1:])) for f in zip.namelist()] if res in files: return res else: if os.path.isfile(res): return res return False
def get_module_resource(module, *args): """Return the full path of a resource of the given module. @param module: the module @param args: the resource path components @return: absolute path to the resource """ a = get_module_path(module) res = a and opj(a, *args) or False if zipfile.is_zipfile( a +'.zip') : zip = zipfile.ZipFile( a + ".zip") files = [opj(a,'/'.join(f.split('/')[1:])) for f in zip.namelist()] if res in files: return opj(a, res) elif os.path.isfile(res): return res return False
467,686
def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """
def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """
467,687
def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """
def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """
467,688
def close(self, *args, **kwargs): db,pool = pooler.get_db_and_pool(self.dbname) cr = db.cursor() cr.commit() try: getattr(self.pool.get('document.directory.content'), 'process_write_'+self.node.content.extension[1:])(cr, self.uid, self.node, self.getvalue()) finally: cr.commit() cr.close() StringIO.StringIO.close(self, *args, **kwargs)
def close(self, *args, **kwargs): db,pool = pooler.get_db_and_pool(self.dbname) cr = db.cursor() cr.commit() try: getattr(self.pool.get('document.directory.content'), 'process_write')(cr, self.uid, self.node, self.getvalue()) finally: cr.commit() cr.close() StringIO.StringIO.close(self, *args, **kwargs)
467,689
def _get_commitment_date(self, cr, uid, ids, name, arg, context={}): res = {} dates_list = [] for order in self.browse(cr, uid, ids): dates_list = [] for line in order.order_line: dt=DateTime.strptime(order.date_order, '%Y-%m-%d') + DateTime.RelativeDateTime(days=line.delay or 0.0) dt_s = dt.strftime('%Y-%m-%d') dates_list.append(dt_s) res[order.id] = min(dates_list) return res
def _get_commitment_date(self, cr, uid, ids, name, arg, context={}): res = {} dates_list = [] for order in self.browse(cr, uid, ids): dates_list = [] for line in order.order_line: dt=DateTime.strptime(order.date_order, '%Y-%m-%d') + DateTime.RelativeDateTime(days=line.delay or 0.0) dt_s = dt.strftime('%Y-%m-%d') dates_list.append(dt_s) if dates_list: res[order.id] = min(dates_list) return res
467,690
def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, unit, context={}): res = {}
def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, unit, context={}): res = {}
467,691
def exec_pg_command(name, *args): prog = find_pg_tool(name) if not prog: raise Exception('Couldn\'t find %s' % name) args2 = (os.path.basename(prog),) + args return subprocess.call(args2, executable=prog)
def exec_pg_command(name, *args): prog = find_pg_tool(name) if not prog: raise Exception('Couldn\'t find %s' % name) args2 = (prog,) + args return subprocess.call(args2, executable=prog)
467,692
def exec_pg_command(name, *args): prog = find_pg_tool(name) if not prog: raise Exception('Couldn\'t find %s' % name) args2 = (os.path.basename(prog),) + args return subprocess.call(args2, executable=prog)
def exec_pg_command(name, *args): prog = find_pg_tool(name) if not prog: raise Exception('Couldn\'t find %s' % name) args2 = (os.path.basename(prog),) + args return subprocess.call(args2)
467,693
def exec_pg_command_pipe(name, *args): prog = find_pg_tool(name) if not prog: raise Exception('Couldn\'t find %s' % name) pop = subprocess.Popen(args, executable=prog, shell=True, bufsize= -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) return (pop.stdin, pop.stdout)
def exec_pg_command_pipe(name, *args): prog = find_pg_tool(name) if not prog: raise Exception('Couldn\'t find %s' % name) pop = subprocess.Popen((prog,) + args, bufsize= -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) return (pop.stdin, pop.stdout)
467,694
def exec_command_pipe(name, *args): prog = find_in_path(name) if not prog: raise Exception('Couldn\'t find %s' % name) pop = subprocess.Popen(args, executable=prog, shell=True, bufsize= -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) return (pop.stdin, pop.stdout)
def exec_command_pipe(name, *args): prog = find_in_path(name) if not prog: raise Exception('Couldn\'t find %s' % name) pop = subprocess.Popen((prog,) + args, bufsize= -1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) return (pop.stdin, pop.stdout)
467,695
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
def _query_get(self, cr, uid, obj='l', context=None): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
467,696
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
467,697
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
467,698
def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None): ''' context = { 'uom': Unit of Measure (int), 'partner': Partner ID (int), 'date': Date of the pricelist (%Y-%m-%d), } ''' context = context or {} currency_obj = self.pool.get('res.currency') product_obj = self.pool.get('product.product') supplierinfo_obj = self.pool.get('product.supplierinfo') price_type_obj = self.pool.get('product.price.type')
def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None): ''' context = { 'uom': Unit of Measure (int), 'partner': Partner ID (int), 'date': Date of the pricelist (%Y-%m-%d), } ''' context = context or {} currency_obj = self.pool.get('res.currency') product_obj = self.pool.get('product.product') supplierinfo_obj = self.pool.get('product.supplierinfo') price_type_obj = self.pool.get('product.price.type')
467,699