← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~oerp.ca/account-invoicing/account_invoice_merge into lp:account-invoicing

 

Daniel Dico (oerp.ca) has proposed merging lp:~oerp.ca/account-invoicing/account_invoice_merge into lp:account-invoicing.

Requested reviews:
  Account Core Editors (account-core-editors)

For more details, see:
https://code.launchpad.net/~oerp.ca/account-invoicing/account_invoice_merge/+merge/204373

Recreate link with invoices originating from account_analytic_line (eg. Timesheet invoice)
-- 
https://code.launchpad.net/~oerp.ca/account-invoicing/account_invoice_merge/+merge/204373
Your team Account Core Editors is requested to review the proposed merge of lp:~oerp.ca/account-invoicing/account_invoice_merge into lp:account-invoicing.
=== modified file 'account_invoice_merge/invoice.py'
--- account_invoice_merge/invoice.py	2013-08-06 10:14:55 +0000
+++ account_invoice_merge/invoice.py	2014-02-01 05:49:38 +0000
@@ -21,7 +21,7 @@
 
 from openerp.osv import orm
 from openerp import netsvc
-from osv.orm import browse_record, browse_null
+from openerp.osv.orm import browse_record, browse_null
 
 
 class account_invoice(orm.Model):
@@ -182,6 +182,13 @@
                 for org_po in po_obj.browse(cr, uid, todo_ids, context=context):
                     po_obj.write(cr, uid, [org_po.id], {'invoice_ids': [(4, new_invoice_id)]}, context)
 
+        # recreate link (if any) between original analytic account line (invoice time sheet for example) and this new invoice
+        account_analytic_line_obj = self.pool.get('account.analytic.line')
+        for new_invoice_id in invoices_info:
+                todo_ids = account_analytic_line_obj.search(cr, uid, [('invoice_id', 'in', invoices_info[new_invoice_id])], context=context)
+                for aa_line in account_analytic_line_obj.browse(cr, uid, todo_ids, context=context):
+                    account_analytic_line_obj.write(cr, uid, [aa_line.id], {'invoice_id': new_invoice_id}, context)
+
         return invoices_info
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:


Follow ups