This commit is contained in:
hoangvv 2025-02-28 12:03:14 +07:00
parent ec733fcc15
commit 21637a5c25
2 changed files with 111 additions and 73 deletions

View File

@ -9,21 +9,21 @@ substitutions:
```{toctree} ```{toctree}
:titlesonly: true :titlesonly: true
payment-providers-wire-transfer payment_providers/wire_transfer
payment-providers-adyen payment_providers/adyen
payment-providers-amazon-payment-services payment_providers/amazon_payment_services
payment-providers-asiapay payment_providers/asiapay
payment-providers-authorize payment_providers/authorize
payment-providers-buckaroo payment_providers/buckaroo
payment-providers-demo payment_providers/demo
payment-providers-flutterwave payment_providers/flutterwave
payment-providers-mercado-pago payment_providers/mercado_pago
payment-providers-mollie payment_providers/mollie
payment-providers-paypal payment_providers/paypal
payment-providers-razorpay payment_providers/razorpay
payment-providers-stripe payment_providers/stripe
payment-providers-worldline payment_providers/worldline
payment-providers-xendit payment_providers/xendit
``` ```
Odoo embeds several **payment providers** that allow your customers to pay online, on their Odoo embeds several **payment providers** that allow your customers to pay online, on their
@ -469,4 +469,3 @@ payments from other payments.
- {doc}`../websites/ecommerce/checkout_payment_shipping/payments` - {doc}`../websites/ecommerce/checkout_payment_shipping/payments`
- {doc}`accounting/bank` - {doc}`accounting/bank`
::: :::

View File

