Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
7373 มุมมอง

I want a popup when a user is saving for example a product. I tried to override the write method but it didn't work. So I'm returning a new action but it gets ignored. Any ideas on this ? 

write:

def write(self, vals):
res = super(ProductTemplate, self).write(vals)
if vals:
# call popup window action:
view_item = [(self.env.ref('versioning.versioning_text_wizard_view').id, 'form')]
view = self.env.ref('versioning.versioning_text_wizard_view')
return {
'name': 'Versioning Text',
'view_type': 'form',
'view_mode': 'form',
'view_id': view.id,
'res_model': 'product.template',
'views': view_item,
'type': 'ir.actions.act_window',
'target': 'new',
}
return res

Thank you

อวตาร
ละทิ้ง
ผู้เขียน

no information about this? any other solutions?

You can not add two return method for same method

คำตอบที่ดีที่สุด

Odoo framework does not allow to return any action/wizard from ORM methods like create/write/search, etc.

You will have to change your requirement and look for other ways to open a popup wizard like from the button.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi, you can follow following link for this:

https://youtu.be/oMnHpHH54QU

Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

why not you can raise the wizard using the exception RedirectWarning.


from odoo.exceptions import RedirectWarning

@api.model
def create(self, vals):
res = super().create(vals)
 wizrd_action_id = self.env.ref('stock_move_location.wiz_stock_quant_location_action')
msg = "Are You sure! "
raise RedirectWarning(msg, wizrd_action_id.id, _('Go to the wizard'),
{'active_id': self._origin.id,})
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ม.ค. 25
1124
1
มี.ค. 15
5422
0
มี.ค. 15
3787
0
ก.ค. 25
240
0
พ.ค. 24
1009