[tryton-debian-vcs] tryton-modules-stock branch upstream-2.2 created. 65d7f590344b18300b9a17e3698d3b87bfa263b9
Mathias Behrle
tryton-debian-vcs at alioth.debian.org
Wed Nov 27 17:10:23 UTC 2013
The following commit has been merged in the upstream-2.2 branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-modules-stock.git;a=commitdiff;h=65d7f590344b18300b9a17e3698d3b87bfa263b9
commit 65d7f590344b18300b9a17e3698d3b87bfa263b9
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Wed Aug 7 17:11:39 2013 +0200
Adding upstream version 2.2.8.
diff --git a/CHANGELOG b/CHANGELOG
index e5ea6ca..7638747 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 2.2.8 - 2013-07-22
+* Bug fixes (see mercurial logs for details)
+
Version 2.2.7 - 2013-06-09
* Bug fixes (see mercurial logs for details)
diff --git a/PKG-INFO b/PKG-INFO
index 29fb981..123e0a3 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond_stock
-Version: 2.2.7
+Version: 2.2.8
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
diff --git a/__tryton__.py b/__tryton__.py
index 018f582..8ccf91b 100644
--- a/__tryton__.py
+++ b/__tryton__.py
@@ -8,7 +8,7 @@
'name_es_ES': 'Gestión de existencias',
'name_fr_FR': 'Gestion des stocks',
'name_ru_RU': 'Управление складами',
- 'version': '2.2.7',
+ 'version': '2.2.8',
'author': 'B2CK',
'email': 'info at b2ck.com',
'website': 'http://www.tryton.org/',
diff --git a/product.py b/product.py
index ae63abf..bbe74b1 100644
--- a/product.py
+++ b/product.py
@@ -365,8 +365,8 @@ class Product(ModelSQL, ModelView):
period_id, = period_ids
period = period_obj.browse(period_id)
state_date_clause += (' AND '
- '(COALESCE(effective_date, planned_date) > %s)')
- state_date_vals.append(period.date)
+ '(COALESCE(effective_date, planned_date, %s) > %s)')
+ state_date_vals.extend([datetime.date.max, period.date])
period_vals[0] = period.id
if with_childs:
diff --git a/trytond_stock.egg-info/PKG-INFO b/trytond_stock.egg-info/PKG-INFO
index 10be356..bbfc863 100644
--- a/trytond_stock.egg-info/PKG-INFO
+++ b/trytond_stock.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond-stock
-Version: 2.2.7
+Version: 2.2.8
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
commit 2b8d9e5aac9c9ec6dca775319bbd4908a4f6872c
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Tue Jun 11 13:53:37 2013 +0200
Adding upstream version 2.2.7.
diff --git a/CHANGELOG b/CHANGELOG
index ec24a3c..e5ea6ca 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 2.2.7 - 2013-06-09
+* Bug fixes (see mercurial logs for details)
+
Version 2.2.6 - 2013-05-02
* Bug fixes (see mercurial logs for details)
diff --git a/PKG-INFO b/PKG-INFO
index 7a0d4a0..29fb981 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond_stock
-Version: 2.2.6
+Version: 2.2.7
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
diff --git a/__tryton__.py b/__tryton__.py
index eb53327..018f582 100644
--- a/__tryton__.py
+++ b/__tryton__.py
@@ -8,7 +8,7 @@
'name_es_ES': 'Gestión de existencias',
'name_fr_FR': 'Gestion des stocks',
'name_ru_RU': 'Управление складами',
- 'version': '2.2.6',
+ 'version': '2.2.7',
'author': 'B2CK',
'email': 'info at b2ck.com',
'website': 'http://www.tryton.org/',
diff --git a/product.py b/product.py
index af809f0..ae63abf 100644
--- a/product.py
+++ b/product.py
@@ -356,16 +356,18 @@ class Product(ModelSQL, ModelView):
context['stock_date_start'], today,
])
else:
- period_ids = period_obj.search([
- ('date', '<', context['stock_date_end']),
- ], order=[('date', 'DESC')], limit=1)
- if period_ids:
- period_id, = period_ids
- period = period_obj.browse(period_id)
- state_date_clause += (' AND '
- '(COALESCE(effective_date, planned_date) > %s)')
- state_date_vals.append(period.date)
- period_vals[0] = period.id
+ with Transaction().set_user(0, set_context=True):
+ period_ids = period_obj.search([
+ ('date', '<', context['stock_date_end']),
+ ('state', '=', 'closed'),
+ ], order=[('date', 'DESC')], limit=1)
+ if period_ids:
+ period_id, = period_ids
+ period = period_obj.browse(period_id)
+ state_date_clause += (' AND '
+ '(COALESCE(effective_date, planned_date) > %s)')
+ state_date_vals.append(period.date)
+ period_vals[0] = period.id
if with_childs:
query, args = location_obj.search([
diff --git a/trytond_stock.egg-info/PKG-INFO b/trytond_stock.egg-info/PKG-INFO
index fe73e09..10be356 100644
--- a/trytond_stock.egg-info/PKG-INFO
+++ b/trytond_stock.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond-stock
-Version: 2.2.6
+Version: 2.2.7
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
commit 65bb9f7c6c93bb9de147b5da9326612b30b20cf3
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Sat May 4 16:48:09 2013 +0200
Adding upstream version 2.2.6.
diff --git a/CHANGELOG b/CHANGELOG
index 81fa9d6..ec24a3c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 2.2.6 - 2013-05-02
+* Bug fixes (see mercurial logs for details)
+
Version 2.2.5 - 2013-02-12
* Bug fixes (see mercurial logs for details)
diff --git a/COPYRIGHT b/COPYRIGHT
index 101ffe2..590768d 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,7 +1,7 @@
Copyright (C) 2012 Openlabs Technologies & Consulting (P) LTD.
-Copyright (C) 2008-2012 Cédric Krier.
+Copyright (C) 2008-2013 Cédric Krier.
Copyright (C) 2008-2011 Bertrand Chenal.
-Copyright (C) 2008-2012 B2CK SPRL.
+Copyright (C) 2008-2013 B2CK SPRL.
Copyright (C) 2004-2008 Tiny SPRL.
This program is free software: you can redistribute it and/or modify
diff --git a/PKG-INFO b/PKG-INFO
index 632eb3f..7a0d4a0 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond_stock
-Version: 2.2.5
+Version: 2.2.6
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
diff --git a/__tryton__.py b/__tryton__.py
index 8b271a7..eb53327 100644
--- a/__tryton__.py
+++ b/__tryton__.py
@@ -8,7 +8,7 @@
'name_es_ES': 'Gestión de existencias',
'name_fr_FR': 'Gestion des stocks',
'name_ru_RU': 'Управление складами',
- 'version': '2.2.5',
+ 'version': '2.2.6',
'author': 'B2CK',
'email': 'info at b2ck.com',
'website': 'http://www.tryton.org/',
diff --git a/product.py b/product.py
index 0abfb8d..af809f0 100644
--- a/product.py
+++ b/product.py
@@ -255,9 +255,9 @@ class Product(ModelSQL, ModelView):
'(' \
'(effective_date IS NULL) '\
'AND '\
- '(planned_date <= %s) '\
+ '(COALESCE(planned_date, %s) <= %s) '\
'AND '\
- '(planned_date >= %s)'\
+ '(COALESCE(planned_date, %s) >= %s)'\
')'\
'OR '\
'(' \
@@ -273,7 +273,8 @@ class Product(ModelSQL, ModelView):
'done', context.get('stock_assign') and 'assigned' or 'done',
today, today,
'done', 'assigned', 'draft',
- context['stock_date_end'], today,
+ datetime.date.max, context['stock_date_end'],
+ datetime.date.max, today,
context['stock_date_end'], today,
]
diff --git a/trytond_stock.egg-info/PKG-INFO b/trytond_stock.egg-info/PKG-INFO
index 408c351..fe73e09 100644
--- a/trytond_stock.egg-info/PKG-INFO
+++ b/trytond_stock.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond-stock
-Version: 2.2.5
+Version: 2.2.6
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
commit d8fad8fe24317424a1ac92beb6f637475dcb289c
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Sun Feb 24 21:43:59 2013 +0100
Adding upstream version 2.2.5.
diff --git a/CHANGELOG b/CHANGELOG
index 39fa2d2..81fa9d6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 2.2.5 - 2013-02-12
+* Bug fixes (see mercurial logs for details)
+
Version 2.2.4 - 2012-11-05
* Bug fixes (see mercurial logs for details)
diff --git a/PKG-INFO b/PKG-INFO
index 2c561cf..632eb3f 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond_stock
-Version: 2.2.4
+Version: 2.2.5
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
diff --git a/__tryton__.py b/__tryton__.py
index 6e7d228..8b271a7 100644
--- a/__tryton__.py
+++ b/__tryton__.py
@@ -8,7 +8,7 @@
'name_es_ES': 'Gestión de existencias',
'name_fr_FR': 'Gestion des stocks',
'name_ru_RU': 'Управление складами',
- 'version': '2.2.4',
+ 'version': '2.2.5',
'author': 'B2CK',
'email': 'info at b2ck.com',
'website': 'http://www.tryton.org/',
diff --git a/location.py b/location.py
index e055796..4d1198c 100644
--- a/location.py
+++ b/location.py
@@ -205,11 +205,11 @@ class Location(ModelSQL, ModelView):
location_ids.add(location.output_location.id)
if not location.storage_location.parent:
location_ids.add(location.storage_location.id)
- location_ids = list(location_ids)
- if location_ids:
- self.write(location_ids, {
- 'parent': location.id,
- })
+ if location_ids:
+ self.write(list(location_ids), {
+ 'parent': location.id,
+ })
+ location_ids.clear()
def create(self, vals):
res = super(Location, self).create(vals)
diff --git a/trytond_stock.egg-info/PKG-INFO b/trytond_stock.egg-info/PKG-INFO
index a50ea72..408c351 100644
--- a/trytond_stock.egg-info/PKG-INFO
+++ b/trytond_stock.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond-stock
-Version: 2.2.4
+Version: 2.2.5
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
commit da8637271a61d6f7218922b7552a0998b8f5e0e7
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Sun Feb 24 19:50:31 2013 +0100
Adding upstream version 2.2.4.
diff --git a/CHANGELOG b/CHANGELOG
index e5a7327..39fa2d2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 2.2.4 - 2012-11-05
+* Bug fixes (see mercurial logs for details)
+
Version 2.2.3 - 2012-09-02
* Bug fixes (see mercurial logs for details)
diff --git a/PKG-INFO b/PKG-INFO
index 6f94c8d..2c561cf 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
Name: trytond_stock
-Version: 2.2.3
+Version: 2.2.4
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
diff --git a/__tryton__.py b/__tryton__.py
index da1be26..6e7d228 100644
--- a/__tryton__.py
+++ b/__tryton__.py
@@ -8,7 +8,7 @@
'name_es_ES': 'Gestión de existencias',
'name_fr_FR': 'Gestion des stocks',
'name_ru_RU': 'Управление складами',
- 'version': '2.2.3',
+ 'version': '2.2.4',
'author': 'B2CK',
'email': 'info at b2ck.com',
'website': 'http://www.tryton.org/',
diff --git a/product.py b/product.py
index fdd5f4f..0abfb8d 100644
--- a/product.py
+++ b/product.py
@@ -478,16 +478,21 @@ class Product(ModelSQL, ModelView):
if location.parent.id in leafs:
leafs.remove(location.parent.id)
parent[location.id] = location.parent.id
-
+ locations = set((l.id for l in locations))
while leafs:
- next_leafs = set()
for l in leafs:
+ locations.remove(l)
if l not in parent:
continue
- next_leafs.add(parent[l])
for product in res_product_ids:
res.setdefault((parent[l], product), 0)
res[(parent[l], product)] += res.get((l,product), 0)
+ next_leafs = set(locations)
+ for l in locations:
+ if l not in parent:
+ continue
+ if parent[l] in next_leafs and parent[l] in locations:
+ next_leafs.remove(parent[l])
leafs = next_leafs
# clean result
diff --git a/trytond_stock.egg-info/PKG-INFO b/trytond_stock.egg-info/PKG-INFO
index 3448616..a50ea72 100644
--- a/trytond_stock.egg-info/PKG-INFO
+++ b/trytond_stock.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
Name: trytond-stock
-Version: 2.2.3
+Version: 2.2.4
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
commit fdff1cac696ff3796bdd4eed17d4eb4689258288
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Tue Sep 11 19:36:38 2012 +0200
Adding upstream version 2.2.3.
diff --git a/CHANGELOG b/CHANGELOG
index dd046e9..e5a7327 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 2.2.3 - 2012-09-02
+* Bug fixes (see mercurial logs for details)
+
Version 2.2.2 - 2012-05-07
* Bug fixes (see mercurial logs for details)
diff --git a/PKG-INFO b/PKG-INFO
index 2475c99..6f94c8d 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.0
Name: trytond_stock
-Version: 2.2.2
+Version: 2.2.3
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
diff --git a/__tryton__.py b/__tryton__.py
index 658437e..da1be26 100644
--- a/__tryton__.py
+++ b/__tryton__.py
@@ -8,7 +8,7 @@
'name_es_ES': 'Gestión de existencias',
'name_fr_FR': 'Gestion des stocks',
'name_ru_RU': 'Управление складами',
- 'version': '2.2.2',
+ 'version': '2.2.3',
'author': 'B2CK',
'email': 'info at b2ck.com',
'website': 'http://www.tryton.org/',
diff --git a/location.py b/location.py
index 0f14437..e055796 100644
--- a/location.py
+++ b/location.py
@@ -138,7 +138,7 @@ class Location(ModelSQL, ModelView):
], order=[])
if ids:
return [('id', 'in', ids)]
- return [(self._rec_name,) + clause[1:]]
+ return [(self._rec_name,) + tuple(clause[1:])]
def get_quantity(self, ids, name):
product_obj = Pool().get('product.product')
diff --git a/trytond_stock.egg-info/PKG-INFO b/trytond_stock.egg-info/PKG-INFO
index c05e229..3448616 100644
--- a/trytond_stock.egg-info/PKG-INFO
+++ b/trytond_stock.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.0
Name: trytond-stock
-Version: 2.2.2
+Version: 2.2.3
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
commit f098b43d17dfe3d06b3d1f305005008b16d12996
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Wed May 9 11:47:29 2012 +0200
Adding upstream version 2.2.2.
diff --git a/CHANGELOG b/CHANGELOG
index e8e2ee7..dd046e9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 2.2.2 - 2012-05-07
+* Bug fixes (see mercurial logs for details)
+
Version 2.2.1 - 2011-12-26
* Bug fixes (see mercurial logs for details)
diff --git a/COPYRIGHT b/COPYRIGHT
index a9feb41..101ffe2 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,6 +1,7 @@
-Copyright (C) 2008-2011 Cédric Krier.
+Copyright (C) 2012 Openlabs Technologies & Consulting (P) LTD.
+Copyright (C) 2008-2012 Cédric Krier.
Copyright (C) 2008-2011 Bertrand Chenal.
-Copyright (C) 2008-2011 B2CK SPRL.
+Copyright (C) 2008-2012 B2CK SPRL.
Copyright (C) 2004-2008 Tiny SPRL.
This program is free software: you can redistribute it and/or modify
diff --git a/PKG-INFO b/PKG-INFO
index 3fdd532..2475c99 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond_stock
-Version: 2.2.1
+Version: 2.2.2
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
diff --git a/__tryton__.py b/__tryton__.py
index 432f5c7..658437e 100644
--- a/__tryton__.py
+++ b/__tryton__.py
@@ -8,7 +8,7 @@
'name_es_ES': 'Gestión de existencias',
'name_fr_FR': 'Gestion des stocks',
'name_ru_RU': 'Управление складами',
- 'version': '2.2.1',
+ 'version': '2.2.2',
'author': 'B2CK',
'email': 'info at b2ck.com',
'website': 'http://www.tryton.org/',
diff --git a/move.py b/move.py
index 0352926..735eec3 100644
--- a/move.py
+++ b/move.py
@@ -456,6 +456,8 @@ class Move(ModelSQL, ModelView):
if isinstance(uom, (int, long)):
uom = uom_obj.browse(uom)
+ if isinstance(currency, (int, long)):
+ currency = currency_obj.browse(currency)
if isinstance(company, (int, long)):
company = company_obj.browse(company)
@@ -517,18 +519,20 @@ class Move(ModelSQL, ModelView):
product = product_obj.browse(vals['product'])
if vals.get('state') == 'done':
vals['effective_date'] = effective_date
+ currency_id = vals.get('currency', self.default_currency())
+ company_id = vals.get('company', self.default_company())
from_location = location_obj.browse(vals['from_location'])
to_location = location_obj.browse(vals['to_location'])
if from_location.type == 'supplier' \
and product.cost_price_method == 'average':
self._update_product_cost_price(vals['product'],
vals['quantity'], vals['uom'], vals['unit_price'],
- vals['currency'], vals['company'], effective_date)
+ currency_id, company_id, effective_date)
if to_location.type == 'supplier' \
and product.cost_price_method == 'average':
self._update_product_cost_price(vals['product'],
-vals['quantity'], vals['uom'], vals['unit_price'],
- vals['currency'], vals['company'], effective_date)
+ currency_id, company_id, effective_date)
if not vals.get('cost_price'):
# Re-read product to get the updated cost_price
product = product_obj.browse(vals['product'])
diff --git a/product.py b/product.py
index ca79200..fdd5f4f 100644
--- a/product.py
+++ b/product.py
@@ -495,6 +495,14 @@ class Product(ModelSQL, ModelView):
if location not in location_ids:
del res[(location, product)]
+ # Round quantities
+ default_uom = dict((p.id, p.default_uom) for p in
+ self.browse(list(res_product_ids)))
+ for key, quantity in res.iteritems():
+ location, product = key
+ uom = default_uom[product]
+ res[key] = uom_obj.round(quantity, uom.rounding)
+
# Complete result with missing products if asked
if not skip_zero:
# Search for all products, even if not linked with moves
diff --git a/shipment.py b/shipment.py
index 00150d4..d24a423 100644
--- a/shipment.py
+++ b/shipment.py
@@ -9,6 +9,7 @@ from trytond.backend import TableHandler
from trytond.pyson import Eval, Not, Equal, If, Or, And, Bool, In, Get
from trytond.transaction import Transaction
from trytond.pool import Pool
+from trytond.tools import reduce_ids
STATES = {
'readonly': "state in ('cancel', 'done')",
@@ -159,7 +160,12 @@ class ShipmentIn(ModelWorkflow, ModelSQL, ModelView):
for company_id, values in itertools.groupby(cursor.fetchall(),
operator.itemgetter(1)):
shipment_ids = [x[0] for x in values]
- self.write(shipment_ids, {'company': company_id})
+ for i in range(0, len(shipment_ids), cursor.IN_MAX):
+ sub_ids = shipment_ids[i:i + cursor.IN_MAX]
+ red_sql, red_ids = reduce_ids('id', sub_ids)
+ cursor.execute('UPDATE "' + self._table + '" '
+ 'SET company = %s WHERE ' + red_sql,
+ [company_id] + red_ids)
table.not_null_action('company', action='add')
# Add index on create_date
@@ -520,7 +526,12 @@ class ShipmentInReturn(ModelWorkflow, ModelSQL, ModelView):
for company_id, values in itertools.groupby(cursor.fetchall(),
operator.itemgetter(1)):
shipment_ids = [x[0] for x in values]
- self.write(shipment_ids, {'company': company_id})
+ for i in range(0, len(shipment_ids), cursor.IN_MAX):
+ sub_ids = shipment_ids[i:i + cursor.IN_MAX]
+ red_sql, red_ids = reduce_ids('id', sub_ids)
+ cursor.execute('UPDATE "' + self._table + '" '
+ 'SET company = %s WHERE ' + red_sql,
+ [company_id] + red_ids)
table.not_null_action('company', action='add')
# Add index on create_date
@@ -797,7 +808,12 @@ class ShipmentOut(ModelWorkflow, ModelSQL, ModelView):
for company_id, values in itertools.groupby(cursor.fetchall(),
operator.itemgetter(1)):
shipment_ids = [x[0] for x in values]
- self.write(shipment_ids, {'company': company_id})
+ for i in range(0, len(shipment_ids), cursor.IN_MAX):
+ sub_ids = shipment_ids[i:i + cursor.IN_MAX]
+ red_sql, red_ids = reduce_ids('id', sub_ids)
+ cursor.execute('UPDATE "' + self._table + '" '
+ 'SET company = %s WHERE ' + red_sql,
+ [company_id] + red_ids)
table.not_null_action('company', action='add')
# Migration from 1.0 customer_location is no more used
@@ -1018,12 +1034,12 @@ class ShipmentOut(ModelWorkflow, ModelSQL, ModelView):
if outgoing_qty.get(move.product.id, 0.0) > 0.0:
exc_qty = uom_obj.compute_qty(move.product.default_uom,
outgoing_qty[move.product.id], move.uom)
- move_obj.write(move.id,{
- 'quantity': max(0.0, move.quantity-exc_qty),
- })
removed_qty = uom_obj.compute_qty(move.uom,
min(exc_qty, move.quantity), move.product.default_uom,
round=False)
+ move_obj.write(move.id,{
+ 'quantity': max(0.0, move.quantity-exc_qty),
+ })
outgoing_qty[move.product.id] -= removed_qty
move_obj.write([x.id for x in shipment.outgoing_moves
@@ -1286,7 +1302,12 @@ class ShipmentOutReturn(ModelWorkflow, ModelSQL, ModelView):
for company_id, values in itertools.groupby(cursor.fetchall(),
operator.itemgetter(1)):
shipment_ids = [x[0] for x in values]
- self.write(shipment_ids, {'company': company_id})
+ for i in range(0, len(shipment_ids), cursor.IN_MAX):
+ sub_ids = shipment_ids[i:i + cursor.IN_MAX]
+ red_sql, red_ids = reduce_ids('id', sub_ids)
+ cursor.execute('UPDATE "' + self._table + '" '
+ 'SET company = %s WHERE ' + red_sql,
+ [company_id] + red_ids)
table.not_null_action('company', action='add')
# Add index on create_date
@@ -1742,7 +1763,12 @@ class ShipmentInternal(ModelWorkflow, ModelSQL, ModelView):
for company_id, values in itertools.groupby(cursor.fetchall(),
operator.itemgetter(1)):
shipment_ids = [x[0] for x in values]
- self.write(shipment_ids, {'company': company_id})
+ for i in range(0, len(shipment_ids), cursor.IN_MAX):
+ sub_ids = shipment_ids[i:i + cursor.IN_MAX]
+ red_sql, red_ids = reduce_ids('id', sub_ids)
+ cursor.execute('UPDATE "' + self._table + '" '
+ 'SET company = %s WHERE ' + red_sql,
+ [company_id] + red_ids)
table.not_null_action('company', action='add')
# Add index on create_date
diff --git a/tests/test_stock.py b/tests/test_stock.py
index 1caa6f1..d81ba98 100644
--- a/tests/test_stock.py
+++ b/tests/test_stock.py
@@ -9,6 +9,7 @@ if os.path.isdir(DIR):
sys.path.insert(0, os.path.dirname(DIR))
import unittest
+import doctest
import datetime
from decimal import Decimal
from dateutil.relativedelta import relativedelta
@@ -16,6 +17,7 @@ from functools import partial
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, test_view,\
test_depends
+from trytond.backend.sqlite.database import Database as SQLiteDatabase
from trytond.transaction import Transaction
@@ -113,13 +115,14 @@ class StockTestCase(unittest.TestCase):
category_id = self.category.create({
'name': 'Test products_by_location',
})
- unit_id, = self.uom.search([('name', '=', 'Unit')])
+ kg_id, = self.uom.search([('name', '=', 'Kilogram')])
+ g_id, = self.uom.search([('name', '=', 'Gram')])
product_id = self.product.create({
'name': 'Test products_by_location',
'type': 'stockable',
'category': category_id,
'cost_price_method': 'fixed',
- 'default_uom': unit_id,
+ 'default_uom': kg_id,
})
supplier_id, = self.location.search([('code', '=', 'SUP')])
customer_id, = self.location.search([('code', '=', 'CUS')])
@@ -136,7 +139,7 @@ class StockTestCase(unittest.TestCase):
self.move.create({
'product': product_id,
- 'uom': unit_id,
+ 'uom': kg_id,
'quantity': 5,
'from_location': supplier_id,
'to_location': storage_id,
@@ -149,7 +152,7 @@ class StockTestCase(unittest.TestCase):
})
self.move.create({
'product': product_id,
- 'uom': unit_id,
+ 'uom': kg_id,
'quantity': 1,
'from_location': supplier_id,
'to_location': storage_id,
@@ -161,7 +164,7 @@ class StockTestCase(unittest.TestCase):
})
self.move.create({
'product': product_id,
- 'uom': unit_id,
+ 'uom': kg_id,
'quantity': 1,
'from_location': storage_id,
'to_location': customer_id,
@@ -174,7 +177,7 @@ class StockTestCase(unittest.TestCase):
})
self.move.create({
'product': product_id,
- 'uom': unit_id,
+ 'uom': kg_id,
'quantity': 1,
'from_location': storage_id,
'to_location': customer_id,
@@ -186,7 +189,7 @@ class StockTestCase(unittest.TestCase):
})
self.move.create({
'product': product_id,
- 'uom': unit_id,
+ 'uom': kg_id,
'quantity': 2,
'from_location': storage_id,
'to_location': customer_id,
@@ -198,7 +201,7 @@ class StockTestCase(unittest.TestCase):
})
self.move.create({
'product': product_id,
- 'uom': unit_id,
+ 'uom': kg_id,
'quantity': 5,
'from_location': supplier_id,
'to_location': storage_id,
@@ -290,6 +293,23 @@ class StockTestCase(unittest.TestCase):
today + relativedelta(days=-3),
today + relativedelta(days=-2),
]
+
+ self.move.create({
+ 'product': product_id,
+ 'uom': g_id,
+ 'quantity': 1,
+ 'from_location': supplier_id,
+ 'to_location': storage_id,
+ 'planned_date': today + relativedelta(days=-5),
+ 'effective_date': today + relativedelta(days=-5),
+ 'state': 'done',
+ 'company': company_id,
+ 'unit_price': Decimal('1'),
+ 'currency': currency_id,
+ })
+ # Nothing should change when adding a small quantity
+ test_products_by_location()
+
for period_date in periods:
period_id = self.period.create({
'date': period_date,
@@ -441,6 +461,19 @@ class StockTestCase(unittest.TestCase):
self.assertRaises(Exception, self.period.button_close, [period_id])
+def doctest_dropdb(test):
+ '''
+ Remove sqlite memory database
+ '''
+ database = SQLiteDatabase().connect()
+ cursor = database.cursor(autocommit=True)
+ try:
+ database.drop(cursor, ':memory:')
+ cursor.commit()
+ finally:
+ cursor.close()
+
+
def suite():
suite = trytond.tests.test_tryton.suite()
from trytond.modules.company.tests import test_company
@@ -448,6 +481,10 @@ def suite():
if test not in suite:
suite.addTest(test)
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(StockTestCase))
+ suite.addTests(doctest.DocFileSuite('scenario_stock_shipment_out.rst',
+ setUp=doctest_dropdb, tearDown=doctest_dropdb, encoding='utf-8',
+ optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
+
return suite
if __name__ == '__main__':
diff --git a/trytond_stock.egg-info/PKG-INFO b/trytond_stock.egg-info/PKG-INFO
index 03a5b48..c05e229 100644
--- a/trytond_stock.egg-info/PKG-INFO
+++ b/trytond_stock.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond-stock
-Version: 2.2.1
+Version: 2.2.2
Summary: Stock Management and Inventory Control with:
- Location definition
- Stock move
--
tryton-modules-stock
More information about the tryton-debian-vcs
mailing list