[POS-commit] r7160 - in stoqlib/trunk: data/glade data/sql stoqlib/domain stoqlib/gui/wizards

george at async.com.br george at async.com.br
Tue Aug 28 18:40:25 BRT 2007


Author: george
Date: Tue Aug 28 18:40:25 2007
New Revision: 7160

Added:
   stoqlib/trunk/data/glade/StockTransferFinishStep.glade
   stoqlib/trunk/data/sql/patch-27.sql
   stoqlib/trunk/stoqlib/domain/transfer.py
   stoqlib/trunk/stoqlib/gui/wizards/stocktransferwizard.py
Modified:
   stoqlib/trunk/data/glade/AbstractItemStep.glade
   stoqlib/trunk/data/sql/schema-2.sql

Log:
#2258: Implementar diálogo de transferência de estoque. r=jdahlin


Modified: stoqlib/trunk/data/glade/AbstractItemStep.glade
==============================================================================
--- stoqlib/trunk/data/glade/AbstractItemStep.glade	(original)
+++ stoqlib/trunk/data/glade/AbstractItemStep.glade	Tue Aug 28 18:40:25 2007
@@ -19,6 +19,7 @@
                                 <property name="data_type">unicode</property>
                                 <property name="is_focus">True</property>
                                 <property name="label" context="yes" translatable="yes">Item:</property>
+                                <property name="model_attribute">kiwilabel1</property>
                                 <property name="selectable">True</property>
                                 <property name="visible">True</property>
                                 <property name="xalign">1.0</property>
@@ -28,19 +29,19 @@
                             </packing>
                         </child>
                         <child>
-                            <widget class="ProxyComboEntry" id="item">
+                            <widget class="ProxyComboEntry" id="sellable">
                                 <property name="data_type">object</property>
-                                <property name="model_attribute">item</property>
+                                <property name="model_attribute">sellable</property>
                                 <property name="visible">True</property>
                             </widget>
                             <packing>
-                                <property name="expand">True</property>
                                 <property name="position">1</property>
                             </packing>
                         </child>
                         <child>
                             <widget class="ProxyLabel" id="kiwilabel2">
                                 <property name="label" context="yes" translatable="yes">Quantity:</property>
+                                <property name="model_attribute"></property>
                                 <property name="visible">True</property>
                                 <property name="xalign">1.0</property>
                             </widget>
@@ -93,6 +94,7 @@
                         <child>
                             <widget class="ProxyLabel" id="kiwilabel4">
                                 <property name="label" context="yes" translatable="yes">Cost:</property>
+                                <property name="model_attribute"></property>
                                 <property name="visible">True</property>
                                 <property name="xalign">1.0</property>
                             </widget>
@@ -104,8 +106,8 @@
                         <child>
                             <widget class="ProxyEntry" id="cost">
                                 <property name="data_type">Decimal</property>
-                                <property name="is_focus">True</property>
                                 <property name="editable">False</property>
+                                <property name="is_focus">True</property>
                                 <property name="model_attribute">cost</property>
                                 <property name="visible">True</property>
                                 <property name="width_chars">7</property>
@@ -121,7 +123,7 @@
                                 <property name="spacing">5</property>
                                 <property name="visible">True</property>
                                 <child>
-                                    <widget class="GtkButton" id="add_item_button">
+                                    <widget class="GtkButton" id="add_sellable_button">
                                         <property name="is_focus">True</property>
                                         <property name="visible">True</property>
                                         <child>

