diff --git a/addons/project/project.py b/addons/project/project.py
index e180bf92a1b..e1af9e8293a 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -156,26 +156,20 @@ class project(osv.osv):
return res
def copy(self, cr, uid, id, default={},context={}):
+ proj = self.browse(cr, uid, id, context=context)
default = default or {}
- default['child_id'] = []
- return super(project, self).copy(cr, uid, id, default, context)
+ context['active_test'] = False
+ default['state'] = 'open'
+ default['name'] = proj.name+_(' (copy)')
+ res = super(project, self).copy(cr, uid, id, default, context)
+ ids = self.search(cr, uid, [('parent_id','child_of', [res])])
+ cr.execute('update project_task set active=True where project_id in ('+','.join(map(str,ids))+')')
+ return res
def duplicate_template(self, cr, uid, ids,context={}):
- for proj in self.browse(cr, uid, ids):
- parent_id=context.get('parent_id',False)
- new_id=self.pool.get('project.project').copy(cr, uid, proj.id,default={'name':proj.name+_(' (copy)'),'state':'open','parent_id':parent_id})
- cr.execute('select id from project_task where project_id=%s', (proj.id,))
- res = cr.fetchall()
- for (tasks_id,) in res:
- self.pool.get('project.task').copy(cr, uid, tasks_id,default={'project_id':new_id,'active':True}, context=context)
- cr.execute('select id from project_project where parent_id=%s', (proj.id,))
- res = cr.fetchall()
- project_ids = [x[0] for x in res]
- for child in project_ids:
- self.duplicate_template(cr, uid, [child],context={'parent_id':new_id})
-
- # TODO : Improve this to open the new project (using a wizard)
-
+ default = {'parent_id': context.get('parent_id',False)}
+ for id in ids:
+ self.copy(cr, uid, id, default=default)
cr.commit()
raise osv.except_osv(_('Operation Done'), _('A new project has been created !\nWe suggest you to close this one and work on this new project.'))
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index 1e10a534ece..2784a0780bc 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -512,7 +512,7 @@
form
tree,form,calendar,graph,gantt
[('project_id', 'child_of', [active_id])]
- {'project_id':active_id}
+ {'project_id':active_id, 'active_test':False}
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 6df6d8911d5..e591269f9c3 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -135,6 +135,15 @@ class purchase_order(osv.osv):
result[line.order_id.id] = True
return result.keys()
+ def _invoiced(self, cursor, user, ids, name, arg, context=None):
+ res = {}
+ for purchase in self.browse(cursor, user, ids, context=context):
+ if purchase.invoice_id.reconciled:
+ res[purchase.id] = purchase.invoice_id.reconciled
+ else:
+ res[purchase.id] = False
+ return res
+
_columns = {
'name': fields.char('Order Reference', size=64, required=True, select=True),
'origin': fields.char('Origin', size=64,
@@ -163,7 +172,7 @@ class purchase_order(osv.osv):
'picking_ids': fields.one2many('stock.picking', 'purchase_id', 'Picking List', readonly=True, help="This is the list of picking list that have been generated for this purchase"),
'shipped':fields.boolean('Received', readonly=True, select=True),
'shipped_rate': fields.function(_shipped_rate, method=True, string='Received', type='float'),
- 'invoiced':fields.boolean('Invoiced & Paid', readonly=True, select=True),
+ 'invoiced': fields.function(_invoiced, method=True, string='Invoiced & Paid', type='boolean'),
'invoiced_rate': fields.function(_invoiced_rate, method=True, string='Invoiced', type='float'),
'invoice_method': fields.selection([('manual','Manual'),('order','From Order'),('picking','From Picking')], 'Invoicing Control', required=True,
help="From Order: a draft invoice will be pre-generated based on the purchase order. The accountant " \
diff --git a/addons/purchase/purchase_workflow.xml b/addons/purchase/purchase_workflow.xml
index 2a3884739ed..26f83d5a554 100644
--- a/addons/purchase/purchase_workflow.xml
+++ b/addons/purchase/purchase_workflow.xml
@@ -55,7 +55,7 @@
invoice_done
- write({'invoiced':1,'state':'approved'})
+ write({'state':'approved'})
function
diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py
index df74b52036a..11383b66b19 100644
--- a/addons/purchase/stock.py
+++ b/addons/purchase/stock.py
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
+# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved
# $Id$
#
@@ -46,7 +46,7 @@ class stock_picking(osv.osv):
_defaults = {
'purchase_id': lambda *a: False,
}
-
+
def get_currency_id(self, cursor, user, picking):
if picking.purchase_id:
return picking.purchase_id.pricelist_id.currency_id.id
@@ -93,8 +93,7 @@ class stock_picking(osv.osv):
def _invoice_hook(self, cursor, user, picking, invoice_id):
purchase_obj = self.pool.get('purchase.order')
if picking.purchase_id:
- purchase_obj.write(cursor, user, [picking.purchase_id.id], {'invoiced':True,
- 'invoice_id': invoice_id,
+ purchase_obj.write(cursor, user, [picking.purchase_id.id], {'invoice_id': invoice_id,
})
return super(stock_picking, self)._invoice_hook(cursor, user,
picking, invoice_id)
diff --git a/addons/purchase/wizard/wizard_group.py b/addons/purchase/wizard/wizard_group.py
index a538a80bc23..8c0bc2dd319 100644
--- a/addons/purchase/wizard/wizard_group.py
+++ b/addons/purchase/wizard/wizard_group.py
@@ -62,7 +62,7 @@ def _mergeOrders(self, cr, uid, data, context):
list_key.append((field, field_val))
list_key.sort()
return tuple(list_key)
-
+
# compute what the new orders should contain
new_orders = {}
for porder in [order for order in order_obj.browse(cr, uid, data['ids']) if order.state == 'draft']:
@@ -120,7 +120,6 @@ def _mergeOrders(self, cr, uid, data, context):
del value['uom_factor']
value.update(dict(key))
order_data['order_line'] = [(0, 0, value) for value in order_data['order_line'].itervalues()]
-
# create the new order
neworder_id = order_obj.create(cr, uid, order_data)
allorders.append(neworder_id)
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index ed908dff6bb..cd1f8ab26ce 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -880,7 +880,7 @@ class sale_order_line(osv.osv):
pack = self.pool.get('product.packaging').browse(cr, uid, packaging, context)
q = product_uom_obj._compute_qty(cr, uid, uom, pack.qty, default_uom)
# qty = qty - qty % q + q
- if not (qty % q) == 0 :
+ if qty and (not (qty % q) == 0):
ean = pack.ean
qty_pack = pack.qty
type_ul = pack.ul