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 set default value from function for fields Date in V8? [SOLVED]

By
yopi
on 5/4/15, 1:10 AM 785 views

Hello,

How to set default value from function for fields Date in V8?


Thank You

1

zbik

--zbik--
5976
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 5/4/15, 5:32 AM

For example:

@api.model
def _default_date(self):
  inv_type = self._context.get('type', 'out_invoice')
  if inv_type == 'out_invoice':
     current_date = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
     return current_date
date_invoice = fields.Date(string='Invoice Date',readonly=True, states={'draft': [('readonly', False)]}, index=True, help="Keep empty to use the current date", copy=False, default=_default_date)    

0
yopi
On 5/4/15, 6:25 AM

yes, it's works

Thanks zbik

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: 5/4/15, 1:10 AM
Seen: 785 times
Last updated: 5/12/15, 6:34 AM