Last active
April 27, 2024 18:16
-
-
Save ray-odoo/06c93cec1e5fd3b154620b486234b16a to your computer and use it in GitHub Desktop.
Update Customer Lead Time based on longest Vendor Delivery Time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# custom_ray_odoo | |
# loop through all selected product(s) | |
for record in records: | |
# set lead time to default 3 days | |
lead_time = 3 | |
found_vendor = False | |
# loop through all the vendor(s) on the purchase tab | |
for vendor_price_line in record.seller_ids: | |
if vendor_price_line.delay > lead_time: | |
lead_time = vendor_price_line.delay | |
found_vendor = vendor_price_line.partner_id.name | |
# update the record | |
record.update({ | |
'sale_delay': lead_time | |
}) | |
if found_vendor: | |
# notify via chatter | |
body='Customer Lead Time updated to %s days based on %s' % (lead_time, found_vendor) | |
record.message_post(body=body) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment