~camptocamp/account-invoicing/correct_payment_term_balance_mdh

« back to all changes in this revision

Viewing changes to account_invoice_merge/invoice.py

  • Committer: Yannick Vaucher
  • Author(s): ddico at oerp
  • Date: 2014-03-04 12:43:19 UTC
  • mfrom: (30.1.1 account-invoicing)
  • Revision ID: yannick.vaucher@camptocamp.com-20140304124319-06fxo40zigm3im6h
Recreate link with invoices originating from account_analytic_line (eg. Timesheet invoice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from openerp.osv import orm
23
23
from openerp import netsvc
24
 
from osv.orm import browse_record, browse_null
 
24
from openerp.osv.orm import browse_record, browse_null
25
25
 
26
26
 
27
27
class account_invoice(orm.Model):
182
182
                for org_po in po_obj.browse(cr, uid, todo_ids, context=context):
183
183
                    po_obj.write(cr, uid, [org_po.id], {'invoice_ids': [(4, new_invoice_id)]}, context)
184
184
 
 
185
        # recreate link (if any) between original analytic account line (invoice time sheet for example) and this new invoice
 
186
        anal_line_obj = self.pool.get('account.analytic.line')
 
187
        for new_invoice_id in invoices_info:
 
188
            todo_ids = anal_line_obj.search(cr, uid, [('invoice_id', 'in', invoices_info[new_invoice_id])], context=context)
 
189
            anal_line_obj.write(cr, uid, todo_ids, {'invoice_id': new_invoice_id}, context=context)
 
190
 
185
191
        return invoices_info
186
192
 
187
193
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: