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.

0

problem with wizard (purchase_confirm) [Closed]

By
vgze
on 6/27/13, 6:39 AM 2,064 views

The Question has been closed

by
Sudhir Arya (SA)
on 06/28/2013 07:40:08

I have so problem with a module that I try to install (purchase_confirm). In fact, I modify it, because he was written in the old style wizard. The installation work but when I launch the action he does nothing. Any idea?

wizard/po_confirm.py:

class confirm_po(osv.osv_memory):
    _name = "purchase.order.confirm.all"

    def _makePo(self, cr, uid, data, context):
        wf_service = netsvc.LocalService("workflow")
        for id in data['ids']:
            wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_confirm', cr)
            wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_approve', cr)
        return {}
    states = {
        'init' : {
            'actions' : [_makePo],
            'result' : {
                'type' : 'state',
                'state' : 'end'
            }
        },
    }
confirm_po()

purchase_confirm_wizard.xml:

<?xml version="1.0" ?>
<openerp>
    <data>

        <wizard
            string="Confirm Selected Purchase Orders"
            model="purchase.order"
            name="purchase.order.confirm.all"
            keyword="client_action_multi"
            multi="True"
            id="wizard_po_confirm"/>

    </data>
</openerp>

__openerp__.py:

{
    "name" : "Confirm all selected purchase order at once",
    "version" : "1.0",
    "author" : "Tiny",
    "category" : "Generic Modules/Sales & Purchases",
    "description": """Add a wizard on PO to confirm a whole list at once.""",
    "depends" : ["purchase"],
    "init_xml" : [],
    "demo_xml" : [],
    "update_xml" : ["purchase_confirm_wizard.xml"],
    "active": True,
    "installable": True,
}
3

Keyur

--Keyur--
1165
| 4 4 8
Ahmedabad, India
--Keyur--

Odoo Expert

Keyur
On 6/27/13, 7:00 AM

Hi Gosselin,

I think you have not implemented wizard properly. Are you trying to convert old wizard into new wizard?

If you want to keep your wizard in old style you need to do some changes,

Instead of

class confirm_po(osv.osv_memory):

You need to do like this

class confirm_po(wizard.interface):

And also need to add some form view & fields.

My suggestion is better to convert wizard.interface(old) in osv.osv_memory(new) wizard.

Check out the difference between osv memory wizard & interface wizard here.

Thanks.

So firstable, it's not my module it's a module that I find on v6apps. I took the trunk version but the installation doesn't working. I try to convert and I have succesfully installed it. But it doesn't work. More precision: the choice appear but the action is not launched.

vgze
on 6/27/13, 7:15 AM

The wizard you have specified won't work because it is not proper. Have a look at interface wizard and osv_memory wizard

Keyur
on 6/27/13, 7:22 AM
0
vgze
On 6/28/13, 6:49 AM

I did it, the wizard works but the function doesn't work.

TypeError: list indices must be integers, not str

wizard/purchase_order_confirm.py:

from openerp.osv import fields, osv
import netsvc
import pooler

class purchase_order_confirm(osv.osv_memory):
    _name = "purchase.order.confirm"

    def makePo(self, cr, uid, data, context):
        wf_service = netsvc.LocalService("workflow")
        for id in data['ids']:
            wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_confirm', cr)
            wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_approve', cr)
        return {}
purchase_order_confirm()

wizard/purchase_order_confirm_view.xml:

<?xml version="1.0" ?>
<openerp>
    <data>

        <record id="purchase_order_confirm_view" model="ir.ui.view">
            <field name="name">purchase.order.confirm.form</field>
            <field name="model">purchase.order.confirm</field>
            <field name="arch" type="xml">
                <form string="Confirm Draft Purchases" version="7.0">
                    <p class="oe_grey">
                        Once draft invoices are confirmed, you will not be able
                        to modify them. The invoices will receive a unique
                        number and journal items will be created in your chart
                        of accounts.
                    </p>
                    <footer>
                        <button string="Confirm Purchases" name="makePo" type="object" default_focus="1" class="oe_highlight"/>
                        or
                        <button string="Cancel" class="oe_link" special="cancel"/>
                    </footer>
                </form>
            </field>
        </record>

        <act_window id="action_purchase_order_confirm"
            context="{'search_default_draft': 1, 'search_default_approved': False}"
            multi="True"
            key2="client_action_multi" name="Confirm Draft Purchases"
            res_model="purchase.order.confirm" src_model="purchase.order"
            view_mode="form" target="new" view_type="form" view_id="purchase_order_confirm_view"/>  

    </data>
</openerp>

__openerp__.py:

{
    "name" : "Confirm all selected purchase order at once",
    "version" : "1.0",
    "author" : "Tiny",
    "category" : "Generic Modules/Sales & Purchases",
    "description": """Add a wizard on PO to confirm a whole list at once.""",
    "depends" : ["purchase"],
    'data': [
        'wizard/purchase_order_confirm_view.xml',
    ],
    "init_xml" : [],
    "demo_xml" : [],
    "active": True,
    "installable": True,
}

Hi Gosselin, I feel your method a bit confusing. The fourth parameter you have taken is data. There will come list of ids or id. In the case of wizard there will be a list of id. So you are trying to fetch data['ids'] which is not correct. So it will not work. Try with this def makePo(self, cr, uid, ids, context):. That will definitely work.

Keyur
on 6/30/13, 2:46 AM

About This Community

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

Question tools

2 follower(s)

Stats

Asked: 6/27/13, 6:39 AM
Seen: 2064 times
Last updated: 3/16/15, 8:10 AM