Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
4233 Переглядів

Hello all, I need a little help here, so odoo has a default form view in the stock.picking model. where the form is used for outgoing, internal, and incoming type picking. so I've created several different views for those types, but there are some cases if I open the form via a many2one link it leads to the default form view, so how do I change the default form view. I've tried using the fields_view_get function but it doesn't work because it can't get the id from stock.picking. here's the fields_view_get function I've created in stock.picking model:

@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
    if view_type == 'form':
if self.picking_type_id.code == "outgoing":
view_id = self.env.ref('gg_warehouse.wh_os_outgoing_form').id
if self.picking_type_id.code == "incoming":
view_id = self.env.ref('gg_warehouse.wh_os_incoming_form').id
if self.picking_type_id.code == "internal":
view_id = self.env.ref('gg_warehouse.wh_os_transfer_form').id
return super(StockPickingInherit2, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)

Аватар
Відмінити
Автор

actually I've managed to open a new form from fields.Many2one using context {'form_view_ref': 'my_module.new_custom_form_view'}, but if the page is refreshed it will return to the default odoo view. so that's why i want to just replace the default view of odoo.

Найкраща відповідь

Hi Admaja,
You can change the Priority (Sequence) value of the view. Higher Priority Views will be shown first. Try with adding high Priority value into your views and check. 

But when you refresh, your Prioritised View will be shown, because now your view will be the High Priority.
Hope it will help you. 

Аватар
Відмінити
Найкраща відповідь

Hi Admaja,

inside fields view get function, you cannot access the field values in it, as a better and easy solution, can you keep single view and control the visibility of the fields according to picking type using attrs

Thank You

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
вер. 23
4525
1
черв. 22
3131
7
серп. 20
5137
6
трав. 19
6408
2
лип. 23
784