Skip to Content
Menu
This question has been flagged
3 Replies
37591 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.

Avatar
Discard
Best Answer

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" />
Avatar
Discard
Author

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]

Author

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]

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

Author

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

Best Answer

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

Avatar
Discard
Author

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

Author

I would like to bring up the buttons.

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

Author Best Answer

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>
Avatar
Discard
Author

IT'S OK ! :) very thanks

Author

But my buttons do not appear :(

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

Author

How to reference "ir.ui.view"?

my skype : dhifi.borni

Related Posts Replies Views Activity
6
Jun 18
12839
2
Jun 17
8819
1
Dec 15
6443
1
Feb 23
11571
0
Dec 15
5975