[IMP] website_sale_payment_terms: keep default terms on order

1. Keep default payment terms on order at checkout
2. Do not set terms on order until user agrees to conditions
3. Make date context-aware for terms amount calculation
This commit is contained in:
Cedric Collins
2022-03-04 18:56:51 -06:00
parent cebc7757ab
commit 24721b0bd4
4 changed files with 62 additions and 70 deletions

View File

@@ -14,16 +14,12 @@ class WebsiteSalePaymentTerms(WebsiteSaleDelivery):
def shop_payment(self, **post):
order = request.website.sale_get_order()
payment_term_id = post.get('payment_term_id')
if order.amount_total > request.website.payment_deposit_threshold:
if payment_term_id:
payment_term_id = int(payment_term_id)
if order:
order._check_payment_term_quotation(payment_term_id)
if payment_term_id:
payment_term_id = int(payment_term_id)
if order:
order._check_payment_term_quotation(payment_term_id)
if payment_term_id:
return request.redirect("/shop/payment")
else:
order.payment_term_id = False
return request.redirect("/shop/payment")
return super(WebsiteSalePaymentTerms, self).shop_payment(**post)
# Main JS driven payment term updater.