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

IntegrityError: null value in column "partner_id" violates not-null constraint

so
By
kaynis
on 8/19/13, 12:26 PM 2,893 views

Help with my code I don't know where i seem to be going wrong. Thank you in advance

class sale_order_confirm(osv.osv):
_name = 'sale.order.confirm'
_inherit = "sale.order"


def my_action_button_confirm(self, cr, uid, ids, context=None):
    wf_service = netsvc.LocalService('workflow')
    if context is None:
        context = {}

  #  record_id = context and context.get('ids', False)
    pool_obj = pooler.get_pool(cr.dbname)
    order = pool_obj.get('sale.order').read(cr, uid, ids, ['state'], context=context)
    for o in order:
        if not o.order_line:
            raise osv.except_osv(_('Error'),_("Cannot confirm order without order line"))
        wf_service.trg_validate(uid, 'sale.order', o.id, 'order_confirm', cr)

   #        view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
   #        view_id = view_ref and view_ref[1] or False,

    return {'type': 'ir.actions.act_window_close'}

   sale_order_confirm()

   <openerp>
       <data>
    <record id="view_sale_confirm_order" model="ir.ui.view">
        <field name="name">sale.order.confirm.form1</field>
        <field name="model">sale.order.confirm</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Confirm Sale Orders">
                <separator colspan="4" string="Do you really want to confirm order(s) ?" />
                <separator string="" colspan="6"/>
                <button special="cancel" string="Cancel" icon="gtk-cancel"/>
                <button name="my_action_button_confirm" string="Confirm SO" icon="gtk-execute" type="object"/>
           </form>
        </field>
    </record>        

    <act_window id="action_sale_order_confirm_sales"
        multi="True"
        key2="client_action_multi" name="Confirm SO"
        res_model="sale.order.confirm" src_model="sale.order"
        view_mode="form" target="new" view_type="form" />

    <record model="ir.values" id="sale_order_confirm_sales">
        <field name="model_id" ref="sale.model_sale_order" />
        <field name="name">Confirm SO</field>
        <field name="value" eval="'ir.actions.act_window,' + str(ref('action_sale_order_confirm_sales'))"/>
        <field name="key">action</field>
        <field name="model">sale.order</field>
    </record>

</data>

</openerp>

help please and thank you in advance log message is

2013-08-20 15:30:14,575 7100 INFO ? werkzeug: 127.0.0.1 - - [20/Aug/2013 15:30:14] "POST /web/action/load HTTP/1.1" 200 -
2013-08-20 15:30:14,851 7100 INFO ? werkzeug: 127.0.0.1 - - [20/Aug/2013 15:30:14] "POST /web/view/load HTTP/1.1" 200 -
2013-08-20 15:30:15,608 7100 INFO ? werkzeug: 127.0.0.1 - - [20/Aug/2013 15:30:15] "POST /web/dataset/create HTTP/1.1" 200 -
2013-08-20 15:30:15,742 7100 INFO ? werkzeug: 127.0.0.1 - - [20/Aug/2013 15:30:15] "POST /web/dataset/get HTTP/1.1" 200 -
2013-08-20 15:30:15,946 7100 INFO ? werkzeug: 127.0.0.1 - - [20/Aug/2013 15:30:15] "POST /web/dataset/call_button HTTP/1.1" 200 -
2013-08-20 15:30:15,966 7100 INFO ? werkzeug: 127.0.0.1 - - [20/Aug/2013 15:30:15] "POST /web/session/eval_domain_and_context HTTP/1.1" 200 -
2013-08-20 15:30:16,188 7100 INFO ? werkzeug: 127.0.0.1 - - [20/Aug/2013 15:30:16] "POST /web/dataset/search_read HTTP/1.1" 200 -
0
Xsias
On 8/19/13, 12:41 PM

Ok, i will try something :

 class sale_order(osv.osv):
    _inherit = "sale.order"

    def my_action_button_confirm(self, cr, uid, ids, context=None):
        wf_service = netsvc.LocalService('workflow')
        if context is None:
            context = {}
        print "ids",ids
        order = self.read(cr,uid,ids,['state'])
        print "order",order
        for o in order:
            print "o",o
            if not o.order_line:
                raise osv.except_osv(_('Error'),_("Cannot confirm order without order line"))
            wf_service.trg_validate(uid, 'sale.order', o.id, 'order_confirm', cr)

    return {'type': 'ir.actions.act_window_close'}
