Fix pep8 and pyflakes

This commit is contained in:
Cédric Krier
2012-04-03 20:07:44 +02:00
parent 53b6cca5da
commit b2f8d73a1e
3 changed files with 27 additions and 22 deletions
+6 -6
View File
@@ -20,7 +20,7 @@ past. Once the form confirmed, the corresponding moves are created and
spread homogeneously across the period. Those moves will allow other
process to take forecasts into account.
''',
'description_bg_BG':'''Предоставя модел за "прогнозиране" при управление на инвентазирация
'description_bg_BG': '''Предоставя модел за "прогнозиране" при управление на инвентазирация
- Формата за "Прогноза" позволява да се зададат очакваните движения на наличност
към клиенти в бъдещ период. Помощник позволява да се изчислят очакваните
количества отчитайки периоди в миналто. След потвърждаване на формата, съответните
@@ -30,12 +30,12 @@ process to take forecasts into account.
'description_ca_ES': '''Proveeix el model de «Previsió» en la gestió d'inventaris.
El formulari de previsió permet definir els moviments d'estoc previstos
cap a clients en el futur. Un assistent permet calcular les quantitats previstes
respecte a un període en el passat. Una vegada el formulari es confirma, els
moviments corresponents es creen i es distribueixen homogèniament al llarg del
període. Aquests moviments permetran a altres processos tenir en compte les
respecte a un període en el passat. Una vegada el formulari es confirma, els
moviments corresponents es creen i es distribueixen homogèniament al llarg del
període. Aquests moviments permetran a altres processos tenir en compte les
previsions.
''',
'description_de_DE':'''Bedarfsermittlung für die Lagerverwaltung
'description_de_DE': '''Bedarfsermittlung für die Lagerverwaltung
- Fügt das Modell "Vorhersage" zur Lagerverwaltung hinzu.
- Das Formular "Bedarfsermittlung" ermöglicht die Erstellung von zu
erwartenden Lagerbewegungen zu Kunden in einem beliebigen Zeitraum in der
@@ -63,7 +63,7 @@ en el pasado. Una vez el formulario se confirma, los movimientos
correspondientes se crean y se distribuyen homogeneamente a lo largo del
periodo. Dichos movimientos permitirá a otros procesos tener en cuenta las previsiones.
''',
'description_fr_FR':'''Fournit le modèle "Prévision" dans la gestion des stocks.
'description_fr_FR': '''Fournit le modèle "Prévision" dans la gestion des stocks.
Le formulaire de prévision permet de définir les mouvements attendus
vers les clients pour n'importe quelle période dans le futur. Un
wizard permet de calculer les quantités attendues en fonction d'une
+18 -15
View File
@@ -108,6 +108,7 @@ class Forecast(Workflow, ModelSQL, ModelView):
if migrate_warehouse:
location2warehouse = {}
def find_warehouse(location):
if location.type == 'warehouse':
return location.id
@@ -115,7 +116,7 @@ class Forecast(Workflow, ModelSQL, ModelView):
return find_warehouse(location.parent)
cursor.execute('SELECT id, location FROM "%s"' % self._table)
for forecast_id, location_id in cursor.fetchall():
warehouse_id = location_id # default fallback
warehouse_id = location_id # default fallback
if location_id in location2warehouse:
warehouse_id = location2warehouse[location_id]
else:
@@ -123,7 +124,8 @@ class Forecast(Workflow, ModelSQL, ModelView):
warehouse_id = find_warehouse(location) or location_id
location2warehouse[location_id] = warehouse_id
cursor.execute('UPDATE "%s" SET warehouse = %%s '
'WHERE id = %%s' % self._table, (warehouse_id, forecast_id))
'WHERE id = %%s' % self._table,
(warehouse_id, forecast_id))
table.not_null_action('warehouse',
action=self.warehouse.required and 'add' or 'remove')
table.drop_column('location', True)
@@ -275,7 +277,7 @@ class ForecastLine(ModelSQL, ModelView):
digits=(16, Eval('unit_digits', 2)), required=True,
depends=['unit_digits'])
moves = fields.Many2Many('stock.forecast.line-stock.move',
'line', 'move','Moves', readonly=True)
'line', 'move', 'Moves', readonly=True)
forecast = fields.Many2One(
'stock.forecast', 'Forecast', required=True, ondelete='CASCADE')
quantity_executed = fields.Function(fields.Float('Quantity Executed',
@@ -378,9 +380,10 @@ class ForecastLine(ModelSQL, ModelView):
'AND COALESCE(m.effective_date, m.planned_date) <= %s '
'AND lm.id IS NULL '
'GROUP BY m.product',
red_ids + [forecast.warehouse.left, forecast.warehouse.right,
forecast.destination.left, forecast.destination.right,
'cancel', forecast.from_date, forecast.to_date])
red_ids + [forecast.warehouse.left,
forecast.warehouse.right, forecast.destination.left,
forecast.destination.right, 'cancel',
forecast.from_date, forecast.to_date])
for product_id, quantity in cursor.fetchall():
line = product2line[product_id]
result[line.id] = uom_obj.compute_qty(
@@ -434,7 +437,7 @@ class ForecastLine(ModelSQL, ModelView):
'planned_date': (line.forecast.from_date
+ datetime.timedelta(day)),
'company': line.forecast.company.id,
'currency':line.forecast.company.currency.id,
'currency': line.forecast.company.currency.id,
'unit_price': unit_price,
})
moves.append(mid)
@@ -452,21 +455,22 @@ class ForecastLine(ModelSQL, ModelView):
while qty > 0:
if qty > delta:
for i in range_delta:
a[i] += qty//delta
qty = qty%delta
elif delta//qty > 1:
a[i] += qty // delta
qty = qty % delta
elif delta // qty > 1:
i = 0
while i < qty:
a[i*delta//qty + (delta//qty/2)] += 1
a[i * delta // qty + (delta // qty / 2)] += 1
i += 1
qty = 0
else:
for i in range_delta:
a[i] += 1
qty = delta-qty
qty = delta - qty
i = 0
while i < qty:
a[delta - ((i*delta//qty) + (delta//qty/2)) - 1] -= 1
a[delta - ((i * delta // qty) + (delta // qty / 2)) - 1
] -= 1
i += 1
qty = 0
return a
@@ -530,7 +534,6 @@ class ForecastComplete(Wizard):
'from_to_date': '"From Date" should be smaller than "To Date"!',
})
def default_ask(self, session, fields):
"""
Forecast dates shifted by one year.
@@ -601,7 +604,7 @@ class ForecastComplete(Wizard):
if -qty <= 0:
continue
if product in prod2line:
forecast_line_obj.write(prod2line[product],{
forecast_line_obj.write(prod2line[product], {
'product': product,
'quantity': -qty,
'uom': prod2uom[product],
+3 -1
View File
@@ -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):
@@ -142,6 +143,7 @@ class StockForecastTestCase(unittest.TestCase):
self.assertEqual(len(line.moves), 4)
self.assertEqual(sum(move.quantity for move in line.moves), 8)
def suite():
suite = trytond.tests.test_tryton.suite()
from trytond.modules.company.tests import test_company