[tryton-debian-vcs] tryton-modules-stock branch upstream-4.2 updated. upstream/4.2.2-1-ga66d8cf
Mathias Behrle
tryton-debian-vcs at alioth.debian.org
Thu Aug 17 12:42:17 UTC 2017
The following commit has been merged in the upstream-4.2 branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-modules-stock.git;a=commitdiff;h=upstream/4.2.2-1-ga66d8cf
commit a66d8cf5b64f9f34930ce6c9e9124764f4032046
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Thu Aug 17 12:19:55 2017 +0200
Adding upstream version 4.2.3.
Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>
diff --git a/CHANGELOG b/CHANGELOG
index 38ac6d4..68b3eea 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 4.2.3 - 2017-08-08
+* Bug fixes (see mercurial logs for details)
+
Version 4.2.2 - 2017-07-01
* Bug fixes (see mercurial logs for details)
diff --git a/PKG-INFO b/PKG-INFO
index 6b1d805..22c2bb5 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond_stock
-Version: 4.2.2
+Version: 4.2.3
Summary: Tryton module for stock and inventory
Home-page: http://www.tryton.org/
Author: Tryton
diff --git a/inventory.py b/inventory.py
index 875d6ed..17ca0a8 100644
--- a/inventory.py
+++ b/inventory.py
@@ -266,7 +266,6 @@ class Inventory(Workflow, ModelSQL, ModelView):
class InventoryLine(ModelSQL, ModelView):
'Stock Inventory Line'
__name__ = 'stock.inventory.line'
- _rec_name = 'product'
_states = {
'readonly': Eval('inventory_state') != 'draft',
}
@@ -357,6 +356,10 @@ class InventoryLine(ModelSQL, ModelView):
def get_rec_name(self, name):
return self.product.rec_name
+ @classmethod
+ def search_rec_name(cls, name, clause):
+ return [('product',) + tuple(clause[1:])]
+
def get_uom(self, name):
return self.product.default_uom.id
diff --git a/location.py b/location.py
index 0a3b219..ca236d6 100644
--- a/location.py
+++ b/location.py
@@ -176,15 +176,19 @@ class Location(ModelSQL, ModelView):
""" Check locations with moves have types compatible with moves. """
invalid_move_types = ['warehouse', 'view']
Move = Pool().get('stock.move')
- if (self.type in invalid_move_types
- and Move.search([
+ if self.type in invalid_move_types:
+ # Use root to compute for all companies
+ with Transaction().set_user(0):
+ moves = Move.search([
['OR',
('to_location', '=', self.id),
('from_location', '=', self.id),
],
('state', 'not in', ['staging', 'draft']),
- ])):
- self.raise_user_error('invalid_type_for_moves', (self.rec_name,))
+ ])
+ if moves:
+ self.raise_user_error(
+ 'invalid_type_for_moves', (self.rec_name,))
@staticmethod
def default_active():
diff --git a/move.py b/move.py
index 2a95fab..0c7fa94 100644
--- a/move.py
+++ b/move.py
@@ -82,10 +82,12 @@ class StockMixin(object):
return quantities
product_ids = products and [p.id for p in products] or None
+ with_childs = Transaction().context.get(
+ 'with_childs', len(location_ids) == 1)
with Transaction().set_context(cls._quantity_context(name)):
pbl = Product.products_by_location(location_ids=location_ids,
- product_ids=product_ids, with_childs=True,
+ product_ids=product_ids, with_childs=with_childs,
grouping=grouping)
for key, quantity in pbl.iteritems():
@@ -113,47 +115,35 @@ class StockMixin(object):
whose quantity is computed.
"""
pool = Pool()
- Location = pool.get('stock.location')
- Move = pool.get('stock.move')
+ Product = pool.get('product.product')
if not location_ids or not domain:
return []
-
- # Skip warehouse location in favor of their storage location
- # to compute quantities. Keep track of which ids to remove
- # and to add after the query.
- if Transaction().context.get('stock_skip_warehouse'):
- location_ids = set(location_ids)
- for location in Location.browse(list(location_ids)):
- if location.type == 'warehouse':
- location_ids.remove(location.id)
- location_ids.add(location.storage_location.id)
- location_ids = list(location_ids)
+ with_childs = Transaction().context.get(
+ 'with_childs', len(location_ids) == 1)
with Transaction().set_context(cls._quantity_context(name)):
- query = Move.compute_quantities_query(location_ids,
- with_childs=True, grouping=grouping,
- grouping_filter=None)
- having_domain = getattr(cls, name)._field.convert_domain(domain, {
- None: (query, {}),
- }, cls)
- # The last column of 'query' is always the quantity for the 'key'.
- # It is computed with a SUM() aggregator so in having we have to
- # use the SUM() expression and not the name of column
- having_domain.left = query.columns[-1].expression
- if query.having:
- query.having &= having_domain
- else:
- query.having = having_domain
- quantities = Move.compute_quantities(query, location_ids,
- with_childs=True, grouping=grouping,
- grouping_filter=None)
+ pbl = Product.products_by_location(
+ location_ids=location_ids, with_childs=with_childs,
+ grouping=grouping)
+ _, operator_, operand = domain
+ operator_ = {
+ '=': operator.eq,
+ '>=': operator.ge,
+ '>': operator.gt,
+ '<=': operator.le,
+ '<': operator.lt,
+ '!=': operator.ne,
+ 'in': lambda v, l: v in l,
+ 'not in': lambda v, l: v not in l,
+ }.get(operator_, lambda v, l: False)
record_ids = []
- for key, quantity in quantities.iteritems():
- # pbl could return None in some keys
- if key[position] is not None:
- record_ids.append(key[position])
+ for key, quantity in pbl.iteritems():
+ if operator_(quantity, operand):
+ # pbl could return None in some keys
+ if key[position] is not None:
+ record_ids.append(key[position])
return [('id', 'in', record_ids)]
@@ -560,6 +550,7 @@ class Move(Workflow, ModelSQL, ModelView):
locations = Location.search([
('type', '=', 'storage'),
])
+ context['with_childs'] = False
context['locations'] = [l.id for l in locations]
context['stock_date_end'] = Date.today()
with Transaction().set_context(context):
diff --git a/period.py b/period.py
index 5b9b802..2a272df 100644
--- a/period.py
+++ b/period.py
@@ -13,7 +13,6 @@ __all__ = ['Period', 'Cache']
class Period(Workflow, ModelSQL, ModelView):
'Stock Period'
__name__ = 'stock.period'
- _rec_name = 'date'
date = fields.Date('Date', required=True, states={
'readonly': Eval('state') == 'closed',
}, depends=['state'])
@@ -71,6 +70,10 @@ class Period(Workflow, ModelSQL, ModelView):
return pool.get('stock.period.cache')
@classmethod
+ def get_rec_name(self, name):
+ return str(self.date)
+
+ @classmethod
@ModelView.button
@Workflow.transition('draft')
def draft(cls, periods):
diff --git a/tryton.cfg b/tryton.cfg
index 9799ab7..a6c9b63 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=4.2.2
+version=4.2.3
depends:
company
currency
diff --git a/trytond_stock.egg-info/PKG-INFO b/trytond_stock.egg-info/PKG-INFO
index 08480da..970820f 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: 4.2.2
+Version: 4.2.3
Summary: Tryton module for stock and inventory
Home-page: http://www.tryton.org/
Author: Tryton
--
tryton-modules-stock
More information about the tryton-debian-vcs
mailing list