[POS-commit] r3248 - in stoqlib/trunk: data data/sql stoqlib/domain
stoqlib/domain/examples stoqlib/domain/payment
stoqlib/gui/base stoqlib/gui/dialogs stoqlib/gui/editors
stoqlib/gui/search stoqlib/lib stoqlib/reporting
Evandro Vale Miquelito
evandro at async.com.br
Thu Apr 6 19:55:04 BRT 2006
Author: evandro
Date: Thu Apr 6 19:55:02 2006
New Revision: 3248
Modified:
stoqlib/trunk/data/GiftCertificateEditor.glade
stoqlib/trunk/data/SellableEditor.glade
stoqlib/trunk/data/StartPurchaseStep.glade
stoqlib/trunk/data/sql/postgres-schema.sql
stoqlib/trunk/stoqlib/domain/columns.py
stoqlib/trunk/stoqlib/domain/examples/giftcertificate.py
stoqlib/trunk/stoqlib/domain/examples/product.py
stoqlib/trunk/stoqlib/domain/examples/purchase.py
stoqlib/trunk/stoqlib/domain/examples/sale.py
stoqlib/trunk/stoqlib/domain/examples/service.py
stoqlib/trunk/stoqlib/domain/payment/base.py
stoqlib/trunk/stoqlib/domain/purchase.py
stoqlib/trunk/stoqlib/domain/sale.py
stoqlib/trunk/stoqlib/domain/sellable.py
stoqlib/trunk/stoqlib/domain/service.py
stoqlib/trunk/stoqlib/gui/base/search.py
stoqlib/trunk/stoqlib/gui/dialogs/tilloperation.py
stoqlib/trunk/stoqlib/gui/editors/giftcertificate.py
stoqlib/trunk/stoqlib/gui/editors/product.py
stoqlib/trunk/stoqlib/gui/editors/sellable.py
stoqlib/trunk/stoqlib/gui/editors/service.py
stoqlib/trunk/stoqlib/gui/search/giftcertificate.py
stoqlib/trunk/stoqlib/gui/search/product.py
stoqlib/trunk/stoqlib/gui/search/service.py
stoqlib/trunk/stoqlib/gui/wizards/abstract.py
stoqlib/trunk/stoqlib/gui/wizards/receiving.py
stoqlib/trunk/stoqlib/lib/drivers.py
stoqlib/trunk/stoqlib/lib/parameters.py
stoqlib/trunk/stoqlib/reporting/product.py
stoqlib/trunk/stoqlib/reporting/purchase.py
Log:
Fixing bug 2214: implementing an autoincrement sqlobject based column and
using it where it's necessary. We are also adding a new barcode attribute on
AbstractSellable table which makes the process of creating sellables a lot
more simple.
Modified: stoqlib/trunk/data/GiftCertificateEditor.glade
==============================================================================
--- stoqlib/trunk/data/GiftCertificateEditor.glade (original)
+++ stoqlib/trunk/data/GiftCertificateEditor.glade Thu Apr 6 19:55:02 2006
@@ -10,7 +10,7 @@
<property name="border_width">6</property>
<property name="visible">True</property>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="title_label">
+ <widget class="ProxyLabel" id="title_label">
<property name="label" context="yes" translatable="yes">How many gift certificates would you like to create ?</property>
<property name="visible">True</property>
</widget>
@@ -23,12 +23,12 @@
<property name="row_spacing">6</property>
<property name="visible">True</property>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel6">
+ <widget class="ProxyLabel" id="kiwilabel6">
<property name="visible">True</property>
</widget>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel7">
+ <widget class="ProxyLabel" id="kiwilabel7">
<property name="visible">True</property>
</widget>
<packing>
@@ -44,7 +44,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+radiobutton+RadioButton" id="single_check">
+ <widget class="ProxyRadioButton" id="single_check">
<property name="data_type">bool</property>
<property name="is_focus">True</property>
<property name="label" context="yes" translatable="yes"></property>
@@ -56,7 +56,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+radiobutton+RadioButton" id="multiple_check">
+ <widget class="ProxyRadioButton" id="multiple_check">
<property name="active">False</property>
<property name="data_type">bool</property>
<property name="group">single_check</property>
@@ -80,8 +80,8 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="label111">
- <property name="label" context="yes" translatable="yes">Only one with number</property>
+ <widget class="ProxyLabel" id="label111">
+ <property name="label" context="yes" translatable="yes">Only one with barcode</property>
<property name="visible">True</property>
<property name="xalign">0.0</property>
</widget>
@@ -92,8 +92,8 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="label11123">
- <property name="label" context="yes" translatable="yes">Multiple. From number</property>
+ <widget class="ProxyLabel" id="label11123">
+ <property name="label" context="yes" translatable="yes">Multiple. From barcode</property>
<property name="visible">True</property>
<property name="xalign">0.0</property>
</widget>
@@ -114,7 +114,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+entry+Entry" id="number">
+ <widget class="ProxyEntry" id="number">
<property name="data_type">unicode</property>
<property name="model_attribute">number</property>
<property name="visible">True</property>
@@ -126,7 +126,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+entry+Entry" id="first_number">
+ <widget class="ProxyEntry" id="first_number">
<property name="data_type">int</property>
<property name="model_attribute">first_number</property>
<property name="visible">True</property>
@@ -157,7 +157,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel5">
+ <widget class="ProxyLabel" id="kiwilabel5">
<property name="label" context="yes" translatable="yes">To</property>
<property name="visible">True</property>
</widget>
@@ -185,7 +185,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+entry+Entry" id="last_number">
+ <widget class="ProxyEntry" id="last_number">
<property name="data_type">int</property>
<property name="is_focus">True</property>
<property name="model_attribute">last_number</property>
@@ -221,7 +221,7 @@
<property name="spacing">6</property>
<property name="visible">True</property>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel8">
+ <widget class="ProxyLabel" id="kiwilabel8">
<property name="label" context="yes" translatable="yes">Type of Gift Certificate:</property>
<property name="visible">True</property>
<property name="xalign">1.0</property>
Modified: stoqlib/trunk/data/SellableEditor.glade
==============================================================================
--- stoqlib/trunk/data/SellableEditor.glade (original)
+++ stoqlib/trunk/data/SellableEditor.glade Thu Apr 6 19:55:02 2006
@@ -18,28 +18,30 @@
<property name="xalign">1.0</property>
</widget>
<packing>
- <property name="x_options">fill</property>
- <property name="y_options">fill</property>
+ <property name="bottom_attach">10</property>
+ <property name="top_attach">9</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label2">
- <property name="label" context="yes" translatable="yes">Description:</property>
+ <widget class="GtkLabel" id="label6">
+ <property name="label" context="yes" translatable="yes">Barcode:</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>
- <property name="y_options">fill</property>
+ <property name="bottom_attach">11</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
- <placeholder/>
+ <widget class="GtkLabel" id="label2">
+ <property name="label" context="yes" translatable="yes">Description:</property>
+ <property name="visible">True</property>
+ <property name="xalign">1.0</property>
+ </widget>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="bottom_attach">12</property>
+ <property name="top_attach">11</property>
</packing>
</child>
<child>
@@ -56,10 +58,9 @@
</child>
</widget>
<packing>
- <property name="bottom_attach">4</property>
+ <property name="bottom_attach">13</property>
<property name="right_attach">4</property>
- <property name="top_attach">3</property>
- <property name="y_options">fill</property>
+ <property name="top_attach">12</property>
</packing>
</child>
<child>
@@ -69,10 +70,8 @@
<property name="xalign">1.0</property>
</widget>
<packing>
- <property name="bottom_attach">5</property>
- <property name="top_attach">4</property>
- <property name="x_options">fill</property>
- <property name="y_options">fill</property>
+ <property name="bottom_attach">14</property>
+ <property name="top_attach">13</property>
</packing>
</child>
<child>
@@ -82,21 +81,19 @@
<property name="xalign">1.0</property>
</widget>
<packing>
- <property name="bottom_attach">6</property>
- <property name="top_attach">5</property>
- <property name="x_options">fill</property>
- <property name="y_options">fill</property>
+ <property name="bottom_attach">15</property>
+ <property name="top_attach">14</property>
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="requires_weighing_label">
+ <widget class="ProxyLabel" id="requires_weighing_label">
<property name="visible">True</property>
<property name="xalign">1.0</property>
</widget>
<packing>
- <property name="bottom_attach">7</property>
+ <property name="bottom_attach">16</property>
<property name="right_attach">4</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">15</property>
</packing>
</child>
<child>
@@ -107,67 +104,69 @@
<property name="yalign">0.0</property>
</widget>
<packing>
- <property name="bottom_attach">8</property>
- <property name="top_attach">7</property>
+ <property name="bottom_attach">17</property>
+ <property name="top_attach">16</property>
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+entry+Entry" id="code">
+ <widget class="ProxyLabel" id="code">
<property name="data_type">unicode</property>
- <property name="is_focus">True</property>
- <property name="mandatory">True</property>
- <property name="model_attribute">code</property>
+ <property name="model_attribute">code_str</property>
<property name="visible">True</property>
<property name="xalign">1.0</property>
</widget>
<packing>
+ <property name="bottom_attach">10</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="y_options">fill</property>
+ <property name="top_attach">9</property>
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+entry+Entry" id="description">
+ <widget class="ProxyEntry" id="barcode">
<property name="data_type">unicode</property>
<property name="is_focus">True</property>
- <property name="mandatory">True</property>
- <property name="model_attribute">base_sellable_info.description</property>
+ <property name="model_attribute">barcode</property>
<property name="visible">True</property>
</widget>
<packing>
- <property name="bottom_attach">2</property>
+ <property name="bottom_attach">11</property>
<property name="left_attach">1</property>
- <property name="right_attach">4</property>
- <property name="top_attach">1</property>
- <property name="y_options">fill</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
- <placeholder/>
+ <widget class="ProxyEntry" id="description">
+ <property name="data_type">unicode</property>
+ <property name="is_focus">True</property>
+ <property name="mandatory">True</property>
+ <property name="model_attribute">base_sellable_info.description</property>
+ <property name="visible">True</property>
+ </widget>
<packing>
+ <property name="bottom_attach">12</property>
<property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">11</property>
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+entry+Entry" id="cost">
+ <widget class="ProxyEntry" id="cost">
<property name="data_type">currency</property>
<property name="model_attribute">cost</property>
<property name="visible">True</property>
<property name="xalign">1.0</property>
</widget>
<packing>
- <property name="bottom_attach">5</property>
+ <property name="bottom_attach">14</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="y_options">fill</property>
+ <property name="top_attach">13</property>
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+entry+Entry" id="price">
+ <widget class="ProxyEntry" id="price">
<property name="data_type">currency</property>
<property name="mandatory">True</property>
<property name="model_attribute">base_sellable_info.price</property>
@@ -175,11 +174,10 @@
<property name="xalign">1.0</property>
</widget>
<packing>
- <property name="bottom_attach">6</property>
+ <property name="bottom_attach">15</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="y_options">fill</property>
+ <property name="top_attach">14</property>
</packing>
</child>
<child>
@@ -189,7 +187,7 @@
<property name="visible">True</property>
<property name="vscrollbar_policy">automatic</property>
<child>
- <widget class="kiwi+ui+widgets+textview+TextView" id="notes">
+ <widget class="ProxyTextView" id="notes">
<property name="data_type">unicode</property>
<property name="is_focus">True</property>
<property name="left_margin">5</property>
@@ -201,10 +199,10 @@
</child>
</widget>
<packing>
- <property name="bottom_attach">8</property>
+ <property name="bottom_attach">17</property>
<property name="left_attach">1</property>
<property name="right_attach">4</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">16</property>
</packing>
</child>
<child>
@@ -214,19 +212,10 @@
<property name="xalign">1.0</property>
</widget>
<packing>
+ <property name="bottom_attach">11</property>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="x_options">fill</property>
- <property name="y_options">fill</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
@@ -236,12 +225,10 @@
<property name="xalign">1.0</property>
</widget>
<packing>
- <property name="bottom_attach">5</property>
+ <property name="bottom_attach">14</property>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">4</property>
- <property name="x_options">fill</property>
- <property name="y_options">fill</property>
+ <property name="top_attach">13</property>
</packing>
</child>
<child>
@@ -293,7 +280,7 @@
<property name="xalign">0.0</property>
<property name="xscale">0.0</property>
<child>
- <widget class="kiwi+ui+widgets+entry+Entry" id="unit_entry">
+ <widget class="ProxyEntry" id="unit_entry">
<property name="completion">True</property>
<property name="data_type">unicode</property>
<property name="is_focus">True</property>
@@ -311,12 +298,10 @@
</child>
</widget>
<packing>
- <property name="bottom_attach">6</property>
+ <property name="bottom_attach">15</property>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
- <property name="top_attach">5</property>
- <property name="x_options">fill</property>
- <property name="y_options">fill</property>
+ <property name="top_attach">14</property>
</packing>
</child>
<child>
@@ -326,33 +311,24 @@
<property name="visible">True</property>
</widget>
<packing>
+ <property name="bottom_attach">11</property>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
- <property name="y_options">fill</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- <packing>
- <property name="left_attach">3</property>
- <property name="right_attach">4</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="stock_total_lbl">
+ <widget class="ProxyLabel" id="stock_total_lbl">
<property name="data_type">currency</property>
<property name="model_attribute">average_stock_price</property>
<property name="visible">True</property>
<property name="xalign">0.0</property>
</widget>
<packing>
- <property name="bottom_attach">5</property>
+ <property name="bottom_attach">14</property>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
- <property name="top_attach">4</property>
- <property name="y_options">fill</property>
+ <property name="top_attach">13</property>
</packing>
</child>
</widget>
Modified: stoqlib/trunk/data/StartPurchaseStep.glade
==============================================================================
--- stoqlib/trunk/data/StartPurchaseStep.glade (original)
+++ stoqlib/trunk/data/StartPurchaseStep.glade Thu Apr 6 19:55:02 2006
@@ -18,7 +18,7 @@
<property name="row_spacing">12</property>
<property name="visible">True</property>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel1">
+ <widget class="ProxyLabel" id="kiwilabel1">
<property name="data_type">unicode</property>
<property name="label" context="yes" translatable="yes">Open Date:</property>
<property name="visible">True</property>
@@ -26,7 +26,7 @@
</widget>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel4">
+ <widget class="ProxyLabel" id="kiwilabel4">
<property name="data_type">unicode</property>
<property name="label" context="yes" translatable="yes">Branch:</property>
<property name="visible">True</property>
@@ -38,7 +38,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel2">
+ <widget class="ProxyLabel" id="kiwilabel2">
<property name="data_type">unicode</property>
<property name="label" context="yes" translatable="yes">Supplier:</property>
<property name="visible">True</property>
@@ -50,7 +50,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel5">
+ <widget class="ProxyLabel" id="kiwilabel5">
<property name="data_type">unicode</property>
<property name="label" context="yes" translatable="yes">Freight Type:</property>
<property name="visible">True</property>
@@ -129,7 +129,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel3">
+ <widget class="ProxyLabel" id="kiwilabel3">
<property name="data_type">unicode</property>
<property name="label" context="yes" translatable="yes">Order Number:</property>
<property name="visible">True</property>
@@ -159,7 +159,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel6">
+ <widget class="ProxyLabel" id="kiwilabel6">
<property name="data_type">unicode</property>
<property name="label" context="yes" translatable="yes">Freight:</property>
<property name="visible">True</property>
@@ -173,14 +173,10 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+entry+Entry" id="order_number">
- <property name="data_type">int</property>
- <property name="is_focus">True</property>
- <property name="mandatory">True</property>
- <property name="max_length">60</property>
- <property name="model_attribute">order_number</property>
+ <widget class="ProxyLabel" id="order_number">
+ <property name="data_type">unicode</property>
+ <property name="model_attribute">order_number_str</property>
<property name="visible">True</property>
- <property name="width_chars">10</property>
<property name="xalign">1.0</property>
</widget>
<packing>
@@ -189,7 +185,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel12">
+ <widget class="ProxyLabel" id="kiwilabel12">
<property name="data_type">unicode</property>
<property name="visible">True</property>
</widget>
@@ -216,7 +212,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+spinbutton+SpinButton" id="freight">
+ <widget class="ProxySpinButton" id="freight">
<property name="adjustment">0 0 100 1 10 0</property>
<property name="data_type">Decimal</property>
<property name="digits">2</property>
@@ -233,7 +229,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel15">
+ <widget class="ProxyLabel" id="kiwilabel15">
<property name="data_type">unicode</property>
<property name="visible">True</property>
</widget>
@@ -243,7 +239,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel14">
+ <widget class="ProxyLabel" id="kiwilabel14">
<property name="data_type">unicode</property>
<property name="visible">True</property>
</widget>
@@ -255,7 +251,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel13">
+ <widget class="ProxyLabel" id="kiwilabel13">
<property name="data_type">unicode</property>
<property name="visible">True</property>
</widget>
@@ -267,7 +263,7 @@
</packing>
</child>
<child>
- <widget class="kiwi+ui+widgets+label+Label" id="kiwilabel7">
+ <widget class="ProxyLabel" id="kiwilabel7">
<property name="data_type">unicode</property>
<property name="label" context="yes" translatable="yes">%</property>
<property name="visible">True</property>
Modified: stoqlib/trunk/data/sql/postgres-schema.sql
==============================================================================
--- stoqlib/trunk/data/sql/postgres-schema.sql (original)
+++ stoqlib/trunk/data/sql/postgres-schema.sql Thu Apr 6 19:55:02 2006
@@ -24,6 +24,12 @@
--
+-- Functions definitions
+--
+
+
+CREATE OR REPLACE FUNCTION drop_existing_view(text)
+--
-- Checks if a certain view exists and drop it. We need this feature
-- since CREATE OR REPLACE statement doesn't apply when changing or
-- adding view attributes.
@@ -31,7 +37,6 @@
-- the information_schema catalog so we can not fetch a list of user defined
-- views and drop then in one call of this function.
--
-CREATE OR REPLACE FUNCTION drop_existing_view(text)
RETURNS integer AS '
DECLARE
view_exists int;
@@ -48,6 +53,44 @@
END;
' LANGUAGE 'plpgsql';
+
+CREATE OR REPLACE FUNCTION create_stoqlib_sequence(text)
+--
+-- Checks if a certain sequence exists and create it if it doesn't exists
+--
+RETURNS integer AS '
+DECLARE
+ sequence_exists int;
+ currschema text;
+BEGIN
+
+ select into currschema current_schema();
+ select into sequence_exists count(*) from pg_statio_user_sequences
+ where schemaname = currschema and relname = $1;
+
+ IF sequence_exists = 0 THEN
+ execute ''CREATE SEQUENCE '' || quote_ident($1);
+ END IF;
+
+ RETURN 1;
+END;
+' LANGUAGE 'plpgsql';
+
+
+--
+-- Sequences
+--
+-- Note that every sequence name must have a 'stoqlib' prefix to
+-- avoid conflicts with SQLObject sequences.
+--
+
+
+select create_stoqlib_sequence('stoqlib_payment_identifier_seq');
+select create_stoqlib_sequence('stoqlib_sale_ordernumber_seq');
+select create_stoqlib_sequence('stoqlib_purchase_ordernumber_seq');
+select create_stoqlib_sequence('stoqlib_sellable_code_seq');
+
+
--
-- Abstract Views: do not use them on directly on applications
--
@@ -55,19 +98,21 @@
select drop_existing_view('abstract_stock_view');
CREATE VIEW abstract_stock_view AS
- --
- -- This is an abstract view which stores stock informations to other views.
- -- Available fields are:
- -- id - the id of the abstract_sellable table
- -- code - the product code
- -- status - the product status
- -- stock - the total amount of stock for a certain product
- -- branch_id - the id of the person_adapt_to_branch table
- -- stock_cost - the total cost for the given stock
- -- product_id - the id of product table
- --
+ --
+ -- This is an abstract view which stores stock informations to other views.
+ -- Available fields are:
+ -- id - the id of the abstract_sellable table
+ -- code - the product code
+ -- barcode - the product barcode
+ -- status - the product status
+ -- stock - the total amount of stock for a certain product
+ -- branch_id - the id of the person_adapt_to_branch table
+ -- stock_cost - the total cost for the given stock
+ -- product_id - the id of product table
+ --
SELECT DISTINCT
- abstract_sellable.id, abstract_sellable.code, abstract_sellable.status,
+ abstract_sellable.id, abstract_sellable.code, abstract_sellable.barcode,
+ abstract_sellable.status,
abstract_stock_item.quantity + abstract_stock_item.logic_quantity as stock,
abstract_stock_item.branch_id, abstract_stock_item.stock_cost,
product.id as product_id
@@ -239,6 +284,7 @@
-- Available fields are:
-- id - the id of the abstract_sellable table
-- code - the sellable code
+ -- barcode - the sellable barcode
-- status - the sellable status
-- stock - the stock in case the sellable is a product
-- branch_id - the if of person_adapt_to_branch table
@@ -253,7 +299,8 @@
-- product_id - the id of the product table
--
SELECT DISTINCT
- abstract_sellable.id, abstract_sellable.code, abstract_sellable.status,
+ abstract_sellable.id, abstract_sellable.code, abstract_sellable.barcode,
+ abstract_sellable.status,
sum(abstract_stock_view.stock) as stock, abstract_stock_view.branch_id,
abstract_sellable.cost, base_sellable_info.price,
base_sellable_info.is_valid_model,
@@ -278,7 +325,8 @@
base_sellable_info.id AND base_sellable_info.is_valid_model = 't')
group by abstract_sellable.code, abstract_sellable.status,
- abstract_sellable.id, abstract_sellable.cost, base_sellable_info.price,
+ abstract_sellable.barcode, abstract_sellable.id,
+ abstract_sellable.cost, base_sellable_info.price,
base_sellable_info.description, sellable_unit.description,
base_sellable_info.is_valid_model, abstract_stock_view.branch_id,
abstract_product_supplier_view.supplier_name, abstract_stock_view.product_id;
@@ -293,13 +341,13 @@
-- Available fields are: the same fields of sellable_view table.
--
SELECT DISTINCT
- sum(stock) as stock, id, code, status, 0 as branch_id, cost, price, is_valid_model,
- description, unit, supplier_name, product_id
+ sum(stock) as stock, id, code, barcode, status, 0 as branch_id, cost,
+ price, is_valid_model, description, unit, supplier_name, product_id
FROM sellable_view
- GROUP BY code, status, id, cost, price, is_valid_model, description,
- unit, supplier_name, product_id;
+ GROUP BY code, barcode, status, id, cost, price, is_valid_model,
+ description, unit, supplier_name, product_id;
select drop_existing_view('product_full_stock_view');
@@ -321,6 +369,7 @@
-- Available fields are:
-- id - the id of the abstract_sellable table
-- code - the sellable code
+ -- barcode - the sellable barcode
-- status - the sellable status
-- cost - the sellable cost
-- price - the sellable price
@@ -331,7 +380,8 @@
-- service_id - the id of the service table
--
SELECT DISTINCT
- abstract_sellable.id, abstract_sellable.code, abstract_sellable.status,
+ abstract_sellable.id, abstract_sellable.code, abstract_sellable.barcode,
+ abstract_sellable.status,
abstract_sellable.cost, base_sellable_info.price,
base_sellable_info.is_valid_model,
base_sellable_info.description, sellable_unit.description as unit,
Modified: stoqlib/trunk/stoqlib/domain/columns.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/columns.py (original)
+++ stoqlib/trunk/stoqlib/domain/columns.py Thu Apr 6 19:55:02 2006
@@ -29,7 +29,8 @@
from formencode.validators import Validator
from kiwi.datatypes import currency
-from sqlobject.col import SODecimalCol, Col
+from sqlobject.col import SODecimalCol, Col, SOIntCol
+from sqlobject.sqlbuilder import func
from sqlobject.converters import registerConverter
from stoqlib.domain.parameter import ParameterData
@@ -44,6 +45,11 @@
registerConverter(currency, _CurrencyConverter)
+#
+# Validators
+#
+
+
class _PriceValidator(Validator):
def to_python(self, value, state):
@@ -56,7 +62,6 @@
def from_python(self, value, state):
return value
-
class _DecimalValidator(Validator):
def to_python(self, value, state):
@@ -70,8 +75,12 @@
return value
-class AbstractDecimalCol(SODecimalCol):
+#
+# Abstract Classes
+#
+
+class AbstractDecimalCol(SODecimalCol):
def __init__(self, **kw):
conn = get_connection()
if conn.tableExists(ParameterData.get_db_table_name()):
@@ -88,15 +97,38 @@
return ([_DecimalValidator()] +
super(AbstractDecimalCol, self).createValidators())
-
-class DecimalCol(Col):
- baseClass = AbstractDecimalCol
-
-
class SOPriceCol(AbstractDecimalCol):
def createValidators(self):
return [_PriceValidator()] + super(SOPriceCol, self).createValidators()
+class SOAutoIncCol(SOIntCol):
+ def __init__(self, **kw):
+ kw['default'] = func.nextval(kw['seq_name'])
+ del kw['seq_name']
+ kw['alternateID'] = True
+ SOIntCol.__init__(self, **kw)
+
+
+#
+# Custom SQLObject columns
+#
+
+
+class DecimalCol(Col):
+ baseClass = AbstractDecimalCol
class PriceCol(DecimalCol):
baseClass = SOPriceCol
+
+class AutoIncCol(Col):
+ """This column defines an auto increment integer column. Domain classes
+ must always supply a 'sequence name' argument when instantiating this
+ column.
+
+ @cvar seq_name: the postgres database sequence name
+ """
+ baseClass = SOAutoIncCol
+
+ def __init__(self, seq_name, *args, **kw):
+ kw['seq_name'] = seq_name
+ Col.__init__(self, *args, **kw)
Modified: stoqlib/trunk/stoqlib/domain/examples/giftcertificate.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/examples/giftcertificate.py (original)
+++ stoqlib/trunk/stoqlib/domain/examples/giftcertificate.py Thu Apr 6 19:55:02 2006
@@ -35,10 +35,8 @@
print_msg('Creating gift certificates...', break_line=False)
conn = new_transaction()
- general_data = [dict(code='GC23',
- status=AbstractSellable.STATUS_SOLD),
- dict(code='GC34',
- status=AbstractSellable.STATUS_AVAILABLE)]
+ statuses = [AbstractSellable.STATUS_SOLD,
+ AbstractSellable.STATUS_AVAILABLE]
sellable_data = [dict(description='Christmas Gift Certificate',
price=430),
@@ -54,10 +52,10 @@
base_sellable_info=sellable_info)
certificate = GiftCertificate(connection=conn)
- cert_data = general_data[index]
+ status = statuses[index]
certificate.addFacet(ISellable, connection=conn,
base_sellable_info=sellable_info,
- **cert_data)
+ status=status)
conn.commit()
print_msg('done.')
Modified: stoqlib/trunk/stoqlib/domain/examples/product.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/examples/product.py (original)
+++ stoqlib/trunk/stoqlib/domain/examples/product.py Thu Apr 6 19:55:02 2006
@@ -70,8 +70,6 @@
'LCD',
'AMD Durom']
- codes = ['K15', 'M73', 'M025', 'P83']
-
descriptions = ['Keyboard AXDR', 'Optical Mouse 45FG',
'Monitor LCD SXDF', 'Processor AMD Durom 1.2Ghz']
@@ -125,11 +123,10 @@
price=price)
cost = random.randrange(*COST_RANGE)
- code = codes[index]
unit = units[index]
product_obj.addFacet(ISellable, connection=conn, category=cat,
- code=code, cost=cost, unit=unit,
+ cost=cost, unit=unit,
base_sellable_info=sellable_info)
storable = product_obj.addFacet(IStorable, connection=conn)
Modified: stoqlib/trunk/stoqlib/domain/examples/purchase.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/examples/purchase.py (original)
+++ stoqlib/trunk/stoqlib/domain/examples/purchase.py Thu Apr 6 19:55:02 2006
@@ -100,9 +100,7 @@
purchase_args = purchase_data[index]
order = PurchaseOrder(connection=conn, supplier=supplier,
- branch=branch,
- order_number=index + 1,
- **purchase_args)
+ branch=branch, **purchase_args)
order.set_valid()
Modified: stoqlib/trunk/stoqlib/domain/examples/sale.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/examples/sale.py (original)
+++ stoqlib/trunk/stoqlib/domain/examples/sale.py Thu Apr 6 19:55:02 2006
@@ -117,9 +117,6 @@
method = sysparam(conn).BASE_PAYMENT_METHOD
check_method = ICheckPM(method, connection=conn)
- # We need to increment payment_id attribute automatically. Waiting
- # for SQLObject support
- payment_id = 1
for index in range(DEFAULT_SALE_NUMBER):
#
@@ -131,8 +128,7 @@
salesperson = salespersons[index]
# Order number field will be filled automatically after bug 2214
sale = Sale(connection=conn, till=till, client=clients[index],
- order_number=index + 1, status=status,
- open_date=open_date, salesperson=salesperson)
+ status=status, open_date=open_date, salesperson=salesperson)
sellable_facet = ISellable(product_list[index], connection=conn)
sellable_facet.add_sellable_item(sale=sale)
sale_total = sellable_facet.base_sellable_info.price
Modified: stoqlib/trunk/stoqlib/domain/examples/service.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/examples/service.py (original)
+++ stoqlib/trunk/stoqlib/domain/examples/service.py Thu Apr 6 19:55:02 2006
@@ -31,38 +31,34 @@
MAX_SERVICES_NUMBER = 4
-PRICE_RANGE = 100, 200
+PRICE_RANGE = 100, 200
COST_RANGE = 1, 99
def create_services():
print_msg('Creating services...', break_line=False)
conn = new_transaction()
-
+
descriptions = ['General Service', 'Cleanness', 'Computer Maintenance',
'Computer Components Switch']
- codes = ['General89', 'C762', '872626', 'S123']
-
# Creating services and facets
for index in range(MAX_SERVICES_NUMBER):
service_obj = Service(connection=conn)
-
+
price = round(random.uniform(*PRICE_RANGE))
description = descriptions[index]
- sellable_info = BaseSellableInfo(connection=conn,
+ sellable_info = BaseSellableInfo(connection=conn,
description=description,
price=price)
cost = round(random.uniform(*COST_RANGE))
- code = codes[index]
-
service_obj.addFacet(ISellable, connection=conn,
base_sellable_info=sellable_info,
- cost=cost, code=code)
+ cost=cost)
conn.commit()
print_msg('done.')
-
+
if __name__ == "__main__":
create_services()
Modified: stoqlib/trunk/stoqlib/domain/payment/base.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/payment/base.py (original)
+++ stoqlib/trunk/stoqlib/domain/payment/base.py Thu Apr 6 19:55:02 2006
@@ -36,7 +36,7 @@
from stoqlib.lib.parameters import sysparam
from stoqlib.lib.defaults import (get_method_names, get_all_methods_dict,
METHOD_MULTIPLE, METHOD_MONEY)
-from stoqlib.domain.columns import PriceCol
+from stoqlib.domain.columns import PriceCol, AutoIncCol
from stoqlib.domain.base import Domain, ModelAdapter, InheritableModelAdapter
from stoqlib.domain.payment.operation import PaymentOperation
from stoqlib.domain.interfaces import (IInPayment, IOutPayment, IPaymentGroup,
@@ -75,9 +75,7 @@
STATUS_CONFIRMED: _(u'Confirmed'),
STATUS_CANCELLED: _(u'Cancelled')}
- # XXX The payment_id attribute will be an alternateID after
- # fixing bug 2214
- payment_id = IntCol(default=None)
+ identifier = AutoIncCol('stoqlib_payment_identifier_seq')
status = IntCol(default=STATUS_PREVIEW)
due_date = DateTimeCol()
paid_date = DateTimeCol(default=None)
@@ -175,9 +173,8 @@
self._check_status(self.STATUS_TO_PAY, 'reverse selection')
self.status = self.STATUS_CANCELLED
payment = self.clone()
- # payment_id should be incremented automatically.
- # Waiting for bug 2214.
- description = _('Cancellation of payment number %s') % self.payment_id
+ description = (_('Cancellation of payment number %s')
+ % self.identifier)
payment.description = description
payment.value *= -1
payment.due_date = datetime.datetime.now()
Modified: stoqlib/trunk/stoqlib/domain/purchase.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/purchase.py (original)
+++ stoqlib/trunk/stoqlib/domain/purchase.py Thu Apr 6 19:55:02 2006
@@ -39,7 +39,7 @@
from stoqlib.lib.translation import stoqlib_gettext
from stoqlib.domain.base import Domain, BaseSQLView
from stoqlib.domain.payment.base import AbstractPaymentGroup
-from stoqlib.domain.columns import PriceCol, DecimalCol
+from stoqlib.domain.columns import PriceCol, DecimalCol, AutoIncCol
from stoqlib.domain.interfaces import (ICheckPM, IBillPM, IMoneyPM,
IPaymentGroup)
from stoqlib.lib.validators import format_quantity
@@ -122,8 +122,7 @@
FREIGHT_CIF : _(u'CIF')}
status = IntCol(default=ORDER_QUOTING)
- # Field order_number must be unique. Waiting for bug 2214
- order_number = IntCol(default=None)
+ order_number = AutoIncCol('stoqlib_purchase_ordernumber_seq')
open_date = DateTimeCol(default=datetime.datetime.now)
quote_deadline = DateTimeCol(default=None)
expected_receival_date = DateTimeCol(default=None)
@@ -282,10 +281,7 @@
return self.transporter.get_adapted().name
def get_order_number_str(self):
- if self.order_number:
- return u'%03d' % self.order_number
- return u""
-
+ return u'%05d' % self.order_number
def get_purchase_subtotal(self):
total = sum([i.get_total() for i in self.get_items()], currency(0))
Modified: stoqlib/trunk/stoqlib/domain/sale.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/sale.py (original)
+++ stoqlib/trunk/stoqlib/domain/sale.py Thu Apr 6 19:55:02 2006
@@ -35,7 +35,7 @@
from stoqlib.lib.validators import get_formatted_price
from stoqlib.lib.defaults import METHOD_GIFT_CERTIFICATE
from stoqlib.lib.translation import stoqlib_gettext
-from stoqlib.domain.columns import PriceCol, DecimalCol
+from stoqlib.domain.columns import PriceCol, DecimalCol, AutoIncCol
from stoqlib.domain.base import Domain, BaseSQLView
from stoqlib.domain.sellable import AbstractSellableItem
from stoqlib.domain.payment.base import AbstractPaymentGroup
@@ -91,7 +91,7 @@
STATUS_REVIEWING: _(u"Reviewing")}
coupon_id = IntCol(default=None)
- order_number = IntCol(default=None)
+ order_number = AutoIncCol('stoqlib_sale_ordernumber_seq')
open_date = DateTimeCol(default=datetime.now)
close_date = DateTimeCol(default=None)
status = IntCol(default=STATUS_OPENED)
@@ -136,6 +136,9 @@
# Auxiliar methods
#
+ def get_order_number_str(self):
+ return u'%05d' % self.order_number
+
def get_salesperson_name(self):
return self.salesperson.get_adapted().name
Modified: stoqlib/trunk/stoqlib/domain/sellable.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/sellable.py (original)
+++ stoqlib/trunk/stoqlib/domain/sellable.py Thu Apr 6 19:55:02 2006
@@ -37,7 +37,7 @@
from stoqlib.lib.validators import is_date_in_interval, get_formatted_price
from stoqlib.lib.runtime import get_connection
from stoqlib.lib.parameters import sysparam
-from stoqlib.domain.columns import PriceCol, DecimalCol
+from stoqlib.domain.columns import PriceCol, DecimalCol, AutoIncCol
from stoqlib.domain.interfaces import ISellable, IContainer, IDescribable
from stoqlib.domain.base import (Domain, InheritableModelAdapter,
InheritableModel, BaseSQLView)
@@ -190,7 +190,8 @@
STATUS_CLOSED: _(u"Closed"),
STATUS_BLOCKED: _(u"Blocked")}
- code = UnicodeCol(alternateID=True)
+ code = AutoIncCol('stoqlib_sellable_code_seq')
+ barcode = UnicodeCol(default="")
status = IntCol(default=STATUS_AVAILABLE)
markup = DecimalCol(default=0)
cost = PriceCol(default=0)
@@ -287,6 +288,9 @@
# Accessors
#
+ def get_code_str(self):
+ return u"%05d" % self.code
+
def get_price_string(self):
return get_formatted_price(self.get_price())
@@ -339,52 +343,52 @@
@classmethod
- def _get_sellables_by_code(cls, conn, code, extra_query,
+ def _get_sellables_by_barcode(cls, conn, barcode, extra_query,
notify_callback):
- query = AND(cls.q.code == code, extra_query)
+ query = AND(cls.q.barcode == barcode, extra_query)
sellables = cls.select(query, connection=conn)
qty = sellables.count()
if not qty:
- msg = _("The sellable with code '%s' doesn't exists" % code)
+ msg = _("The sellable with barcode '%s' doesn't exists" % barcode)
notify_callback(msg)
return
if qty != 1:
raise DatabaseInconsistency('You should have only one '
- 'sellable with code %s'
- % code)
+ 'sellable with barcode %s'
+ % barcode)
return sellables[0]
@classmethod
- def get_availables_by_code(cls, conn, code, notify_callback):
+ def get_availables_by_barcode(cls, conn, barcode, notify_callback):
"""Returns a list of avaliable sellables that can be sold.
A sellable that can be sold can have only one possible
status: STATUS_AVAILABLE
@param conn: a sqlobject Transaction instance
- @param code: a string representing a sellable code
+ @param barcode: a string representing a sellable barcode
@notify_callback: a function which is a callback that will be called
- if the sellable code doesn't exists
+ if the sellable barcode doesn't exists
"""
extra_query = cls.q.status == cls.STATUS_AVAILABLE
- return cls._get_sellables_by_code(conn, code, extra_query,
+ return cls._get_sellables_by_barcode(conn, barcode, extra_query,
notify_callback)
@classmethod
- def get_availables_and_sold_by_code(cls, conn, code, notify_callback):
+ def get_availables_and_sold_by_barcode(cls, conn, barcode, notify_callback):
"""Returns a list of avaliable sellables and also sellables that
can be sold. Here we will get sellables with the following
statuses: STATUS_AVAILABLE, STATUS_SOLD
@param conn: a sqlobject Transaction instance
- @param code: a string representing a sellable code
+ @param barcode: a string representing a sellable barcode
@notify_callback: a function which is a callback that will be called
- if the sellable code doesn't exists
+ if the sellable barcode doesn't exists
"""
statuses = [cls.STATUS_AVAILABLE, cls.STATUS_SOLD]
extra_query = IN(cls.q.status, statuses)
- return cls._get_sellables_by_code(conn, code, extra_query,
+ return cls._get_sellables_by_barcode(conn, barcode, extra_query,
notify_callback)
#
@@ -392,13 +396,13 @@
#
- def _set_code(self, code):
+ def _set_barcode(self, barcode):
conn = get_connection()
- query = AbstractSellable.q.code == code
+ query = AbstractSellable.q.barcode == barcode
# FIXME We should raise a proper stoqlib exception here if we find
- # an existing code. Waiting for kiwi support
+ # an existing barcode. Waiting for kiwi support
if not AbstractSellable.select(query, connection=conn).count():
- self._SO_set_code(code)
+ self._SO_set_barcode(barcode)
def set_default_commission(self):
if not self.category:
@@ -418,7 +422,8 @@
companies
"""
stock = DecimalCol()
- code = UnicodeCol()
+ code = IntCol()
+ barcode = UnicodeCol()
status = IntCol()
cost = PriceCol()
price = PriceCol()
@@ -434,5 +439,8 @@
def get_unit(self):
return self.unit or u""
+
class SellableFullStockView(SellableView):
- pass
+ """Stores the total stock in all branch companies and other general
+ informations for sellables
+ """
Modified: stoqlib/trunk/stoqlib/domain/service.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/service.py (original)
+++ stoqlib/trunk/stoqlib/domain/service.py Thu Apr 6 19:55:02 2006
@@ -165,7 +165,8 @@
class ServiceView(SQLObject, BaseSQLView):
"""Stores service informations """
- code = UnicodeCol()
+ code = IntCol()
+ barcode = UnicodeCol()
status = IntCol()
cost = PriceCol()
price = PriceCol()
Modified: stoqlib/trunk/stoqlib/gui/base/search.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/base/search.py (original)
+++ stoqlib/trunk/stoqlib/gui/base/search.py Thu Apr 6 19:55:02 2006
@@ -932,6 +932,22 @@
def hide_new_button(self):
self._toolbar.new_button.hide()
+ def update_edited_item(self, model):
+ """Update the edited item to its proper type and select it on the
+ list results.
+ This method must be overwritten on subclasses when editors don't
+ return a valid instance or when returning more than one model.
+ """
+ if self._selected:
+ selected = self._selected
+ selected.sync()
+ self.klist.update(selected)
+ else:
+ # user just added a new instance
+ selected = self.get_searchlist_model(model)
+ self.klist.append(selected)
+ self.klist.select(selected)
+
def run(self, obj=None):
self._selected = obj
if obj:
@@ -951,15 +967,7 @@
rv = rv.get_adapted()
self.conn.commit()
- if self._selected:
- selected = self._selected
- selected.sync()
- self.klist.update(selected)
- else:
- # user just added a new instance
- selected = self.get_searchlist_model(rv)
- self.klist.append(selected)
- self.klist.select(selected)
+ self.update_edited_item(rv)
self.enable_ok()
def run_editor(self, obj):
Modified: stoqlib/trunk/stoqlib/gui/dialogs/tilloperation.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/dialogs/tilloperation.py (original)
+++ stoqlib/trunk/stoqlib/gui/dialogs/tilloperation.py Thu Apr 6 19:55:02 2006
@@ -151,18 +151,9 @@
else:
self.total_balance_label.set_color('black')
- def _get_payment_id(self, value):
- # Attribute payment_id will be mandatory soon.
- # Waiting for bug 2214.
- if not value:
- return 0
- return '%03d' % value
-
def _get_columns(self, *args):
- return [Column('payment_id', _('Number'), data_type=int, width=100,
- format_func=self._get_payment_id, sorted=True),
- # XXX Waiting for bug 2214
- # format='%03d'),
+ return [Column('identifier', _('Number'), data_type=int, width=100,
+ format='%03d', sorted=True),
Column('due_date', _('Due Date'),
data_type=datetime.date, width=120),
Column('description', _('Description'), data_type=str,
@@ -207,7 +198,7 @@
# This method is wrong.
# A good way to get the initial cash amount payment would be to
# use the payment_id.
- # Waiting for bug 2214.
+ # Waiting for bug 2524
for item in self.selected_item:
if item.description == _('Initial cash amount'):
return True
Modified: stoqlib/trunk/stoqlib/gui/editors/giftcertificate.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/editors/giftcertificate.py (original)
+++ stoqlib/trunk/stoqlib/gui/editors/giftcertificate.py Thu Apr 6 19:55:02 2006
@@ -109,10 +109,10 @@
self.last_number.set_sensitive(not single)
self.number.set_sensitive(single)
- def _create_gift_certificate(self, sellable_info, code):
+ def _create_gift_certificate(self, sellable_info, barcode):
certificate = GiftCertificate(connection=self.conn)
certificate.addFacet(ISellable, connection=self.conn,
- code=unicode(code),
+ barcode=unicode(barcode),
base_sellable_info=sellable_info)
#
Modified: stoqlib/trunk/stoqlib/gui/editors/product.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/editors/product.py (original)
+++ stoqlib/trunk/stoqlib/gui/editors/product.py Thu Apr 6 19:55:02 2006
@@ -221,7 +221,7 @@
sellable_info = BaseSellableInfo(connection=conn)
model.addFacet(ISellable, base_sellable_info=sellable_info,
- code='', connection=conn)
+ connection=conn)
model.addFacet(IStorable, connection=conn)
supplier = sysparam(conn).SUGGESTED_SUPPLIER
supplier_info = ProductSupplierInfo(connection=conn,
@@ -247,4 +247,4 @@
or decimal.Decimal("0.0"))
price = cost + ((markup / 100) * cost)
self.sellable_proxy.model.base_sellable_info.price = price
- self.sellable_proxy.update('price')
+ self.sellable_proxy.update('base_sellable_info.price')
Modified: stoqlib/trunk/stoqlib/gui/editors/sellable.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/editors/sellable.py (original)
+++ stoqlib/trunk/stoqlib/gui/editors/sellable.py Thu Apr 6 19:55:02 2006
@@ -34,6 +34,7 @@
from stoqlib.exceptions import DatabaseInconsistency
from stoqlib.gui.base.editors import BaseEditor
from stoqlib.gui.base.dialogs import run_dialog
+from stoqlib.database import finish_transaction
from stoqlib.domain.sellable import (SellableCategory, AbstractSellable,
SellableUnit)
from stoqlib.domain.interfaces import ISellable, IStorable
@@ -158,6 +159,7 @@
sellable_unit_widgets = ("unit_combo",
"unit_entry")
sellable_widgets = ('code',
+ 'barcode',
'description',
'category_combo',
'cost',
@@ -170,7 +172,7 @@
BaseEditor.__init__(self, conn, model)
self.notes.set_accepts_tab(False)
self.setup_widgets()
- self._original_code = self.sellable_proxy.model.code
+ self._original_barcode = self.sellable_proxy.model.barcode
def set_widget_formats(self):
for widget in (self.cost, self.stock_total_lbl, self.price):
@@ -280,16 +282,16 @@
self.edit_sale_price()
def validate_confirm(self, *args):
- code = self.code.get_text()
+ barcode = self.barcode.get_text()
confirmed = True
- if code != self._original_code:
+ if barcode and barcode != self._original_barcode:
conn = new_transaction()
- qty = AbstractSellable.selectBy(code=code, connection=conn).count()
+ qty = AbstractSellable.selectBy(barcode=barcode, connection=conn).count()
if qty:
- msg = _('This code already exists!')
- self.code.set_invalid(msg)
+ msg = _('This barcode already exists!')
+ self.barcode.set_invalid(msg)
confirmed = False
- conn._connection.close()
+ finish_transaction(conn)
if confirmed:
self.ensure_sellable_unit()
return confirmed
Modified: stoqlib/trunk/stoqlib/gui/editors/service.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/editors/service.py (original)
+++ stoqlib/trunk/stoqlib/gui/editors/service.py Thu Apr 6 19:55:02 2006
@@ -79,6 +79,6 @@
model = Service(connection=conn)
sellable_info = BaseSellableInfo(connection=conn,
description='', price=currency(0))
- model.addFacet(ISellable, code='', base_sellable_info=sellable_info,
+ model.addFacet(ISellable, base_sellable_info=sellable_info,
connection=conn)
return model
Modified: stoqlib/trunk/stoqlib/gui/search/giftcertificate.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/search/giftcertificate.py (original)
+++ stoqlib/trunk/stoqlib/gui/search/giftcertificate.py Thu Apr 6 19:55:02 2006
@@ -147,9 +147,14 @@
# SearchEditor Hooks
#
+ def update_edited_item(self, *args):
+ self.search_bar.search_items()
+
def get_columns(self):
- return [Column('code', _('Number'), data_type=str,
- width=120),
+ return [Column('code', _('Number'), data_type=int,
+ format='%03d', width=80),
+ Column('barcode', title=_('Barcode'), data_type=str,
+ visible=True, width=80),
Column('base_sellable_info.description',
_('Type Name'), data_type=str, width=260),
Column('base_sellable_info.price', _('Price'),
Modified: stoqlib/trunk/stoqlib/gui/search/product.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/search/product.py (original)
+++ stoqlib/trunk/stoqlib/gui/search/product.py Thu Apr 6 19:55:02 2006
@@ -118,8 +118,10 @@
return Product.get(model.product_id, connection=self.conn)
def get_columns(self):
- return [Column('code', title=_('Code'), data_type=str, sorted=True,
- width=80),
+ return [Column('code', title=_('Code'), data_type=int, sorted=True,
+ format='%03d', width=80),
+ Column('barcode', title=_('Barcode'), data_type=str,
+ visible=False, width=80),
Column('description', title=_('Description'), data_type=str,
expand=True),
Column('supplier_name', title=_('Supplier'), data_type=str,
Modified: stoqlib/trunk/stoqlib/gui/search/service.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/search/service.py (original)
+++ stoqlib/trunk/stoqlib/gui/search/service.py Thu Apr 6 19:55:02 2006
@@ -86,8 +86,10 @@
return Service.get(model.service_id, connection=self.conn)
def get_columns(self):
- columns = [Column('code', title=_('Code'), data_type=str, sorted=True,
- width=80),
+ columns = [Column('code', title=_('Code'), data_type=int, sorted=True,
+ format="%03d", width=80),
+ Column('barcode', title=_('Barcode'), data_type=str,
+ visible=False, width=80),
Column('description', title=_('Description'), data_type=str,
expand=True)]
Modified: stoqlib/trunk/stoqlib/gui/wizards/abstract.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/wizards/abstract.py (original)
+++ stoqlib/trunk/stoqlib/gui/wizards/abstract.py Thu Apr 6 19:55:02 2006
@@ -95,10 +95,10 @@
else:
sellable = None
if not sellable:
- code = self.product.get_text()
+ barcode = self.product.get_text()
table = self.table
- sellable = table.get_availables_and_sold_by_code(self.conn, code,
- self._product_notify)
+ sellable = table.get_availables_and_sold_by_barcode(self.conn,
+ barcode, self._product_notify)
if sellable:
# Waiting for a select method on kiwi entry using entry
# completions
Modified: stoqlib/trunk/stoqlib/gui/wizards/receiving.py
==============================================================================
--- stoqlib/trunk/stoqlib/gui/wizards/receiving.py (original)
+++ stoqlib/trunk/stoqlib/gui/wizards/receiving.py Thu Apr 6 19:55:02 2006
@@ -307,10 +307,11 @@
self._update_view()
def on_details_button__clicked(self, *args):
- order = self.orders.get_selected()
- if not order:
+ selected = self.orders.get_selected()
+ if not selected:
raise ValueError('You should have one order selected '
'at this point, got nothing')
+ order = PurchaseOrder.get(selected.id, connection=self.conn)
run_dialog(PurchaseDetailsDialog, self, self.conn, model=order)
Modified: stoqlib/trunk/stoqlib/lib/drivers.py
==============================================================================
--- stoqlib/trunk/stoqlib/lib/drivers.py (original)
+++ stoqlib/trunk/stoqlib/lib/drivers.py Thu Apr 6 19:55:02 2006
@@ -294,7 +294,8 @@
unit = sellable.unit.index
unit = unit or UNIT_EMPTY
max_len = get_capability(self.printer, "item_code")
- code = sellable.code[:max_len]
+ code_str = str(sellable.code)
+ code = code_str[:max_len]
# FIXME: TAX_NONE is a HACK, waiting for bug #2269
item_id = self.printer.add_item(code, item.quantity, item.price,
Modified: stoqlib/trunk/stoqlib/lib/parameters.py
==============================================================================
--- stoqlib/trunk/stoqlib/lib/parameters.py (original)
+++ stoqlib/trunk/stoqlib/lib/parameters.py Thu Apr 6 19:55:02 2006
@@ -184,13 +184,6 @@
'coupon will be printed on '
'that application instead of '
'Point of Sales')),
- 'EDIT_SALES_ORDER_NUMBER': ParameterDetails(_('Sales'),
- _('Edit Sales Order Number'),
- _('Once this parameter is set '
- 'to true, every time we '
- 'create a new sale order, the '
- 'user will be asked for a '
- 'order number')),
'ACCEPT_CHANGE_SALESPERSON': ParameterDetails(_('Sales'),
_('Accept Change Salesperson'),
_('Once this parameter is set '
@@ -291,7 +284,6 @@
ParameterAttr('STATE_SUGGESTED', str, initial='MG'),
ParameterAttr('COUNTRY_SUGGESTED', str, initial='Brasil'),
ParameterAttr('CONFIRM_SALES_ON_TILL', bool, initial=False),
- ParameterAttr('EDIT_SALES_ORDER_NUMBER', bool, initial=False),
ParameterAttr('MANDATORY_INTEREST_CHARGE', bool, initial=False),
ParameterAttr('USE_PURCHASE_PREVIEW_PAYMENTS', bool,
initial=True),
@@ -561,7 +553,7 @@
sellable_info = BaseSellableInfo(connection=self.conn,
description=_('Delivery'))
- sellable = service.addFacet(ISellable, code='SD',
+ sellable = service.addFacet(ISellable,
base_sellable_info=sellable_info,
connection=self.conn)
self._set_schema(key, sellable.id)
Modified: stoqlib/trunk/stoqlib/reporting/product.py
==============================================================================
--- stoqlib/trunk/stoqlib/reporting/product.py (original)
+++ stoqlib/trunk/stoqlib/reporting/product.py Thu Apr 6 19:55:02 2006
@@ -54,7 +54,8 @@
self._setup_items_table()
def _get_columns(self):
- return [OTC(_("Code"), lambda obj: obj.code, width=120, truncate=True),
+ return [OTC(_("Code"), lambda obj: '%03d' % obj.code, width=120,
+ truncate=True),
OTC(_("Description"), lambda obj: obj.description,
width=265, expand=True, expand_factor=1, truncate=True),
OTC(_("Supplier"),
Modified: stoqlib/trunk/stoqlib/reporting/purchase.py
==============================================================================
--- stoqlib/trunk/stoqlib/reporting/purchase.py (original)
+++ stoqlib/trunk/stoqlib/reporting/purchase.py Thu Apr 6 19:55:02 2006
@@ -206,7 +206,5 @@
#
def get_title(self):
- order_number = self._order.get_order_number_str()
- if order_number:
- order_number = "#" + order_number
+ order_number = '#' + self._order.get_order_number_str()
return _("Purchase Order %s") % order_number
More information about the POS-commit
mailing list