コード例 #1
0
ファイル: models.py プロジェクト: gmimano/commcaretest
    def to_xml(self, E=None, **kwargs):
        if not E:
            E = XML()

        tx_type = 'balance' if self.action in (
            StockActions.STOCKONHAND,
            StockActions.STOCKOUT,
        ) else 'transfer'

        attr = {}
        if self.timestamp:
            attr['date'] = dateparse.json_format_datetime(self.timestamp)

        attr['section-id'] = 'stock'
        if tx_type == 'balance':
            attr['entity-id'] = self.case_id
        elif tx_type == 'transfer':
            here, there = ('dest', 'src') if self.action == StockActions.RECEIPTS else ('src', 'dest')
            attr[here] = self.case_id
            # no 'there' for now
            if self.subaction:
                attr['type'] = self.subaction

        return getattr(E, tx_type)(
            E.entry(
                id=self.product_id,
                quantity=str(self.quantity if self.action != StockActions.STOCKOUT else 0),
            ),
            **attr
        )
コード例 #2
0
ファイル: models.py プロジェクト: elbowink/commcare-hq
    def to_xml(self, E=None, **kwargs):
        if not E:
            E = XML()

        return E.entry(
            id=self.product_id,
            quantity=str(self.quantity if self.action != StockActions.STOCKOUT else 0),
        )
コード例 #3
0
ファイル: helpers.py プロジェクト: ye-man/commcare-hq
    def to_xml(self, E=None, **kwargs):
        if not E:
            E = XML()

        return E.entry(
            id=self.product_id,
            quantity=str(self.quantity if self.action != StockActions.STOCKOUT
                         else 0),
        )