~domsense/domsense-agilebg-addons/adding_invoice_contract

« back to all changes in this revision

Viewing changes to sale_hour_package/sale.py

  • Committer: Lorenzo Battistini
  • Date: 2012-08-29 15:24:58 UTC
  • Revision ID: lorenzo.battistini@agilebg.com-20120829152458-caw8czwwrc2r6ibh
[add] pass the analytic account to invoice

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        'is_hour_pack': fields.related('product_id', 'hour_pack', type='boolean', string='Is hour package', store=True),
33
33
        'order_state': fields.related('order_id', 'state', type='char', size=64, string='Order state', store=True),
34
34
        }
 
35
        
 
36
    def invoice_line_create(self, cr, uid, ids, context=None):
 
37
        if context is None:
 
38
            context = {}
 
39
        line_obj = self.pool.get('account.invoice.line')
 
40
        create_ids = super(sale_order_line, self).invoice_line_create(cr, uid, ids, context=context)
 
41
        i = 0
 
42
        for line in self.browse(cr, uid, ids, context=context):
 
43
            if line.hour_pack_id:
 
44
                line_obj.write(cr, uid, [create_ids[i]], {'account_analytic_id': line.hour_pack_id.id})
 
45
            i = i + 1
 
46
        return create_ids
35
47
 
36
48
    def generate_hour_pack(self, cr, uid, ids, context=None):
37
49
        anal_acc_pool = self.pool.get('account.analytic.account')