Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
6233 Vistas

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>

Avatar
Descartar
Mejor respuesta

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 !!

Thanks,

dsouzajoseph199@gmail.com

Avatar
Descartar
Mejor respuesta

did you stop/ start your server?

did you make your module depend on purchase?

try these two things and see if that fixes it.

Avatar
Descartar
Autor

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

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.

Publicaciones relacionadas Respuestas Vistas Actividad
3
jul 18
3897
0
ene 22
2756
1
jul 15
3814
0
mar 15
5149
3
dic 22
4604