@ -30,12 +30,12 @@ if not os.path.isfile(input_file):
changes_made = 0 changes_made = 0
# Process each line # Process each line
with open(input_file, 'r') as f: with open(input_file, "r") as f:
for line in f: for line in f:
# Split line by ':' and trim whitespace # Split line by ':' and trim whitespace
parts = [part.strip() for part in line.split(':', 4)] parts = [part.strip() for part in line.split(":", 4)]
if len(parts) < 5: if len(parts) < 5:
parts.extend([''] * (5 - len(parts))) # Ensure 5 parts parts.extend([""] * (5 - len(parts))) # Ensure 5 parts
file_path, line_err, status, desc, data = parts file_path, line_err, status, desc, data = parts
print(f"{GRAY}DEBUG: Processing line:{NC}") print(f"{GRAY}DEBUG: Processing line:{NC}")
@ -51,39 +51,44 @@ with open(input_file, 'r') as f:
if desc == "undefined label": if desc == "undefined label":
print(f"{GRAY}DEBUG: Found 'undefined label' case{NC}") print(f"{GRAY}DEBUG: Found 'undefined label' case{NC}")
# Check if data is enclosed in < and >
if re.match(r'^<.*>$', data):
# Remove < and > for processing
clean_data = re.sub(r'^<|>$', '', data)
# Replace \, /, or _ with - in clean_data
new_data = clean_data.replace('\\', '-').replace('/', '-').replace('_', '-')
print(f"{GRAY}DEBUG: Changing '{data}' to '<{new_data}>'{NC}")
# Remove < and > for processing
clean_data = f"<{data}>"
# Replace \, /, or _ with - in clean_data
new_data = (
clean_data.replace("\\", "-").replace("/", "-").replace("_", "-")
)
print(f"{GRAY}DEBUG: Changing '{data}' to '{new_data}'{NC}")
# Check if the data appears in an {image} directive # Check if the data appears in an {image} directive
with open(file_path, 'r') as file_content: with open(file_path, "r") as file_content:
lines = file_content.readlines() lines = file_content.readlines()
skip = False skip = False
for i, line_content in enumerate(lines): for i, line_content in enumerate(lines):
if data in line_content and i > 0 and '{image}' in lines[i-1]: if data in line_content and i > 0 and "{image}" in lines[i - 1]:
skip = True skip = True
break break
if skip: if skip:
print(f"{GRAY}DEBUG: Skipping '{data}' as it appears in an {{image}} directive{NC}") print(
f"{GRAY}DEBUG: Skipping '{data}' as it appears in an {{image}} directive{NC}"
)
else: else:
# Replace the old data with new data in the file # Replace the old data with new data in the file
try: try:
with fileinput.FileInput(file_path, inplace=True) as file: with fileinput.FileInput(file_path, inplace=True) as file:
for line_content in file: for line_content in file:
if '{image}' not in line_content: if "{image}" not in line_content:
line_content = line_content.replace(data, f"<{new_data}>") line_content = line_content.replace(
print(line_content, end='') f'<{data}>', f"{new_data}"
)
print(line_content, end="")
changes_made += 1 changes_made += 1
print(f"{GREEN}Processed: {file_path} - Changed '{data}' to '<{new_data}>'{NC}") print(
f"{GREEN}Processed: {file_path} - Changed '{data}' to '{new_data}'{NC}"
)
except Exception as e: except Exception as e:
print(f"{RED}WARNING: Failed to modify {file_path} - {str(e)}{NC}") print(
else: f"{RED}WARNING: Failed to modify {file_path} - {str(e)}{NC}"
print(f"{GRAY}DEBUG: Skipping '{data}' as it is not enclosed in <> {NC}") )
elif "toctree contains reference to nonexisting document" in desc: elif "toctree contains reference to nonexisting document" in desc:
print(f"{GRAY}DEBUG: Found 'toctree' case{NC}") print(f"{GRAY}DEBUG: Found 'toctree' case{NC}")
@ -92,73 +97,107 @@ with open(input_file, 'r') as f:
if doc_ref_match: if doc_ref_match:
doc_ref = doc_ref_match.group(1) doc_ref = doc_ref_match.group(1)
# Replace \, /, or _ with - in doc_ref # Replace \, /, or _ with - in doc_ref
new_data = doc_ref.replace('\\', '-').replace('/', '-').replace('_', '-') new_data = (
doc_ref.replace("\\", "-").replace("/", "-").replace("_", "-")
)
print(f"{GRAY}DEBUG: Changing '{doc_ref}' to '{new_data}'{NC}") print(f"{GRAY}DEBUG: Changing '{doc_ref}' to '{new_data}'{NC}")
# Check if the doc_ref appears in an {image} directive # Check if the doc_ref appears in an {image} directive
with open(file_path, 'r') as file_content: with open(file_path, "r") as file_content:
lines = file_content.readlines() lines = file_content.readlines()
skip = False skip = False
for i, line_content in enumerate(lines): for i, line_content in enumerate(lines):
if doc_ref in line_content and i > 0 and '{image}' in lines[i-1]: if (
doc_ref in line_content
and i > 0
and "{image}" in lines[i - 1]
):
skip = True skip = True
break break
if skip: if skip:
print(f"{GRAY}DEBUG: Skipping '{doc_ref}' as it appears in an {{image}} directive{NC}") print(
f"{GRAY}DEBUG: Skipping '{doc_ref}' as it appears in an {{image}} directive{NC}"
)
else: else:
# Replace the old data with new data in the file # Replace the old data with new data in the file
try: try:
with fileinput.FileInput(file_path, inplace=True) as file: with fileinput.FileInput(file_path, inplace=True) as file:
for line_content in file: for line_content in file:
if '{image}' not in line_content: if "{image}" not in line_content:
line_content = line_content.replace(doc_ref, new_data) line_content = line_content.replace(
print(line_content, end='') doc_ref, new_data
)
print(line_content, end="")
changes_made += 1 changes_made += 1
print(f"{GREEN}Processed: {file_path} - Changed '{doc_ref}' to '{new_data}'{NC}") print(
f"{GREEN}Processed: {file_path} - Changed '{doc_ref}' to '{new_data}'{NC}"
)
except Exception as e: except Exception as e:
print(f"{RED}WARNING: Failed to modify {file_path} - {str(e)}{NC}") print(
f"{RED}WARNING: Failed to modify {file_path} - {str(e)}{NC}"
)
else: else:
print(f"{RED}WARNING: Could not extract document reference from '{data}' in {file_path}{NC}") print(
f"{RED}WARNING: Could not extract document reference from '{data}' in {file_path}{NC}"
)
elif "card directive targets nonexisting document" in desc: elif "card directive targets nonexisting document" in desc:
print(f"{GRAY}DEBUG: Found 'card directive' case{NC}") print(f"{GRAY}DEBUG: Found 'card directive' case{NC}")
# Extract the document reference from desc (since data might be empty), remove .rst # Extract the document reference from desc (since data might be empty), remove .rst
doc_ref_match = re.search(r"'([^']*)'", desc) doc_ref_match = re.search(r"'([^']*)'", desc)
if doc_ref_match: if doc_ref_match:
doc_ref = doc_ref_match.group(1).replace('.rst', '') doc_ref = doc_ref_match.group(1).replace(".rst", "")
# Replace \, /, or _ with - in doc_ref # Replace \, /, or _ with - in doc_ref
new_data = doc_ref.replace('\\', '-').replace('/', '-').replace('_', '-') new_data = (
doc_ref.replace("\\", "-").replace("/", "-").replace("_", "-")
)
print(f"{GRAY}DEBUG: Changing '{doc_ref}' to '{new_data}'{NC}") print(f"{GRAY}DEBUG: Changing '{doc_ref}' to '{new_data}'{NC}")
# Check if the doc_ref appears in an {image} directive # Check if the doc_ref appears in an {image} directive
with open(file_path, 'r') as file_content: with open(file_path, "r") as file_content:
lines = file_content.readlines() lines = file_content.readlines()
skip = False skip = False
for i, line_content in enumerate(lines): for i, line_content in enumerate(lines):
if doc_ref in line_content and i > 0 and '{image}' in lines[i-1]: if (
doc_ref in line_content
and i > 0
and "{image}" in lines[i - 1]
):
skip = True skip = True
break break
if skip: if skip:
print(f"{GRAY}DEBUG: Skipping '{doc_ref}' as it appears in an {{image}} directive{NC}") print(
f"{GRAY}DEBUG: Skipping '{doc_ref}' as it appears in an {{image}} directive{NC}"
)
else: else:
# Replace the old data with new data in the file # Replace the old data with new data in the file
try: try:
with fileinput.FileInput(file_path, inplace=True) as file: with fileinput.FileInput(file_path, inplace=True) as file:
for line_content in file: for line_content in file:
if '{image}' not in line_content: if "{image}" not in line_content:
line_content = line_content.replace(doc_ref, new_data) line_content = line_content.replace(
print(line_content, end='') doc_ref, new_data
)
print(line_content, end="")
changes_made += 1 changes_made += 1
print(f"{GREEN}Processed: {file_path} - Changed '{doc_ref}' to '{new_data}'{NC}") print(
f"{GREEN}Processed: {file_path} - Changed '{doc_ref}' to '{new_data}'{NC}"
)
except Exception as e: except Exception as e:
print(f"{RED}WARNING: Failed to modify {file_path} - {str(e)}{NC}") print(
f"{RED}WARNING: Failed to modify {file_path} - {str(e)}{NC}"
)
else: else:
print(f"{RED}WARNING: Could not extract document reference from '{desc}' in {file_path}{NC}") print(
f"{RED}WARNING: Could not extract document reference from '{desc}' in {file_path}{NC}"
)
else: else:
print(f"{GRAY}DEBUG: Description '{desc}' doesn't match any conditions{NC}") print(
f"{GRAY}DEBUG: Description '{desc}' doesn't match any conditions{NC}"
)
else: else:
print(f"{RED}WARNING: File not found: {file_path}{NC}") print(f"{RED}WARNING: File not found: {file_path}{NC}")
print(f"{GRAY}DEBUG: ---{NC}") print(f"{GRAY}DEBUG: ---{NC}")