Пример #1
0
    def _setup_widgets(self):
        if not self.model.client_id:
            self.details_button.set_sensitive(False)
        self._setup_columns()

        self.sale_order = self.model.sale
        if self.sale_order.status == Sale.STATUS_RENEGOTIATED:
            self.status_details_button.show()
        else:
            self.status_details_button.hide()

        parent_items = SaleItemsView.find_parent_items(self.store, self.sale_order)
        for parent_item in parent_items:
            self.items_list.append(None, parent_item)
            if parent_item.product and not parent_item.product.is_package:
                # Prevent Production components to be shown
                continue
            for children in parent_item.get_children():
                self.items_list.append(parent_item, children)

        notes = []
        details = self.sale_order.get_details_str()
        if details:
            notes.append(details)

        # Information about the original sale (in this case, this sale was
        # created as a trade for some items)
        returned_sale = self.store.find(ReturnedSale, new_sale=self.model.id).one()
        if returned_sale:
            if returned_sale.sale:
                traded_sale = returned_sale.sale.identifier
            else:
                traded_sale = _("Unknown")
            trade_notes = [
                "* %s" % _("Items traded for this sale"),
                _("Date: %s") % get_full_date(returned_sale.return_date),
                _("Traded sale: %s") % traded_sale,
                _("Invoice number: %s") % returned_sale.invoice.invoice_number,
                _("Reason: %s") % returned_sale.reason,
            ]
            notes.append("\n".join(trade_notes))

        returned_items = ReturnedSaleItemsView.find_parent_items(self.store, self.sale_order)
        seen_set = set()
        for item in returned_items:
            self.returned_items_list.append(None, item)
            if not item.is_package():
                continue
            for child in item.get_children():
                self.returned_items_list.append(item, child)
            if item.invoice_number in seen_set:
                continue

            fmt = _("Itens returned on %s")
            return_notes = ["* %s" % (fmt % (get_full_date(item.return_date)))]
            if item.new_sale:
                fmt = _("Traded for sale: %s")
                return_notes.append(fmt % (item.new_sale.identifier))

            return_notes.extend([_("Invoice number: %s") % item.invoice_number, _("Reason: %s") % item.reason])

            notes.append("\n".join(return_notes))
            seen_set.add(item.invoice_number)
        if len(list(self.returned_items_list)) == 0:
            page_no = self.details_notebook.page_num(self.returned_items_vbox)
            self.details_notebook.remove_page(page_no)

        buffer = gtk.TextBuffer()
        buffer.set_text("\n\n".join(notes))
        self.notes.set_buffer(buffer)

        self.payments_list.add_list(self._get_payments(self.sale_order))
        changes = PaymentChangeHistoryView.find_by_group(self.store, self.sale_order.group)
        self.payments_info_list.add_list(changes)

        for widget, method_name in [(self.print_bills, u"bill"), (self.print_booklets, u"store_credit")]:
            widget.set_visible(
                any([p.method.method_name == method_name and not p.is_cancelled() for p in self.payments_list])
            )

        self._refresh_comments()
        self.comment_info.set_sensitive(False)
