Merge lp:~camptocamp/openobject-addons/hr_expense_cancelling into lp:openobject-addons/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/hr_expense_cancelling
Merge into: lp:openobject-addons/7.0
Diff against target: 40 lines (+19/-0)
2 files modified
hr_expense/hr_expense.py (+18/-0)
hr_expense/hr_expense_view.xml (+1/-0)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/hr_expense_cancelling
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp (community) Approve
OpenERP Core Team Pending
Review via email: mp+177523@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :
review: Needs Fixing (code, no test)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Made fixes

review: Approve

Unmerged revisions

9296. By Yannick Vaucher @ Camptocamp

[PEP8]

9295. By Yannick Vaucher @ Camptocamp

[FIX] add missing context

9294. By Yannick Vaucher @ Camptocamp

[FIX] call workflow even when account_move_id is not set

9293. By Yannick Vaucher @ Camptocamp

[IMP] remove trailing spaces

9292. By Vincent Renaville@camptocamp

[FIX] Allow to cancel an expense

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hr_expense/hr_expense.py'
--- hr_expense/hr_expense.py 2013-05-22 17:49:45 +0000
+++ hr_expense/hr_expense.py 2013-09-02 09:43:57 +0000
@@ -227,6 +227,24 @@
227 total_currency -= i['amount_currency'] or i['price']227 total_currency -= i['amount_currency'] or i['price']
228 return total, total_currency, account_move_lines228 return total, total_currency, account_move_lines
229229
230 def action_expense_cancel(self, cr, uid, ids, context=None):
231 ## We will first check the the move is not reconciled
232 for expense in self.browse(cr, uid, ids, context=context):
233 if expense.account_move_id:
234 for move_line in expense.account_move_id.line_id:
235 if move_line.reconcile_id or move_line.reconcile_partial_id:
236 raise osv.except_osv(
237 _('Error!'),
238 _('Please unreconcile payment accounting entries before cancelling this expense'))
239 ### Then we unlink the move line
240 self.pool.get('account.move').unlink(cr, uid, [expense.account_move_id.id], context=context)
241 wf_service = netsvc.LocalService("workflow")
242 wf_service.trg_delete(uid, 'hr.expense.expense', expense.id, cr)
243 wf_service.trg_create(uid, 'hr.expense.expense', expense.id, cr)
244 wf_service.trg_validate(uid, 'hr.expense.expense', expense.id, 'draft', cr)
245
246 return True
247
230248
231 def action_receipt_create(self, cr, uid, ids, context=None):249 def action_receipt_create(self, cr, uid, ids, context=None):
232 '''250 '''
233251
=== modified file 'hr_expense/hr_expense_view.xml'
--- hr_expense/hr_expense_view.xml 2013-07-02 13:14:56 +0000
+++ hr_expense/hr_expense_view.xml 2013-09-02 09:43:57 +0000
@@ -67,6 +67,7 @@
67 <button name="refuse" states="confirm,accepted" string="Refuse" type="workflow" groups="base.group_hr_user" />67 <button name="refuse" states="confirm,accepted" string="Refuse" type="workflow" groups="base.group_hr_user" />
68 <button name="draft" states="confirm,cancelled" string="Set to Draft" type="workflow" groups="base.group_hr_user" />68 <button name="draft" states="confirm,cancelled" string="Set to Draft" type="workflow" groups="base.group_hr_user" />
69 <button name="done" states="accepted" string="Generate Accounting Entries" type="workflow" groups="account.group_account_invoice" class="oe_highlight"/>69 <button name="done" states="accepted" string="Generate Accounting Entries" type="workflow" groups="account.group_account_invoice" class="oe_highlight"/>
70 <button name="action_expense_cancel" states="done,paid" string="Cancel Expense" type="object" />
70 <button name="action_view_receipt" states="done" string="Open Accounting Entries" type="object" groups="account.group_account_invoice"/>71 <button name="action_view_receipt" states="done" string="Open Accounting Entries" type="object" groups="account.group_account_invoice"/>
71 <field name="state" widget="statusbar" statusbar_visible="draft,confirm,accepted,done,paid" statusbar_colors='{"confirm":"blue","cancelled":"red"}'/>72 <field name="state" widget="statusbar" statusbar_visible="draft,confirm,accepted,done,paid" statusbar_colors='{"confirm":"blue","cancelled":"red"}'/>
72 </header>73 </header>