Added: stoqlib/trunk/data/glade/StockTransferFinishStep.glade
==============================================================================
--- (empty file)
+++ stoqlib/trunk/data/glade/StockTransferFinishStep.glade	Tue Aug 28 18:40:25 2007
@@ -0,0 +1,194 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://gazpacho.sicem.biz/gazpacho-0.1.dtd">
+<glade-interface>
+    <widget class="GtkWindow" id="StockTransferFinishStep">
+        <property name="default_height">250</property>
+        <property name="default_width">440</property>
+        <child>
+            <widget class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <child>
+                    <widget class="GtkTable" id="table1">
+                        <property name="border_width">6</property>
+                        <property name="column_spacing">6</property>
+                        <property name="n_columns">4</property>
+                        <property name="n_rows">3</property>
+                        <property name="row_spacing">6</property>
+                        <property name="visible">True</property>
+                        <child>
+                            <widget class="ProxyLabel" id="kiwilabel3">
+                                <property name="label" context="yes" translatable="yes">Sending branch:</property>
+                                <property name="model_attribute">kiwilabel3</property>
+                                <property name="visible">True</property>
+                                <property name="xalign">1.0</property>
+                            </widget>
+                            <packing>
+                                <property name="x_options">fill</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyLabel" id="kiwilabel1">
+                                <property name="label" context="yes" translatable="yes">Open date:</property>
+                                <property name="model_attribute">kiwilabel1</property>
+                                <property name="visible">True</property>
+                                <property name="xalign">1.0</property>
+                            </widget>
+                            <packing>
+                                <property name="bottom_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="x_options">fill</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyLabel" id="kiwilabel5">
+                                <property name="label" context="yes" translatable="yes">Sender:</property>
+                                <property name="model_attribute">kiwilabel5</property>
+                                <property name="visible">True</property>
+                                <property name="xalign">1.0</property>
+                            </widget>
+                            <packing>
+                                <property name="bottom_attach">3</property>
+                                <property name="top_attach">2</property>
+                                <property name="x_options">fill</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyLabel" id="source_branch">
+                                <property name="data_type">unicode</property>
+                                <property name="model_attribute">source_branch</property>
+                                <property name="visible">True</property>
+                                <property name="xalign">0.0</property>
+                            </widget>
+                            <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="y_options">fill</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyDateEntry" id="open_date">
+                                <property name="data_type">date</property>
+                                <property name="mandatory">True</property>
+                                <property name="model_attribute">open_date</property>
+                                <property name="visible">True</property>
+                            </widget>
+                            <packing>
+                                <property name="bottom_attach">2</property>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">1</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyComboEntry" id="source_responsible">
+                                <property name="data_type">object</property>
+                                <property name="mandatory">True</property>
+                                <property name="model_attribute">source_responsible</property>
+                                <property name="spacing">2</property>
+                                <property name="visible">True</property>
+                            </widget>
+                            <packing>
+                                <property name="bottom_attach">3</property>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">2</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyLabel" id="kiwilabel4">
+                                <property name="label" context="yes" translatable="yes">Receiving branch:</property>
+                                <property name="model_attribute">kiwilabel4</property>
+                                <property name="visible">True</property>
+                                <property name="xalign">1.0</property>
+                            </widget>
+                            <packing>
+                                <property name="left_attach">2</property>
+                                <property name="right_attach">3</property>
+                                <property name="x_options">fill</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyLabel" id="kiwilabel2">
+                                <property name="label" context="yes" translatable="yes">Receival date:</property>
+                                <property name="model_attribute">kiwilabel2</property>
+                                <property name="visible">True</property>
+                                <property name="xalign">1.0</property>
+                            </widget>
+                            <packing>
+                                <property name="bottom_attach">2</property>
+                                <property name="left_attach">2</property>
+                                <property name="right_attach">3</property>
+                                <property name="top_attach">1</property>
+                                <property name="x_options">fill</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyLabel" id="kiwilabel6">
+                                <property name="label" context="yes" translatable="yes">Receiver:</property>
+                                <property name="model_attribute">kiwilabel6</property>
+                                <property name="visible">True</property>
+                                <property name="xalign">1.0</property>
+                            </widget>
+                            <packing>
+                                <property name="bottom_attach">3</property>
+                                <property name="left_attach">2</property>
+                                <property name="right_attach">3</property>
+                                <property name="top_attach">2</property>
+                                <property name="x_options">fill</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyComboBox" id="destination_branch">
+                                <property name="data_type">object</property>
+                                <property name="model_attribute">destination_branch</property>
+                                <property name="visible">True</property>
+                            </widget>
+                            <packing>
+                                <property name="left_attach">3</property>
+                                <property name="right_attach">4</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyDateEntry" id="receival_date">
+                                <property name="data_type">date</property>
+                                <property name="mandatory">True</property>
+                                <property name="model_attribute">receival_date</property>
+                                <property name="visible">True</property>
+                            </widget>
+                            <packing>
+                                <property name="bottom_attach">2</property>
+                                <property name="left_attach">3</property>
+                                <property name="right_attach">4</property>
+                                <property name="top_attach">1</property>
+                            </packing>
+                        </child>
+                        <child>
+                            <widget class="ProxyComboEntry" id="destination_responsible">
+                                <property name="data_type">object</property>
+                                <property name="mandatory">True</property>
+                                <property name="model_attribute">destination_responsible</property>
+                                <property name="spacing">2</property>
+                                <property name="visible">True</property>
+                            </widget>
+                            <packing>
+                                <property name="bottom_attach">3</property>
+                                <property name="left_attach">3</property>
+                                <property name="right_attach">4</property>
+                                <property name="top_attach">2</property>
+                            </packing>
+                        </child>
+                    </widget>
+                    <packing>
+                        <property name="expand">False</property>
+                    </packing>
+                </child>
+                <child>
+                    <placeholder/>
+                    <packing>
+                        <property name="position">1</property>
+                    </packing>
+                </child>
+            </widget>
+        </child>
+    </widget>
+</glade-interface>

