Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2550 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
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 :)

Related Posts Odpovědi Zobrazení Aktivita
2
kvě 25
2063
3
pro 24
6045
1
čvc 24
2893
1
čvn 24
2045
2
čvn 24
2859