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.

1

How to auto calculate and update quantity field when modify other field

By
Steven Foong
on 2/24/13, 2:30 PM 2,151 views

I manage to add in two more field into order line. When user click to change these fields, I need the system to auto calculate base on these two fields and update the quantity field. I am new to javascript, not able to get it work. Thank a lot.

All I know is the following code will update the field whenever user click on the numpad. But I am not manage to tweak it.

setValue: function(val) {
            /*
            var param = {};
            param[this.numpadState.get('mode')] = val;
            var order = this.shop.get('selectedOrder');
            if (order.get('orderLines').length !== 0) {
               order.selected.set(param);

            } else {
                this.shop.get('selectedOrder').destroy();
            }
        },
1

Vasiliy Birukov

--Vasiliy Birukov--
3446
| 6 6 8
Russian Federation
--Vasiliy Birukov--

Help develop and implement any project on base Odoo.

Vasiliy Birukov
On 2/27/13, 12:43 AM

Better to use framework builtin event - onchange. Define onchange function in object(like in account):

def onchange_journal_id(self, cr, uid, ids, journal_id, context=None): company_id = False if journal_id: journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context) if journal.company_id.id: company_id = journal.company_id.id return {'value': {'company_id': company_id}}

And define call of function in form view XML definition:

<field name="journal_id" domain="[('type', '=', 'bank')]" on_change="onchange_journal_id(journal_id)" widget="selection"/>

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

0 follower(s)

Stats

Asked: 2/24/13, 2:30 PM
Seen: 2151 times
Last updated: 3/16/15, 8:10 AM