Added: stoqlib/trunk/data/sql/patch-27.sql
==============================================================================
--- (empty file)
+++ stoqlib/trunk/data/sql/patch-27.sql	Tue Aug 28 18:40:25 2007
@@ -0,0 +1,25 @@
+-- #2258: Implementar diálogo de transferência de estoque
+
+CREATE TABLE transfer_order (
+    id serial NOT NULL PRIMARY KEY,
+    te_created_id bigint REFERENCES transaction_entry(id),
+    te_modified_id bigint REFERENCES transaction_entry(id),
+
+    open_date timestamp NOT NULL,
+    receival_date timestamp,
+
+    source_branch_id bigint NOT NULL REFERENCES person_adapt_to_branch(id),
+    destination_branch_id bigint NOT NULL REFERENCES person_adapt_to_branch(id),
+    source_responsible_id bigint NOT NULL REFERENCES person_adapt_to_employee(id),
+    destination_responsible_id bigint NOT NULL REFERENCES person_adapt_to_employee(id)
+    );
+
+CREATE TABLE transfer_order_item (
+    id serial NOT NULL PRIMARY KEY,
+    te_created_id bigint REFERENCES transaction_entry(id),
+    te_modified_id bigint REFERENCES transaction_entry(id),
+
+    sellable_id bigint NOT NULL REFERENCES asellable(id),
+    transfer_order_id bigint NOT NULL REFERENCES transfer_order(id),
+    quantity numeric(10,2) NOT NULL CONSTRAINT positive_quantity CHECK (quantity > 0)
+    );

Modified: stoqlib/trunk/data/sql/schema-2.sql
==============================================================================
--- stoqlib/trunk/data/sql/schema-2.sql	(original)
+++ stoqlib/trunk/data/sql/schema-2.sql	Tue Aug 28 18:40:25 2007
@@ -1028,6 +1028,30 @@
     payment_id bigint NOT NULL UNIQUE REFERENCES payment(id)
 );
 