Пример #2
0
    def _setup_widgets(self):
        if not self.model.client_id:
            self.details_button.set_sensitive(False)
        self._setup_columns()

        self.sale_order = self.model.sale
        if self.sale_order.status == Sale.STATUS_RENEGOTIATED:
            self.status_details_button.show()
        else:
            self.status_details_button.hide()

        parent_items = SaleItemsView.find_parent_items(self.store, self.sale_order)
        for parent_item in parent_items:
            self.items_list.append(None, parent_item)
            if parent_item.product and not parent_item.product.is_package:
                # Prevent Production components to be shown
                continue
            for children in parent_item.get_children():
                self.items_list.append(parent_item, children)

        notes = []
        details = self.sale_order.get_details_str()
        if details:
            notes.append(details)

        # Information about the original sale (in this case, this sale was
        # created as a trade for some items)
        returned_sale = self.store.find(ReturnedSale,
                                        new_sale=self.model.id).one()
        if returned_sale:
            if returned_sale.sale:
                traded_sale = returned_sale.sale.identifier
            else:
                traded_sale = _("Unknown")
            trade_notes = [
                '* %s' % _("Items traded for this sale"),
                _("Date: %s") % get_full_date(returned_sale.return_date),
                _("Traded sale: %s") % traded_sale,
                _("Invoice number: %s") % returned_sale.invoice_number,
                _("Reason: %s") % returned_sale.reason,
            ]
            notes.append('\n'.join(trade_notes))

        returned_items = ReturnedSaleItemsView.find_parent_items(self.store,
                                                                 self.sale_order)
        seen_set = set()
        for item in returned_items:
            self.returned_items_list.append(None, item)
            if not item.is_package():
                continue
            for child in item.get_children():
                self.returned_items_list.append(item, child)
            if item.invoice_number in seen_set:
                continue

            fmt = _("Itens returned on %s")
            return_notes = ['* %s' % (
                fmt % (get_full_date(item.return_date)))]
            if item.new_sale:
                fmt = _("Traded for sale: %s")
                return_notes.append(fmt % (item.new_sale.identifier))

            return_notes.extend([
                _("Invoice number: %s") % item.invoice_number,
                _("Reason: %s") % item.reason,
            ])

            notes.append('\n'.join(return_notes))
            seen_set.add(item.invoice_number)
        if len(list(self.returned_items_list)) == 0:
            page_no = self.details_notebook.page_num(self.returned_items_vbox)
            self.details_notebook.remove_page(page_no)

        buffer = gtk.TextBuffer()
        buffer.set_text('\n\n'.join(notes))
        self.notes.set_buffer(buffer)

        self.payments_list.add_list(self._get_payments(self.sale_order))
        changes = PaymentChangeHistoryView.find_by_group(self.store,
                                                         self.sale_order.group)
        self.payments_info_list.add_list(changes)

        for widget, method_name in [(self.print_bills, u'bill'),
                                    (self.print_booklets, u'store_credit')]:
            widget.set_visible(any(
                [p.method.method_name == method_name and not p.is_cancelled()
                 for p in self.payments_list]))

        self._refresh_comments()
        self.comment_info.set_sensitive(False)
