Skip to Content
Menu
This question has been flagged
1 Reply
2549 Views

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
Discard
Best Answer

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
Discard
Author

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

Author

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

Related Posts Replies Views Activity
2
May 25
2063
3
Dec 24
6043
1
Jul 24
2892
1
Jun 24
2043
2
Jun 24
2854