bzr revid: nch@tinyerp.com-20090506051341-cpd7pk22zne07zfp
This commit is contained in:
Naresh Choksy 2009-05-06 10:43:41 +05:30
commit 08d596707c
7 changed files with 28 additions and 27 deletions

View File

@ -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.'))

View File

@ -512,7 +512,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph,gantt</field>
<field name="domain">[('project_id', 'child_of', [active_id])]</field>
<field name="context">{'project_id':active_id}</field>
<field name="context">{'project_id':active_id, 'active_test':False}</field>
</record>
<record id="ir_project_task_open" model="ir.values">
<field eval=" 'tree_but_open'" name="key2"/>

View File

@ -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 " \

View File

@ -55,7 +55,7 @@
<record id="act_invoice_done" model="workflow.activity">
<field name="wkf_id" ref="purchase_order"/>
<field name="name">invoice_done</field>
<field name="action">write({'invoiced':1,'state':'approved'})</field>
<field name="action">write({'state':'approved'})</field>
<field name="kind">function</field>
</record>
<record id="act_invoice_end" model="workflow.activity">

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). 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)

View File

@ -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)

View File

@ -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