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

Lines Functional values how to shows before saving the record

By
Prakash
on 8/13/13, 11:56 AM 3,373 views

Openerp 7 based on this requirement Sale order lines Remaining days Calculate Start Date minus Today at all times. Functional Field and on_change function used:-

def _remaining_days(self, cr, uid, ids, field_name, arg, context=None):
            res = {}
            if not ids:
                return {}
            for val in self.browse(cr, uid, ids, context=context):
                result = datetime.datetime.strptime(val.start_date, '%Y-%m-%d') - datetime.datetime.strptime(current_date, '%Y-%m-%d')
                res[val.id] = result.days
            return res

    'remaining_days': fields.function(_remaining_days, method=True, string='Remaining days', type='integer'),


    def onchange_holddays(self, cr, uid, ids, start_date, context=None):
        result = {}  
        context = context or {}
        if release_date:
            current_date = time.strftime('%Y-%m-%d')
            remaining = datetime.datetime.strptime(release_date, '%Y-%m-%d') - datetime.datetime.strptime(current_date, '%Y-%m-%d')
            result['remaining_days'] = remaining.days                
        return {'value': result}

In order lines Remaining days Values not updated automatically. once save the main sale order record then only lines Remaining days value updated. How to shows the remaining days values in list view before saving the record.

Functional field will have value only after you save the record.

Sudhir Arya (SA)
on 8/17/13, 4:44 AM

Using on_change functional field output values able to shows in form view. But in tree view on_change field output values not shown in function field?..

Prakash
on 8/17/13, 5:01 AM

Based on the requirement "Remaining days Calculate Start Date minus Today at all times" is it possible to any other way to shows remaining days in lines before saving the record. Because our client to see the output before saving the record.

Prakash
on 8/17/13, 5:52 AM
0

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 8/17/13, 5:51 AM

Make your field float type and then return the calculated value from on_change.

Thanks for reply but in our case remaining days [Float data type] Daily need to update automatically based on [Start Date - Today]. After changing Functional field into Float field the daily auto calculation will not work based on this situation how to apply the auto calculation?

Prakash
on 8/17/13, 6:02 AM

I think based on Sever action and Schedule action use but in that case also have problem reaming days non editable field [readonly=True]. In readonly field output not shown please guide me the right direction to solve this issue. Thanks

Prakash
on 8/17/13, 6:41 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/13/13, 11:56 AM
Seen: 3373 times
Last updated: 10/13/15, 9:23 AM