[tryton-debian-vcs] tryton-modules-product-cost-fifo branch debian updated. debian/4.4.0-4-5-gf95b6f4

Mathias Behrle tryton-debian-vcs at alioth.debian.org
Fri Nov 10 12:12:26 UTC 2017


The following commit has been merged in the debian branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-modules-product-cost-fifo.git;a=commitdiff;h=debian/4.4.0-4-5-gf95b6f4

commit f95b6f436f939307fe441087ce261116ccabc3e1
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Tue Nov 7 16:24:50 2017 +0100

    Releasing debian version 4.6.0-1.
    
    Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>

diff --git a/debian/changelog b/debian/changelog
index 613aba7..1351727 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+tryton-modules-product-cost-fifo (4.6.0-1) unstable; urgency=medium
+
+  * Bump the Standards-Version to 4.1.0, no changes needed.
+  * Bump the Standards-Version to 4.1.1, no changes needed.
+  * Merging upstream version 4.6.0.
+  * Use https in the watch file.
+
+ -- Mathias Behrle <mathiasb at m9s.biz>  Tue, 07 Nov 2017 10:20:16 +0100
+
 tryton-modules-product-cost-fifo (4.4.0-4) unstable; urgency=medium
 
   * Switch to Python3.
commit b8570b38e6603eac9287c38ff5d94feaaf8b8186
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Tue Nov 7 10:16:46 2017 +0100

    Use https in the watch file.

diff --git a/debian/watch b/debian/watch
index ee38b57..9d6f0a4 100644
--- a/debian/watch
+++ b/debian/watch
@@ -1,2 +1,2 @@
 version=3
-opts=pgpsigurlmangle=s/$/.asc/ http://downloads.tryton.org/current/ .*trytond_product_cost_fifo-(\d.*)\.(?:tgz|tbz2|txz|tar\.(?:gz|bz2|xz))
+opts=pgpsigurlmangle=s/$/.asc/ https://downloads.tryton.org/current/ .*trytond_product_cost_fifo-(\d.*)\.(?:tgz|tbz2|txz|tar\.(?:gz|bz2|xz))
commit f4ea17c22a1f2bd41b1faddc7949599967b43c75
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Mon Nov 6 14:41:03 2017 +0100

    Merging upstream version 4.6.0.

diff --git a/.drone.yml b/.drone.yml
new file mode 100644
index 0000000..e0bc2f7
--- /dev/null
+++ b/.drone.yml
@@ -0,0 +1,51 @@
+clone:
+    hg:
+        image: plugins/hg
+
+pipeline:
+    tox:
+        image: ${IMAGE}
+        environment:
+            - CFLAGS=-O0
+            - DB_CACHE=/cache
+            - TOX_TESTENV_PASSENV=CFLAGS DB_CACHE
+            - POSTGRESQL_URI=postgresql://postgres@postgresql:5432/
+        commands:
+            - pip install tox
+            - tox -e "${TOXENV}-${DATABASE}"
+        volumes:
+            - cache:/root/.cache
+
+services:
+    postgresql:
+        image: postgres
+        when:
+            matrix:
+                DATABASE: postgresql
+
+matrix:
+    include:
+        - IMAGE: python:2.7
+          TOXENV: py27
+          DATABASE: sqlite
+        - IMAGE: python:2.7
+          TOXENV: py27
+          DATABASE: postgresql
+        - IMAGE: python:3.4
+          TOXENV: py34
+          DATABASE: sqlite
+        - IMAGE: python:3.4
+          TOXENV: py34
+          DATABASE: postgresql
+        - IMAGE: python:3.5
+          TOXENV: py35
+          DATABASE: sqlite
+        - IMAGE: python:3.5
+          TOXENV: py35
+          DATABASE: postgresql
+        - IMAGE: python:3.6
+          TOXENV: py36
+          DATABASE: sqlite
+        - IMAGE: python:3.6
+          TOXENV: py36
+          DATABASE: postgresql
diff --git a/CHANGELOG b/CHANGELOG
index a432165..8b66e2a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 4.6.0 - 2017-10-30
+* Bug fixes (see mercurial logs for details)
+
 Version 4.4.0 - 2017-05-01
 * Bug fixes (see mercurial logs for details)
 
diff --git a/PKG-INFO b/PKG-INFO
index c2dbafd..c62633e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: trytond_product_cost_fifo
-Version: 4.4.0
+Version: 4.6.0
 Summary: Tryton module to add FIFO cost method
 Home-page: http://www.tryton.org/
 Author: Tryton
 Author-email: issue_tracker at tryton.org
 License: GPL-3