+CREATE TABLE transfer_order (
+    id serial NOT NULL PRIMARY KEY,
+    te_created_id bigint REFERENCES transaction_entry(id),
+    te_modified_id bigint REFERENCES transaction_entry(id),
+
+    open_date timestamp NOT NULL,
+    receival_date timestamp,
+
+    source_branch_id bigint NOT NULL REFERENCES person_adapt_to_branch(id),
+    destination_branch_id bigint NOT NULL REFERENCES person_adapt_to_branch(id),
+    source_responsible_id bigint NOT NULL REFERENCES person_adapt_to_employee(id),
+    destination_responsible_id bigint NOT NULL REFERENCES person_adapt_to_employee(id)
+);
+
+CREATE TABLE transfer_order_item (
+    id serial NOT NULL PRIMARY KEY,
+    te_created_id bigint REFERENCES transaction_entry(id),
+    te_modified_id bigint REFERENCES transaction_entry(id),
+
+    sellable_id bigint NOT NULL REFERENCES asellable(id),
+    transfer_order_id bigint NOT NULL REFERENCES transfer_order(id),
+    quantity numeric(10, 2) NOT NULL CONSTRAINT positive_quantity CHECK (quantity > 0)
+);
+
 ALTER TABLE transaction_entry
     ADD CONSTRAINT transaction_entry_user_id_fkey FOREIGN KEY
         (user_id) REFERENCES person_adapt_to_user (id),

Added: stoqlib/trunk/stoqlib/domain/transfer.py
==============================================================================
--- (empty file)
+++ stoqlib/trunk/stoqlib/domain/transfer.py	Tue Aug 28 18:40:25 2007
@@ -0,0 +1,92 @@
+# -*- coding: utf-8 -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+##
+## Copyright (C) 2007 Async Open Source <http://www.async.com.br>
+## All rights reserved
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., or visit: http://www.gnu.org/.
+##
+##  Author(s):      George Kussumoto    <george at async.com.br>
+##
+"""  Product transfer management """
+
+import datetime
+from kiwi.argcheck import argcheck
+from zope.interface import implements
+
+from sqlobject import ForeignKey
+from sqlobject.col import DateTimeCol
+
+from stoqlib.database.columns import DecimalCol
+from stoqlib.domain.base import Domain
+from stoqlib.domain.interfaces import IContainer
+from stoqlib.lib.translation import stoqlib_gettext
+
+
+_ = stoqlib_gettext
+
+
+class TransferOrderItem(Domain):
+    """Transfer order item
+
+    @ivar sellable: The sellable to transfer
+    @ivar transfer_order: The order this item belongs to
+    @ivar quantity: The quantity to transfer
+    """
+    sellable = ForeignKey('ASellable')
+    transfer_order = ForeignKey('TransferOrder')
+    quantity = DecimalCol()
+
+
+class TransferOrder(Domain):
+    """ Transfer Order class
+
+    @ivar open_date: The date the order was created
+    @ivar receival_date: The date the order was received
+    @ivar source_branch: The branch sending the stock
+    @ivar destination_branch: The branch receiving the stock
+    @ivar source_responsible: Employee responsible for the transfer at
+        source branch
+     @ivar destination_responsible: Employee responsible for the transfer at
+        destination branch
+    """
+    implements(IContainer)
+
+    open_date = DateTimeCol(default=datetime.datetime.now)
+    receival_date = DateTimeCol(default=datetime.datetime.now)
+    source_branch = ForeignKey('PersonAdaptToBranch')
+    destination_branch = ForeignKey('PersonAdaptToBranch')
+    source_responsible = ForeignKey('PersonAdaptToEmployee')
+    destination_responsible = ForeignKey('PersonAdaptToEmployee')
+
+    #
+    # IContainer implementation
+    #
+
+    def get_items(self):
+        return TransferOrderItem.selectBy(transfer_order=self,
+                                          connection=self.get_connection())
+
+    def add_item(self):
+        pass
+
+    @argcheck(TransferOrderItem)
+    def remove_item(self, item):
+        if item.transfer_order is not self:
+            raise ValueError('The item does not belong to this '
+                             'transfer order')
+        TransferOrderItem.delete(item.id,
+                                 connection=self.get_connection())

