Skip to content

Instantly share code, notes, and snippets.

@faniska
faniska / report_url.txt
Created July 27, 2023 17:04
Set report.url to avoid wkhtmltopdf error: Exit with code 1 due to network error: ConnectionRefusedError
# If odoo deployed in docker
# set the system parameter "report.url" as "http://localhost:8069"
@faniska
faniska / deep_suspend_mode_acer_laptop.sh
Created January 29, 2024 17:43
Enable deep suspend mode in Acer Aspire A514-56M
sudo nano /etc/default/grub
# Add "mem_sleep_default=deep" to GRUB_CMDLINE_LINUX_DEFAULT line
# Save file
sudo update-grub
sudo reboot
@faniska
faniska / try_to_unlink.py
Last active January 16, 2025 12:35
Try to delete multiple records in Odoo without interrupting
@faniska
faniska / record_merge_mixin.py
Created January 20, 2025 14:35
Odoo record merge mixin
from odoo import models
class RecordMergeMixin(models.AbstractModel):
_name = 'record.merge.mixin'
_description = 'Record Merge Mixin Abstract'
def get_referencing_fields(self, exclude_models=None):
domain = [
('relation', '=', self._name),
@faniska
faniska / python_install_certificates.sh
Created February 14, 2025 12:30
Mac OS - python install certificates
# This code line aims to fix the following error:
# urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
# Run Command. Here 3.11 actual Python version
/Applications/Python\ 3.11/Install\ Certificates.command
@faniska
faniska / psql_for_macos.sh
Created February 18, 2025 08:45
PSQL MacOS M4
#!/bin/bash
brew install libpq
echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
sudo ln -s $(brew --prefix)/opt/libpq/bin/psql /usr/local/bin/psql
@faniska
faniska / SERIALIZATION_FAILURE.py
Created March 10, 2025 14:16
Odoo - emulate SERIALIZATION_FAILURE
import threading
import time
def transaction_1():
env = self.env(context={'active_test': False})
with env.registry.cursor() as cr:
env1 = self.env(cr=cr)
lines = env1['account.bank.statement.line'].browse(st_lines.ids)
lines.write({'field_name': 'value'})
time.sleep(2) # Simulate delay to overlap with transaction_2