-Download-URL: http://downloads.tryton.org/4.4/
+Download-URL: http://downloads.tryton.org/4.6/
 Description: trytond_product_cost_fifo
         =========================
         
@@ -70,9 +70,9 @@ Classifier: Natural Language :: Slovenian
 Classifier: Natural Language :: Spanish
 Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: Implementation :: CPython
 Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Topic :: Office/Business
diff --git a/locale/bg.po b/locale/bg.po
index f910d0a..ef042f3 100644
--- a/locale/bg.po
+++ b/locale/bg.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,11 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr "FIFO количество"
 
-#, fuzzy
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr "FIFO"
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr "FIFO"
diff --git a/locale/ca.po b/locale/ca.po
index 0bad2eb..0242fe9 100644
--- a/locale/ca.po
+++ b/locale/ca.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -16,10 +16,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr "Quantitat FIFO"
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr "FIFO"
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr "FIFO"
diff --git a/locale/cs.po b/locale/cs.po
index 877a84d..02359e2 100644
--- a/locale/cs.po
+++ b/locale/cs.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr ""
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr ""
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr ""
diff --git a/locale/de.po b/locale/de.po
index adc3e21..0f4a9f2 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -16,10 +16,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr "Anzahl FIFO"
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr "FIFO"
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr "FIFO"
diff --git a/locale/es.po b/locale/es.po
index f4a2ab1..d66e1c3 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -16,10 +16,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr "Cantidad FIFO"
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr "FIFO"
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr "FIFO"
diff --git a/locale/es_419.po b/locale/es_419.po
index 304271d..538c092 100644
--- a/locale/es_419.po
+++ b/locale/es_419.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -16,10 +16,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr ""
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr ""
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr ""
diff --git a/locale/fr.po b/locale/fr.po
index 4b1e94a..42e9b42 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -16,10 +16,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr "Quantité FIFO"
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr "FIFO"
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr "FIFO"
diff --git a/locale/hu_HU.po b/locale/hu_HU.po
index d81c9ac..8cd49eb 100644
--- a/locale/hu_HU.po
+++ b/locale/hu_HU.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -16,11 +16,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr "FIFO mennyiség"
 
-#, fuzzy
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr "FIFO"
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr "FIFO"
diff --git a/locale/it_IT.po b/locale/it_IT.po
index 877a84d..02359e2 100644
--- a/locale/it_IT.po
+++ b/locale/it_IT.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr ""
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr ""
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr ""
diff --git a/locale/ja_JP.po b/locale/ja_JP.po
index 877a84d..02359e2 100644
--- a/locale/ja_JP.po
+++ b/locale/ja_JP.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr ""
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr ""
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr ""
diff --git a/locale/lo.po b/locale/lo.po
index 877a84d..02359e2 100644
--- a/locale/lo.po
+++ b/locale/lo.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr ""
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr ""
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr ""
diff --git a/locale/lt.po b/locale/lt.po
index 877a84d..02359e2 100644
--- a/locale/lt.po
+++ b/locale/lt.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr ""
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr ""
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr ""
diff --git a/locale/nl.po b/locale/nl.po
index 877a84d..02359e2 100644
--- a/locale/nl.po
+++ b/locale/nl.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr ""
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr ""
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr ""
diff --git a/locale/pl.po b/locale/pl.po
index fe3269b..665a0a3 100644
--- a/locale/pl.po
+++ b/locale/pl.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr "Ilość FIFO"
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr "FIFO"
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr "FIFO"
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index 76029b8..172a230 100644
--- a/locale/pt_BR.po
+++ b/locale/pt_BR.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -16,10 +16,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr "Quantidade PEPS"
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr "PEPS"
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr "PEPS"
diff --git a/locale/ru.po b/locale/ru.po
index 877a84d..02359e2 100644
--- a/locale/ru.po
+++ b/locale/ru.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr ""
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr ""
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr ""
diff --git a/locale/sl.po b/locale/sl.po
index 9569b8e..d518c02 100644
--- a/locale/sl.po
+++ b/locale/sl.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr "FIFO količina"
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr "FIFO"
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr "FIFO"
diff --git a/locale/zh_CN.po b/locale/zh_CN.po
index 877a84d..02359e2 100644
--- a/locale/zh_CN.po
+++ b/locale/zh_CN.po
@@ -1,4 +1,4 @@
-# 
+#
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
@@ -14,10 +14,6 @@ msgctxt "field:stock.move,fifo_quantity:"
 msgid "FIFO Quantity"
 msgstr ""
 
