Skip to Content
Menu
This question has been flagged
1 Reply
12372 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?


Avatar
Discard

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.

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?

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

Best Answer

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.

Avatar
Discard
Related Posts Replies Views Activity
1
Apr 19
3355
0
Mar 15
203
3
Mar 15
6396
3
Sep 24
10008
2
Feb 24
610