Odoo v12
On "create" method i just save records in self.order_line_copy, then in the method "_onchange_order_line"
i want to call wizard if self.order_line_copy not set, but i can't.
Can you explain what the problem might be?
@api.model
def create(self, vals):
ids = None
res = super(VerificationPurchaseOrder, self).create(vals)
if 'order_line' in vals.keys():
for value in vals['order_line']:
ids = value[2]
if ids:
records = self.env['purchase.order.line'].browse(ids)
if records:
self.order_line_copy = records
for record in records:
try:
if 'check_status' in vals.keys():
if int(record.check_status) < int(vals['check_status']):
record.check_status = vals['check_status']
except ValueError:
_logger.info('Create method error: Cannot implicitly convert type \'string\' to \'int\'')
return res
@api.onchange('order_line')
def _onchange_order_line(self):
if not self.order_line_copy:
form_view = self.env.ref('verification_purchase_order.user_error_wizard_form_view')
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'user.error.wizard',
'views': [
(form_view.id, 'form'),
],
'type': 'ir.actions.act_window',
'target': 'new',
'context': {
'default_error_message': "Message.",
},
}
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Hi, Try with this.. I hope it might help you.
view = self.env.ref('verification_purchase_order.user_error_wizard_form_view')
wiz = self.env['user.error.wizard'].create({'purchase_order_id':order.id})
return {
'name': _('Error Wizard'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'user.error.wizard',
'views': [(view.id, 'form')],
'view_id': view.id,
'target': 'new',
'res_id': wiz.id,
'context': self.env.context,
}
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Apr 24
|
1798 | ||
|
0
Dec 19
|
4503 | ||
|
5
Dec 19
|
3581 | ||
|
0
Aug 19
|
4 | ||
|
5
Aug 19
|
2655 |