Я пытаюсь создать запись в модели document.propose.in. Тем не менее, я получил предупреждение, когда я нажал на кнопку data_create. Я пытался проверить, где код идет не так, и это код в этой строке:
message_obj.create({
'res_id': self.ids[0],
'model': 'document.propose.in',
'subtype_id': subtype_id,
'body': _('Changes in the document %s has been approved by QMR.') % self.name
})
Нет информации об ошибке в терминале. Тем не менее, он отображается в консоли браузера.
web.assets_common.js: 3023 Ошибка приложения сервера {"message": "Ошибка сервера Odoo", "код": 200, "данные": {"отладка": "Трассировка (последний последний вызов): \ n Файл \ "/ home / odoo10 / odoo / http.py \", строка 640, в _handle_exception \ n возвращает супер (JsonRequest, self) ._ handle_exception (исключение) \ n Файл \ "/ home / odoo10 / odoo / http.py \ ", строка 677, в диспетчере \ n result = self._call_function (** self.params) \ n Файл \" / home / odoo10 / odoo / http.py \ ", строка 333, в _call_function \ n вернуть check_call ( self.db, * args, ** kwargs) \ n Файл \ "/ home / odoo10 / odoo / service / model.py \", строка 101, в обёртке \ n, возвращает f (имя db, * args, ** kwargs) \ n Файл \ "/ home / odoo10 / odoo / http.py \", строка 326, в поле selected_call \ n result = self.endpoint (* a, ** kw) \ n Файл \ "/ home / odoo10 / odoo / http.py \ ", строка 935, в вызов \ n, возврат self.method (* args, ** kw) \ n Файл \" / home / odoo10 / odoo / http.py \ ", строка 506, в response_wrap \ n response = f (* args, ** kw) \ n File \ "/ home / odoo10 / addons / web / controllers / main.py \", строка 889, в c all_button \ n action = self._call_kw (модель, метод, аргументы, {}) \ n Файл \ "/ home / odoo10 / addons / web / controllers / main.py \", строка 877, в _call_kw \ n вернуть call_kw ( request.env [модель], метод, args, kwargs) \ n Файл \ "/ home / odoo10 / odoo / api.py \", строка 689, в call_kw \ n, возвращаем call_kw_multi (метод, модель, аргументы, kwargs) \ n Файл \ "/ home / odoo10 / odoo / api.py \", строка 680, в call_kw_multi \ n result = метод (recs, * args, ** kwargs) \ n Файл \ "/ home / innotek4 / Documents / ISO /odoo_komp/mgmt_documents/wizards/document_register.py \ ", строка 113, в data_create \ n 'body': _ ('Изменения в документе% s утверждены QMR.')% self.name \ n File \" /home/odoo10/addons/mail/models/mail_message.py \ ", строка 724, в create \ n values ['record_name'] = self._get_record_name (values) \ n файл \" / home / odoo10 / addons / mail /models/mail_message.py \ ", строка 680, в _get_record_name \ n вернуть self.env [модель] .sudo (). browse (res_id) .name_get () [0] [1] \ n файл \" / home / odoo10 / odoo / models.py \ ", строка 1546, в name_get \ nr esult.append ((record.id, convert (record [name], record))) \ n Файл \ "/ home / odoo10 / odoo / models.py \", строка 5211, в getitem \ n вернуть self._fields [key]. get (self, type (self)) \ n Файл \ "/ home / odoo10 / odoo / fields.py \", строка 913, в get \ n value = record._cache [self] \ n File \ "/ home / odoo10 / odoo / models.py \", строка 5563, в getitem \ n возвращаемое значение.get () если isinstance (значение, SpecialValue), иначе значение \ n Файл \ "/ home / odoo10 / odoo / fields.py \", строка 48, в get \ n вызвать self.exception \ nMissingError: (u'Record не существует или имеет был удален. ', Нет) \ n "," тип_исключения ":" отсутствует_террор "," сообщение ":" Запись не существует или была удалена. \ nНет "," имя ":" odoo.exceptions.MissingError "," arguments ": [" Запись не существует или была удалена. ", null]}}
В строке 113 находится функция create message_obj. Я пытался обновить модуль, но не повезло. Вот код (на случай, если он поможет):
class documentregister(models.TransientModel):
_name = "document.register"
_description = "document register"
name = fields.Char('Title', required=True)
type = fields.Selection(
[('content', 'Content'), ('category', 'Category')],
'Type',
help="Page type",
default="content"
)
act = fields.Selection(
[('create', 'Create'), ('edit', 'Edit')],
'Action'
)
parent_id = fields.Many2one(
'document.page',
'Category',
domain=[('type', '=', 'category')]
)
doc_page = fields.Many2one('document.page','Document')
content = fields.Text("Content")
revision = fields.Integer('Revision', default=0)
doc_no = fields.Char('Document Number')
dept = fields.Many2one('hr.department', 'Department',domain=[('parent_id', '=', False)])
section = fields.Many2one('hr.department','Section')
id_dpi = fields.Many2one('document.propose.in', 'id_dpi')
document_attc1 = fields.Many2many(comodel_name='ir.attachment', relation='document_propose_attachment_wiz', string="Add Attachment")
issue_plan = fields.Date('Document Issue Plan')
distribution_ids = fields.One2many('document.distribusi.regis', 'doc_id', 'Distribution Dept')
@api.multi
def data_create(self):
if self.act =="create":
if self.content:
document_page_obj = self.env['document.page']
masterdist=[]
for di in self.id_dpi.distribusi_ids:
masterdist2=(0, 0, {'dept':di.dept.id})
masterdist.append(masterdis2)
id_create = document_page_obj.create(
{'name': self.name,
'type': 'content',
'dept': self.dept.id,
'section': self.section.id,
'doc_no': self.doc_no,
'content': self.content,
'parent_id': self.parent_id.id,
'write_uid': self.env.uid,
'write_date': time.strftime('%Y-%m-%d'),
'distribusi_ids': masterdist,
}
)
document_page_history_obj = self.env['document.page.history']
dph_ids_list = document_page_history_obj.search([('page_id', '=', id_create.id)])
dph_ids_list.sorted(key=lambda r: r.id)
attach = []
for att in self.document_attc1:
attach.append(att.id)
dph_ids_list.write({'date_confirm': self.issue_plan,'lamp':[(6, 0,attach)]})
id_create.page_approval_approved2()
id_create.distribusi_act()
document_page_in_obj = self.env['document.propose.in']
model_data_obj = self.env['ir.model.data']
message_obj = self.env['mail.message']
subtype_id = model_data_obj.get_object_reference('mail', 'mt_comment')[1]
message_obj.create({
'res_id': self.ids[0],
'model': 'document.propose.in',
'subtype_id': subtype_id,
'body': _('Changes in the document %s has been approved by QMR.') % self.name
})
return self.id_dpi.write({'date_limit': time.strftime('%Y-%m-%d'),'confirm_id': self.env.uid,'propose_id_new': id_create.id,'state': 'convert','doc_regis_bool':True})
else:
raise osv.except_osv(_('Invalid Action!'), _('Please Entry Content Document First!'))
elif self.act=="edit":
if self.content:
document_page_obj = self.env['document.page']
dp_ids=document_page_obj.search([('id', '=',self.doc_page.id)])[0]
masterdist = []
for di in self.id_dpi.distribusi_ids:
masterdist2 = (0, 0, {'dept': di.dept.id})
masterdist.append(masterdist2)
vals={'name': self.name,
'dept': self.dept.id,
'section': self.section.id,
'doc_no': self.doc_no,
'content': self.content,
'parent_id': self.parent_id.id,
}
dp_ids.write(vals)
document_distribution_master_obj = self.env['document.distribution.master']
ddm_ids = document_distribution_master_obj.search([('doc_id_master', '=', self.doc_page.id)]).unlink()
dp_ids.write({
'distribution_ids': masterdist,
})
document_page_history_obj = self.env['document.page.history']
dph_ids_list=dp_ids.create_history(self.doc_page.id, self.content, "content", self.doc_no, revision=self.revision)
distribution = dp_ids.create_distributionmaster_revision_2(dph_ids_list.id,self.id_dpi.distribution_ids)
attach = []
for att in self.document_attc1:
attach.append(att.id)
dph_ids_list.write({'date_confirm': self.issue_plan, 'lamp': [(6, 0, attach)]})
dp_ids.page_approval_approved2()
dp_ids.distribusi_act()
document_page_in_obj = self.env['document.propose.in']
model_data_obj = self.env['ir.model.data']
message_obj = self.env['mail.message']
subtype_id = model_data_obj.get_object_reference('mail', 'mt_comment')[1]
message_obj.create(
{'res_id': self.id_dpi.id,
'model': 'document.propose.in',
'subtype_id': subtype_id,
'body': _('Changes in the document %s has been approved by QMR.') % self.name
}
)
return self.id_dpi.write({'date_limit': time.strftime('%Y-%m-%d'),'confirm_id': self.env.uid,'state': 'convert','doc_regis_bool':True})
else:
raise osv.except_osv(_('Invalid Action!'), _('Please Entry Content Document First!'))