实际上,当在Odoo服务器上创建/更新任何记录时,我想使用Google Cloud pubsub将消息发送到主题
我重写了如下创建函数
@api.model
def create(self, values):
values = self._remove_reified_groups(values)
user = super(Users, self).create(values) // created and return id just like res.users(67,)
group_multi_company = self.env.ref('base.group_multi_company', False)
if group_multi_company and 'company_ids' in values:
if len(user.company_ids) <= 1 and user.id in group_multi_company.users.ids:
group_multi_company.write({'users': [(3, user.id)]})
elif len(user.company_ids) > 1 and user.id not in group_multi_company.users.ids:
group_multi_company.write({'users': [(4, user.id)]})
# Publish message to subscriber
pubsub = PubSub()
// Here I used own middleware service which is used for CRUD opertion on
Odoo model
// Below API return record of model 'res.users'
// Here user.id return 67
req = requests.get('http://localhost:8080/users/' + str(user.id))
fetch_user = req.text // response return user not found because record nor save in table
result = pubsub.publish_message_on_topic(self.project_id, self.topic_name, fetch_user)
return user
在用户创建的创建函数中,它的返回ID在用户变量中,但是直到“返回用户”(函数的最后一行)不运行时,它才保存在表中。我不知道创建功能在Odoo中如何工作?
因此,我搜索记录创建/更新时触发的任何事件,因此我将实现该功能的pubsub逻辑。
有什么帮助或建议吗?
谢谢。
答案 0 :(得分:0)