Esempio n. 1
0
    def process_state_using_ps_data(self, order_state):
        """Process Sale state as per the current state

        :param order_state: Site order state corresponding to ps order state
        """
        Sale = Pool().get('sale.sale')

        # Do not process sale if sale has exception
        if self.has_channel_exception:
            return

        self.channel.get_prestashop_client()

        # Cancel the order if its cancelled on prestashop
        if order_state.order_state == 'sale.cancel':
            Sale.cancel([self])
            return

        # Confirm and process the order in any other case
        Sale.quote([self])
        Sale.confirm([self])

        if order_state.order_state != 'sale.confirmed':
            # XXX: To mark sale as Done, sale must be in Processing state
            # as marking sale as Done is part of transition workflow now,
            # which allows only processed sale to be marked as Done.
            # But not sure if calling proceed before process is the right
            # way to do.
            Sale.proceed([self])
            Sale.process([self])
Esempio n. 2
0
    def process_state_using_ps_data(self, order_state):
        """Process Sale state as per the current state

        :param order_state: Site order state corresponding to ps order state
        """
        Sale = Pool().get('sale.sale')

        # Do not process sale if sale has exception
        if self.has_channel_exception:
            return

        self.channel.get_prestashop_client()

        # Cancel the order if its cancelled on prestashop
        if order_state.order_state == 'sale.cancel':
            Sale.cancel([self])
            return

        # Confirm and process the order in any other case
        Sale.quote([self])
        Sale.confirm([self])

        if order_state.order_state != 'sale.confirmed':
            # XXX: To mark sale as Done, sale must be in Processing state
            # as marking sale as Done is part of transition workflow now,
            # which allows only processed sale to be marked as Done.
            # But not sure if calling proceed before process is the right
            # way to do.
            Sale.proceed([self])
            Sale.process([self])
Esempio n. 3
0
 def cancel(cls, transfers):
     Receipt = Pool().get('cash_bank.receipt')
     rcps = []
     for transfer in transfers:
         rcps += [transfer.receipt_from, transfer.receipt_to]
     Receipt.cancel(rcps)
     write_log('Cancelled', transfers)
Esempio n. 4
0
 def cancel_move(cls, lines):
     Move = Pool().get('stock.move')
     Move.cancel([l.move for l in lines if l.move])
     Move.delete([l.move for l in lines if l.move])
     cls.write([l for l in lines if l.move], {
         'move': None,
         })
Esempio n. 5
0
 def cancel(cls, shipments):
     Move = Pool().get('stock.move')
     Move.cancel([m for s in shipments for m in s.supplier_moves])
     Move.cancel([
         m for s in shipments for m in s.customer_moves
         if s.state == 'shipped'
     ])
     Move.write([
         m for s in shipments
         for m in s.customer_moves if s.state != 'shipped'
     ], {'shipment': None})
    def cancel(cls, payments):
        """
        Cancel all payment transactions related to payment
        """
        PaymentTransaction = Pool().get('payment_gateway.transaction')

        payment_transactions = []
        for payment in payments:
            payment_transactions.extend(payment.payment_transactions)

        PaymentTransaction.cancel(payment_transactions)
    def cancel(cls, payments):
        """
        Cancel all payment transactions related to payment
        """
        PaymentTransaction = Pool().get('payment_gateway.transaction')

        payment_transactions = []
        for payment in payments:
            payment_transactions.extend(payment.payment_transactions)

        PaymentTransaction.cancel(payment_transactions)
Esempio n. 8
0
    def _clear_cart(self):
        """
        Clear the shopping cart by deleting both the sale associated
        with it and the cart itself.
        """
        Sale = Pool().get('sale.sale')

        if self.sale:
            Sale.cancel([self.sale])
            Sale.delete([self.sale])
        self.__class__.delete([self])
Esempio n. 9
0
    def _clear_cart(self):
        """
        Clear the shopping cart by deleting both the sale associated
        with it and the cart itself.
        """
        Sale = Pool().get('sale.sale')

        if self.sale:
            Sale.cancel([self.sale])
            Sale.delete([self.sale])
        self.__class__.delete([self])
Esempio n. 10
0
    def _clear_cart(self):
        """
        Clear the shopping cart by deleting both the sale associated
        with it and the cart itself.
        """
        Sale = Pool().get('sale.sale')

        if self.sale:
            Sale.cancel([self.sale])
            Sale.delete([self.sale])
        if self.id is not None:
            # An unsaved active record ?
            self.__class__.delete([self])
Esempio n. 11
0
    def _clear_cart(self):
        """
        Clear the shopping cart by deleting both the sale associated
        with it and the cart itself.
        """
        Sale = Pool().get('sale.sale')

        if self.sale:
            Sale.cancel([self.sale])
            Sale.delete([self.sale])
        if self.id is not None:
            # An unsaved active record ?
            self.__class__.delete([self])
Esempio n. 12
0
    def cancel(cls, opportunities):
        super().lost(opportunities)
        Design = Pool().get('configurator.design')
        QuoteLine = Pool().get('configurator.quotation.line')
        designs = []
        rejected_lines = []
        for opportunity in opportunities:
            designs += opportunity.design
            rejected_lines += opportunity.get_quoted_lines(
                opportunity.design, STATES)

        QuoteLine.write(rejected_lines, {'state': 'cancel'})
        Design.cancel(designs)
Esempio n. 13
0
    def process_sale_using_magento_state(self, magento_state):
        """
        Process the sale in tryton based on the state of order
        when its imported from magento

        :param magento_state: State on magento the order was imported in
        """
        Sale = Pool().get('sale.sale')

        data = MagentoOrderState.get_tryton_state(magento_state)

        # If order is canceled, just cancel it
        if data['tryton_state'] == 'sale.cancel':
            Sale.cancel([self])
            return

        # Order is not canceled, move it to quotation
        Sale.quote([self])
        Sale.confirm([self])

        if data['tryton_state'] not in ['sale.quotation', 'sale.confirmed']:
            Sale.process([self])
Esempio n. 14
0
 def cancel(cls, shipments):
     Move = Pool().get('stock.move')
     Move.cancel([m for s in shipments for m in s.moves])
Esempio n. 15
0
 def cancel(cls, shipments):
     Move = Pool().get('stock.move')
     Move.cancel([m for s in shipments for m in s.supplier_moves])
     Move.write([m for s in shipments for m in s.customer_moves],
         {'shipment': None})
Esempio n. 16
0
 def cancel(cls, shipments):
     Move = Pool().get('stock.move')
     Move.cancel([m for s in shipments for m in s.moves])
Esempio n. 17
0
 def cancel_move(cls, lines):
     Move = Pool().get('stock.move')
     moves = [m for l in lines for m in l.moves if l.moves]
     Move.cancel(moves)
     Move.delete(moves)
Esempio n. 18
0
 def cancel_move(cls, lines):
     Move = Pool().get('stock.move')
     moves = [m for l in lines for m in l.moves if l.moves]
     Move.cancel(moves)
     Move.delete(moves)