diff --git a/addons/account/account.py b/addons/account/account.py index 9a1b796ef5e..caa70065bb1 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -665,6 +665,15 @@ class account_move(osv.osv): return periods[0] else: return False + + def _amount_compute(self, cr, uid, ids, name, args, context, where =''): + if not ids: return {} + cr.execute('select move_id,sum(debit) from account_move_line where move_id in ('+','.join(map(str,ids))+') group by move_id') + result = dict(cr.fetchall()) + for id in ids: + result.setdefault(id, 0.0) + return result + _columns = { 'name': fields.char('Entry Name', size=64, required=True), 'ref': fields.char('Ref', size=64), @@ -673,6 +682,8 @@ class account_move(osv.osv): 'state': fields.selection([('draft','Draft'), ('posted','Posted')], 'Status', required=True, readonly=True), 'line_id': fields.one2many('account.move.line', 'move_id', 'Entries', states={'posted':[('readonly',True)]}), 'to_check': fields.boolean('To Be Verified'), + 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store=True), + 'amount': fields.function(_amount_compute, method=True, string='Amount', digits=(16,2), store=True), } _defaults = { 'state': lambda *a: 'draft', diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 5c1acf39e1c..461ee657531 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -465,6 +465,8 @@ + + @@ -807,11 +809,15 @@
+ - - + + + + + diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index b72d9ce0503..56c096bd85b 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -176,8 +176,13 @@ class mrp_bom(osv.osv): 'name': fields.char('Name', size=64, required=True), 'code': fields.char('Code', size=16), 'active': fields.boolean('Active'), - 'type': fields.selection([('normal','Normal BoM'),('phantom','Sets / Phantom')], 'BoM Type', required=True, help="Use a phantom bill of material in lines that have a sub-bom and that have to be automatically computed in one line, without having two production orders."), - + 'type': fields.selection([('normal','Normal BoM'),('phantom','Sets / Phantom')], 'BoM Type', required=True, help= + "Use a phantom bill of material in raw materials lines that have to be " \ + "automatically computed in on eproduction order and not one per level." \ + "If you put \"Phantom/Set\" at the root level of a bill of material " \ + "it is considered as a set or pack: the products are replaced by the components " \ + "between the sale order to the picking without going through the production order." \ + "The normal BoM will generate one production order per BoM level."), 'method': fields.function(_compute_type, string='Method', method=True, type='selection', selection=[('',''),('stock','On Stock'),('order','On Order'),('set','Set / Pack')]), 'date_start': fields.date('Valid From', help="Validity of this BoM or component. Keep empty if it's always valid."), diff --git a/addons/project/project.py b/addons/project/project.py index f27fa4f00c9..3319bd1e571 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -132,7 +132,7 @@ class project(osv.osv): 'warn_footer': fields.text('Mail footer'), 'notes': fields.text('Notes'), 'timesheet_id': fields.many2one('hr.timesheet.group', 'Working Time'), - 'state': fields.selection([('template', 'Template'), ('open', 'Open'), ('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'State', required=True), + 'state': fields.selection([('template', 'Template'), ('open', 'Open'), ('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'State', required=True, readonly=True), } _defaults = { @@ -153,6 +153,22 @@ class project(osv.osv): res = self.setActive(cr, uid, ids, value=False, context=context) return res + def set_done(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'done'}, context=context) + return True + + def set_cancel(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'cancelled'}, context=context) + return True + + def set_pending(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'pending'}, context=context) + return True + + def set_open(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'open'}, context=context) + return True + def reset_project(self, cr, uid, ids, context={}): res = self.setActive(cr, uid, ids,value=True, context=context) return res @@ -176,7 +192,11 @@ class project(osv.osv): project_ids = [x[0] for x in res] for child in project_ids: self.duplicate_template(cr, uid, [child],context={'parent_id':new_id}) - return True + + # TODO : Improve this to open the new project (using a wizard) + + 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.')) # set active value for a project, its sub projects and its tasks def setActive(self, cr, uid, ids, value=True, context={}): diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index edbabad208d..45db7cee9dd 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -30,11 +30,17 @@ - +