2016-04-04 22 views
0

Nesne odoo hiçbir özellik env hata var

class slotcheck(models.Model): 
_name = 'slotcheck' 
_inherit = ['book.meeting'] 
_rec_name = 'display_total' 


unit_exceed = fields.Boolean('Exceeded limit',default=False) 
addnl_usage = fields.Integer('Additional usage') 
display_total = fields.Integer(string='Dispaly total usage', compute='_display_slot_check') 
current_company = fields.Many2one('res.company','Enter your company name') 

_defaults = { 

    'current_company': lambda obj, cr, uid, context: uid, 

} 



def _display_slot_check(self): 
    _logger = logging.getLogger(__name__) 
    _logger.info('#######################coming here ###########') 
    currentMonth = datetime.now().month 
    currentYear = datetime.now().year 
    first_day = datetime(currentYear, currentMonth, 1) 
    num_days = calendar.monthrange(currentYear, currentMonth) 
    last_day = datetime(currentYear, currentMonth, num_days[1]) 
    conv_date = ((last_day.strftime('%Y-%m-%d'))+' '+'23:59:59') 
    query = "select sum(units) from book_meeting where company_name=%s and end_time>=%s and end_time<=%s " #line 41 

    rows_count=self._cr.execute(query,(self.current_company.id,first_day,conv_date)) 
    data1=self._cr.fetchall() 
    for row in data1: 
     total = row 
    monthly = total[0] 
    _logger.info('#######################coming here ###########') 
    self.display_total = monthly 

Sanki hata veriyor şöyle Benim kodudur: u'self._display_slot_check değerlendirirken nesne hiçbir özellik env sahip slotcheck()' doğrultusunda 41

Nasıl

StackTrace nitelik env'nin bu hatayı bulunamadı hatası üstesinden gelebilir:

Traceback (most recent call last): 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\http.py", line 537, in _handle_exception 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\http.py", line 574, in dispatch 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\http.py", line 310, in _call_function 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\service\model.py", line 118, in wrapper 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\http.py", line 307, in checked_call 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\http.py", line 803, in __call__ 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\http.py", line 403, in response_wrap 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\openerp\addons\web\controllers\main.py", line 1255, in run 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\http.py", line 908, in proxy 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\api.py", line 250, in wrapper 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\openerp\addons\base\ir\ir_actions.py", line 1002, in run 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\api.py", line 250, in wrapper 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\openerp\addons\base\ir\ir_actions.py", line 836, in run_action_code_multi 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\tools\safe_eval.py", line 314, in safe_eval 
    File "", line 1, in <module> 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\openerp\addons\stpi\models\slot_manage.py", line 39, in _display_slot_check 
    File "C:\Program Files (x86)\Odoo 8.0-20151015\server\.\openerp\models.py", line 5289, in <lambda> 
ValueError: "'slotcheck' object has no attribute 'env'" while evaluating 
u'self._display_slot_check()' 
+0

Lütfen stacktraceinizi de gönderin. –

+0

@ Muhammed Tahir, stacktrace eklendi –

+0

'api.model' decorater'ını' def _display_slot_check (self): 'yöntemiyle deneyin. –

cevap

1

Sanırım bir hata yaptınız. Sizin model adı slotcheck ama

self._cr.execute kullanmayan farklı modelden bir model üzerinde bir sorgu yürütme ediyorsanız (select sum(units) from book_meeting where company_name=%s and end_time>=%s and end_time<=%s

olarak book_meeting veritabanı üzerinde sorgu yürütme bunun yerine)

sadece

cr.execute kullanımı()

+0

Teşekkürler. Şimdi çalışıyor. –