Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to remove 'provision' from selection list when configuring Cash Flow Codes in OpenERP(Odoo)?

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 196
    Comment on it

    In below example, I have written Python script to remove 'provision' from selection list when configuring Cash Flow Codes. Use below python code in your .py file :

    def fields_get(self, cr, uid, fields=None, context=None):
     res = super(account_cashflow_code, self).fields_get(cr, uid, fields, context)
    if context.get('manage_cfc') and res.get('type'):
                res['type']['selection'].remove(('provision', u'Provision'))
            # rename date fields
            format_date = self.format_date
            if context.has_key('date_start'):
                date_start = datetime.strptime(context.get('date_start'), '%Y-%m-%d').date()            
                nbr_days = int(context.get('nbr_days'))
                days = [format_date(cr, uid, date_start, context)] + [format_date(cr, uid, date_start + timedelta(days=x), context) for x in range(1, nbr_days)]        
                for x in range(1, nbr_days + 1):
                    if x < 10:
                        field = 'balance_day0' + str(x)
                    else:
                        field = 'balance_day' + str(x)
                    if res.get(field, None):
                        res[field]['string'] = days[x-1]
            return res
    
        def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
            res = super(account_cashflow_code, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
            if context.has_key('nbr_days') and view_type=='tree':
                view_obj = etree.XML(res['arch'])
                nbr_days = int(context.get('nbr_days'))        
                for el in view_obj:
                    if 'balance_day' in el.get('name'):
                        day = int(el.get('name')[11:])
                        if day > nbr_days:
                            el.getparent().remove(el)               
                    res['arch'] = etree.tostring(view_obj)        
            return res
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: