1

我在 odoo 中有一个按钮,单击它会引发错误,如下图所示,我需要一些帮助才能完成这项工作 在此处输入图像描述

class ratecard_multiple(models.Model):
    # pudb.set_trace()
    _name = 'ratecard.multiple'
    _rec_name = 'display_name'
    name = fields.Char(string='Multiple RateCard Product  Name ', required=True)
    code = fields.Char(string='Multiple RateCard Code ', readonly=True)
    scheduled_for = fields.Integer(string='SCHEDULED FOR', default=1, track_visibility='always', store=True)
    # scheduled_for  = fields.Integer(string='SCHEDULED FOR',  compute='_compute_scheduled_for',default=1 ,track_visibility='always',store=True)
    min_weeks = fields.Integer(string="MINIMUM NO OF WEEKS", default=1, store=True)
    max_weeks = fields.Integer(string="Maximum NO OF WEEKS", default=1, track_visibility='always', store=True)

    multiple_ratecard_id = fields.Many2many(comodel_name='ratecard.sin.radio',
                                            relation='ratecard_multiple_singular_rel',
                                            column1='ratecard_multiple_id',
                                            column2='ratecard_sin_radio_id',
                                            string='RATECARDS')


class ratecard_sin_radio(models.Model):
    _name = 'ratecard.sin.radio'
    _description = 'RATECARD SINGULAR RADIO  '

    code = fields.Char(string='RADIO SINGULR RATECARD CODE', readonly=True)
    name = fields.Char(string='NAME')
    outlet_id = fields.Many2one(comodel_name='outlet', string='Outlet')
    timeband_id = fields.Many2one(comodel_name='timeband', string='TimeBand')

    def action_four_weeks_schedule_form(self,cr,uid,ids,context):
        order_obj = self.pool.get('ratecard.multiple').browse(cr,uid,ids)[0]
        print  'order_obj.scheduled_for' , order_obj.scheduled_for
        print  'default_code  order_obj.code' ,  order_obj.code
        return {
            'name':_("Four  Week Schedule to Process"),
            'view_mode': 'form',
            'view_id': False,
            'view_type': 'form',
            'res_model': 'four.weeks.schedule',
            'context':{'default_scheduled_for': order_obj.scheduled_for, 'default_code': order_obj.code},
            'type': 'ir.actions.act_window',
            'nodestroy': True,
            'target': 'new',
            'domain': '[]',
            'flags': {'form': {'action_buttons': True}}

    }

在 ratecard.multiple 看来,我有这个

<tree  editable="bottom">
    <group colspan="2"  col="2" >
        <field name="name"/>
         <field name='display_name'/>
        <field name='code'/>
        <field name="validity_date"/>
        <field name="scheduled_for"/>
        <field name="min_weeks"/>
        <field name="max_weeks"/>
        <!--<field name="multiple_ratecard_id_count"/>-->
        <field name="multiple_ratecard_id_count" widget="statinfo"/>


         <!--<field name="allocate_schedule_count"/>-->
         <!--<field name='company_id'/>-->
          </group>
    <field name='multiple_ratecard_id' nolabel="1" options="{'reload_on_button': true}">  <!-- widget="many2many"-->
    <tree  string="ALLOCATE SPOTS" editable="bottom" >
             <button name="action_four_weeks_schedule_form" string="CREATE SCHEDULE" type="object" />

                       <field name="code"/>
                        <field name="name"/>
                        <field name="outlet_id" on_change="onchange_outlet(outlet_id)" placeholder="OUTLET"/>
          </tree>
  </field>
</tree>

在调试模式下的终端中抛出此错误

 2015-12-14 09:53:50,615 13824 ERROR ragtimeorder openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "/home/daniel/CRUCIAL/odoo/openerp/http.py", line 537, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/daniel/CRUCIAL/odoo/openerp/http.py", line 574, in dispatch
    result = self._call_function(**self.params)
  File "/home/daniel/CRUCIAL/odoo/openerp/http.py", line 310, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/daniel/CRUCIAL/odoo/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/daniel/CRUCIAL/odoo/openerp/http.py", line 307, in checked_call
    return self.endpoint(*a, **kw)
  File "/home/daniel/CRUCIAL/odoo/openerp/http.py", line 803, in __call__
    return self.method(*args, **kw)
  File "/home/daniel/CRUCIAL/odoo/openerp/http.py", line 403, in response_wrap
    response = f(*args, **kw)
  File "/home/daniel/CRUCIAL/odoo/addons/web/controllers/main.py", line 948, in call_button
    action = self._call_kw(model, method, args, {})
  File "/home/daniel/CRUCIAL/odoo/addons/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/home/daniel/CRUCIAL/odoo/openerp/api.py", line 256, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/daniel/CRUCIAL/rag_modules/ragtimeorder_modules/ragtimeorder/models/ragdefaults.py", line 1055, in action_four_weeks_schedule_form
    print  'order_obj  ' , order_obj
  File "/home/daniel/CRUCIAL/odoo/openerp/fields.py", line 825, in __get__
    return record._cache[self]
  File "/home/daniel/CRUCIAL/odoo/openerp/models.py", line 6024, in __getitem__
    return value.get() if isinstance(value, SpecialValue) else value
  File "/home/daniel/CRUCIAL/odoo/openerp/fields.py", line 55, in get
    raise self.exception
MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.')
4

1 回答 1

1

当您尝试搜索或访问不存在的记录 ID 时会发生此错误,我怀疑您的问题可能来自这里

order_obj = self.pool.get('ratecard.multiple').browse(cr,uid,ids)[0]

检查您传递给函数的 ID,它可能在数据库中不存在,您可以将其打印到控制台或日志文件,然后检查您的数据库psql并查看它是否存在。

于 2016-04-20T09:44:20.977 回答