I try to add a state x_approve_quotation in sale.order statusBar but it doesn't work.
class complement_sale_order(osv.osv):
_inherit = 'sale.order'
_defaults = {
'x_num_devis' : lambda obj, cr, uid, context: '/',
'x_num_commande' : lambda obj, cr, uid, context: '/',
}
_columns = {
'x_num_devis' : fields.char('Numéro Devis', size=15),
'x_num_commande' : fields.char('Numéro de commande', size=15),
'state': fields.selection([
('draft', 'Draft Quotation'),
('sent', 'Quotation Sent'),
('x_approve_quotation', 'Demander approbation'),
('cancel', 'Cancelled'),
('waiting_date', 'Waiting Schedule'),
('progress', 'Sales Order'),
('manual', 'Sale to Invoice'),
('invoice_except', 'Invoice Exception'),
('done', 'Done'),
], 'Status', readonly=True, track_visibility='onchange',
help="Gives the status of the quotation or sales order. \nThe exception status is automatically set when a cancel operation occurs in the processing of a document linked to the sales order. \nThe 'Waiting Schedule' status is set when the invoice is confirmed but waiting for the scheduler to run on the order date.", select=True),
}
complement_view.xml
<openerp>
<data>
<!-- Inherit the sale order model's form view and customize -->
<record id="x_sale_form_view" model="ir.ui.view">
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<!-- Statusbar widget should also contain the new status -->
<field name="state" position="replace">
<field name="state" widget="statusbar" statusbar_visible="draft,sent,x_approve_quotation,invoiced,done" statusbar_colors='{"invoice_except":"red","waiting_date":"blue"}'/>
</field>
<!-- Add button and condition -->
<button name="print_quotation" position="after">
<button name="test_mdel" type="object" string="Demande d'approbation" states="draft,sent" />
</button>
<button name="action_button_confirm" position="attributes">
<attribute name="states">x_approve_quotation</attribute> <!-- Précise quand le bouton cofirm pourra apparaitre -->
</button>
<button name="cancel" position="attributes">
<attribute name="states">draft,sent,x_approve_quotation</attribute>
</button>
<!-- Add field sequence -->
<field name="client_order_ref" position="after">
<field name="x_num_devis" readonly="1"/>
<field name="x_num_commande" readonly="1"/>
</field>
</field>
</record>
help please