我需要隐藏新消息'按钮,其中包括邮件消息历史记录的顶部。它只能对经理可见。我尝试过几种方式。但它不起作用。 这是我的代码
<templates>
<t t-name="mail.Chatter">
<div class="o_chatter">
<div class="o_chatter_topbar">
<button type="button" class="btn btn-sm btn-primary o_chatter_button_new_message" title="Send a message" groups="toweriq_pm.group_manager">
New message
</button>
<button t-if="widget.options.display_log_button" class="btn btn-sm btn-link o_chatter_button_log_note" title="Log a note. Followers will not be notified.">
Log an internal note
</button>
</div>
</div>
</t>
</templates>
任何人都可以帮助我
答案 0 :(得分:0)
我只是通过重写JS方法来限制。首先,我在自定义模块中创建一个字段,以检查登录用户是自定义模块的管理员还是用户。 这是我的
的python代码on_open_composer_new_message: function () {
this.open_composer();},
然后我编辑邮件模块中的chatter.js文件。在这里我重申
on_open_composer_new_message: function () {
var Model = require('web.DataModel');
var manager = this;
new Model('project.task').query(['identify_manager'])
.filter([['active', '=', true]])
.first()
.then(function(uid) {
console.log(uid);
if (uid.identify_manager == true){
manager.open_composer();
}else{
alert("You can not proceed this action.");
}
});
},
代码
public class BusinessTypeAdapter extends RecyclerView.Adapter<BusinessTypeAdapter.MyViewHolder> {
private List<BusinessTypeModel> moviesList;
private int lastSelectedPosition = -1;
private Context context;
private OnItemClick mCallback;
public class MyViewHolder extends RecyclerView.ViewHolder {
public TextView title,id;
RadioButton radioButton;
public MyViewHolder(View view) {
super(view);
title = (TextView) view.findViewById(R.id.businessname);
id = (TextView) view.findViewById(R.id.id);
radioButton = (RadioButton) view.findViewById(R.id.select);
//
// radioButton.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// final BusinessTypeModel movie = new BusinessTypeModel();
//// boolean isChecked = radioButton.isChecked();
//// if (isChecked) {
//// String clickValue = movie.getId();
//
//// Log.d("list", moviesList.toString());
//
// lastSelectedPosition = getAdapterPosition();
// notifyDataSetChanged();
//// Toast.makeText(BusinessTypeAdapter.this.context,
//// "selected offer is " + clickValue,
//// Toast.LENGTH_LONG).show();
// }
//
//// }
// });
}
}
public BusinessTypeAdapter(List<BusinessTypeModel> moviesList,Context ctx,OnItemClick listener) {
this.moviesList = moviesList;
context = ctx;
this.mCallback = listener;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.businestypelistitem, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
final BusinessTypeModel movie = moviesList.get(position);
holder.title.setText(movie.getTitle());
holder.id.setText(movie.getId());
holder.radioButton.setChecked(lastSelectedPosition == position);
boolean isChecked = holder.radioButton.isChecked();
if(isChecked) {
String clickValue = movie.getId();
mCallback.onClick(clickValue);
Toast.makeText(BusinessTypeAdapter.this.context,
"selected offer is holder " + clickValue,
Toast.LENGTH_LONG).show();
}
}
@Override
public int getItemCount() {
return moviesList.size();
}
public interface OnItemClick {
void onClick (String value);
}
}
这种方法对我来说很好......当用户点击“新消息”按钮时,它会发出警报,当管理点击它时,它会打开消息编辑器。