~openerp-bpso/bpso.openerp/BPSO_improvements_2

« back to all changes in this revision

Viewing changes to BPSO_Expense/BPSO_Expense.py

  • Committer: husen
  • Date: 2010-06-30 07:53:26 UTC
  • mfrom: (2805.1.1 addons)
  • Revision ID: husen@husen-laptop-20100630075326-claz3au3j58jyocj
Improved views menus and search

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    _name = "product.product"
28
28
    _inherit = "product.product"
29
29
    _description = "Product"
 
30
 
 
31
    def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
 
32
        if context is None:
 
33
            context = {}
 
34
        if context.get('analytic_account',False):
 
35
            account_pool = self.pool.get('account.analytic.account')
 
36
            account_rec = account_pool.browse(cr, uid, context['analytic_account'])
 
37
            print "account_rec",account_rec.related_expense_ids
 
38
            type_ids = [type_id.id for type_id in account_rec.related_expense_ids]
 
39
            args.append(('id','in',type_ids))
 
40
        return super(product_product, self).search(cr, uid, args, offset, limit, order, context, count)
 
41
 
30
42
    _columns = {
31
43
        'invoice_id': fields.many2one('hr_timesheet_invoice.factor', 'Invoicing'),
32
44
    }
88
100
            v = super(hr_expense_line, self).onchange_product_id(cr, uid, ids, product_id, uom_id, context=context)
89
101
            inv = self.pool.get("product.product").browse(cr, uid, product_id).invoice_id
90
102
            v['value'].update({'invoice_id': inv.id})
 
103
            v['value'].update({'name': ''})
91
104
            return v
92
105
    def onchange_analytic_account_id(self, cr, uid, ids, account_id, context={}):
93
106
        res={}