Odoo Help


confirming multiple sales order on Tree View

on 8/5/13, 12:16 PM 4,215 views

Hi All,

I migrated some sales order from another system (more than 100) and I want to confirm all the sales order on OpenERP. I have to do this often because they are validated in batches

OpenERP 6.1 on windows

class sale_order_inherit(osv.osv):
 _inherit = "sale.order"
    def action_button_confirm(self, cr, uid, ids, context=None):
       wf_service = netsvc.LocalService('workflow')

       return self.write(cr, uid, ids, {'state': 'done'})        


the xml is

    <record id="action_sale_order_confirm_sales" model="ir.actions.server">
        <field name="name">Confirm Orders</field>
        <field name="type">ir.actions.server</field>
        <field name="model_id" ref="model_sale_order"/>
        <field name="state">code</field>
        <field name="code">obj.action_button_confirm(context=context)</field>
    <record id="id_action_sale_order_confirm_sales" model="ir.values">
        <field name="name">Confirm Orders</field>
        <field name="action_id" ref="action_sale_order_confirm_sales"/>
        <field name="value" eval="'ir.actions.server,' + str(ref('action_sale_order_confirm_sales'))"/>
        <field name="key">action</field>
        <field name="model_id" ref="model_sale_order"/>
        <field name="model">sale.order</field>
        <field name="key2">client_action_multi</field>


The code above sets the sales order to Done but I need the order to be picked as well because it is left at zero and I can't raise invoices for the orders, need to set the picking to 100% under "PICKED" so that I can invoice the sales order. thank you



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

Techno Functional Consultant Odoo(OpenERP) 


Skype : dhifi.borni

On 8/20/13, 5:42 AM


use the funtion action_button_confirm in sale.py:

class sale_order_inherit(osv.osv):
    _inherit = "sale.order"
    def my_action_button_confirm(self, cr, uid, ids, context=None):
            self.action_button_confirm(cr, uid, ids, context=context)       

Thanks for responding. Please, should I use directly and with my existing xml posted above? Any suggestions please because your code does not work

on 8/20/13, 5:52 AM
On 8/19/13, 10:19 AM
class sale_order_confirm(osv.osv):
_name = 'sale.order.confirm'

def sale_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)
    order = pooler.get_pool(cr.dbname).get('sale.order').browse(cr, uid, record_id, context=context)

    if not order.order_line:
        raise osv.except_osv(_('Error'),_("Cannot confirm order without order line"))

    wf_service.trg_validate(uid, 'sale.order', ids, 'order_confirm', cr)
    view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_tree')
    view_id = view_ref and view_ref[1] or False,

    return True


the xml am using is: <openerp>


    <record id="view_sale_confirm_order" model="ir.ui.view">
        <field name="name">Confirm Order</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="sale_confirm" string="Confirm Sale" type="object" icon="terp-gtk-go-back-rtl"/>

    <record id="action_sale_order_confirm_sales" model="ir.actions.act_window">
        <field name="name">Confirm Order</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">sale.order</field>
        <field name="view_type">tree</field>
        <field name="view_mode">form</field>
        <field name="view_id" ref="view_sale_confirm_order"/>
        <field name="target">new</field>
        <field name="multi">True</field>
    <record model="ir.values" id="sale_order_confirm_sales">
        <field name="model_id" ref="sale.model_sale_order" />
        <field name="name">Confirm Order</field>
        <field name="key2">client_action_multi</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>


I get this error message

2013-08-19 13:17:19,243 3912 ERROR ? openerp.sql_db: bad query: insert into "sale_order" (id,"shop_id","user_id","name","partner_shipping_id","picking_policy","order_policy","partner_order_id","state","invoice_quantity","partner_invoice_id","shipped","date_order",create_uid,create_date) values (204550,1,1,E'SO30053',NULL,E'direct',E'picking',NULL,E'draft',E'order',NULL,E'False',E'2013-08-19',1,(now() at time zone 'UTC')) Traceback (most recent call last): File "C:\Program Files (x86)\OpenERP 6.1-1\server.\openerp\sql_db.py", line 212, in execute IntegrityError: null value in column "partner_id" violates not-null constraint

2013-08-19 13:17:19,246 3912 ERROR db_150813 openerp.netsvc: 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: partner_id - partner.id] I don't know why it is returning null values for partner_id please help thank you all

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 8/5/13, 12:16 PM
Seen: 4215 times
Last updated: 3/16/15, 8:10 AM