Skip to content

Instantly share code, notes, and snippets.

View ofelix03's full-sized avatar

Felix Otoo ofelix03

View GitHub Profile
def action_add_bank(self):
return {
'name': 'Add New Bank',
'type': 'ir.actions.act_window',
'res_model': 'kyc.customer.bank',
'view_type': 'form',
'view_mode': 'form',
'view_id': form_view.id,
'res_id': self.id,
'target': 'new',
def action_add_bank(self):
action = self.env.ref("kyc.add_bank_action").read()[0]
action['target'] = 'new'
action['context'] = {
'default_bank_reference': self.bank_reference
}
return action
select u.*, last_visited
from users u,
lateral(
select concat(date, ' ', time) "last_visited" from site_visits
where user_id = u.id
order by id desc
limit 1
) last_visited
where u.email = 'myuryichev2@guardian.co.uk'
select *, (
select concat(date, ' ', time) "last_visited" from site_visits
where user_id = u.id
order by id desc
limit 1
) "last_visited"
from users u
name email ip_addresses
Cyb Tratton ctratton0@blogtalkradio.com 144.229.128.12
Phillie Godfray pgodfray5@bravesites.com 42.37.250.26
Ringo Bras rbras7@salon.com 27.78.199.6
Chrissy Daniells cdaniells8@cmu.edu
Molly Domek mdomek9@creativecommons.org
Jaynell Jertz jjertze@amazonaws.com 78.184.170.180
Nannie Ewell newellf@soundcloud.com
Earlie Duffin eduffing@skyrock.com 168.13.188.42
Letta Folger lfolgeri@illinois.edu 70.43.100.92
SELECT name, email, s.ip_addresses
FROM users u
LEFT JOIN LATERAL (
SELECT user_id, string_agg(ip_address, ',') "ip_addresses"
FROM site_visits
WHERE country in ('China')
and user_id = u.id
GROUP BY user_id
) s
ON u.id = s.user_id
SELECT name, email, s.ip_addresses
FROM users u
LEFT JOIN (
SELECT user_id, string_agg(ip_address, ',') "ip_addresses"
FROM site_visits
WHERE country in ('China')
and user_id = u.id
GROUP BY user_id
) s
ON u.id = s.user_id
def pay_bill(bill_type, meter_number, amount):
# we'll put the logic for how to process bill payment
# this could include validation rules, and service calls to complete pyment
pass
# 1st call
median1 = find_median([40, 57, 12])
print(f"median1 = {median1}")
# 2nd call
median2 = find_median([3, 13, 7, 5, 21, 23, 39, 23, 40, 23, 14, 12, 56, 23, 29])
print(f"median1 = {median2}")
# 3rd call
median3 = find_median([3, 13, 7, 5, 21, 23, 23, 40, 23, 14, 12, 56, 23, 29])
@ofelix03
ofelix03 / function-example-written-in-python.py
Last active February 4, 2022 09:15
Example of a function written in Python
import math
def find_median(numbers=[]):
"""
Implementation details
Algorithm:
1. Reorder numbers in ascending order
2. Determine if the count of the numbers is even or odd
3. If odd, divide by 2 and round up the result. Look up the median using your result as the lookup index. Skip step 4