İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
2551 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

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

Üretici

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 :)

İlgili Gönderiler Cevaplar Görünümler Aktivite
2
May 25
2063
3
Ara 24
6045
1
Tem 24
2893
1
Haz 24
2045
2
Haz 24
2859