콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3508 화면

I'm doing a large import of partners through the API (because the data is too complex to use CSV).

I would like to set the create_date and insert the messages into mail_message myself, so I can use the correct users, dates, etc.

My questions:

  • Can you manually create entries (ideally through the API)  into mail_message table (mail.message model) with custom date and creator?

  • Can you prevent the "Contact Created" and "Added to Company" messages from being created somehow?

  • And, optionally, is there a way to set the create_date / update_date for an import?

아바타
취소
작성자

This is for Odoo 11 - I've tried to edit the original post, but it didn't let me.

작성자 베스트 답변

There is no way to do this without overriding a method on partner level.

My current solution:

During import, search model: mail.message for:

[
    ('model', '=', 'res.partner'),
    ('res_id', '=', partner_id),
    ('body', '=', '<p>Contact created</p>')
]

Then update the following fields:

        message_contents = {
            'date': new_date,
            'author_id': new_partner_id,
            'email_from': "Name <email@server.com>",
        }


-----------

Alternate solution:

Overriding the message_post method to prevent the message from being posted:

    @api.multi
    @api.returns('self', lambda value: value.id)
    def message_post(self, body='', subject=None, message_type='notification',
                     subtype=None, parent_id=False, attachments=None,
                     content_subtype='html', **kwargs):
        """ This whole method, and the property of skip_messages can be removed after import is finalized. """
        for partner in self:
            if partner.skip_messages:
                return None
        return super(ResPartner, self).message_post(
                body=body, subject=subject, message_type=message_type, subtype=subtype,
                parent_id=parent_id, attachments=attachments, content_subtype=content_subtype,
                **kwargs)

아바타
취소
관련 게시물 답글 화면 활동
0
10월 20
3742
5
10월 19
9516
0
10월 15
4745
4
8월 15
4747
1
8월 25
322