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
select schemaname as table_schema, | |
relname as table_name, | |
pg_size_pretty(pg_total_relation_size(relid)) as total_size, | |
pg_size_pretty(pg_relation_size(relid)) as data_size, | |
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) | |
as external_size | |
from pg_catalog.pg_statio_user_tables | |
order by pg_total_relation_size(relid) desc, | |
pg_relation_size(relid) desc | |
limit 10; |
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
#!/usr/bin/env lua | |
conky_color = "${color1}%2d${color}" | |
t = os.date('*t', os.time()) | |
year, month, currentday = t.year, t.month, t.day | |
daystart = os.date("*t",os.time{year=year,month=month,day=01}).wday | |
month_name = os.date("%B") |
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
# This is just a cheat sheet: | |
# On production | |
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz | |
# On local | |
scp -C production:~/database.sql.gz | |
dropdb database && createdb database | |
gunzip < database.sql.gz | psql database |
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
<record id="action_view_link_mo_to_task" model="ir.actions.act_window"> | |
<field name="name">Link MO to Task</field> | |
<field name="type">ir.actions.act_window</field> | |
<field name="res_model">link.mo.to.task</field> | |
<field name="view_mode">form</field> | |
<field name="target">new</field> | |
<field name="binding_model_id" ref="mrp.model_mrp_production"/> | |
<field name="binding_view_types">list</field> | |
</record> |
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
atts = self.env['ir.attachment'].search([('res_model', '=', 'syscoon.financeinterface'), | |
('type', '=', 'binary'), | |
('res_id', '=', export_id)]) | |
for at in atts: | |
# order lines by date asc. just revert CSV file data rows. | |
data = base64.decodebytes(at.datas).decode("latin") | |
stream = StringIO(data) | |
dialect = csv.Sniffer().sniff(data[:5000]) | |
data_list = list(csv.reader(stream, dialect=dialect)) | |
file_path = "/var/tmp/" + at.name |
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
import PyPDF2 | |
to_rotate_path = '/var/tmp/to_rotate.pdf' | |
fh = open(to_rotate_path, "wb") | |
fh.write(base64.decodebytes(att.datas)) | |
fh.close() | |
rotated_path = self.rotate_pdf(to_rotate_path) | |
def rotate_pdf(self, path): | |
pdf_in = open(path, 'rb') |
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
from pdf2image import convert_from_path, convert_from_bytes | |
from io import BytesIO | |
image = convert_from_bytes(base64.decodebytes(att.datas))[0].rotate(90, expand=True) | |
buffered = BytesIO() | |
image.save(buffered, format="JPEG") | |
img_str = base64.b64encode(buffered.getvalue()) |
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
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - | |
echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/prod bionic main" | sudo tee /etc/apt/sources.list.d/mssql-release.list | |
sudo apt update | |
sudo apt install msodbcsql17 | |
import pyodbc | |
import pandas as pd | |
cnxn = pyodbc.connect("Driver={/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.7.so.2.1};" |
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
notification = { | |
'type': 'ir.actions.client', | |
'tag': 'display_notification', | |
'params': { | |
'title': ('Your Custom Title'), | |
'message': 'Your Custom Message', | |
'type':'success', #types: success,warning,danger,info | |
'sticky': True, #True/False will display for few seconds if false | |
}, | |
} |
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
<templates id="template" xml:space="preserve"> | |
<!-- main_menu is a template in module stock_barcode --> | |
<t t-extend="main_menu"> | |
<t t-jquery=".message_demo_barcodes" t-operation="append"> | |
And barcode <a href="/mrp_workorder/static/src/pdf/barcodes_actions_Manufacturing.pdf" target="_blank" aria-label="Download" title="Download">commands for Manufacturing</a>. | |
</t> | |
</t> | |
</templates> |
NewerOlder