This question has been flagged
2 Replies
9653 Views

Hello, I try ti add a sale state to sale order but I can not do it.

Here is my models.py : 

from odoo import fields, models, api
class SaleOrder(models.Model):
_inherit = 'sale.order'
state = fields.Selection(selection_add([('FichierOk', 'Fichier Ok')])
@api.multi
def action_fichierOk(self):
self.state = 'fichierOk'

Then My Xml : 

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Inherit the sale order model's form view and customize -->
<record id="view_order_form_flexink" model="ir.ui.view">
<field name="name">sale.order.form.flexink</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="priority">1000</field>
<field name="arch" type="xml">
<!-- Statusbar widget with the new status -->
<xpath expr="//field[@name='state']" position="replace">
<field name="state" widget="statusbar" statusbar_visible="draft,fichierOk,sent,invoiced,done" statusbar_colors='{"invoice_except":"red","waiting_date":"blue"}'/>
</xpath>
<!-- Add New Button -->
<xpath expr="/form/header/button[@name='print_quotation']" position="after">
<button name="action_fichierOk" states="draft" string="FichierOk" class="oe_highlight" type="object"/>
</xpath>
</field>
</record>
</data>
  </odoo>

I can see my new Button but I don't see the Satus 'FichierOk' in status bar and the button give me an error :

AttributeError: type object 'sale.order' has no attribute 'action_fichierOk'

Can you help me ?

Avatar
Discard
Author Best Answer

Hello,

Thanks for your response.

In fact my code was good.

I just missed to restart odoo server.

Avatar
Discard
Best Answer

Hi,

In your manifest file, have you add a dependency for sale module?

Try with this:

 
state = fields.Selection(selection_add=[('fichierok', 'Fichier Ok')])

<field name="state" position="attributes">
    <attribute name="statusbar_visible">draft,fichierok,sent,invoiced,done</attribute>
</field>

I hope this will help you.

Areli.

Avatar
Discard