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

I am inheriting maintenance.request and adding four buttons on maintenance form. I only want to show one button at new request stage and all other three on the next stage. Any help would be appreciable.

XML:

<record model="ir.ui.view" id="maintenance_requests_inherit_view">
<field name="name">Maintenance Requests</field>
<field name="model">maintenance.request</field>
<field name="inherit_id" ref="maintenance.hr_equipment_request_view_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='archive_equipment_request']" position="after">
<button string="Repaired" class="oe_highlight" type="object" name="on_repaired"> </button>
</xpath>
<xpath expr="//button[@name='archive_equipment_request']" position="after">
<button string="Inspect" class="oe_highlight" type="object" name="on_inspect"> </button>
</xpath>
<xpath expr="//button[@name='archive_equipment_request']" position="after">
<button string="Material Requisition" class="oe_highlight" type="object" name="on_material_requisition"> </button>
</xpath>
<xpath expr="//button[@name='archive_equipment_request']" position="after">
<button string="Invoice" class="oe_highlight" type="object" name="generate_invoice"> </button>
</xpath>
Ảnh đại diện
Huỷ bỏ

states  attribute can't be used here because states are not declared in source maintenance model as a Selection field. 
maintenance_stage.py

class MaintenanceStage(models.Model):
""" Model for case stages. This models the main stages of a Maintenance Request management flow. """

_name = 'maintenance.stage'
_description = 'Maintenance Stage'
_order = 'sequence, id'

name = fields.Char('Name', required=True, translate=True)
sequence = fields.Integer('Sequence', default=20)
fold = fields.Boolean('Folded in Maintenance Pipe')
done = fields.Boolean('Request Done')

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

Hi,

Along with the button you can specify states, see this example, this cancel button will be visible only in the draft state as states="draft" is given.

<button name="action_cancel" string="Cancel" type="object" class="oe_highlight" states="draft"/>

You can apply same logic for your buttons too, give states="state1,state2" , so that the button will be visible only in this two states.

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 20
5508
2
thg 12 19
3416
2
thg 10 22
6511
4
thg 6 20
5424
1
thg 2 18
9565