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

my field


state = fields.Selection(string="Status", selection=[('draft', 'Draft'), ('confirm', 'Confirm'),
('validate', 'Validated'), ('refuse', 'Refuse'),('reset','Reset to Draft'),('cancel','Cancel'),
('approved', 'Approved'), ], default="draft", track_visibility='onchange', )



My view 

button name="confirm_request" string="Confirm" class="oe_highlight" states="draft" type="object"/>
<button name="validate_request" string="Validate" class="oe_highlight" states="confirm" type="object" groups="hr.group_hr_user"/>
<button name="approve_request" string="Approve" class="oe_highlight" states="validate" type="object" groups="hr.group_hr_manager"/>
<button name="refuse_request" string="Refuse" states="confirm,validate" type="object" groups="hr.group_hr_user,hr.group_hr_manager"/>
<button name="%(launch_customer_wizard)d" type="action" state="validate"
string="Cancel" class="oe_highlight"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate"/>
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

It's a two steps manipulation, you create the button in the view as you did for refurse,confirm and validate, then you create a function with the same name as the button's name. here's the simplest way to do it:

@api.multi
def action_draft(self):
self.write({'state': 'draft'})

<button name="action_draft" string="return to draft" states="confirm,validate" type="object"groups="hr.group_hr_user,hr.group_hr_manager"/>
Ảnh đại diện
Huỷ bỏ
Tác giả

ok, I see . Thank you very much

Câu trả lời hay nhất

Hello

add new button "Reset to Draft" with type object. and call the method which set the State to "Draft".

for more information you can see into Sale order or Accounting Invoice part.


Ảnh đại diện
Huỷ bỏ