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

How to get value order line sales order before saving form?

By
Ajeng Shilvie
on 1/11/15, 11:42 PM 480 views

i want to insert approve boolean field in order_line sales order  . using this code :

class sales_order_line(osv.osv):
    _inherit = 'sale.order.line'
    _columns = {
                'approve' : fields.boolean('Approve')
                }

then, i want to insert approve all boolean field in header of sales order . it has a method to make all approve field in order line checked/true but it didn't work at all. how can i loop every order_line before i hit button create ? all i know that i can get order_line value if i already hit button save , is there any way?

class wtc_sales_order(osv.osv):
    _inherit = 'sale.order'
    _columns = {
                'approve_all' : fields.boolean('Approve all order line')
                }
    def _onchange_approve(self, cr, uid, ids, approve_all):
        x={}
        if approve_all:
             for rec in order_line :
                 x[rec.approve] = True
                    
         return {'value':x}

here xml code :

        <record model="ir.ui.view" id="wtc_sales_order_form_view">
            <field name="name">wtc_sales_order_form_view</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <field name="warehouse_id" position="after">
                    <field name="approve_all" on_change="_onchange_approve(approve_all)"/>
                </field>
                <field name="price_subtotal" position="after">
                    <field name="approve"></field>
                </field>        
                <field name="address_allotment_id" position="after">
                    <field name="approve"></field>
                </field>
            </field>
        </record>

 

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

2 follower(s)

Stats

Asked: 1/11/15, 11:42 PM
Seen: 480 times
Last updated: 3/16/15, 8:10 AM