Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
5289 Visualizzazioni

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>
Avatar
Abbandona

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')

Risposta migliore

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
ago 20
5458
2
dic 19
3389
2
ott 22
6472
4
giu 20
5354
1
feb 18
9549