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

Make a field editable

By
Kevin
on 7/31/15, 5:57 AM 760 views

How do I make a field editable, for example on the Delivery Order there is a Date of Delivery field (date_done which is on object stock.picking.out) which is non editable on the delivery orders form and we would like to edit this field.

I can see the modifier on the form which is {"readonly".[["state","in",["cancel","done"]]]} which I assume needs to be changed somewhere?


Curious why you want to do this. The reason fields are read-only to users is so that Odoo can use them. This field gets set by Odoo, and on if you ever need to process a delivery and set the date back, you should be using 'Date of Transfer' on the Additional Information tab. You should know that your changes to this date field may not be preserved as Odoo may edit this field after you.

Bista Solutions US, Ray Carnes
on 7/31/15, 1:54 PM

Generally, I agree with you. But for our case I checked and found that the 'Date of Transfer' you mentioned is the 'date_done' Kevin cited above. This field is editable in all states except 'cancel' and 'done' states. This field has the attribute "required=False", and when the user didn't enter a date in this field the system fills it automatically with the system date. My opinion is that why don't give the user a chance to add the delivery date after the delivery in case he forgot to add it. What do you think?

Tarek Mohamed Ibrahim
on 7/31/15, 4:59 PM

Thanks for the message Ray,

 

The reason is that sometimes we’ll raise the invoice a few days before delivery is physically made so we would sometimes like to amend the date.

 

I could add another field to the object and use on the delivery note but thought it might be easier to edit the existing field?

 

Thanks and regards,

Kevin

 

From: Ray Carnes [mailto:rcarnes-ursainfosystems-com@mail.odoo.com]
Sent: 31 July 2015 18:54
To: Kevin Starkey <kevin@atg-equip.com>
Subject: Re: Make a field editable

 

Curious why you want to do this. The reason fields are read-only to users is so that Odoo can use them. This field gets set by Odoo, and on if you ever need to process a delivery and set the date back, you should be using 'Date of Transfer' on the Additional Information tab. You should know that your changes to this date field may not be preserved as Odoo may edit this field after you.

--
Ray Carnes
Sent by Odoo Inc. using Odoo about Forum Post Make a field editable

Kevin
on 8/2/15, 6:21 AM
1

Tarek Mohamed Ibrahim

--Tarek Mohamed Ibrahim--
896
| 5 3 7
Gîza, Egypt
--Tarek Mohamed Ibrahim--

I am an old VFP developer on ERP

I have moved to 2p since Nov-2014 and started developing with Python on Odoo.

https://www.linkedin.com/profile/public-profile-settings?trk=prof-edit-edit-public_profile

tibrahim@2p.com.sa

Tarek Mohamed Ibrahim
On 7/31/15, 9:10 AM

This field is originally defined in the class stock.picking. The delivery order is based on the class stock.picking.out which inherits from stock.picking

The field definition is :

'date_done': fields.datetime('Date of Transfer', help="Date of Completion", states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}), 

To make this field editable while the order is delivered, i.e. state is 'done', you have to remove the 'done' key from the states dictionary. I inherited the stock.picking class and overrode this field then nothing changed in the delivery order screen. I then inherited the stock.picking.out class and added to the _columns dictionary the following key:

'date_done': fields.datetime('Date of Transfer', help="Date of Completion", states={cancel':[('readonly',True)]}),

, restarted the server and upgraded my custom module which includes the inherited class and went to the delivery order screen and found that the field 'done_date' is editable.

I hope this replies your question.

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

1 follower(s)

Stats

Asked: 7/31/15, 5:57 AM
Seen: 760 times
Last updated: 8/2/15, 6:21 AM