From 521fdb0fb2f1f7930956e594b351bcd1c3aa0ab4 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Tue, 14 Dec 2010 17:52:13 +0530
Subject: [PATCH 01/18] [IMP]Improvement in purchase_double_validation Module
Taskid-1774
bzr revid: ron@tinyerp.com-20101214122213-3bcu7lhvvnwt3uoa
---
addons/purchase/purchase_view.xml | 2 +-
addons/purchase_double_validation/__init__.py | 26 +++++++++
.../purchase_double_validation/__openerp__.py | 45 +++++++++++++++
.../purchase_double_validation_installer.py | 55 +++++++++++++++++++
.../purchase_double_validation_installer.xml | 52 ++++++++++++++++++
.../purchase_double_validation_view.xml | 22 ++++++++
.../purchase_double_validation_workflow.xml | 46 ++++++++++++++++
7 files changed, 247 insertions(+), 1 deletion(-)
create mode 100644 addons/purchase_double_validation/__init__.py
create mode 100644 addons/purchase_double_validation/__openerp__.py
create mode 100644 addons/purchase_double_validation/purchase_double_validation_installer.py
create mode 100644 addons/purchase_double_validation/purchase_double_validation_installer.xml
create mode 100644 addons/purchase_double_validation/purchase_double_validation_view.xml
create mode 100644 addons/purchase_double_validation/purchase_double_validation_workflow.xml
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index b0463957e9a..2cfa8a01726 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -155,7 +155,7 @@
-
+
diff --git a/addons/purchase_double_validation/__init__.py b/addons/purchase_double_validation/__init__.py
new file mode 100644
index 00000000000..f3c3af5ba22
--- /dev/null
+++ b/addons/purchase_double_validation/__init__.py
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved
+# $Id$
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import purchase_double_validation_installer
+
+
diff --git a/addons/purchase_double_validation/__openerp__.py b/addons/purchase_double_validation/__openerp__.py
new file mode 100644
index 00000000000..6a02ad2f9b5
--- /dev/null
+++ b/addons/purchase_double_validation/__openerp__.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved
+# $Id$
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU 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" : "Tiny",
+ "description": """
+ This module modifies purchase workflow in order to validate purchases that exceeds minimum amount set by wizard
+ """,
+ 'author': 'OpenERP SA',
+ '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..7ec602b10a2
--- /dev/null
+++ b/addons/purchase_double_validation/purchase_double_validation_installer.py
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved
+# $Id$
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU 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)
+ 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..8e23f252a87
--- /dev/null
+++ b/addons/purchase_double_validation/purchase_double_validation_workflow.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+ waiting
+ function
+ write({'state':'wait'})
+
+
+
+
+ router1
+ OR
+ dummy
+
+
+
+
+
+ True
+ draft_router1
+
+
+
+
+
+ True
+
+
+
+
+
+
+ True
+
+
+
+
+
+ True
+ waiting_confirmed
+
+
+
+
\ No newline at end of file
From 953a15d2a7391370414462402198780b06d45243 Mon Sep 17 00:00:00 2001
From: "rpa (Open ERP)"
Date: Wed, 15 Dec 2010 11:22:38 +0530
Subject: [PATCH 02/18] [FIX]: stock: Put proper function to change state of
move to "Available" insted of using write method
bzr revid: rpa@tinyerp.com-20101215055238-9ftnx82ftlqrg9kh
---
addons/stock/stock.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 5b14cc0dc67..33b43ce6060 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -2057,7 +2057,7 @@ class stock_move(osv.osv):
if move.move_dest_id.id and (move.state != 'done'):
cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id))
if move.move_dest_id.state in ('waiting', 'confirmed'):
- self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'})
+ self.action_assign(cr, uid, [move.move_dest_id.id])
if move.move_dest_id.picking_id:
wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr)
if move.move_dest_id.auto_validate:
From d7496a8ea44df329960c6572b94ef3ec72902b69 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Wed, 15 Dec 2010 11:56:29 +0530
Subject: [PATCH 03/18] [FIX]Warehouse:-shouldnt be able to change the company
after have validated an inventory
lp bug: https://launchpad.net/bugs/690228 fixed
bzr revid: ron@tinyerp.com-20101215062629-dl40cw2g1kyacgpw
---
addons/stock/stock.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 4d6b2643743..5b4c87c26ef 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1671,7 +1671,7 @@ class stock_move(osv.osv):
result['product_qty'] = product_uos_qty
return {'value': result}
-
+
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False,
loc_dest_id=False, address_id=False):
""" On change of product id, if finds UoM, UoS, quantity and UoS quantity.
@@ -2440,7 +2440,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'),
From c332aab56355c243577b3c583674ff0e428498b0 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Wed, 15 Dec 2010 16:44:20 +0530
Subject: [PATCH 04/18] [IMP]Master Procurement Schedule: Solved Group By
company
bzr revid: ron@tinyerp.com-20101215111420-f61717tjgjardjwk
---
addons/stock_planning/stock_planning_view.xml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
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 @@
+
From bf62673f06e2eb0d2b5a8c4fd591877972767a0b Mon Sep 17 00:00:00 2001
From: "rpa (Open ERP)"
Date: Thu, 16 Dec 2010 12:01:49 +0530
Subject: [PATCH 05/18] [FIX]: Production orders ignore chained location at
destination
lp bug: https://launchpad.net/bugs/535401 fixed
bzr revid: rpa@tinyerp.com-20101216063149-kwcm7j41ppej3gm8
---
addons/mrp/mrp.py | 7 +------
addons/mrp/stock.py | 7 +++++++
addons/stock/stock.py | 29 ++++++++++++++++++++++-------
3 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index 951dfcda0df..37b857de42d 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -664,8 +664,6 @@ class mrp_production(osv.osv):
"""
stock_mov_obj = self.pool.get('stock.move')
production = self.browse(cr, uid, production_id, context=context)
-
- final_product_todo = []
produced_qty = 0
if production_mode == 'consume_produce':
@@ -706,10 +704,7 @@ class mrp_production(osv.osv):
stock_mov_obj.action_consume(cr, uid, [raw_product.id], consumed_qty, production.location_src_id.id, context=context)
if production_mode == 'consume_produce':
- # To produce remaining qty of final product
- vals = {'state':'confirmed'}
- final_product_todo = [x.id for x in production.move_created_ids]
- stock_mov_obj.write(cr, uid, final_product_todo, vals)
+
produced_products = {}
for produced_product in production.move_created_ids2:
if produced_product.scrapped:
diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py
index 8758bc09cd5..f8fad71fc58 100644
--- a/addons/mrp/stock.py
+++ b/addons/mrp/stock.py
@@ -140,6 +140,13 @@ class StockMove(osv.osv):
res.append(new_move)
return {}
+ def trigger_move_state(self, cr, uid, move, state, context=None):
+ new_moves = super(StockMove, self).trigger_move_state(cr, uid, move, state, context=context)
+ if state == 'confirm':
+ new_moves =[x.id for x in new_moves]
+ self.write(cr, uid, new_moves, {'production_id': False}, context=context)
+ return new_moves
+
StockMove()
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 0d8249b1b12..8f741ccfae5 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1745,6 +1745,7 @@ class stock_move(osv.osv):
result.setdefault(m.picking_id, [])
result[m.picking_id].append( (m, dest) )
return result
+
def _create_chained_picking(self, cr, uid, pick_name,picking,ptype,move, context=None):
res_obj = self.pool.get('res.company')
picking_obj = self.pool.get('stock.picking')
@@ -1762,6 +1763,7 @@ class stock_move(osv.osv):
'date': picking.date,
})
return pick_id
+
def action_confirm(self, cr, uid, ids, context=None):
""" Confirms stock move.
@return: List of ids.
@@ -1804,9 +1806,10 @@ class stock_move(osv.osv):
if pickid:
wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
if new_moves:
- create_chained_picking(self, cr, uid, new_moves, context)
- create_chained_picking(self, cr, uid, moves, context)
- return []
+ new_moves += create_chained_picking(self, cr, uid, new_moves, context)
+ return new_moves
+ all_moves = create_chained_picking(self, cr, uid, moves, context)
+ return all_moves
def action_assign(self, cr, uid, ids, *args):
""" Changes state to confirmed or waiting.
@@ -2059,8 +2062,7 @@ class stock_move(osv.osv):
if move.picking_id:
picking_ids.append(move.picking_id.id)
if move.move_dest_id.id and (move.state != 'done'):
- self.write(cr, uid, [move.id], {'move_history_ids': [(4, move.move_dest_id.id)]})
- #cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id))
+ self.write(cr, uid, [move.id], {'stock_move_history_ids': [(4, move.move_dest_id.id)]}, context=context)
if move.move_dest_id.state in ('waiting', 'confirmed'):
self.action_assign(cr, uid, [move.move_dest_id.id])
if move.move_dest_id.picking_id:
@@ -2248,7 +2250,18 @@ class stock_move(osv.osv):
self.write(cr, uid, [current_move], update_val)
return res
- def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None):
+ def trigger_move_state(self, cr, uid, move, state, context=None):
+ if isinstance(move, (int, long)):
+ move = [move]
+ res = []
+ if state == 'confirm':
+ res = self.action_confirm(cr, uid, move, context=context)
+ if state == 'assigned':
+ self.check_assign(cr, uid, move, context=context)
+ self.force_assign(cr, uid, move, context=context)
+ return res
+
+ def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None):
""" Consumed product with specific quatity from specific source location
@param cr: the database cursor
@param uid: the user id
@@ -2276,12 +2289,12 @@ class stock_move(osv.osv):
quantity = move.product_qty
uos_qty = quantity / move_qty * move.product_uos_qty
+ state = (move.state in ('confirm', 'assign') and move.state) or 'confirm'
if quantity_rest > 0:
default_val = {
'product_qty': quantity,
'product_uos_qty': uos_qty,
- 'state': move.state,
'location_id': location_id or move.location_id.id,
}
if move.product_id.track_production and location_id:
@@ -2314,6 +2327,8 @@ class stock_move(osv.osv):
for (id, name) in product_obj.name_get(cr, uid, [new_move.product_id.id]):
message = _('Product ') + " '" + name + "' "+ _("is consumed with") + " '" + str(new_move.product_qty) + "' "+ _("quantity.")
self.log(cr, uid, new_move.id, message)
+
+ self.trigger_move_state(cr, uid, res, state, context=context)
self.action_done(cr, uid, res)
return res
From 754c921bd02858cd0a09ecc9a5cfbcf1146071ab Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Thu, 16 Dec 2010 17:34:02 +0530
Subject: [PATCH 06/18] [FIX]Stock_planning:Unable to create Forecasting
periods from Create Stock and Sales Periods Menu
lp bug: https://launchpad.net/bugs/690581 fixed
bzr revid: ron@tinyerp.com-20101216120402-h832bva5c7t30296
---
.../wizard/stock_planning_create_periods.py | 43 ++++++++++++++-----
1 file changed, 33 insertions(+), 10 deletions(-)
diff --git a/addons/stock_planning/wizard/stock_planning_create_periods.py b/addons/stock_planning/wizard/stock_planning_create_periods.py
index 12e0d56e755..72acc603ff8 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):
interval = context.get('interval',0)
name = context.get('name','Daily')
@@ -59,28 +59,51 @@ class stock_period_createlines(osv.osv_memory):
lines = []
for p in self.browse(cr, uid, ids, context=context):
dt = p.date_start
+ dt_s = p.date_stop
+ 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.strftime('%Y-%m-%d') <= p.date_stop:
if name =='Daily':
- de = ds + relativedelta(days=interval, minutes =-1)
+ de = ds + relativedelta(days=(interval + 1), seconds =-1)
new_name = de.strftime('%Y-%m-%d')
new_id = period_obj.create(cr, uid, {
'name': new_name,
'date_start': ds.strftime('%Y-%m-%d'),
'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)
+ start_week = ds.strftime('%W')
+ start_year = ds.strftime('%Y')
+ end_week = de.strftime('%W')
+ end_year = de.strftime('%Y')
+ if start_year <> end_year:
+ if end_week == '00':
+ new_name = "Week " + start_week +"-" + start_year
+ else:
+ new_name = "Week " + start_week +", " + start_year +" - Week " +end_week +", " + end_year
+ elif start_week == end_week:
+ new_name = "Week " + start_week +"-" +start_year
+
+ else:
+ new_name = "Week " + start_week +"-" + end_week+", " + start_year
new_id = period_obj.create(cr, uid, {
'name': new_name,
'date_start': ds.strftime('%Y-%m-%d'),
'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')
new_id =period_obj.create(cr, uid, {
'name': new_name,
From 2646ac2706cd3dbd62968c52b7fb933978a786a4 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Thu, 16 Dec 2010 18:10:52 +0530
Subject: [PATCH 07/18] [FIX]PRODUCT: the ean13 check is incorrect for check
digit 0
lp bug: https://launchpad.net/bugs/690763 fixed
bzr revid: ron@tinyerp.com-20101216124052-pqkbymrrlm0yr8ia
---
addons/product/product.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/addons/product/product.py b/addons/product/product.py
index b51a0df9c5f..ef9d9965a84 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
@@ -503,9 +503,9 @@ class product_product(osv.osv):
if sellers:
for s in sellers:
mydict = {
- 'id': product.id,
- 'name': s.product_name or product.name,
- 'default_code': s.product_code or product.default_code,
+ 'id': product.id,
+ 'name': s.product_name or product.name,
+ 'default_code': s.product_code or product.default_code,
'variants': product.variants
}
result.append(_name_get(mydict))
From 876bcf590be102c0ac1cd0a0f0048fe20f7fe929 Mon Sep 17 00:00:00 2001
From: "rha@tinyerp.com" <>
Date: Mon, 20 Dec 2010 18:37:36 +0530
Subject: [PATCH 08/18] [Fix]: Bug #691433 purchase.report view model does not
work
bzr revid: rha@tinyerp.com-20101220130736-lgn6zmsxpskzfw54
---
addons/purchase/report/purchase_report.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py
index f30d65d8f28..251876da416 100644
--- a/addons/purchase/report/purchase_report.py
+++ b/addons/purchase/report/purchase_report.py
@@ -99,7 +99,10 @@ class purchase_report(osv.osv):
extract(epoch from age(l.date_planned,s.date_order))/(24*60*60)::decimal(16,2) as delay_pass,
count(*) as nbr,
(l.price_unit*l.product_qty*u.factor)::decimal(16,2) as price_total,
- avg(100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor))::decimal(16,2) as negociation,
+ avg(case when t.standard_price <= 0 then (100.0 * (l.price_unit*l.product_qty*u.factor))
+ else
+ (100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor))
+ end) as negociation,
sum(t.standard_price*l.product_qty*u.factor)::decimal(16,2) as price_standard,
(sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average
from purchase_order s
From d776dc002561039d0e7f9b777ef613fd41d7a752 Mon Sep 17 00:00:00 2001
From: "rha@tinyerp.com" <>
Date: Tue, 21 Dec 2010 12:33:04 +0530
Subject: [PATCH 09/18] [Merge]
bzr revid: rha@tinyerp.com-20101221070304-dp0tb1lc8pqfb28e
---
addons/product/i18n/product.pot | 1 -
addons/product/i18n/vi.po | 1 -
2 files changed, 2 deletions(-)
diff --git a/addons/product/i18n/product.pot b/addons/product/i18n/product.pot
index 3c3416460cb..0583959553b 100644
--- a/addons/product/i18n/product.pot
+++ b/addons/product/i18n/product.pot
@@ -1401,7 +1401,6 @@ msgstr ""
#. module: product
#: model:product.pricelist,name:product.list0
-#: report:product.pricelist:0
msgid "Public Pricelist"
msgstr ""
diff --git a/addons/product/i18n/vi.po b/addons/product/i18n/vi.po
index 867cff0a9ac..62c8ca5e0b1 100644
--- a/addons/product/i18n/vi.po
+++ b/addons/product/i18n/vi.po
@@ -1518,7 +1518,6 @@ msgstr ""
#. module: product
#: model:product.pricelist,name:product.list0
-#: report:product.pricelist:0
msgid "Public Pricelist"
msgstr "Bảng giá công bố"
From bcdfc08fb79a3005f6a98430318d7bfcd41ad6fc Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Tue, 21 Dec 2010 12:42:38 +0530
Subject: [PATCH 10/18] [FIX]mrp: in MO consuming product not taking Exiting
Lot
lp bug: https://launchpad.net/bugs/691012 fixed
bzr revid: ron@tinyerp.com-20101221071238-3zyspxlqmow7nmh0
---
addons/mrp/mrp_view.xml | 12 ++++++------
addons/stock/stock.py | 6 ++----
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index 0720aa3e829..2bf8a9fd5a5 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -600,8 +600,13 @@
+
-
From d1736e906a3a6969084a26ed3b699a050029c274 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Tue, 21 Dec 2010 16:38:52 +0530
Subject: [PATCH 13/18] [FIX]PO- Filter Button Approved shows approved and
done on Domain
lp bug: https://launchpad.net/bugs/692913 fixed
bzr revid: ron@tinyerp.com-20101221110852-v8xtn0sypuf5oclx
---
addons/purchase/purchase_view.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index 2cfa8a01726..406125e9d4f 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -199,7 +199,7 @@
-
+
From 40756ba216ab71753ee35852767c991b61c500d2 Mon Sep 17 00:00:00 2001
From: "rha@tinyerp.com" <>
Date: Tue, 21 Dec 2010 16:44:06 +0530
Subject: [PATCH 14/18] [Fix]: Bug #692868 Custom Reports do not open
bzr revid: rha@tinyerp.com-20101221111406-k7tny7cmx8v01uyr
---
.../base_report_creator/base_report_creator.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/addons/base_report_creator/base_report_creator.py b/addons/base_report_creator/base_report_creator.py
index 28228b4ab58..663df95047b 100644
--- a/addons/base_report_creator/base_report_creator.py
+++ b/addons/base_report_creator/base_report_creator.py
@@ -193,16 +193,17 @@ class report_creator(osv.osv):
if context is None:
context = {}
data = context.get('report_id', False)
+ res = super(report_creator, self).read(cr, user, ids, fields, context, load)
if (not context) or 'report_id' not in context:
- return super(report_creator, self).read(cr, user, ids, fields, context, load)
+ return res
ctx = context or {}
wp = ''
- if data:
+ for data in res:
+ if not data.get('sql_query'):
+ return res
if self.model_set_id:
wp = [self._id_get(cr, user, data, context) + (' in (%s)' % (','.join(map(lambda x: "'" + str(x) + "'", ids))))]
- report = self._sql_query_get(cr, user, [data], 'sql_query', None, ctx, where_plus = wp)
- sql_query = report[data]
- cr.execute(sql_query)
+ cr.execute(data['sql_query'])
res = cr.dictfetchall()
fields_get = self.fields_get(cr, user, None, context)
for r in res:
@@ -216,7 +217,7 @@ class report_creator(osv.osv):
related_name = self.pool.get(field_dict.get('relation')).name_get(cr, user, [r[k]], context)[0]
r[k] = related_name
- return res
+ return res
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
"""
@@ -253,9 +254,8 @@ class report_creator(osv.osv):
newargs += [("count(*) " + a[1] +" " + str(a[2]))]
ctx = context or {}
ctx['getid'] = True
- report = self._sql_query_get(cr, user, [context_id], 'sql_query', None, ctx, where_plus = newargs, limit=limit, offset=offset)
- query = report[context_id]
- cr.execute(query, newargs2)
+ sql_query = report.sql_query
+ cr.execute(sql_query, newargs2)
result = cr.fetchall()
return map(lambda x: x[0], result)
From 5cb326ed8183aeb55e0372beae52c853d9c68dce Mon Sep 17 00:00:00 2001
From: "rha@tinyerp.com" <>
Date: Tue, 21 Dec 2010 18:38:49 +0530
Subject: [PATCH 15/18] [Fix]: Bug #692950 add a filter button Ready selected
by default in Manufacturing order
bzr revid: rha@tinyerp.com-20101221130849-2ydpumhtp7wr5lcb
---
addons/mrp/mrp_view.xml | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index e17c3370ac3..ba8647814f0 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -730,12 +730,15 @@
-
+
+
-
+ help="Manufacturing Orders which are ready to start production."/>
tree,form,calendar,graph,gantt
- {'search_default_current':1}
+ {'search_default_ready':1}
Manufacturing Orders are usually proposed automatically by OpenERP based on the bill of materials and the procurement rules, but you can also create manufacturing orders manually. OpenERP will handle the consumation of the raw materials (stock decrease) and the production of the finished products (stock increase) when the order is processed.
From c4d5104dd6f25a9a9b33c66663d027e6f6640d2a Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Wed, 22 Dec 2010 10:20:21 +0530
Subject: [PATCH 16/18] [IMP]MRP:-Improvement Code BUG :-691012
bzr revid: ron@tinyerp.com-20101222045021-hmyte79qnqneo1xe
---
addons/mrp/mrp_view.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index 500366d6b0a..52142fe2e64 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -606,7 +606,7 @@
name="%(stock.track_line)d"
string="Split in production lots"
type="action" icon="gtk-justify-fill"
- states="raft,waiting,confirmed,assigned" />
+ states="draft,waiting,confirmed,assigned" />
Date: Wed, 22 Dec 2010 14:22:18 +0530
Subject: [PATCH 17/18] [ADD] ADD Field Lot id in wizard to change Product
Quantity from Product form View
bzr revid: ron@tinyerp.com-20101222085218-dukwbse1bt5yu2z5
---
.../stock/wizard/stock_change_product_qty.py | 35 +++++++++++++------
.../wizard/stock_change_product_qty_view.xml | 4 +++
2 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py
index 4e437eef815..1d97f9f2072 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', 'Lot Number',domain="[('product_id','=',product_id)]"),
+ 'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade", 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','=',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..01d46ff5780 100644
--- a/addons/stock/wizard/stock_change_product_qty_view.xml
+++ b/addons/stock/wizard/stock_change_product_qty_view.xml
@@ -10,6 +10,9 @@
+
+
+
@@ -27,6 +30,7 @@
stock.change.product.qty
form
form
+ {'default_product_id': active_id}
new
From 48f64d6312199407ca1dd6d5297e50deaa59cf9c Mon Sep 17 00:00:00 2001
From: "rpa (Open ERP)"
Date: Wed, 22 Dec 2010 17:34:20 +0530
Subject: [PATCH 18/18] [FIX]: stock: Fixed picking name according to its type
while creating chained picking
lp bug: https://launchpad.net/bugs/663999 fixed
bzr revid: rpa@tinyerp.com-20101222120420-smwbdjm204z556gm
---
addons/stock/stock.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index cfaa17f4c5d..f2f428513f2 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1763,7 +1763,7 @@ class stock_move(osv.osv):
result[m.picking_id].append( (m, dest) )
return result
- def _create_chained_picking(self, cr, uid, pick_name,picking,ptype,move, context=None):
+ def _create_chained_picking(self, cr, uid, pick_name, picking, ptype, move, context=None):
res_obj = self.pool.get('res.company')
picking_obj = self.pool.get('stock.picking')
pick_id= picking_obj.create(cr, uid, {
@@ -1796,11 +1796,18 @@ class stock_move(osv.osv):
new_moves = []
if context is None:
context = {}
+ seq_obj = self.pool.get('ir.sequence')
for picking, todo in self._chain_compute(cr, uid, moves, context=context).items():
ptype = todo[0][1][5] and todo[0][1][5] or location_obj.picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
- pick_name = picking.name or ''
if picking:
- pickid = self._create_chained_picking(cr, uid, pick_name,picking,ptype,todo,context)
+ # name of new picking according to its type
+ new_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + ptype)
+ pickid = self._create_chained_picking(cr, uid, new_pick_name, picking, ptype, todo, context=context)
+ # Need to check name of old picking because it always considers picking as "OUT" when created from Sale Order
+ old_ptype = location_obj.picking_type_get(cr, uid, picking.move_lines[0].location_id, picking.move_lines[0].location_dest_id)
+ if old_ptype != picking.type:
+ old_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + old_ptype)
+ self.pool.get('stock.picking').write(cr, uid, picking.id, {'name': old_pick_name}, context=context)
else:
pickid = False
for move, (loc, dummy, delay, dummy, company_id, ptype) in todo: