I'm trying to create record into document.propose.in model. However, I got the warning when I clicked on data_create button. I've tried to check where the code goes wrong, and it's the code in this line:
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
})
There's no error information showed in terminal. It does, however, showed in the browser's console.
web.assets_common.js:3023 Server application error {"message":"Odoo Server Error","code":200,"data":{"debug":"Traceback (most recent call last):\n File \"/home/odoo10/odoo/http.py\", line 640, in _handle_exception\n return super(JsonRequest, self)._handle_exception(exception)\n File \"/home/odoo10/odoo/http.py\", line 677, in dispatch\n result = self._call_function(**self.params)\n File \"/home/odoo10/odoo/http.py\", line 333, in _call_function\n return checked_call(self.db, *args, **kwargs)\n File \"/home/odoo10/odoo/service/model.py\", line 101, in wrapper\n return f(dbname, *args, **kwargs)\n File \"/home/odoo10/odoo/http.py\", line 326, in checked_call\n result = self.endpoint(*a, **kw)\n File \"/home/odoo10/odoo/http.py\", line 935, in call\n return self.method(*args, **kw)\n File \"/home/odoo10/odoo/http.py\", line 506, in response_wrap\n response = f(*args, **kw)\n File \"/home/odoo10/addons/web/controllers/main.py\", line 889, in call_button\n action = self._call_kw(model, method, args, {})\n File \"/home/odoo10/addons/web/controllers/main.py\", line 877, in _call_kw\n return call_kw(request.env[model], method, args, kwargs)\n File \"/home/odoo10/odoo/api.py\", line 689, in call_kw\n return call_kw_multi(method, model, args, kwargs)\n File \"/home/odoo10/odoo/api.py\", line 680, in call_kw_multi\n result = method(recs, *args, **kwargs)\n File \"/home/innotek4/Documents/ISO/odoo_komp/mgmt_documents/wizards/document_register.py\", line 113, in data_create\n 'body': _('Changes in the document %s has been approved by QMR.') % self.name\n File \"/home/odoo10/addons/mail/models/mail_message.py\", line 724, in create\n values['record_name'] = self._get_record_name(values)\n File \"/home/odoo10/addons/mail/models/mail_message.py\", line 680, in _get_record_name\n return self.env[model].sudo().browse(res_id).name_get()[0][1]\n File \"/home/odoo10/odoo/models.py\", line 1546, in name_get\n result.append((record.id, convert(record[name], record)))\n File \"/home/odoo10/odoo/models.py\", line 5211, in getitem\n return self._fields[key].get(self, type(self))\n File \"/home/odoo10/odoo/fields.py\", line 913, in get\n value = record._cache[self]\n File \"/home/odoo10/odoo/models.py\", line 5563, in getitem\n return value.get() if isinstance(value, SpecialValue) else value\n File \"/home/odoo10/odoo/fields.py\", line 48, in get\n raise self.exception\nMissingError: (u'Record does not exist or has been deleted.', None)\n","exception_type":"missing_error","message":"Record does not exist or has been deleted.\nNone","name":"odoo.exceptions.MissingError","arguments":["Record does not exist or has been deleted.",null]}}
Line 113 is where the function create message_obj. I've tried updating module, but no luck. Here's the code (in case it's gonna help):
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!'))