Skip to content

Commit

Permalink
maybe a fix for: Invalid content was found starting with element \'ns…
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Jan 21, 2019
1 parent eb1b960 commit 1a2a079
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions oscar_docdata/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,39 @@ def to_xml(self, factory):
class Quantity(object):
"""
An quantity for Docdata
<element name="quantity" minOccurs="1" maxOccurs="1">
<annotation>
<documentation>Quantity of this item that's being ordered.
</documentation>
</annotation>
<complexType>
<simpleContent>
<extension base="int">
<attribute name="unitOfMeasure" use="required">
<annotation>
<documentation>
Unit of measurement.
The attribute can have the
following values: PCS - pieces
SEC- seconds BYT - bytes KB -
kilobytes
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="PCS"/>
<enumeration value="SEC"/>
<enumeration value="BYT"/>
<enumeration value="KB"/>
</restriction>
</simpleType>
</attribute>
</extension>
</simpleContent>
</complexType>
</element>
"""
def __init__(self, value, unit='PCS'):
"""
Expand All @@ -917,15 +950,10 @@ def __init__(self, value, unit='PCS'):
self.unit = unit

def to_xml(self, factory):
# Needs to be an xsd:int with an attribute
# Can't do that with factory.create('ns0:quantity')
#metadata = factory.resolver.find('ns0:quantity')
#ns = metadata.namespace()

element = Element('ns0:quantity')
element.setText(str(self.value))
element.set('unitOfMeasure', self.unit)
return element
node = factory.create('ns0:quantity')
node.unitOfMeasure = self.unit
node.int = self.value
return node

This comment has been minimized.

Copy link
@jedie

jedie Jan 28, 2019

Author

Will raise "Type not found: 'unitOfMeasure'" see: django-oscar#14



class Invoice(object):
Expand Down

0 comments on commit 1a2a079

Please sign in to comment.