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

Python expression in Automated Actions

By
Carlos DuAl
on 5/20/16, 7:18 AM 529 views

Hello, 

I'm trying to define a new automated action in odoo through the odoo interface, but I can't get the python expression to work.

I want to update a datetime field in my crm.claim module, that I have defined in my code as

date': fields.datetime('Claim Date', select = True) 

So I create an automated action, and in server actions to run, I create a new action like this

Base Model: claim

Action to do: Write on record

Update the Current Record

Value MappingFieldEvaluation TypeValue
Claim DatePython Expressiontime.today()

 However, I get

ValueError: "'module' object has no attribute 'today'" while evaluating
u'time.today()'

I've tried importing the time module too, but I get the same error. Even a print "test" doesn't work.

What's the correct way of writing a Python Expression using odoo's interface?

Thank you

0

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2983
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 5/20/16, 8:27 AM

Hello,

You can do:

 object.write({'x_mytime': datetime.datetime.today()})

But what is your use case ? 

Because fyi, you have the 'magic' field write_date that is already updated on each write !

 

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/20/16, 7:18 AM
Seen: 529 times
Last updated: 5/20/16, 8:28 AM