Skip to content

Instantly share code, notes, and snippets.

@umiphos
umiphos / nullification_of_an_invoice.py
Last active April 22, 2019 21:58
Forced cancellation of an invoice in odoo via server action
for rec in records:
move_id = rec.move_id
# move_id.line_ids.remove_move_reconcile()
update_posted_state = rec.journal_id.update_posted
rec.journal_id.write({'update_posted': True})
# move_id.button_cancel()
# This action will delete any move_id that we have
rec.action_cancel()
rec.write({'state': 'cancel'})
@umiphos
umiphos / WSDL_bad_zeep_error.py
Created March 2, 2019 22:46
This is a current error we have when we consult the SUNAT service without propper logging, the error replicates if we try to consume the WSDL without WSSE
from zeep import Client, Settings
from zeep.plugins import HistoryPlugin
from zeep.wsse.username import UsernameToken
settings = Settings(strict=False, xml_huge_tree=True)
history = HistoryPlugin()
client = Client(wsdl='https://e-factura.sunat.gob.pe/ol-ti-itcpfegem/billService?wsdl',
wsse=UsernameToken('MODDATOS','MODDATOS'), settings=settings, plugins=[history])
@umiphos
umiphos / delete_all_invoice_related.py
Last active February 22, 2019 15:47
From a set of id_galaxy, delete all about that invoice
@umiphos
umiphos / delete_all_invoice_related.py
Created February 22, 2019 15:26
From a set of id_galaxy, delete all about that invoice
@umiphos
umiphos / fix_bad_account.py
Created February 21, 2019 06:00
This gist will fix fix the account_id from a bad placed account in a move.
right_journal = env.ref('absa.account_journal_B2353')
bad_account = env.ref('absa.account_account_102_01_016')
for rec in records:
move_id = rec.mapped('move_id')
move_id.button_cancel()
for line in move_id.line_ids:
if line.journal_id == right_journal and line.account_id == bad_account:
line.write({'account_id':
right_journal.default_debit_account_id.id})
move_id.action_post()
@umiphos
umiphos / gist:d146d6b0596f13cba766e01e014c8309
Created October 22, 2018 23:57 — forked from mattkatz/gist:65bbc17dbad94c97a01a472734b65d50
Using the Workday API with Python and the suds client library
import sys
from suds import client
from suds.wsse import Security, UsernameToken
from suds.sax.text import Raw
from suds.sudsobject import asdict
from suds import WebFault
'''
Given a Workday Employee_ID, returns the last name of that employee.
@umiphos
umiphos / pgk_installed_os-sys.py
Last active July 3, 2018 20:24
Check if a pgk is installed
"""If installed it will return 0"""
os.system('which your app')
@umiphos
umiphos / .vimrc
Created June 27, 2018 21:39 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
@umiphos
umiphos / lxml_item_delete.py
Created June 27, 2018 15:11
Deleting an XML element
"""We want to remove //content item, this is one way to do it."""
from lxml.etree import tostring
from lxml.objectify import fromstring
xml = '
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getStatusCdrResponse xmlns:ns2="http://service.sunat.gob.pe">
<statusCdr>