Added: stoqlib/trunk/stoqlib/gui/wizards/stocktransferwizard.py
==============================================================================
--- (empty file)
+++ stoqlib/trunk/stoqlib/gui/wizards/stocktransferwizard.py	Tue Aug 28 18:40:25 2007
@@ -0,0 +1,264 @@
+# -*- coding: utf-8 -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+##
+## Copyright (C) 2007 Async Open Source <http://www.async.com.br>
+## All rights reserved
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., or visit: http://www.gnu.org/.
+##
+## Author(s):   George Kussumoto    <george at async.com.br>
+##
+""" Stock transfer wizard definition """
+
+import datetime
+from decimal import Decimal
+from kiwi.datatypes import ValidationError
+from kiwi.python import Settable
+from kiwi.ui.widgets.list import Column
+
+from stoqlib.database.runtime import get_current_branch
+from stoqlib.domain.interfaces import IBranch, IEmployee, IStorable
+from stoqlib.domain.person import Person
+from stoqlib.domain.sellable import ASellable
+from stoqlib.domain.transfer import TransferOrder, TransferOrderItem
+from stoqlib.gui.base.columns import AccessorColumn
+from stoqlib.gui.base.wizards import BaseWizard, BaseWizardStep
+from stoqlib.gui.wizards.abstractwizard import SellableItemStep
+from stoqlib.lib.translation import stoqlib_gettext
+from stoqlib.lib.validators import format_quantity
+
+_ = stoqlib_gettext
+
+
+#
+# Wizard steps
+#
+
+class TemporaryTransferOrder(object):
+
+    def __init__(self):
+        self.items = []
+        self.open_date = datetime.date.today()
+        self.receival_date = datetime.date.today()
+        self.source_branch = None
+        self.destination_branch = None
+        self.source_responsible = None
+        self.destination_responsible = None
+
+    def add_item(self, item):
+        self.items.append(item)
+
+    def get_items(self):
+        return self.items
+
+
+class TemporaryTransferOrderItem(Settable):
+    pass
+
+
+class StockTransferProductStep(SellableItemStep):
+    model_type = TemporaryTransferOrder
+    item_table = TemporaryTransferOrderItem
+
+    def __init__(self, wizard, conn, model):
+       self.branch = get_current_branch(conn)
+       SellableItemStep.__init__(self, wizard, None, conn, model)
+
+    #
+    # SellableItemStep hooks
+    #
+
+    def setup_sellable_entry(self):
+        branch = get_current_branch(self.conn)
+        sellables = ASellable.get_unblocked_sellables(self.conn,
+                                                      storable=True)
+        self.sellable.prefill([(s.get_description(), s) for s in sellables
+                                if IStorable(s).has_stock_by_branch(self.branch)])
+
+    def get_saved_items(self):
+        return list(self.model.get_items())
+
+    def get_order_item(self, sellable, cost, quantity):
+        item = TemporaryTransferOrderItem(quantity=quantity, sellable=sellable)
+        self.model.add_item(item)
+        return item
+
+    def get_columns(self):
+        return [
+            Column('sellable.description', title=_(u'Description'),
+                   data_type=str, expand=True, searchable=True),
+            AccessorColumn('stock', title=_(u'Stock'), data_type=Decimal,
+                           accessor=self._get_stock_quantity),
+            Column('quantity', title=_(u'Transfer'), data_type=Decimal,
+                   format_func=format_quantity),
+            AccessorColumn('total', title=_(u'Total'), data_type=Decimal,
+                            accessor=self._get_total_quantity),
+            ]
+
+    def _get_stock_quantity(self, item):
+        storable = IStorable(item.sellable)
+        stock_item = storable.get_stock_item(self.branch)
+        return stock_item.quantity or 0
+
+    def _get_total_quantity(self, item):
+        qty = self._get_stock_quantity(item)
+        qty -= item.quantity
+        if qty > 0:
+            return qty
+        return 0
+
+    def _setup_summary(self):
+        self.summary = None
+
+    def _refresh_next(self):
+        can_transfer = False
+        for item in self.model.get_items():
+            storable = IStorable(item.sellable)
+            if item.quantity > storable.get_full_balance():
+                break
+            elif item:
+                can_transfer = True
+
+        self.wizard.refresh_next(can_transfer)
+
+    #
+    # WizardStep hooks
+    #
+
+    def post_init(self):
+        self.product_button.hide()
+        self.hide_add_and_edit_buttons()
+
+    def next_step(self):
+        return StockTransferFinishStep(self.conn, self.wizard,
+                                       self.model, self)
+
+
+class StockTransferFinishStep(BaseWizardStep):
+    gladefile = 'StockTransferFinishStep'
+    proxy_widgets = ('open_date',
+                     'receival_date',
+                     'destination_responsible',
+                     'destination_branch',
+                     'source_responsible')
+
+    def __init__(self, conn, wizard, transfer_order, previous):
+        self.conn = conn
+        self.transfer_order = transfer_order
+        self.branch = get_current_branch(self.conn)
+        BaseWizardStep.__init__(self, self.conn, wizard, previous)
+        self.setup_proxies()
+
+    def setup_proxies(self):
+        self._setup_widgets()
+        self.proxy = self.add_proxy(self.transfer_order,
+                                    StockTransferFinishStep.proxy_widgets)
+
+    def _setup_widgets(self):
+        branches = [(b.person.name, b)
+                    for b in Person.iselect(IBranch, connection=self.conn)
+                                        if b is not self.branch]
+        self.destination_branch.prefill(branches)
+        self.source_branch.set_text(self.branch.person.name)
+        employees = [(e.person.name, e)
+                     for e in Person.iselect(IEmployee,
+                                             connection=self.conn)]
+        self.source_responsible.prefill(employees)
+        self.destination_responsible.prefill(employees)
+
+    #
+    # WizardStep hooks
+    #
+
+    def post_init(self):
+        self.register_validate_function(self.wizard.refresh_next)
+        self.force_validation()
+
+    def has_previous_step(self):
+        return True
+
+    def has_next_step(self):
+        return False
+
+    def validate_step(self):
+        # since this is the last step, this method is used like a
+        # callback for the finish button
+        dest_branch = self.proxy.model.destination_branch
+        assert dest_branch is not None
+
+        for item in self.transfer_order.get_items():
+            storable = IStorable(item.sellable)
+            storable.decrease_stock(item.quantity, self.branch)
+            storable.increase_stock(item.quantity, dest_branch)
+
+        self.transfer_order.source_branch = self.branch
+        return True
+
+    #
+    # Kiwi callbacks
+    #
+
+    def on_open_date__validate(self, widget, date):
+        if date < datetime.date.today():
+            return ValidationError(_(u"The date must be set to today "
+                                      "or a future date"))
+        receival_date = self.receival_date.get_date()
+        if receival_date is not None and date > receival_date:
+            return ValidationError(_(u"The open date must be set to "
+                                      "before the receival date"))
+
+    def on_receival_date__validate(self, widget, date):
+        open_date = self.open_date.get_date()
+        if open_date > date:
+            return ValidationError(_(u"The receival date must be set "
+                                      "to after the open date"))
+
+    def on_destination_branch__content_changed(self, *args):
+        dest_branch = self.destination_branch.get_selected()
+        self.transfer_order.destination_branch = dest_branch
+
+
+#
+# Main wizard
+#
+
+
+class StockTransferWizard(BaseWizard):
+    title = _(u'Stock Transfer')
+    size = (750, 350)
+
+    def __init__(self, conn):
+        self.model = TemporaryTransferOrder()
+        first_step = StockTransferProductStep(self, conn, self.model)
+        BaseWizard.__init__(self, conn, first_step, self.model)
+        self.next_button.set_sensitive(False)
+
+    def finish(self):
+        order = TransferOrder(
+            open_date=self.model.open_date,
+            receival_date=self.model.receival_date,
+            source_branch=self.model.source_branch,
+            destination_branch=self.model.destination_branch,
+            source_responsible=self.model.source_responsible,
+            destination_responsible=self.model.destination_responsible,
+            connection=self.conn)
+        for item in self.model.get_items():
+            TransferOrderItem(connection=self.conn,
+                              transfer_order=order,
+                              sellable=item.sellable,
+                              quantity=item.quantity)
+        self.retval = self.model
+        self.close()


More information about the POS-commit mailing list