Пример #3
0
    def _setup_widgets(self):
        if self._is_batch:
            self._add_batches_tab()

        self.receiving_list.set_columns(self._get_receiving_columns())
        self.sales_list.set_columns(self._get_sale_columns())
        self.transfer_list.set_columns(self._get_transfer_columns())
        self.loan_list.set_columns(self._get_loan_columns())
        self.decrease_list.set_columns(self._get_decrease_columns())
        self.inventory_list.set_columns(self._get_inventory_columns())
        self.returned_list.set_columns(self._get_returned_columns())

        current_branch = api.get_current_branch(self.store)
        items = self.store.find(ReceivingItemView, sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.receiving_list.add_list(list(items))

        items = SaleItemsView.find_confirmed(self.store,
                                             sellable=self.model)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.sales_list.add_list(list(items))

        items = self.store.find(
            TransferOrderItem,
            And(Ne(TransferOrderItem.transfer_order_id, None),
                TransferOrderItem.sellable_id == self.model.id))
        self.transfer_list.add_list(list(items))

        items = self.store.find(LoanItemView, sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.loan_list.add_list(list(items))

        items = self.store.find(StockDecreaseItemsView, sellable=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.decrease_list.add_list(list(items))

        items = InventoryItemsView.find_by_product(self.store, self.model.product)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.inventory_list.add_list(items)

        items = self.store.find(ReturnedSaleItemsView, sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.returned_list.add_list(items)

        value_format = '<b>%s</b>'
        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        receiving_summary_label = SummaryLabel(klist=self.receiving_list,
                                               column='quantity',
                                               label=total_label,
                                               value_format=value_format)
        receiving_summary_label.show()
        self.receiving_vbox.pack_start(receiving_summary_label, False)

        sales_summary_label = SummaryLabel(klist=self.sales_list,
                                           column='quantity',
                                           label=total_label,
                                           value_format=value_format)
        sales_summary_label.show()
        self.sales_vbox.pack_start(sales_summary_label, False)

        transfer_summary_label = SummaryLabel(klist=self.transfer_list,
                                              column='quantity',
                                              label=total_label,
                                              value_format=value_format)
        transfer_summary_label.show()
        self.transfer_vbox.pack_start(transfer_summary_label, False)

        loan_summary_label = SummaryLabel(klist=self.loan_list,
                                          column='quantity',
                                          label=total_label,
                                          value_format=value_format)
        self.loan_vbox.pack_start(loan_summary_label, False)

        decrease_summary_label = SummaryLabel(klist=self.decrease_list,
                                              column='quantity',
                                              label=total_label,
                                              value_format=value_format)
        decrease_summary_label.show()
        self.decrease_vbox.pack_start(decrease_summary_label, False)
Пример #4
0
    def _setup_widgets(self):
        if self._is_batch:
            self._add_batches_tab()

        self.receiving_list.set_columns(self._get_receiving_columns())
        self.sales_list.set_columns(self._get_sale_columns())
        self.transfer_list.set_columns(self._get_transfer_columns())
        self.loan_list.set_columns(self._get_loan_columns())
        self.decrease_list.set_columns(self._get_decrease_columns())
        self.inventory_list.set_columns(self._get_inventory_columns())
        self.returned_list.set_columns(self._get_returned_columns())

        current_branch = api.get_current_branch(self.store)
        items = self.store.find(ReceivingItemView, sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.receiving_list.add_list(list(items))

        items = SaleItemsView.find_confirmed(self.store, sellable=self.model)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.sales_list.add_list(list(items))

        items = TransferItemView.find_by_branch(self.store, self.model,
                                                current_branch)
        self.transfer_list.add_list(list(items))

        items = self.store.find(LoanItemView, sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.loan_list.add_list(list(items))

        items = self.store.find(StockDecreaseItemsView, sellable=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.decrease_list.add_list(list(items))

        items = InventoryItemsView.find_by_product(self.store,
                                                   self.model.product)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.inventory_list.add_list(items)

        items = self.store.find(ReturnedSaleItemsView,
                                sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.returned_list.add_list(items)

        value_format = '<b>%s</b>'
        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        receiving_summary_label = SummaryLabel(klist=self.receiving_list,
                                               column='quantity',
                                               label=total_label,
                                               value_format=value_format)
        receiving_summary_label.show()
        self.receiving_vbox.pack_start(receiving_summary_label, False)

        sales_summary_label = SummaryLabel(klist=self.sales_list,
                                           column='quantity',
                                           label=total_label,
                                           value_format=value_format)
        sales_summary_label.show()
        self.sales_vbox.pack_start(sales_summary_label, False)

        transfer_summary_label = SummaryLabel(klist=self.transfer_list,
                                              column='item_quantity',
                                              label=total_label,
                                              value_format=value_format)
        transfer_summary_label.show()
        self.transfer_vbox.pack_start(transfer_summary_label, False)

        loan_summary_label = SummaryLabel(klist=self.loan_list,
                                          column='quantity',
                                          label=total_label,
                                          value_format=value_format)
        self.loan_vbox.pack_start(loan_summary_label, False)

        decrease_summary_label = SummaryLabel(klist=self.decrease_list,
                                              column='quantity',
                                              label=total_label,
                                              value_format=value_format)
        decrease_summary_label.show()
        self.decrease_vbox.pack_start(decrease_summary_label, False)