This is my script but it don't function (AttributeError: 'purchase.order' object has no attribute 'req_aut')
import time import datetime
from openerp.osv import fields, osv from openerp.tools.translate import _
class Purchase(osv.osv): '''Purchase'''
_name = "purchase.order"
_inherit = 'purchase.order'
#def create(self, cr, uid, ids, context=None):
#TODO:Definire i gruppi e mandare mail
# mail_message = self.pool.get('mail.message')
# mail_message.schedule_with_attach(cr, uid, 'api@ipi.it','ati@gmail.com',"aaaaaa","asdd",subtype='html',)i
#notification_obj.create(cr, uid, {'user_id': uid, 'message_id': msg_id}, context=context)
#return True
def set_req_aut(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'state' : 'req_aut' }, context=context)
return True
def set_aut_conf(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'state' : 'aut_conf' })
return True
STATE_SELECTION = [ ('draft', 'Draft PO'), ('sent', 'RFQ Sent'), ('confirmed', 'Waiting Approval'), ('req_aut', 'Request Authorization'), ('aut_conf', 'Authorization Confirmed'), ('approved', 'Purchase Order'), ('except_picking', 'Shipping Exception'), ('except_invoice', 'Invoice Exception'), ('done', 'Done'), ('cancel', 'Cancelled') ]
_columns = {
'project_ids': fields.many2one('project.project', string='Project refs'),
'state': fields.selection(STATE_SELECTION, 'Status', readonly=True, help="The status of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' status. Then the order has to be confirmed by the user, the status switch to 'Confirmed'. Then the supplier must confirm the order to change the status to 'Approved'. When the purchase order is paid and received, the status becomes 'Done'. If a cancel action occurs in the invoice or in the reception of goods, the status becomes in exception.", select=True),
}
Purchase()
<openerp> <data>
<record model="ir.ui.view" id="edit_order_form">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/header/button[@name='purchase_confirm']" position="before">
<button name="req_aut" states="sent" string="Request Authorization" type="object"/>
<button name="aut_conf" states="req_aut" string="Authorization Confirmed" type="object"/>
</xpath>
<xpath expr="/form/header/field[@name='state']" position="replace">
<field name="state" widget="statusbar" statusbar_visible="draft, sent, req_aut, aut_conf, approved, done" statusbar_colors='{"except_picking":"red","except_invoice":"red","confirmed":"blue"}' readonly="1"/>
</xpath>
<xpath expr="/form/sheet/group/group/field[@name='partner_ref']" position="after">
<field name="project_ids" />
</xpath>
</field>
</record>
</data>
</openerp>