diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index e17c3370ac3..daf00e04006 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -602,6 +602,11 @@
string="Consume Products" type="action"
icon="gtk-go-forward" context="{'consume': True}"
states="draft,waiting,confirmed,assigned" />
+
-
+
diff --git a/addons/product/product.py b/addons/product/product.py
index c2c764bfd6d..6a5aa1de624 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -53,7 +53,7 @@ def check_ean(eancode):
evensum += int(finalean[i])
total=(oddsum * 3) + evensum
- check = int(10 - math.ceil(total % 10.0))
+ check = int(10 - math.ceil(total % 10.0)) %10
if check != int(eancode[-1]):
return False
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index 029f43244e9..30e0fd94f44 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -188,7 +188,7 @@
-
+
@@ -234,7 +234,7 @@
-
+
diff --git a/addons/purchase_double_validation/__init__.py b/addons/purchase_double_validation/__init__.py
new file mode 100644
index 00000000000..989850585bf
--- /dev/null
+++ b/addons/purchase_double_validation/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import purchase_double_validation_installer
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/purchase_double_validation/__openerp__.py b/addons/purchase_double_validation/__openerp__.py
new file mode 100644
index 00000000000..55327b686ec
--- /dev/null
+++ b/addons/purchase_double_validation/__openerp__.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+{
+ "name" : "purchase_double_validation",
+ "version" : "1.1",
+ "category": 'Generic Modules/Sales & Purchases',
+ "depends" : ["base","purchase"],
+ "author" : 'OpenERP SA',
+ "description": """
+ This module modifies purchase workflow in order to validate purchases that exceeds minimum amount set by configuration wizard
+ """,
+ 'website': 'http://www.openerp.com',
+ 'init_xml': [],
+ 'update_xml': [
+ 'purchase_double_validation_view.xml',
+ 'purchase_double_validation_workflow.xml',
+ 'purchase_double_validation_installer.xml'
+ ],
+ 'demo_xml': [],
+ 'installable': True,
+ 'active': False,
+
+}
diff --git a/addons/purchase_double_validation/purchase_double_validation_installer.py b/addons/purchase_double_validation/purchase_double_validation_installer.py
new file mode 100644
index 00000000000..3d4c2d8c422
--- /dev/null
+++ b/addons/purchase_double_validation/purchase_double_validation_installer.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import time
+from osv import fields, osv
+
+class purchase_double_validation_installer(osv.osv_memory):
+ _name = 'purchase.double.validation.installer'
+ _inherit = 'res.config'
+
+ _columns = {
+ 'limit_amount': fields.integer('Limit Amount', required=True, help="Minimum amount after which validation of purchase is required."),
+ }
+
+ _defaults = {
+ 'limit_amount': 1000,
+ }
+
+ def execute(self, cr, uid, ids, context=None):
+ data = self.read(cr, uid, ids, context=context)
+ if not data:
+ return {}
+ amt = data[0]['limit_amount']
+ data_pool = self.pool.get('ir.model.data')
+ transition_obj = self.pool.get('workflow.transition')
+ waiting = data_pool._get_id(cr, uid, 'purchase_double_validation', 'trans_router1_waiting')
+ waiting_id = data_pool.browse(cr, uid, waiting, context=context).res_id
+ confirm = data_pool._get_id(cr, uid, 'purchase', 'trans_draft_confirmed')
+ confirm_id = data_pool.browse(cr, uid, confirm, context=context).res_id
+ transition_obj.write(cr, uid, waiting_id, {'condition': 'amount_total>%s' % (amt), 'signal': False})
+ transition_obj.write(cr, uid, confirm_id, {'condition': 'amount_total<=%s' % (amt), 'signal': False})
+ return {}
+
+purchase_double_validation_installer()
+
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/purchase_double_validation/purchase_double_validation_installer.xml b/addons/purchase_double_validation/purchase_double_validation_installer.xml
new file mode 100644
index 00000000000..1ee4420bc13
--- /dev/null
+++ b/addons/purchase_double_validation/purchase_double_validation_installer.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+ Configure Limit Amount for Purchase
+ purchase.double.validation.installer
+ form
+
+
+
+
+
+ Configure Limit Amount for Purchase
+
+
+ Define minimum amount after which puchase is needed to be validated.
+
+
+ 15
+
+
+
+
+
+
+
+
+
+
+
+ Configure Limit Amount for Purchase
+ ir.actions.act_window
+ purchase.double.validation.installer
+
+ form
+ form
+ new
+
+
+
+
+
+ onskip
+
+
+
+
+
diff --git a/addons/purchase_double_validation/purchase_double_validation_view.xml b/addons/purchase_double_validation/purchase_double_validation_view.xml
new file mode 100644
index 00000000000..5136ffef0e3
--- /dev/null
+++ b/addons/purchase_double_validation/purchase_double_validation_view.xml
@@ -0,0 +1,22 @@
+
+
+
+
+ purchase.order.form.inherit
+ purchase.order
+
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/purchase_double_validation/purchase_double_validation_workflow.xml b/addons/purchase_double_validation/purchase_double_validation_workflow.xml
new file mode 100644
index 00000000000..ea61341fc6a
--- /dev/null
+++ b/addons/purchase_double_validation/purchase_double_validation_workflow.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+ waiting
+ function
+ write({'state':'wait'})
+
+
+
+
+ router1
+ OR
+ dummy
+
+
+
+
+
+ True
+ draft_router1
+
+
+
+
+
+ True
+
+
+
+
+
+
+ True
+ waiting_confirmed
+
+
+
+
+
+ True
+ waiting_confirmed
+
+
+
+
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 8b214d265e7..6478a5fa9ca 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -2279,14 +2279,12 @@ class stock_move(osv.osv):
context = {}
if quantity <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
-
res = []
for move in self.browse(cr, uid, ids, context=context):
move_qty = move.product_qty
if move_qty <= 0:
raise osv.except_osv(_('Error!'), _('Can not consume a move with negative or zero quantity !'))
quantity_rest = move.product_qty
-
quantity_rest -= quantity
uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty
if quantity_rest <= 0:
@@ -2303,7 +2301,7 @@ class stock_move(osv.osv):
'state': move.state,
'location_id': location_id or move.location_id.id,
}
- if move.product_id.track_production and location_id:
+ if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
# IF product has checked track for production lot, move lines will be split by 1
res += self.action_split(cr, uid, [move.id], quantity, split_by_qty=1, context=context)
else:
@@ -2317,7 +2315,7 @@ class stock_move(osv.osv):
else:
quantity_rest = quantity
uos_qty_rest = uos_qty
- if move.product_id.track_production and location_id:
+ if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
res += self.action_split(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context)
else:
res += [move.id]
@@ -2464,7 +2462,8 @@ class stock_inventory(osv.osv):
'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', states={'done': [('readonly', True)]}),
'move_ids': fields.many2many('stock.move', 'stock_inventory_move_rel', 'inventory_id', 'move_id', 'Created Moves'),
'state': fields.selection( (('draft', 'Draft'), ('done', 'Done'), ('confirm','Confirmed'),('cancel','Cancelled')), 'State', readonly=True, select=True),
- 'company_id': fields.many2one('res.company','Company',required=True,select=True),
+ 'company_id': fields.many2one('res.company', 'Company', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
+
}
_defaults = {
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py
index 4e437eef815..56a62520bbf 100644
--- a/addons/stock/wizard/stock_change_product_qty.py
+++ b/addons/stock/wizard/stock_change_product_qty.py
@@ -27,8 +27,10 @@ class stock_change_product_qty(osv.osv_memory):
_name = "stock.change.product.qty"
_description = "Change Product Quantity"
_columns = {
- 'new_quantity': fields.float('Quantity', required=True, help='This quantity is expressed in the Default UoM of the product.'),
- 'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade", domain="[('usage', '=', 'internal')]"),
+ 'product_id' : fields.many2one('product.product', 'Product'),
+ 'new_quantity': fields.float('Quantity', required=True, help='This quantity is expressed in the Default UoM of the product.'),
+ 'prodlot_id': fields.many2one('stock.production.lot', 'Production Lot', domain="[('product_id','=',product_id)]"),
+ 'location_id': fields.many2one('stock.location', 'Location', required=True, domain="[('usage', '=', 'internal')]"),
}
def default_get(self, cr, uid, fields, context):
@@ -40,10 +42,14 @@ class stock_change_product_qty(osv.osv_memory):
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
+ product_id = context and context.get('active_id', False) or False
+ prod_obj =self.pool.get('product.product')
res = super(stock_change_product_qty, self).default_get(cr, uid, fields, context=context)
if 'new_quantity' in fields:
res.update({'new_quantity': 1})
+ if 'product_id' in fields:
+ res.update({'product_id': product_id})
return res
def change_product_qty(self, cr, uid, ids, context=None):
@@ -70,18 +76,27 @@ class stock_change_product_qty(osv.osv_memory):
for data in self.browse(cr, uid, ids, context=context):
inventory_id = inventry_obj.create(cr , uid, {'name': _('INV: ') + str(res_original.name)}, context=context)
line_data ={
- 'inventory_id' : inventory_id,
- 'product_qty' : data.new_quantity,
- 'location_id' : data.location_id.id,
- 'product_id' : rec_id,
- 'product_uom' : res_original.uom_id.id,
+ 'inventory_id' : inventory_id,
+ 'product_qty' : data.new_quantity,
+ 'location_id' : data.location_id.id,
+ 'product_id' : rec_id,
+ 'product_uom' : res_original.uom_id.id,
+ 'prod_lot_id' : data.prodlot_id.id
}
line_id = inventry_line_obj.create(cr , uid, line_data, context=context)
-
+
inventry_obj.action_confirm(cr, uid, [inventory_id], context=context)
inventry_obj.action_done(cr, uid, [inventory_id], context=context)
-
- return {}
+
+ return {
+ 'domain': "[('id','=', %s)]" % (inventory_id),
+ 'name' : _('Physical Inventories'),
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'stock.inventory',
+ 'context': context,
+ 'type': 'ir.actions.act_window',
+ }
stock_change_product_qty()
diff --git a/addons/stock/wizard/stock_change_product_qty_view.xml b/addons/stock/wizard/stock_change_product_qty_view.xml
index 927f3e91f80..6bedd7605e6 100644
--- a/addons/stock/wizard/stock_change_product_qty_view.xml
+++ b/addons/stock/wizard/stock_change_product_qty_view.xml
@@ -10,7 +10,10 @@
+
+
+
diff --git a/addons/stock_planning/stock_planning_view.xml b/addons/stock_planning/stock_planning_view.xml
index aaf7e77c0b2..9995752cb03 100644
--- a/addons/stock_planning/stock_planning_view.xml
+++ b/addons/stock_planning/stock_planning_view.xml
@@ -40,7 +40,7 @@
-
+
stock.period.search
stock.period
@@ -178,10 +178,10 @@
-
+
-
-
@@ -224,7 +224,7 @@
action="action_view_stock_sale_forecast_form"/>
-
+
@@ -319,6 +319,7 @@
+
diff --git a/addons/stock_planning/wizard/stock_planning_create_periods.py b/addons/stock_planning/wizard/stock_planning_create_periods.py
index 13a822ed3fe..47e19d1dda0 100644
--- a/addons/stock_planning/wizard/stock_planning_create_periods.py
+++ b/addons/stock_planning/wizard/stock_planning_create_periods.py
@@ -21,7 +21,7 @@
import time
from datetime import datetime
-from dateutil.relativedelta import relativedelta
+from dateutil.relativedelta import relativedelta
from osv import osv, fields
@@ -35,7 +35,7 @@ class stock_period_createlines(osv.osv_memory):
result = cr.fetchone()
last_date = result and result[0] or False
if last_date:
- period_start = datetime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1)
+ period_start = datetime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1)
period_start = period_start - relativedelta(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second)
else:
period_start = datetime.today()
@@ -51,7 +51,7 @@ class stock_period_createlines(osv.osv_memory):
_defaults={
'date_start': _get_new_period_start,
}
-
+
def create_stock_periods(self, cr, uid, ids, context=None):
if context is None:
context = {}
@@ -60,37 +60,50 @@ class stock_period_createlines(osv.osv_memory):
period_obj = self.pool.get('stock.period')
lines = []
for p in self.browse(cr, uid, ids, context=context):
- dt = p.date_start
+ dt_stp = datetime.strptime(p.date_stop, '%Y-%m-%d')
ds = datetime.strptime(p.date_start, '%Y-%m-%d')
- while ds.strftime('%Y-%m-%d') < p.date_stop:
+
+ while ds <= dt_stp:
if name =='Daily':
- de = ds + relativedelta(days=interval, minutes =-1)
- new_name = de.strftime('%Y-%m-%d')
+ de = ds + relativedelta(days=(interval + 1), seconds =-1)
new_id = period_obj.create(cr, uid, {
- 'name': new_name,
- 'date_start': ds.strftime('%Y-%m-%d'),
+ 'name': de.strftime('%Y-%m-%d'),
+ 'date_start': ds.strftime('%Y-%m-%d %H:%M:%S'),
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
})
- ds = ds + relativedelta(days=interval) + 1
+ ds = ds + relativedelta(days=(interval + 1))
if name =="Weekly":
- de = ds + relativedelta(days=interval, minutes =-1)
- new_name = de.strftime('%Y, week %W')
+ de = ds + relativedelta(days=(interval + 1), seconds =-1)
+ if dt_stp < de:
+ de = dt_stp + relativedelta(days=1, seconds =-1)
+ else:
+ de = ds + relativedelta(days=(interval + 1), seconds =-1)
+ new_name = ds.strftime('Week %W-%Y')
+ if ds.strftime('%Y') != de.strftime('%Y'):
+ new_name = ds.strftime('Week %W-%Y') + ', ' + de.strftime('Week %W-%Y')
new_id = period_obj.create(cr, uid, {
'name': new_name,
- 'date_start': ds.strftime('%Y-%m-%d'),
+ 'date_start': ds.strftime('%Y-%m-%d %H:%M:%S'),
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
})
- ds = ds + relativedelta(days=interval) + 1
+ ds = ds + relativedelta(days=(interval + 1))
if name == "Monthly":
- de = ds + relativedelta(months=interval, minutes=-1)
+ de = ds + relativedelta(months=interval, seconds=-1)
+ if dt_stp < de:
+ de = dt_stp + relativedelta(days=1, seconds =-1)
+ else:
+ de = ds + relativedelta(months=interval, seconds=-1)
new_name = ds.strftime('%Y/%m')
+ if ds.strftime('%m') != de.strftime('%m'):
+ new_name = ds.strftime('%Y/%m') + '-' + de.strftime('%Y/%m')
new_id =period_obj.create(cr, uid, {
- 'name': new_name,
- 'date_start': ds.strftime('%Y-%m-%d'),
+ 'name': new_name,
+ 'date_start': ds.strftime('%Y-%m-%d %H:%M:%S'),
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
})
ds = ds + relativedelta(months=interval)
lines.append(new_id)
+
return {
'domain': "[('id','in', ["+','.join(map(str, lines))+"])]",
'view_type': 'form',