add requests for party
This commit is contained in:
parent
a774127df1
commit
be4acbd796
|
@ -8,6 +8,7 @@ from . import party
|
|||
from . import invoice
|
||||
from . import api_log
|
||||
from . import product
|
||||
from . import voucher
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -27,6 +28,7 @@ def register():
|
|||
product.Section,
|
||||
product.Conservation,
|
||||
product.Template,
|
||||
voucher.Voucher,
|
||||
module='laboratory', type_='model')
|
||||
Pool.register(
|
||||
service_order.CreateInvoice,
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
from trytond.pool import PoolMeta
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
HEADERS = {
|
||||
'Accept': 'application/json',
|
||||
'Content-type': 'application/json',
|
||||
'Autorization': 'Basic c2llc2E6c2llc2EkOThANjcxV3A5MQ=='
|
||||
}
|
||||
|
||||
|
||||
class Voucher(metaclass=PoolMeta):
|
||||
__name__ = 'account.voucher'
|
||||
|
||||
@classmethod
|
||||
def process(cls, records):
|
||||
super(Voucher, cls).process(records)
|
||||
for voucher in records:
|
||||
if voucher.voucher_type == 'receipt':
|
||||
is_person = True
|
||||
if voucher.party.type_document == '31':
|
||||
is_person = False
|
||||
params = {
|
||||
'is_person': is_person,
|
||||
'id_number': voucher.party.id_number,
|
||||
'total_credit': voucher.party.receivable,
|
||||
}
|
||||
request = json.dumps(params)
|
||||
uri = 'http://wee.pasteurlab.com/cupoempresa'
|
||||
requests.post(uri, headers=HEADERS, data=request)
|
Loading…
Reference in New Issue