Fix pep8 and pyflakes
This commit is contained in:
1 parent
47b51e197b
commit
bd7f66d7db
8 files changed
+111
-88
No files matched your search
+1
-1
@@ -82,7 +82,7 @@ Y con los informes:
|
||||
- Lista de recálculo de existencias (con envios de proveedores y envios de devoluciones de clientes)
|
||||
- Productos por ubicación
|
||||
''',
|
||||
'description_fr_FR':'''Gestion des stocks et contrôle de l'inventaire avec:
|
||||
'description_fr_FR': '''Gestion des stocks et contrôle de l'inventaire avec:
|
||||
- Emplacement
|
||||
- Mouvement de stock
|
||||
- Expédition client, fournisseur et interne. Retour d'expédition client et founisseur.
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
|
||||
[Get(Eval('context', {}), 'company'), None]),
|
||||
('code', '=', 'stock.shipment.in.return'),
|
||||
], required=True))
|
||||
shipment_out_sequence = fields.Property(fields.Many2One( 'ir.sequence',
|
||||
shipment_out_sequence = fields.Property(fields.Many2One('ir.sequence',
|
||||
'Customer Shipment Sequence', domain=[
|
||||
('company', 'in',
|
||||
[Get(Eval('context', {}), 'company'), None]),
|
||||
|
||||
+3
-2
@@ -198,7 +198,8 @@ class Inventory(Workflow, ModelSQL, ModelView):
|
||||
quantity, uom_id = 0.0, product2uom[line.product.id]
|
||||
else:
|
||||
quantity, uom_id = 0.0, line.product.default_uom.id
|
||||
values = line_obj.update_values4complete(line, quantity, uom_id)
|
||||
values = line_obj.update_values4complete(line, quantity,
|
||||
uom_id)
|
||||
if values:
|
||||
line_obj.write(line.id, values)
|
||||
|
||||
@@ -277,7 +278,7 @@ class InventoryLine(ModelSQL, ModelView):
|
||||
|
||||
def cancel_move(self, lines):
|
||||
move_obj = Pool().get('stock.move')
|
||||
move_obj.write( [l.move.id for l in lines if l.move], {
|
||||
move_obj.write([l.move.id for l in lines if l.move], {
|
||||
'state': 'cancel',
|
||||
})
|
||||
move_obj.delete([l.move.id for l in lines if l.move])
|
||||
|
||||
+12
-7
@@ -51,7 +51,7 @@ class Location(ModelSQL, ModelView):
|
||||
'required': Equal(Eval('type'), 'warehouse'),
|
||||
},
|
||||
domain=[
|
||||
('type','=','storage'),
|
||||
('type', '=', 'storage'),
|
||||
['OR',
|
||||
('parent', 'child_of', [Eval('id')]),
|
||||
('parent', '=', None),
|
||||
@@ -64,7 +64,8 @@ class Location(ModelSQL, ModelView):
|
||||
'readonly': Not(Bool(Eval('active'))),
|
||||
'required': Equal(Eval('type'), 'warehouse'),
|
||||
},
|
||||
domain=[('type','=','storage'),
|
||||
domain=[
|
||||
('type', '=', 'storage'),
|
||||
['OR',
|
||||
('parent', 'child_of', [Eval('id')]),
|
||||
('parent', '=', None)]],
|
||||
@@ -75,7 +76,8 @@ class Location(ModelSQL, ModelView):
|
||||
'readonly': Not(Bool(Eval('active'))),
|
||||
'required': Equal(Eval('type'), 'warehouse'),
|
||||
},
|
||||
domain=[('type','=','storage'),
|
||||
domain=[
|
||||
('type', '=', 'storage'),
|
||||
['OR',
|
||||
('parent', 'child_of', [Eval('id')]),
|
||||
('parent', '=', None)]],
|
||||
@@ -97,7 +99,8 @@ class Location(ModelSQL, ModelView):
|
||||
'recursive_locations': 'You can not create recursive locations!',
|
||||
'invalid_type_for_moves': 'A location with existing moves ' \
|
||||
'cannot be changed to a type that does not support moves.',
|
||||
'child_of_warehouse': 'Location "%s" must be a child of warehouse "%s"!',
|
||||
'child_of_warehouse': 'Location "%s" must be a child of ' \
|
||||
'warehouse "%s"!',
|
||||
})
|
||||
|
||||
def init(self, module_name):
|
||||
@@ -174,7 +177,7 @@ class Location(ModelSQL, ModelView):
|
||||
product_ids=[Transaction().context['product']],
|
||||
with_childs=True, skip_zero=False).iteritems()
|
||||
|
||||
return dict([(loc,qty) for (loc,prod), qty in pbl])
|
||||
return dict([(loc, qty) for (loc, prod), qty in pbl])
|
||||
|
||||
def get_cost_value(self, ids, name):
|
||||
product_obj = Pool().get('product.product')
|
||||
@@ -298,8 +301,10 @@ class Location(ModelSQL, ModelView):
|
||||
if location.id in warehouse_locations.values():
|
||||
for field, loc_id in warehouse_locations.iteritems():
|
||||
if loc_id == location.id:
|
||||
self.write(Transaction().context['cp_warehouse_id'],
|
||||
{field: new_id})
|
||||
self.write(
|
||||
Transaction().context['cp_warehouse_id'], {
|
||||
field: new_id,
|
||||
})
|
||||
|
||||
res.append(new_id)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
from decimal import Decimal
|
||||
from functools import reduce
|
||||
from trytond.model import ModelView, ModelSQL, fields, OPERATORS
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.backend import TableHandler
|
||||
from trytond.pyson import In, Eval, Not, Equal, If, Get, Bool
|
||||
from trytond.transaction import Transaction
|
||||
@@ -141,7 +141,8 @@ class Move(ModelSQL, ModelView):
|
||||
'set_state_draft': 'You can not set state to draft!',
|
||||
'set_state_assigned': 'You can not set state to assigned!',
|
||||
'set_state_done': 'You can not set state to done!',
|
||||
'del_draft_cancel': 'You can only delete draft or cancelled moves!',
|
||||
'del_draft_cancel': 'You can only delete draft ' \
|
||||
'or cancelled moves!',
|
||||
'period_closed': 'You can not modify move in closed period!',
|
||||
'modify_assigned_done_cancel': ('You can not modify a move '
|
||||
'in the state: "Assigned", "Done" or "Cancel"'),
|
||||
@@ -150,7 +151,7 @@ class Move(ModelSQL, ModelView):
|
||||
def init(self, module_name):
|
||||
cursor = Transaction().cursor
|
||||
# Migration from 1.2: packing renamed into shipment
|
||||
table = TableHandler(cursor, self, module_name)
|
||||
table = TableHandler(cursor, self, module_name)
|
||||
table.drop_constraint('check_packing')
|
||||
for suffix in ('in', 'out', 'in_return', 'out_return', 'internal'):
|
||||
old_column = 'packing_%s' % suffix
|
||||
@@ -183,7 +184,7 @@ class Move(ModelSQL, ModelView):
|
||||
table.not_null_action('internal_quantity', action='add')
|
||||
|
||||
# Migration from 1.0 check_packing_in_out has been removed
|
||||
table = TableHandler(cursor, self, module_name)
|
||||
table = TableHandler(cursor, self, module_name)
|
||||
table.drop_constraint('check_packing_in_out')
|
||||
|
||||
# Add index on create_date
|
||||
@@ -346,7 +347,8 @@ class Move(ModelSQL, ModelView):
|
||||
res = {}
|
||||
moves = self.browse(ids)
|
||||
for m in moves:
|
||||
res[m.id] = "%s%s %s" % (m.quantity, m.uom.symbol, m.product.rec_name)
|
||||
res[m.id] = ("%s%s %s"
|
||||
% (m.quantity, m.uom.symbol, m.product.rec_name))
|
||||
return res
|
||||
|
||||
def search_rec_name(self, name, clause):
|
||||
@@ -412,7 +414,7 @@ class Move(ModelSQL, ModelView):
|
||||
else:
|
||||
digits = product_template_obj.cost_price.digits
|
||||
new_cost_price = new_cost_price.quantize(
|
||||
Decimal(str(10.0**-digits[1])))
|
||||
Decimal(str(10.0 ** -digits[1])))
|
||||
|
||||
with Transaction().set_user(0, set_context=True):
|
||||
product_obj.write(product.id, {
|
||||
@@ -425,7 +427,6 @@ class Move(ModelSQL, ModelView):
|
||||
product.default_uom, round=True)
|
||||
return internal_quantity
|
||||
|
||||
|
||||
def create(self, vals):
|
||||
pool = Pool()
|
||||
location_obj = pool.get('stock.location')
|
||||
@@ -521,7 +522,7 @@ class Move(ModelSQL, ModelView):
|
||||
and move.from_location.type == 'storage'
|
||||
and move.state != 'done'
|
||||
and move.product.cost_price_method == 'average'):
|
||||
self._update_product_cost_price( move.product.id,
|
||||
self._update_product_cost_price(move.product.id,
|
||||
-move.quantity, move.uom, move.unit_price,
|
||||
move.currency, move.company, effective_date)
|
||||
|
||||
@@ -661,10 +662,12 @@ class Move(ModelSQL, ModelView):
|
||||
qty_default_uom = uom_obj.compute_qty(move.uom, qty,
|
||||
move.product.default_uom, round=False)
|
||||
|
||||
pbl[(from_location.id, move.product.id)] = \
|
||||
pbl.get((from_location.id, move.product.id), 0.0) - qty_default_uom
|
||||
pbl[(to_location.id, move.product.id)]= \
|
||||
pbl.get((to_location.id, move.product.id), 0.0) + qty_default_uom
|
||||
pbl[(from_location.id, move.product.id)] = (
|
||||
pbl.get((from_location.id, move.product.id), 0.0)
|
||||
- qty_default_uom)
|
||||
pbl[(to_location.id, move.product.id)] = (
|
||||
pbl.get((to_location.id, move.product.id), 0.0)
|
||||
+ qty_default_uom)
|
||||
return success
|
||||
|
||||
Move()
|
||||
+17
-14
@@ -71,6 +71,7 @@ class Template(ModelSQL, ModelView):
|
||||
|
||||
Template()
|
||||
|
||||
|
||||
class Product(ModelSQL, ModelView):
|
||||
_name = "product.product"
|
||||
|
||||
@@ -117,7 +118,7 @@ class Product(ModelSQL, ModelView):
|
||||
if operator not in ("=", ">=", "<=", ">", "<", "!="):
|
||||
return False
|
||||
if operator == "=":
|
||||
operator= "=="
|
||||
operator = "=="
|
||||
return (safe_eval(str(value) + operator + str(operand)))
|
||||
|
||||
def search_quantity(self, name, domain=None):
|
||||
@@ -145,12 +146,14 @@ class Product(ModelSQL, ModelView):
|
||||
|
||||
processed_lines = []
|
||||
for (location, product), quantity in pbl:
|
||||
processed_lines.append({'location': location, #XXX useful ?
|
||||
'product': product,
|
||||
name: quantity})
|
||||
processed_lines.append({
|
||||
'location': location, # XXX useful ?
|
||||
'product': product,
|
||||
name: quantity,
|
||||
})
|
||||
|
||||
res= [line['product'] for line in processed_lines \
|
||||
if self._search_quantity_eval_domain(line, domain)]
|
||||
res = [line['product'] for line in processed_lines
|
||||
if self._search_quantity_eval_domain(line, domain)]
|
||||
return [('id', 'in', res)]
|
||||
|
||||
def get_cost_value(self, ids, name):
|
||||
@@ -178,11 +181,11 @@ class Product(ModelSQL, ModelView):
|
||||
missing).
|
||||
stock_assign: if set compute also the assigned moves as done.
|
||||
forecast: if set compute the forecast quantity.
|
||||
stock_destinations: A list of location ids. If set, restrict the
|
||||
computation to moves from and to those locations.
|
||||
stock_destinations: A list of location ids. If set, restrict
|
||||
the computation to moves from and to those locations.
|
||||
stock_skip_warehouse: if set, quantities on a warehouse are no
|
||||
more quantities of all child locations but quantities of the
|
||||
storage zone.
|
||||
more quantities of all child locations but quantities of
|
||||
the storage zone.
|
||||
|
||||
:param location_ids: the ids of locations
|
||||
:param product_ids: the ids of the products
|
||||
@@ -424,7 +427,6 @@ class Product(ModelSQL, ModelView):
|
||||
"JOIN product_template "
|
||||
"ON (product_product.template = product_template.id) ")
|
||||
|
||||
|
||||
if context.get('stock_destinations'):
|
||||
destinations = context.get('stock_destinations')
|
||||
dest_clause_from = " AND from_location in ("
|
||||
@@ -497,7 +499,8 @@ class Product(ModelSQL, ModelView):
|
||||
leafs = set(all_location_ids)
|
||||
parent = {}
|
||||
for location in locations:
|
||||
if not location.parent: continue
|
||||
if not location.parent:
|
||||
continue
|
||||
if location.parent.id in leafs:
|
||||
leafs.remove(location.parent.id)
|
||||
parent[location.id] = location.parent.id
|
||||
@@ -510,7 +513,7 @@ class Product(ModelSQL, ModelView):
|
||||
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)
|
||||
res[(parent[l], product)] += res.get((l, product), 0)
|
||||
leafs = next_leafs
|
||||
|
||||
# clean result
|
||||
@@ -533,7 +536,7 @@ class Product(ModelSQL, ModelView):
|
||||
all_product_ids = product_ids
|
||||
else:
|
||||
all_product_ids = Pool().get("product.product").search([])
|
||||
keys = ((l,p) for l in location_ids for p in all_product_ids)
|
||||
keys = ((l, p) for l in location_ids for p in all_product_ids)
|
||||
for location_id, product_id in keys:
|
||||
if (location_id, product_id) not in res:
|
||||
res[(location_id, product_id)] = 0.0
|
||||
|
||||
+59
-49
@@ -114,8 +114,8 @@ class ShipmentIn(Workflow, ModelSQL, ModelView):
|
||||
super(ShipmentIn, self).__init__()
|
||||
self._order[0] = ('id', 'DESC')
|
||||
self._error_messages.update({
|
||||
'incoming_move_input_dest': 'Incoming Moves must ' \
|
||||
'have the warehouse input location as destination location!',
|
||||
'incoming_move_input_dest': 'Incoming Moves must have ' \
|
||||
'the warehouse input location as destination location!',
|
||||
'inventory_move_input_source': 'Inventory Moves must ' \
|
||||
'have the warehouse input location as source location!',
|
||||
'delete_cancel': 'Supplier Shipment "%s" must be cancelled '\
|
||||
@@ -289,7 +289,8 @@ class ShipmentIn(Workflow, ModelSQL, ModelView):
|
||||
for shipment in self.browse(ids):
|
||||
res[shipment.id] = []
|
||||
for move in shipment.moves:
|
||||
if move.from_location.id == shipment.warehouse.input_location.id:
|
||||
if (move.from_location.id ==
|
||||
shipment.warehouse.input_location.id):
|
||||
res[shipment.id].append(move.id)
|
||||
return res
|
||||
|
||||
@@ -345,8 +346,8 @@ class ShipmentIn(Workflow, ModelSQL, ModelView):
|
||||
if default is None:
|
||||
default = {}
|
||||
default = default.copy()
|
||||
default['inventory_moves']= None
|
||||
default['incoming_moves']= None
|
||||
default['inventory_moves'] = None
|
||||
default['incoming_moves'] = None
|
||||
return super(ShipmentIn, self).copy(ids, default=default)
|
||||
|
||||
def _get_inventory_moves(self, incoming_move):
|
||||
@@ -428,7 +429,7 @@ class ShipmentIn(Workflow, ModelSQL, ModelView):
|
||||
if m.state not in ('done', 'cancel')], {
|
||||
'state': 'done',
|
||||
})
|
||||
self.write(ids,{
|
||||
self.write(ids, {
|
||||
'effective_date': date_obj.today(),
|
||||
})
|
||||
|
||||
@@ -441,7 +442,7 @@ class ShipmentInReturn(Workflow, ModelSQL, ModelView):
|
||||
_description = __doc__
|
||||
_rec_name = 'code'
|
||||
|
||||
effective_date =fields.Date('Effective Date', readonly=True)
|
||||
effective_date = fields.Date('Effective Date', readonly=True)
|
||||
planned_date = fields.Date('Planned Date',
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
@@ -706,8 +707,9 @@ class ShipmentInReturn(Workflow, ModelSQL, ModelView):
|
||||
qty_default_uom, move.uom, round=False)
|
||||
if qty < move.quantity:
|
||||
return False
|
||||
pbl[(move.from_location.id, move.product.id)] = \
|
||||
pbl[(move.from_location.id, move.product.id)] - qty_default_uom
|
||||
pbl[(move.from_location.id, move.product.id)] = (
|
||||
pbl[(move.from_location.id, move.product.id)]
|
||||
- qty_default_uom)
|
||||
else:
|
||||
return False
|
||||
self.assign(ids)
|
||||
@@ -1078,16 +1080,18 @@ class ShipmentOut(Workflow, ModelSQL, ModelView):
|
||||
# Sum all outgoing quantities
|
||||
outgoing_qty = {}
|
||||
for move in shipment.outgoing_moves:
|
||||
if move.state == 'cancel': continue
|
||||
if move.state == 'cancel':
|
||||
continue
|
||||
quantity = uom_obj.compute_qty(move.uom, move.quantity,
|
||||
move.product.default_uom, round=False)
|
||||
outgoing_qty.setdefault(move.product.id, 0.0)
|
||||
outgoing_qty[move.product.id] += quantity
|
||||
|
||||
for move in shipment.inventory_moves:
|
||||
if move.state == 'cancel': continue
|
||||
if move.state == 'cancel':
|
||||
continue
|
||||
qty_default_uom = uom_obj.compute_qty(move.uom, move.quantity,
|
||||
move.product.default_uom, round=False)
|
||||
move.product.default_uom, round=False)
|
||||
# Check if the outgoing move doesn't exist already
|
||||
if outgoing_qty.get(move.product.id):
|
||||
# If it exist, decrease the sum
|
||||
@@ -1096,9 +1100,10 @@ class ShipmentOut(Workflow, ModelSQL, ModelView):
|
||||
continue
|
||||
# Else create the complement
|
||||
else:
|
||||
out_quantity = qty_default_uom - outgoing_qty[move.product.id]
|
||||
out_quantity = (qty_default_uom
|
||||
- outgoing_qty[move.product.id])
|
||||
out_quantity = uom_obj.compute_qty(
|
||||
move.product.default_uom, out_quantity, move.uom)
|
||||
move.product.default_uom, out_quantity, move.uom)
|
||||
outgoing_qty[move.product.id] = 0.0
|
||||
else:
|
||||
out_quantity = move.quantity
|
||||
@@ -1121,16 +1126,17 @@ class ShipmentOut(Workflow, ModelSQL, ModelView):
|
||||
|
||||
#Re-read the shipment and remove exceeding quantities
|
||||
for move in shipment.outgoing_moves:
|
||||
if move.state == 'cancel': continue
|
||||
if move.state == 'cancel':
|
||||
continue
|
||||
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)
|
||||
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),
|
||||
})
|
||||
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([m.id for s in shipments for m in s.outgoing_moves
|
||||
@@ -1209,8 +1215,8 @@ class ShipmentOut(Workflow, ModelSQL, ModelView):
|
||||
if default is None:
|
||||
default = {}
|
||||
default = default.copy()
|
||||
default['inventory_moves']= None
|
||||
default['outgoing_moves']= None
|
||||
default['inventory_moves'] = None
|
||||
default['outgoing_moves'] = None
|
||||
return super(ShipmentOut, self).copy(ids, default=default)
|
||||
|
||||
def delete(self, ids):
|
||||
@@ -1258,7 +1264,6 @@ class ShipmentOut(Workflow, ModelSQL, ModelView):
|
||||
ShipmentOut()
|
||||
|
||||
|
||||
|
||||
class ShipmentOutReturn(Workflow, ModelSQL, ModelView):
|
||||
"Customer Return Shipment"
|
||||
_name = 'stock.shipment.out.return'
|
||||
@@ -1574,8 +1579,8 @@ class ShipmentOutReturn(Workflow, ModelSQL, ModelView):
|
||||
if default is None:
|
||||
default = {}
|
||||
default = default.copy()
|
||||
default['inventory_moves']= None
|
||||
default['incoming_moves']= None
|
||||
default['inventory_moves'] = None
|
||||
default['incoming_moves'] = None
|
||||
return super(ShipmentOutReturn, self).copy(ids, default=default)
|
||||
|
||||
def delete(self, ids):
|
||||
@@ -1620,7 +1625,7 @@ class ShipmentOutReturn(Workflow, ModelSQL, ModelView):
|
||||
if m.state not in ('done', 'cancel')], {
|
||||
'state': 'done',
|
||||
})
|
||||
self.write(ids,{
|
||||
self.write(ids, {
|
||||
'effective_date': date_obj.today(),
|
||||
})
|
||||
|
||||
@@ -1724,7 +1729,7 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView):
|
||||
_description = __doc__
|
||||
_rec_name = 'code'
|
||||
|
||||
effective_date =fields.Date('Effective Date', readonly=True)
|
||||
effective_date = fields.Date('Effective Date', readonly=True)
|
||||
planned_date = fields.Date('Planned Date',
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
@@ -1908,7 +1913,7 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView):
|
||||
'state': 'draft',
|
||||
})
|
||||
for shipment in shipments:
|
||||
move_obj.write([m.id for m in shipment.moves ], {
|
||||
move_obj.write([m.id for m in shipment.moves], {
|
||||
'from_location': shipment.from_location.id,
|
||||
'to_location': shipment.to_location.id,
|
||||
'planned_date': shipment.planned_date,
|
||||
@@ -2114,7 +2119,8 @@ class CreateShipmentOutReturn(Wizard):
|
||||
'quantity': move.quantity,
|
||||
'uom': move.uom.id,
|
||||
'from_location': move.to_location.id,
|
||||
'to_location': shipment_out.warehouse.input_location.id,
|
||||
'to_location': \
|
||||
shipment_out.warehouse.input_location.id,
|
||||
'company': move.company.id,
|
||||
}))
|
||||
shipment_out_return_ids.append(
|
||||
@@ -2164,8 +2170,8 @@ class PickingList(CompanyReport):
|
||||
for shipment in objects:
|
||||
sorted_moves[shipment.id] = sorted(
|
||||
shipment.inventory_moves,
|
||||
lambda x,y: cmp(self.get_compare_key(x, compare_context),
|
||||
self.get_compare_key(y, compare_context))
|
||||
lambda x, y: cmp(self.get_compare_key(x, compare_context),
|
||||
self.get_compare_key(y, compare_context))
|
||||
)
|
||||
|
||||
localcontext['moves'] = sorted_moves
|
||||
@@ -2185,9 +2191,10 @@ class PickingList(CompanyReport):
|
||||
from_location_ids = location_obj.search(list(from_location_ids))
|
||||
to_location_ids = location_obj.search(list(to_location_ids))
|
||||
|
||||
return {'from_location_ids' : from_location_ids,
|
||||
'to_location_ids' : to_location_ids}
|
||||
|
||||
return {
|
||||
'from_location_ids': from_location_ids,
|
||||
'to_location_ids': to_location_ids,
|
||||
}
|
||||
|
||||
def get_compare_key(self, move, compare_context):
|
||||
from_location_ids = compare_context['from_location_ids']
|
||||
@@ -2208,8 +2215,8 @@ class SupplierRestockingList(CompanyReport):
|
||||
for shipment in objects:
|
||||
sorted_moves[shipment.id] = sorted(
|
||||
shipment.inventory_moves,
|
||||
lambda x,y: cmp(self.get_compare_key(x, compare_context),
|
||||
self.get_compare_key(y, compare_context))
|
||||
lambda x, y: cmp(self.get_compare_key(x, compare_context),
|
||||
self.get_compare_key(y, compare_context))
|
||||
)
|
||||
|
||||
localcontext['moves'] = sorted_moves
|
||||
@@ -2229,9 +2236,10 @@ class SupplierRestockingList(CompanyReport):
|
||||
from_location_ids = location_obj.search(list(from_location_ids))
|
||||
to_location_ids = location_obj.search(list(to_location_ids))
|
||||
|
||||
return {'from_location_ids' : from_location_ids,
|
||||
'to_location_ids' : to_location_ids}
|
||||
|
||||
return {
|
||||
'from_location_ids': from_location_ids,
|
||||
'to_location_ids': to_location_ids,
|
||||
}
|
||||
|
||||
def get_compare_key(self, move, compare_context):
|
||||
from_location_ids = compare_context['from_location_ids']
|
||||
@@ -2252,8 +2260,8 @@ class CustomerReturnRestockingList(CompanyReport):
|
||||
for shipment in objects:
|
||||
sorted_moves[shipment.id] = sorted(
|
||||
shipment.inventory_moves,
|
||||
lambda x,y: cmp(self.get_compare_key(x, compare_context),
|
||||
self.get_compare_key(y, compare_context))
|
||||
lambda x, y: cmp(self.get_compare_key(x, compare_context),
|
||||
self.get_compare_key(y, compare_context))
|
||||
)
|
||||
|
||||
localcontext['moves'] = sorted_moves
|
||||
@@ -2273,9 +2281,10 @@ class CustomerReturnRestockingList(CompanyReport):
|
||||
from_location_ids = location_obj.search(list(from_location_ids))
|
||||
to_location_ids = location_obj.search(list(to_location_ids))
|
||||
|
||||
return {'from_location_ids' : from_location_ids,
|
||||
'to_location_ids' : to_location_ids}
|
||||
|
||||
return {
|
||||
'from_location_ids': from_location_ids,
|
||||
'to_location_ids': to_location_ids,
|
||||
}
|
||||
|
||||
def get_compare_key(self, move, compare_context):
|
||||
from_location_ids = compare_context['from_location_ids']
|
||||
@@ -2296,8 +2305,8 @@ class InteralShipmentReport(CompanyReport):
|
||||
for shipment in objects:
|
||||
sorted_moves[shipment.id] = sorted(
|
||||
shipment.moves,
|
||||
lambda x,y: cmp(self.get_compare_key(x, compare_context),
|
||||
self.get_compare_key(y, compare_context))
|
||||
lambda x, y: cmp(self.get_compare_key(x, compare_context),
|
||||
self.get_compare_key(y, compare_context))
|
||||
)
|
||||
|
||||
localcontext['moves'] = sorted_moves
|
||||
@@ -2317,9 +2326,10 @@ class InteralShipmentReport(CompanyReport):
|
||||
from_location_ids = location_obj.search(list(from_location_ids))
|
||||
to_location_ids = location_obj.search(list(to_location_ids))
|
||||
|
||||
return {'from_location_ids' : from_location_ids,
|
||||
'to_location_ids' : to_location_ids}
|
||||
|
||||
return {
|
||||
'from_location_ids': from_location_ids,
|
||||
'to_location_ids': to_location_ids,
|
||||
}
|
||||
|
||||
def get_compare_key(self, move, compare_context):
|
||||
from_location_ids = compare_context['from_location_ids']
|
||||
|
||||
+3
-2
@@ -2,7 +2,8 @@
|
||||
#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 sys, os
|
||||
import sys
|
||||
import os
|
||||
DIR = os.path.abspath(os.path.normpath(os.path.join(__file__,
|
||||
'..', '..', '..', '..', '..', 'trytond')))
|
||||
if os.path.isdir(DIR):
|
||||
@@ -82,7 +83,7 @@ class StockTestCase(unittest.TestCase):
|
||||
tests = [
|
||||
(kg_id, 10, 10),
|
||||
(g_id, 100, 0.1),
|
||||
(g_id, 1, 0), # rounded
|
||||
(g_id, 1, 0), # rounded
|
||||
]
|
||||
for uom_id, quantity, internal_quantity in tests:
|
||||
move_id = self.move.create({
|
||||
|
||||
Reference in new issue
Block a user