Merge lp:~gs.clearcorp/openerp-ccorp-addons/7.0_budget2 into lp:openerp-ccorp-addons/7.0

Proposed by Glen Sojo
Status: Merged
Merged at revision: 895
Proposed branch: lp:~gs.clearcorp/openerp-ccorp-addons/7.0_budget2
Merge into: lp:openerp-ccorp-addons/7.0
Diff against target: 70 lines (+33/-2)
2 files modified
budget/account_invoice.py (+32/-1)
budget/budget.py (+1/-1)
To merge this branch: bzr merge lp:~gs.clearcorp/openerp-ccorp-addons/7.0_budget2
Reviewer Review Type Date Requested Status
ClearCorp drivers Pending
Review via email: mp+225091@code.launchpad.net

Description of the change

[FIX] - Fixed budget.move.basic workflow to flow up invoice states.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'budget/account_invoice.py'
2--- budget/account_invoice.py 2014-06-16 15:49:37 +0000
3+++ budget/account_invoice.py 2014-06-30 22:16:51 +0000
4@@ -38,6 +38,20 @@
5 res = context.get('from_order', False)
6 return res
7
8+ def action_cancel(self, cr, uid, ids, context=None):
9+ res = super(account_invoice, self).action_cancel(cr, uid, ids, context=context)
10+ for invoice in self.browse(cr, uid, ids, context=context):
11+ if invoice.budget_move_id:
12+ invoice.budget_move_id._workflow_signal('button_cancel', context=context)
13+ return res
14+
15+ def action_cancel_draft(self, cr, uid, ids, *args):
16+ res = super(account_invoice, self).action_cancel_draft(cr, uid, ids, *args)
17+ for invoice in self.browse(cr, uid, ids):
18+ if invoice.budget_move_id:
19+ invoice.budget_move_id._workflow_signal('button_draft')
20+ return res
21+
22 _columns= {
23 'budget_move_id': fields.many2one('budget.move', 'Budget move', readonly=True, ),
24 'from_order': fields.boolean('From order')
25@@ -58,6 +72,19 @@
26 move_id = bud_move_obj.create(cr, uid, { 'type': type }, context=context)
27 return move_id
28
29+ def update_budget_move(self,cr, uid, ids, context=None):
30+ bud_move_obj = self.pool.get('budget.move')
31+ acc_inv_obj = self.pool.get('account.invoice')
32+ for invoice in acc_inv_obj.browse(cr, uid, ids, context=context):
33+ if invoice.type in ('in_invoice','out_refund'):
34+ type = 'manual_invoice_in'
35+ if invoice.type in ('out_invoice','in_refund'):
36+ type = 'manual_invoice_out'
37+ invoice.budget_move_id.write({ 'type': type}, context=context)
38+ move_ids = [(2, x.id)for x in invoice.budget_move_id.move_lines]
39+ if move_ids:
40+ invoice.budget_move_id.write({'move_lines': move_ids}, context=context)
41+
42
43 def create_budget_move_line_from_invoice(self, cr, uid, line_id, is_tax=False, context=None):
44 acc_inv_obj = self.pool.get('account.invoice')
45@@ -154,7 +181,11 @@
46 validate_result = super(account_invoice,self).invoice_validate(cr, uid, ids, context=context)
47 if not self._check_from_order(cr, uid, context=context, ids=ids):
48 for order in self.browse(cr,uid,ids, context=context):
49- move_id = self.create_budget_move(cr, uid, ids, context=context)
50+ if not order.budget_move_id:
51+ move_id = self.create_budget_move(cr, uid, ids, context=context)
52+ else:
53+ move_id = order.budget_move_id.id
54+ self.update_budget_move(cr, uid, [order.id], context=context)
55 self.write(cr, uid, [order.id], {'budget_move_id' :move_id }, context=context)
56 #creating budget move lines per invoice line
57 for line in order.invoice_line:
58
59=== modified file 'budget/budget.py'
60--- budget/budget.py 2014-02-20 19:26:46 +0000
61+++ budget/budget.py 2014-06-30 22:16:51 +0000
62@@ -1397,7 +1397,7 @@
63 for bud_move_line in self.browse(cr, uid, ids, context=context):
64 if bud_move_line.program_line_id.program_id.plan_id.state in ('cancel','closed'):
65 raise osv.except_osv(_('Error!'), _('You cannot create a budget move with a canceled or closed plan'))
66- super(budget_move_line, self).unlink(cr, uid, ids, vals, context=context)
67+ super(budget_move_line, self).unlink(cr, uid, ids, context=context)
68
69 class account_move_line_distribution(orm.Model):
70 _name = "account.move.line.distribution"

Subscribers

People subscribed via source and target branches