Odoo Help

Welcome!

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.

1

AttributeError: 'NoneType' object has no attribute '_name'

By
Victorien
on 6/12/13, 6:46 AM 8,376 views

Hello,

I am a French student. I want test mymod, for workflow.

But I have this error :

AttributeError: 'NoneType' object has no attribute '_name'

mymod.py

# -*- coding: utf-8 -*-
from osv import fields, osv

def mymod_new(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'new' })
     return True

def mymod_assigned(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'assigned' })
     return True

def mymod_negotiation(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'negotiation' })
     return True

def mymod_won(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'won' })
     return True

def mymod_lost(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'lost' })
     return True

class mymod(osv.osv):
    _name = "mymod.mymod"
    _description = "mymod"
    _columns = { 
    'name' : fields.char("names",),
    'state': fields.selection([
    ('new','New'),
    ('assigned','Assigned'),
    ('negotiation','Negotiation'),
    ('won','Won'),
    ('lost','Lost')], 'Stage', readonly=True),
    }

mymod_workflow.xml

 <?xml version="1.0" encoding="utf-8"?>
    <openerp>
        <data>
            <record model="workflow" id="wkf_mymod">
                <field name="name">mymod.wkf</field>
                <field name="osv">mymod.mymod</field>
                <field name="on_create">True</field>
            </record>
            <record model="workflow.activity" id="act_new">
                <field name="wkf_id" ref="wkf_mymod" />
                <field name="flow_start">True</field>
                <field name="name">new</field>
                <field name="kind">function</field>
                <field name="action">mymod_new()</field>
            </record>

            <record model="workflow.activity" id="act_assigned">
                <field name="wkf_id" ref="wkf_mymod" />
                <field name="name">assigned</field>
                <field name="kind">function</field>
                <field name="action">mymod_assigned()</field>
            </record>

            <record model="workflow.activity" id="act_negotiation">
                <field name="wkf_id" ref="wkf_mymod" />
                <field name="name">negotiation</field>
                <field name="kind">function</field>
                <field name="action">mymod_negotiation()</field>
            </record>

            <record model="workflow.activity" id="act_won">
                <field name="wkf_id" ref="wkf_mymod" />
                <field name="name">won</field>
                <field name="kind">function</field>
                <field name="action">mymod_won()</field>
                <field name="flow_stop">True</field>
            </record>

            <record model="workflow.activity" id="act_lost">
                <field name="wkf_id" ref="wkf_mymod" />
                <field name="name">lost</field>
                <field name="kind">function</field>
                <field name="action">mymod_lost()</field>
                <field name="flow_stop">True</field>
            </record>
            <record model="workflow.transition" id="t1">
                <field name="act_from" ref="act_new" />
                <field name="act_to" ref="act_assigned" />
                <field name="signal">mymod_assigned</field>
            </record>

            <record model="workflow.transition" id="t2">
                <field name="act_from" ref="act_assigned" />
                <field name="act_to" ref="act_negotiation" />
                <field name="signal">mymod_negotiation</field>
            </record>

            <record model="workflow.transition" id="t3">
                <field name="act_from" ref="act_negotiation" />
                <field name="act_to" ref="act_won" />
                <field name="signal">mymod_won</field>
            </record>

            <record model="workflow.transition" id="t4">
                <field name="act_from" ref="act_negotiation" />
                <field name="act_to" ref="act_lost" />
                <field name="signal">mymod_lost</field>
            </record>
        </data>
    </openerp>

mymod_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="mymod_form" model="ir.ui.view">
            <field name="name">mymod.form</field>
            I think ERROR IT'S HERE :
                    <field name="model">mymod.mymod</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="nom_form">
                <separator string="Workflow Actions" colspan="4"/>
                <group colspan="4" col="3">
                    <button name="mymod_assigned" string="Assigned" states="new" />
                    <button name="mymod_negotiation" string="In Negotiation" states="assigned" />
                    <button name="mymod_won" string="Won" states="negotiating" />
                    <button name="mymod_lost" string="Lost" states="negotiating" />
                </group>
                </form>
            </field>
        </record>
        <menuitem name="Menu_Work" icon="terp-project" id="dev_menu" />
        <menuitem name="Workflow" parent="dev_menu" id="dev_menu_person" />
        <menuitem name="Boutton" parent="dev_menu_person" id="view_partner_form" action="mymod_form" />
    </data>
</openerp>

Thanks for your help.

1

Borni DHIFI

--Borni DHIFI--
5102
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

Borni DHIFI
On 6/12/13, 7:19 AM

Hi, your problem it is in the line :

<menuitem name="Boutton" parent="dev_menu_person" id="view_partner_form" action="mymod_form" />

