Reviewers: ,


Please review this at http://codereview.tryton.org/821002/

Affected files:
  M CHANGELOG
  M purchase_request.py


Index: CHANGELOG
===================================================================

--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+* Add warning for late supplier moves when creating purchase request
+
 Version 2.8.0 - 2013-04-22
 * Bug fixes (see mercurial logs for details)
 * find_best_supplier doesn't optimize anymore on the delivery delay

Index: purchase_request.py
===================================================================

--- a/purchase_request.py
+++ b/purchase_request.py
@@ -466,8 +466,28 @@
             ])
     create_ = StateAction('stock_supply.act_purchase_request_form')

+    @classmethod
+    def __setup__(cls):
+        super(CreatePurchaseRequest, cls).__setup__()
+        cls._error_messages.update({
+ 'late_supplier_moves': ('There are some late supplier moves, '
+                    'are you sure to ignore them?'),
+                })
+
     def do_create_(self, action):
-        PurchaseRequest = Pool().get('purchase.request')
+        pool = Pool()
+        PurchaseRequest = pool.get('purchase.request')
+        Move = pool.get('stock.move')
+        Date = pool.get('ir.date')
+        today = Date.today()
+        if Move.search([
+                    ('from_location.type', '=', 'supplier'),
+                    ('to_location.type', '=', 'storage'),
+                    ('state', '=', 'draft'),
+                    ('planned_date', '<', today),
+                    ], order=[]):
+            self.raise_user_warning('%s@%s' % (self.__name__, today),
+                'late_supplier_moves')
         PurchaseRequest.generate_requests()
         return action, {}




Reply via email to