Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2552 Vistas

Trying to figure out where to change the setting for Order Deadline date to be 48 hours from requesting/creating date.

Is there a place to change this for every request, or change for a speific product/vendor category? Rather than changing it record by record....


Thank you

Avatar
Descartar
Mejor respuesta

Hi Chrisy,

You can pass your default date field value in default_get method, as below:

from odoo.fields import Datetime
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'

@api.model
def default_get(self, fields):
res = super(PurchaseOrder, self).default_get(fields)
today = Datetime.today()
res.update({
'date_order': today + datetime.timedelta(hours=48),
})
return res

For more info refer:Default Get Function in Odoo || Set Default Values Using Default Get Function

Hope this will help you

Thank you

Avatar
Descartar
Autor

Yes, thank you for that code, I was hoping if there would be a place in setting that staff (none coding) could just utilise it when required, but thank you for providing the solution.

Otherwise you can create a configuration, for example define a field in the purchase settings for setting the number of days or hours needed to be add along with date order and later passing that value in to the default_get method
You can also refer this blog: https://www.cybrosys.com/blog/set-default-values-to-fields-odoo-13

Autor

Thanks Mehjabin, we will consider both options, but neither is as simple as we have hoped, it can always be done via stuido or coding, but we just hoped it would be a built-in function. Thanks for your help :)

Publicaciones relacionadas Respuestas Vistas Actividad
2
may 25
2069
3
dic 24
6051
1
jul 24
2900
1
jun 24
2049
2
jun 24
2866