Odoo Help

0

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

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

Hello,

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


Thank You

1

Zbik

--Zbik--
6293
| 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

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 5/4/15, 1:10 AM
Seen: 1015 times
Last updated: 5/12/15, 6:34 AM