-msgctxt "selection:product.product,cost_price_method:"
-msgid "FIFO"
-msgstr ""
-
 msgctxt "selection:product.template,cost_price_method:"
 msgid "FIFO"
 msgstr ""
diff --git a/move.py b/move.py
index 93d9c7b..688f312 100644
--- a/move.py
+++ b/move.py
@@ -16,6 +16,8 @@ class Move:
     @classmethod
     def __setup__(cls):
         super(Move, cls).__setup__()
+        cls._allow_modify_closed_period.add('fifo_quantity')
+
         t = cls.__table__()
         cls._sql_constraints += [
             ('check_fifo_quantity_out',
@@ -44,11 +46,11 @@ class Move:
         total_qty = Uom.compute_qty(self.uom, self.quantity,
             self.product.default_uom, round=False)
 
-        fifo_moves = self.product.template.get_fifo_move(total_qty)
+        fifo_moves = self.product.get_fifo_move(total_qty)
 
         cost_price = Decimal("0.0")
         consumed_qty = 0.0
-        to_write = []
+        to_save = []
         for move, move_qty in fifo_moves:
             consumed_qty += move_qty
 
@@ -60,46 +62,49 @@ class Move:
                     move.product.default_uom)
             cost_price += move_unit_price * Decimal(str(move_qty))
 
-            move.quantity = move_qty
-            move._update_product_cost_price('out')
-
             move_qty = Uom.compute_qty(self.product.default_uom, move_qty,
                     move.uom, round=False)
-            # Use write as move instance quantity was modified to call
-            # _update_product_cost_price
-            new_quantity = (move.fifo_quantity or 0.0) + move_qty
-            to_write.extend(([self.__class__(move.id)], {
-                        'fifo_quantity': new_quantity,
-                        }))
-        if to_write:
-            self.__class__.write(*to_write)
+            move.fifo_quantity = (move.fifo_quantity or 0.0) + move_qty
+            to_save.append(move)
+        if to_save:
+            # TODO save in do method when product change
+            self.__class__.save(to_save)
 
         if Decimal(str(consumed_qty)) != Decimal("0"):
             cost_price = cost_price / Decimal(str(consumed_qty))
 
+        # Compute average cost price
+        unit_price = self.unit_price
+        self.unit_price = cost_price
+        average_cost_price = self._compute_product_cost_price('out')
+        self.unit_price = unit_price
+
         if cost_price != Decimal("0"):
             digits = self.__class__.cost_price.digits
-            return cost_price.quantize(
+            cost_price = cost_price.quantize(
                 Decimal(str(10.0 ** -digits[1])))
         else:
-            return self.product.cost_price
+            cost_price = average_cost_price
+        return cost_price, average_cost_price
 
     def _do(self):
+        cost_price = super(Move, self)._do()
         if (self.from_location.type in ('supplier', 'production')
                 and self.to_location.type == 'storage'
                 and self.product.cost_price_method == 'fifo'):
-            self._update_product_cost_price('in')
+            cost_price = self._compute_product_cost_price('in')
         elif (self.to_location.type == 'supplier'
                 and self.from_location.type == 'storage'
                 and self.product.cost_price_method == 'fifo'):
-            self._update_product_cost_price('out')
+            cost_price = self._compute_product_cost_price('out')
         elif (self.from_location.type == 'storage'
                 and self.to_location.type != 'storage'
                 and self.product.cost_price_method == 'fifo'):
-            cost_price = self._update_fifo_out_product_cost_price()
+            fifo_cost_price, cost_price = (
+                self._update_fifo_out_product_cost_price())
             if self.cost_price is None:
-                self.cost_price = cost_price
-        super(Move, self)._do()
+                self.cost_price = fifo_cost_price
+        return cost_price
 
     @classmethod
     @ModelView.button
diff --git a/product.py b/product.py
index 4ef19e8..316057a 100644
--- a/product.py
+++ b/product.py
@@ -16,7 +16,12 @@ class Template:
         super(Template, cls).__setup__()
         new_sel = ('fifo', 'FIFO')
         if new_sel not in cls.cost_price_method.selection:
-            cls.cost_price_method.selection.append(new_sel)
+            cls.cost_price_method._field.selection.append(new_sel)
+
+
+class Product:
+    __metaclass__ = PoolMeta
+    __name__ = 'product.product'
 
     def get_fifo_move(self, quantity=0.0):
         '''
@@ -29,7 +34,6 @@ class Template:
         Move = pool.get('stock.move')
         Uom = pool.get('product.uom')
         Location = pool.get('stock.location')
-        Template = pool.get('product.template')
 
         locations = Location.search([
             ('type', '=', 'storage'),
@@ -38,15 +42,15 @@ class Template:
         location_ids = [l.id for l in locations]
         with Transaction().set_context(locations=location_ids,
                 stock_date_end=stock_date_end):
-            template = Template(self.id)
+            product = self.__class__(self.id)
         offset = 0
         limit = Transaction().database.IN_MAX
-        avail_qty = template.quantity
+        avail_qty = product.quantity
         fifo_moves = []
 
         while avail_qty > 0.0:
             moves = Move.search([
-                ('product.template.id', '=', template.id),
+                ('product', '=', product.id),
                 ('state', '=', 'done'),
                 ('from_location.type', '=', 'supplier'),
                 ], offset=offset, limit=limit,
@@ -58,7 +62,7 @@ class Template:
             for move in moves:
                 qty = Uom.compute_qty(move.uom,
                         move.quantity - move.fifo_quantity,
-                        template.default_uom, round=False)
+                        product.default_uom, round=False)
                 avail_qty -= qty
 
                 if avail_qty <= quantity:
@@ -73,10 +77,5 @@ class Template:
         fifo_moves.reverse()
         return fifo_moves
 
-
-class Product:
-    __metaclass__ = PoolMeta
-    __name__ = 'product.product'
-
     def recompute_cost_price_fifo(self):
         return self.recompute_cost_price_average()
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..8bfd5a1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,4 @@
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index b1ea0b3..d86b3d7 100644
--- a/setup.py
+++ b/setup.py
@@ -102,9 +102,9 @@ setup(name=name,
         'Natural Language :: Spanish',
         'Operating System :: OS Independent',
         'Programming Language :: Python :: 2.7',
-        'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
         'Programming Language :: Python :: Implementation :: CPython',
         'Programming Language :: Python :: Implementation :: PyPy',
         'Topic :: Office/Business',
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..0d5ed55
--- /dev/null
+++ b/tests/__init__.py
@@ -0,0 +1,9 @@
+# This file is part of Tryton.  The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+
+try:
+    from trytond.modules.product_cost_fifo.tests.test_product_cost_fifo import suite
+except ImportError:
+    from .test_product_cost_fifo import suite
+
+__all__ = ['suite']
diff --git a/tests/scenario_product_cost_fifo.rst b/tests/scenario_product_cost_fifo.rst
new file mode 100644
index 0000000..4a76303
--- /dev/null
+++ b/tests/scenario_product_cost_fifo.rst
@@ -0,0 +1,149 @@
+=====================
+Stock FIFO Cost Price
+=====================
+
+Imports::
+
+    >>> import datetime
+    >>> from dateutil.relativedelta import relativedelta
+    >>> from decimal import Decimal
+    >>> from proteus import Model, Wizard
+    >>> from trytond.tests.tools import activate_modules
+    >>> from trytond.modules.company.tests.tools import create_company, \
+    ...     get_company
+    >>> today = datetime.date.today()
+
+Install product_cost_fifo Module::
+
+    >>> config = activate_modules('product_cost_fifo')
+
+Create company::
+
+    >>> _ = create_company()
+    >>> company = get_company()
+
+Create product::
+
+    >>> ProductUom = Model.get('product.uom')
+    >>> ProductTemplate = Model.get('product.template')
+    >>> unit, = ProductUom.find([('name', '=', 'Unit')])
+
+    >>> template = ProductTemplate()
+    >>> template.name = 'Product'
+    >>> template.default_uom = unit
+    >>> template.type = 'goods'
+    >>> template.list_price = Decimal('300')
+    >>> template.cost_price_method = 'fifo'
+    >>> product, = template.products
+    >>> product.cost_price = Decimal('80')
+    >>> template.save()
+    >>> product, = template.products
+
+Get stock locations::
+
+    >>> Location = Model.get('stock.location')
+    >>> supplier_loc, = Location.find([('code', '=', 'SUP')])
+    >>> customer_loc, = Location.find([('code', '=', 'CUS')])
+    >>> storage_loc, = Location.find([('code', '=', 'STO')])
+
+Make 4 units of the product available @ 10 ::
+
+    >>> StockMove = Model.get('stock.move')
+    >>> incoming_move = StockMove()
+    >>> incoming_move.product = product
+    >>> incoming_move.uom = unit
+    >>> incoming_move.quantity = 4
+    >>> incoming_move.from_location = supplier_loc
+    >>> incoming_move.to_location = storage_loc
+    >>> incoming_move.planned_date = today
+    >>> incoming_move.company = company
+    >>> incoming_move.unit_price = Decimal('10')
+    >>> incoming_move.currency = company.currency
+    >>> incoming_move.click('do')
+
+Check Cost Price is 10::
+
+    >>> product.reload()
+    >>> product.cost_price
+    Decimal('10.0000')
+
+Add 2 more units @ 25::
+
+    >>> incoming_move = StockMove()
+    >>> incoming_move.product = product
+    >>> incoming_move.uom = unit
+    >>> incoming_move.quantity = 2
+    >>> incoming_move.from_location = supplier_loc
+    >>> incoming_move.to_location = storage_loc
+    >>> incoming_move.planned_date = today
+    >>> incoming_move.company = company
+    >>> incoming_move.unit_price = Decimal('25')
+    >>> incoming_move.currency = company.currency
+    >>> incoming_move.click('do')
+
+Check Cost Price FIFO is 15::
+
+    >>> product.reload()
+    >>> product.cost_price
+    Decimal('15.0000')
+
+Sell 3 units @ 50::
+
+    >>> outgoing_move = StockMove()
+    >>> outgoing_move.product = product
+    >>> outgoing_move.uom = unit
+    >>> outgoing_move.quantity = 3
+    >>> outgoing_move.from_location = storage_loc
+    >>> outgoing_move.to_location = customer_loc
+    >>> outgoing_move.planned_date = today
+    >>> outgoing_move.company = company
+    >>> outgoing_move.unit_price = Decimal('50')
+    >>> outgoing_move.currency = company.currency
+    >>> outgoing_move.click('do')
+
+Check Cost Price FIFO is 20 and cost is 10::
+
+    >>> product.reload()
+    >>> product.cost_price
+    Decimal('20.0000')
+    >>> outgoing_move.cost_price
+    Decimal('10.0000')
+
+Sell twice 1 more units @ 50::
+
+    >>> outgoing_moves = []
+    >>> outgoing_move = StockMove()
+    >>> outgoing_move.product = product
+    >>> outgoing_move.uom = unit
+    >>> outgoing_move.quantity = 1
+    >>> outgoing_move.from_location = storage_loc
+    >>> outgoing_move.to_location = customer_loc
+    >>> outgoing_move.planned_date = today
+    >>> outgoing_move.company = company
+    >>> outgoing_move.unit_price = Decimal('50')
+    >>> outgoing_move.currency = company.currency
+    >>> outgoing_move.save()
+    >>> outgoing_moves.append(outgoing_move)
+
+    >>> outgoing_move = StockMove()
+    >>> outgoing_move.product = product
+    >>> outgoing_move.uom = unit
+    >>> outgoing_move.quantity = 1
+    >>> outgoing_move.from_location = storage_loc
+    >>> outgoing_move.to_location = customer_loc
+    >>> outgoing_move.planned_date = today
+    >>> outgoing_move.company = company
+    >>> outgoing_move.unit_price = Decimal('50')
+    >>> outgoing_move.currency = company.currency
+    >>> outgoing_move.save()
+    >>> outgoing_moves.append(outgoing_move)
+
+    >>> StockMove.click(outgoing_moves, 'do')
+
+Check Cost Price FIFO is 25 and costs are 10 and 25::
+
+    >>> product.reload()
+    >>> product.cost_price
+    Decimal('25.0000')
+    >>> [m.cost_price for m in outgoing_moves]
+    [Decimal('10.0000'), Decimal('25.0000')]
diff --git a/tests/test_product_cost_fifo.py b/tests/test_product_cost_fifo.py
new file mode 100644
index 0000000..6d97f36
--- /dev/null
+++ b/tests/test_product_cost_fifo.py
@@ -0,0 +1,25 @@
+# This file is part of Tryton.  The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+import unittest
+import doctest
+import trytond.tests.test_tryton
+from trytond.tests.test_tryton import ModuleTestCase
+from trytond.tests.test_tryton import doctest_teardown
+from trytond.tests.test_tryton import doctest_checker
+
+
+class ProductCostFIFOTestCase(ModuleTestCase):
+    'Test ProductCostFIFO module'
+    module = 'product_cost_fifo'
+
+
+def suite():
+    suite = trytond.tests.test_tryton.suite()
+    suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
+        ProductCostFIFOTestCase))
+    suite.addTests(doctest.DocFileSuite(
+            'scenario_product_cost_fifo.rst',
+            tearDown=doctest_teardown, encoding='utf-8',
+            checker=doctest_checker,
+            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
+    return suite
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..527d859
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,18 @@
+[tox]
+envlist = {py27,py34,py35,py36}-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql}
+
+[testenv]
+commands = {envpython} setup.py test
+deps =
+    {py27,py34,py35,py36}-postgresql: psycopg2 >= 2.5
+    pypy-postgresql: psycopg2cffi >= 2.5
+    mysql: MySQL-python
+    sqlite: sqlitebck
+setenv =
+    sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}
+    postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://}
+    mysql: TRYTOND_DATABASE_URI={env:MYSQL_URI:mysql://}
+    sqlite: DB_NAME={env:SQLITE_NAME::memory:}
+    postgresql: DB_NAME={env:POSTGRESQL_NAME:test}
+    mysql: DB_NAME={env:MYSQL_NAME:test}
+install_command = pip install --pre --find-links https://trydevpi.tryton.org/ {opts} {packages}
diff --git a/tryton.cfg b/tryton.cfg
index 11be948..acf7254 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
 [tryton]
-version=4.4.0
+version=4.6.0
 depends:
     ir
     product
diff --git a/trytond_product_cost_fifo.egg-info/PKG-INFO b/trytond_product_cost_fifo.egg-info/PKG-INFO
index bc95b3c..b94b94c 100644
--- a/trytond_product_cost_fifo.egg-info/PKG-INFO
+++ b/trytond_product_cost_fifo.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: trytond-product-cost-fifo
-Version: 4.4.0
+Version: 4.6.0
 Summary: Tryton module to add FIFO cost method
 Home-page: http://www.tryton.org/
 Author: Tryton
 Author-email: issue_tracker at tryton.org
 License: GPL-3
-Download-URL: http://downloads.tryton.org/4.4/
+Download-URL: http://downloads.tryton.org/4.6/
 Description: trytond_product_cost_fifo
         =========================
         
@@ -70,9 +70,9 @@ Classifier: Natural Language :: Slovenian
 Classifier: Natural Language :: Spanish
 Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: Implementation :: CPython
 Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Topic :: Office/Business
diff --git a/trytond_product_cost_fifo.egg-info/SOURCES.txt b/trytond_product_cost_fifo.egg-info/SOURCES.txt
index 88861d5..c20dafb 100644
--- a/trytond_product_cost_fifo.egg-info/SOURCES.txt
+++ b/trytond_product_cost_fifo.egg-info/SOURCES.txt
@@ -1,10 +1,16 @@
+.drone.yml
+.hgtags
 CHANGELOG
 COPYRIGHT
 INSTALL
 LICENSE
 MANIFEST.in
 README
+__init__.py
+move.py
+product.py
 setup.py
+tox.ini
 tryton.cfg
 ./__init__.py
 ./move.py
@@ -47,6 +53,9 @@ locale/pt_BR.po
 locale/ru.po
 locale/sl.po
 locale/zh_CN.po
+tests/__init__.py
+tests/scenario_product_cost_fifo.rst
+tests/test_product_cost_fifo.py
 trytond_product_cost_fifo.egg-info/PKG-INFO
 trytond_product_cost_fifo.egg-info/SOURCES.txt
 trytond_product_cost_fifo.egg-info/dependency_links.txt
diff --git a/trytond_product_cost_fifo.egg-info/requires.txt b/trytond_product_cost_fifo.egg-info/requires.txt
index 89264c2..679d947 100644
--- a/trytond_product_cost_fifo.egg-info/requires.txt
+++ b/trytond_product_cost_fifo.egg-info/requires.txt
@@ -1,3 +1,3 @@
-trytond_product >= 4.4, < 4.5
-trytond_stock >= 4.4, < 4.5
-trytond >= 4.4, < 4.5
+trytond_product >= 4.6, < 4.7
+trytond_stock >= 4.6, < 4.7
+trytond >= 4.6, < 4.7
-- 
tryton-modules-product-cost-fifo



More information about the tryton-debian-vcs mailing list