Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
23849 Widoki

In order to change the state of a record from draft to confirm depending on its own given date... in model after importing datetime, date:

date = fields.Date('Date', default=lambda * a: time.strftime('%Y-%m-%d'))
state = fields.Selection([('draft', 'Draft'), ('confirm', 'Confirm')], readonly=True, default='draft')

method:

@api.multi
def confirm_record(self):
current_date = str(datetime.now().date())
self.search(['date', '==', current_date]).write({'state': 'confirm'}):
return True
     

this metod is call by an automated action (ir.cron) and log file says:

ValueError: Invalid leaf date.

Odoo 10

Awatar
Odrzuć

Is it necesary to format current_date string?

Najlepsza odpowiedź

Hi 

The syntax of search method is wrong.

change this line

self.search([('date', '=', current_date)]).write({'state': 'confirm'})
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
wrz 19
13208
2
lip 25
4669
3
cze 25
948
2
gru 24
7794
2
lis 24
28572