action="mymod_form" must reference in record of type ir.actions.act_window

so add this record :

   <record model="ir.actions.act_window" id="action_mymod_form">
        <field name="name">Workflow</field>
        <field name="res_model">mymod.mymod</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
    </record>   
  <menuitem name="Boutton" parent="dev_menu_person" id="view_partner_form" action="action_mymod_form" />

Thx for your help.

But I have this error : Integrity Error

The operation cannot be completed, probably due to the following: - deletion: you may be trying to delete a record while other records still reference it - creation/update: a mandatory field is not correctly set

[object with reference: res_model - res.model]

Victorien
on 6/12/13, 7:26 AM

In French : Erreur d'intégrité

L'opération n'a pas pu être terminée, probablement à la suite d'une : - suppression : vous avez essayer de supprimer un enregistrement auquel d'autres enregistrements font référence - création/modification : un champ requis n'a pas été correctement rempli

[objet ayant pour référence : res_model - res.model]

Victorien
on 6/12/13, 7:35 AM

test your module a new database . and see this subject http://help.openerp.com/question/16336/how-i-can-create-module-openerp-7/ . you can help you

Borni DHIFI
on 6/12/13, 7:37 AM

It's OK. But I have error : ValueError: No such external ID currently defined in the system: mymod.mymod_form

Victorien
on 6/12/13, 7:40 AM
3

Sandeep

--Sandeep--
6083
| 6 5 8
Delhi, India
--Sandeep--
Python OpenERP Developer http://in.linkedin.com/pub/sandeep-rana/3b/a16/786/
Sandeep
On 6/13/13, 3:40 AM

Hi

there is also a problem in you field declration for charater field we size is must so plz use

          'name' : fields.char("names",size=100),

other wise another error will be there

Thanks
Sandeep

Thanks, but if we size, I have this error : TypeError: VARCHAR parameter should be an int, got <type 'str'>

Victorien
on 6/13/13, 5:22 AM

I would like to bring up the buttons.

Victorien
on 6/13/13, 5:25 AM

size must be in integer like size=100 not size="100"

Sandeep
on 6/13/13, 9:13 AM
0
Victorien
On 6/12/13, 1:39 PM

Sorry I started on openerp, I just want to display the buttons but I do not know how.

mymod.py

# -*- coding: utf-8 -*- from osv import fields, osv



def mymod_new(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'new' })
     return True

def mymod_assigned(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'assigned' })
     return True

def mymod_negotiation(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'negotiation' })
     return True

def mymod_won(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'won' })
     return True

def mymod_lost(self, cr, uid, ids):
     self.write(cr, uid, ids, { 'state' : 'lost' })
     return True

class mymod(osv.osv):
    _name = "mymod.mymod"
    _description = "mymod"
    _columns = { 
    'state': fields.selection([
    ('new','New'),
    ('assigned','Assigned'),
    ('negotiation','Negotiation'),
    ('won','Won'),
    ('lost','Lost')], 'Stage', readonly=True),
    }
    _defaults = { 'state': 'new',}

mymod_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="mymod_tree">
        <field name="name">mymod.tree</field>
        <field name="model">mymod</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
        <separator string="Workflow Actions" colspan="4"/>
        <group colspan="1" col="1">
            <button name="mymod_assigned" string="Assigned" states="new" />
            <button name="mymod_negotiation" string="In Negotiation" states="assigned" />
            <button name="mymod_won" string="Won" states="negotiating" />
            <button name="mymod_lost" string="Lost" states="negotiating" />
        </group>
        </field>
        </record>

        <menuitem name="Menu_Work" icon="terp-project" id="dev_menu" />
        <menuitem name="Workflow" parent="dev_menu" id="dev_menu_person" />
        <menuitem name="Boutton" parent="dev_menu_person" id="view_partner_form" action="mymod_tree" />
    </data>
</openerp>

IT'S OK ! :) very thanks

Victorien
on 6/12/13, 1:46 PM

But my buttons do not appear :(

Victorien
on 6/12/13, 2:06 PM

many errors in your code. the record form should be type ir.ui.view and not ir.actions.act_window because menuitem name="Boutton" should be reference to record action and not record form.

in your model mymod add defualt state to display first button _defaults = { 'state':'new',}

and others...

Borni DHIFI
on 6/13/13, 6:14 AM

How to reference "ir.ui.view"?

Victorien
on 6/13/13, 6:46 AM

my skype : dhifi.borni

Borni DHIFI
on 6/13/13, 6:50 AM

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

1 follower(s)

Stats

Asked: 6/12/13, 6:46 AM
Seen: 8376 times
Last updated: 10/15/15, 7:01 AM