Skip to Content
Menu
This question has been flagged
1 Reply
1591 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
3
Dec 24
2363
1
Jul 24
705
1
Jun 24
774
2
Jun 24
897
1
Mar 24
537