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

I want to hide the action reports of stock.picking based on the picking_type_code. Specifically, if picking_type_code = "outgoing", I want to hide stock.action_report_delivery; if picking_type_code = "incoming", I want to hide stock.stock_reception_report_action. All other reports should remain visible. How can I achieve this? Here is what I have tried so far:


class StockPicking(models.Model):

_inherit = "stock.picking"


def _get_action_ids(self, xml_ids):

action_ids = []

for xml_id in xml_ids:

try:

action_ids.append(self.env.ref(xml_id).id)

except ValueError:

_logger.warning("XML ID not found: %s", xml_id)

return action_ids


def _filter_toolbar_actions(self, view, allowed_ids=None, hidden_ids=None):

if not view or not view.get("toolbar"):

return

print_actions = view["toolbar"].get("print", [])

if allowed_ids is not None:

view["toolbar"]["print"] = [

a for a in print_actions if a.get("id") in allowed_ids

]

elif hidden_ids is not None:

view["toolbar"]["print"] = [

a for a in print_actions if a.get("id") not in hidden_ids

]


@api.model

def get_views(self, views, options=None):

res = super().get_views(views, options)

picking_type_code = self.env.context.get("restricted_picking_type_code")


if picking_type_code == "outgoing":

hidden_xml_ids = [

"stock.action_report_delivery",

]

hidden_ids = self._get_action_ids(hidden_xml_ids)

form_view = res["views"].get("form")

self._filter_toolbar_actions(form_view, hidden_ids=hidden_ids)

if picking_type_code == "incoming":

hidden_xml_ids = [

"stock.stock_reception_report_action",

]

hidden_ids = self._get_action_ids(hidden_xml_ids)

form_view = res["views"].get("form")

self._filter_toolbar_actions(form_view, hidden_ids=hidden_ids)


return res


아바타
취소
베스트 답변

Hi,

Try the following module.

https://apps.odoo.com/apps/modules/19.0/hide_all_print_button

Hope it helps


아바타
취소
작성자 베스트 답변

I want to hide the Print button in the toolbar. I've tried several times, but the Print button still doesn't go away. Is there any other way to do it?

아바타
취소

You need to customize as per your needs in below file:
-> action_menu.js
static defaultProps = {
printDropdownTitle: _t("Print"),
onActionExecuted: () => {},
shouldExecuteAction: () => true,
loadExtraPrintItems: () => [],
};
->action_menu.xml
Template name: <t t-name="web.ActionMenus">

Also you can check this free app by Cybrosys: https://apps.odoo.com/apps/modules/19.0/hide_all_print_button
Hope it is helpful for you.

베스트 답변

Hello,

You can use domain in the XML code of report action like below:
<field name="domain" eval=[(custom condition based on picking_type_code)]"/>

아바타
취소
관련 게시물 답글 화면 활동
2
8월 25
873
1
5월 25
1894
2
4월 25
2915
0
1월 25
1533
1
12월 24
2417