Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How i can add a new state to PO?

mirko lazzarini
on 9/27/13, 12:04 PM 1,030 views

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



<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 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 expr="/form/sheet/group/group/field[@name='partner_ref']" position="after">
                 <field name="project_ids" />


joseph d'souza
On 9/28/13, 3:56 AM

Remove this things in your inherited class

 _name = "purchase.order"

Add purchase in custom module __openerp__.py file

'depends': ['purchase'],

Restart your OpenERP serevr and update or install your custom module in your database.

Hope it works !!




AJ Schrafel Paper Corp

--AJ Schrafel Paper Corp--
| 4 5 8
Bronx, United States
--AJ Schrafel Paper Corp--

Exploring OpenERP for business

AJ Schrafel Paper Corp
On 9/27/13, 2:20 PM

did you stop/ start your server?

did you make your module depend on purchase?

try these two things and see if that fixes it.

yes it depend on purchase... but don't function

mirko lazzarini
on 9/27/13, 3:14 PM

did you completely stop/ start your server? Stop the server then type ps aux | grep openerp or look at your process list in windows to make sure you have stopped all instances of the server.

AJ Schrafel Paper Corp
on 9/27/13, 6:39 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


Asked: 9/27/13, 12:04 PM
Seen: 1030 times
Last updated: 3/16/15, 8:10 AM