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 in Odoo

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 242
    Comment on it

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

    1. def fields_get(self, cr, uid, fields=None, context=None):
    2. res = super(account_cashflow_code, self).fields_get(cr, uid, fields, context)
    3. if context.get('manage_cfc') and res.get('type'):
    4. res['type']['selection'].remove(('provision', u'Provision'))
    5. # rename date fields
    6. format_date = self.format_date
    7. if context.has_key('date_start'):
    8. date_start = datetime.strptime(context.get('date_start'), '%Y-%m-%d').date()
    9. nbr_days = int(context.get('nbr_days'))
    10. 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)]
    11. for x in range(1, nbr_days + 1):
    12. if x < 10:
    13. field = 'balance_day0' + str(x)
    14. else:
    15. field = 'balance_day' + str(x)
    16. if res.get(field, None):
    17. res[field]['string'] = days[x-1]
    18. return res
    19.  
    20. def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
    21. 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)
    22. if context.has_key('nbr_days') and view_type=='tree':
    23. view_obj = etree.XML(res['arch'])
    24. nbr_days = int(context.get('nbr_days'))
    25. for el in view_obj:
    26. if 'balance-day' in el.get('name'):
    27. day = int(el.get('name')[11:])
    28. if day > nbr_days:
    29. el.getparent().remove(el)
    30. res['arch'] = etree.tostring(view_obj)
    31. return res

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: