Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
7612 Lượt xem

Hallo All,

Is there any way to change field value from Wizard?

eg: I have model hr.employee:

            state = fields.Selection(selection=[('active','Active'), ('inactive','Inactive')])

I have transient model hr.employee.wizard:

            state = fields.Selection(selection=[('active','Active'), ('inactive','Inactive')])


The thing is, i need to change the state from Wizard(hr.employee.wizard) and it also change the state in hr.employee.
I use @api.onchange but it didn't work.


Please advise.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Try to do it using a button click, using the active_ids from the wizard model you can get the record id of the main model, using the browse get the corresponding record and you can update the record using the write operation.

If you install the CRM, you can see similar implementation in Mark as Lost button.


Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks Niyas,

I learn it and its work fine with the model hr.employee.

this time i want to change the state only from 'open' to 'done' in model hr.contract from wizard when the state in wizard is 'inactive'

I try this in my wizard:

contract = self.env['hr.contract'].browse(self.env.context.get('active_ids'))

if contract.state == 'open':

contract.write({'state': 'done'})

but it return an error = 'The record has been deleted hr.contract(id), user(id)

do we can make domain in browse get function?

or something else, please advice

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 12 22
5530
2
thg 2 23
4152
1
thg 1 21
5364
1
thg 12 19
2859
1
thg 8 24
2814