Fix PEP8
This commit is contained in:
parent
980fc70c05
commit
e8b374d4b4
34
invoice.py
34
invoice.py
|
@ -368,13 +368,15 @@ class Invoice(metaclass=PoolMeta):
|
|||
invoice=self.rec_name))
|
||||
if not move_line.payment_type.facturae_type:
|
||||
raise UserError(gettext(
|
||||
'account_invoice_facturae.missing_payment_type_facturae_type',
|
||||
'account_invoice_facturae.'
|
||||
'missing_payment_type_facturae_type',
|
||||
payment_type=move_line.payment_type.rec_name,
|
||||
invoice=self.rec_name))
|
||||
if move_line.payment_type.facturae_type in ('02', '04'):
|
||||
if not hasattr(move_line, 'account_bank'):
|
||||
raise UserError(gettext(
|
||||
'account_invoice_facturae.missing_account_bank_module',
|
||||
'account_invoice_facturae.'
|
||||
'missing_account_bank_module',
|
||||
payment_type=move_line.payment_type.rec_name,
|
||||
invoice=self.rec_name))
|
||||
if not move_line.bank_account:
|
||||
|
@ -430,7 +432,6 @@ class Invoice(metaclass=PoolMeta):
|
|||
invoice=self.rec_name, message=e))
|
||||
return True
|
||||
|
||||
|
||||
def _sign_facturae(self, xml_string, certificate_password):
|
||||
"""
|
||||
Inspired by https://github.com/pedrobaeza/l10n-spain/blob/d01d049934db55130471e284012be7c860d987eb/l10n_es_facturae/wizard/create_facturae.py
|
||||
|
@ -506,7 +507,8 @@ class Invoice(metaclass=PoolMeta):
|
|||
ref = xmlsig.template.add_reference(
|
||||
sign, xmlsig.constants.TransformSha1, name=reference_id, uri=""
|
||||
)
|
||||
xmlsig.template.add_transform(ref, xmlsig.constants.TransformEnveloped)
|
||||
xmlsig.template.add_transform(ref,
|
||||
xmlsig.constants.TransformEnveloped)
|
||||
object_node = etree.SubElement(
|
||||
sign,
|
||||
etree.QName(xmlsig.constants.DSigNs, "Object"),
|
||||
|
@ -524,14 +526,16 @@ class Invoice(metaclass=PoolMeta):
|
|||
attrib={xmlsig.constants.ID_ATTR: signed_properties_id},
|
||||
)
|
||||
signed_signature_properties = etree.SubElement(
|
||||
signed_properties, etree.QName(etsi, "SignedSignatureProperties")
|
||||
signed_properties, etree.QName(etsi,
|
||||
"SignedSignatureProperties")
|
||||
)
|
||||
now = datetime.datetime.now()
|
||||
etree.SubElement(
|
||||
signed_signature_properties, etree.QName(etsi, "SigningTime")
|
||||
).text = now.isoformat()
|
||||
signing_certificate = etree.SubElement(
|
||||
signed_signature_properties, etree.QName(etsi, "SigningCertificate")
|
||||
signed_signature_properties, etree.QName(etsi,
|
||||
"SigningCertificate")
|
||||
)
|
||||
signing_certificate_cert = etree.SubElement(
|
||||
signing_certificate, etree.QName(etsi, "Cert")
|
||||
|
@ -547,17 +551,20 @@ class Invoice(metaclass=PoolMeta):
|
|||
|
||||
hash_cert = hashlib.sha1(crt)
|
||||
etree.SubElement(
|
||||
cert_digest, etree.QName(xmlsig.constants.DSigNs, "DigestValue")
|
||||
cert_digest, etree.QName(xmlsig.constants.DSigNs,
|
||||
"DigestValue")
|
||||
).text = base64.b64encode(hash_cert.digest())
|
||||
|
||||
issuer_serial = etree.SubElement(
|
||||
signing_certificate_cert, etree.QName(etsi, "IssuerSerial")
|
||||
)
|
||||
etree.SubElement(
|
||||
issuer_serial, etree.QName(xmlsig.constants.DSigNs, "X509IssuerName")
|
||||
issuer_serial, etree.QName(xmlsig.constants.DSigNs,
|
||||
"X509IssuerName")
|
||||
).text = xmlsig.utils.get_rdns_name(certificate.issuer.rdns)
|
||||
etree.SubElement(
|
||||
issuer_serial, etree.QName(xmlsig.constants.DSigNs, "X509SerialNumber")
|
||||
issuer_serial, etree.QName(xmlsig.constants.DSigNs,
|
||||
"X509SerialNumber")
|
||||
).text = str(certificate.serial_number)
|
||||
|
||||
signature_policy_identifier = etree.SubElement(
|
||||
|
@ -565,7 +572,8 @@ class Invoice(metaclass=PoolMeta):
|
|||
etree.QName(etsi, "SignaturePolicyIdentifier"),
|
||||
)
|
||||
signature_policy_id = etree.SubElement(
|
||||
signature_policy_identifier, etree.QName(etsi, "SignaturePolicyId")
|
||||
signature_policy_identifier, etree.QName(etsi,
|
||||
"SignaturePolicyId")
|
||||
)
|
||||
sig_policy_id = etree.SubElement(
|
||||
signature_policy_id, etree.QName(etsi, "SigPolicyId")
|
||||
|
@ -586,7 +594,8 @@ class Invoice(metaclass=PoolMeta):
|
|||
)
|
||||
hash_value = sig_policy_hash_value
|
||||
etree.SubElement(
|
||||
sig_policy_hash, etree.QName(xmlsig.constants.DSigNs, "DigestValue")
|
||||
sig_policy_hash, etree.QName(xmlsig.constants.DSigNs,
|
||||
"DigestValue")
|
||||
).text = hash_value
|
||||
signer_role = etree.SubElement(
|
||||
signed_signature_properties, etree.QName(etsi, "SignerRole")
|
||||
|
@ -598,7 +607,8 @@ class Invoice(metaclass=PoolMeta):
|
|||
claimed_roles, etree.QName(etsi, "ClaimedRole")
|
||||
).text = "supplier"
|
||||
signed_data_object_properties = etree.SubElement(
|
||||
signed_properties, etree.QName(etsi, "SignedDataObjectProperties")
|
||||
signed_properties, etree.QName(etsi,
|
||||
"SignedDataObjectProperties")
|
||||
)
|
||||
data_object_format = etree.SubElement(
|
||||
signed_data_object_properties,
|
||||
|
|
Loading…
Reference in New Issue