sale_order()

<openerp>
    <data>
         <record id="view_sale_confirm_order" model="ir.ui.view">
             <field name="name">sale.order.confirm.form1</field>
             <field name="model">sale.order</field>
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Confirm Sale Orders">
                     <separator colspan="4" string="Do you really want to confirm order(s) ?" />
                     <separator string="" colspan="6"/>
                     <button special="cancel" string="Cancel" icon="gtk-cancel"/>
                     <button name="my_action_button_confirm" string="Confirm SO" icon="gtk-execute" type="object"/>
                </form>
             </field>
         </record>        

        <act_window id="action_sale_order_confirm_sales"
            multi="True"
            key2="client_action_multi" name="Confirm SO"
            res_model="sale.order" view_mode="form"
            src_model="sale.order" view_type="form"/>

        <record model="ir.values" id="sale_order_confirm_sales">
            <field name="model_id" ref="sale.model_sale_order" />
            <field name="name">Confirm SO</field>
            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_sale_order_confirm_sales'))"/>
            <field name="key">action</field>
            <field name="model">sale.order</field>
        </record>
    </data>
</openerp>

Please can you post the log now ?

thanks for your response. I was trying to create a confirm button for multiple Sales order in tree view. the error comes up when i click the confirm button.

kaynis
on 8/19/13, 12:53 PM

Multiple Sales order in tree view ? What's exactly going on ? In which view are you ? What would you doing with you button ?

Xsias
on 8/20/13, 7:02 AM

I guess you want to select multiple sales orders in the tree view in purpose to validate them in one click ?

Xsias
on 8/20/13, 7:04 AM

I have imported some sales order into openerp from access about 100 of them and I want to confrm them all without doing it one at a time. So i want to create a button that allows me to confirm one or many sales order at once from tree view. this orders are old but needed them for tracability of past sales. Yes i want to validate many selected SOs in one click. Thank you so much

kaynis
on 8/20/13, 7:07 AM

Yes is the answer to your last question.

kaynis
on 8/20/13, 7:15 AM

This is an operation you should repeat often ? Because if it's no, maybe a script is more indicate (or more ugly : edit directly in db with a sql script). Anyway, your mandatories fields in each sale order are well filled ?

Xsias
on 8/20/13, 7:39 AM

Yes the is an operation that will be repeated many times because SO are validated in batches therefore will need this function. I have tried but i keep getting error not sure if my xml or python code is letting me down. Will be glad if you can help.

kaynis
on 8/20/13, 7:42 AM

Yes they are all filled. Like i said they are old sales that i imported into the system

kaynis
on 8/20/13, 7:58 AM

I've edited my answer.

Xsias
on 8/20/13, 10:14 AM

Thanks will do those and get back to you.

kaynis
on 8/20/13, 11:28 AM

I have made changes to the code above but i am still not getting anything. The application loads but does nothing

kaynis
on 8/20/13, 12:31 PM

I made the changes but nothing is still happening can you please check if my xml is correct as well. Thank so very much for your help, merci beaucoup

kaynis
on 8/21/13, 6:37 AM

Yes i know, my new edit don't change anything but normally it prints some values on the logs. And this should help for debugging. I take a look on the xml.

Xsias
on 8/21/13, 7:12 AM

Your new edit does not work the confirm so button did not show up on Sales Order I added src_model="sale.order" to bring it to Sales order. Now is shows but when I click it tries to create a new quote.

kaynis
on 8/21/13, 7:24 AM

And now ?

Xsias
on 8/21/13, 9:12 AM

It tries to create a new sales order/quote

kaynis
on 8/21/13, 9:53 AM

Ok, i have no more ideas. Sorry. Can you keeping me in touch if you find, please.

Xsias
on 8/23/13, 10:16 AM

Ok, thanks for your time

kaynis
on 8/23/13, 10:57 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: 8/19/13, 12:26 PM
Seen: 2893 times
Last updated: 3/16/15, 8:10 AM