Now property are also browse record
authorced <>
Thu, 9 Aug 2007 06:06:56 +0000 (06:06 +0000)
committerced <>
Thu, 9 Aug 2007 06:06:56 +0000 (06:06 +0000)
bzr revid: ced-315ea94bfeeaec57242089e941c1da0eb6b6b074

27 files changed:
addons/account/account.py
addons/account/account_analytic_line.py
addons/account/account_bank_statement.py
addons/account/account_move_line.py
addons/account/invoice.py
addons/delivery/sale.py
addons/delivery/wizard/delivery_invoice_onshipping.py
addons/delivery/wizard/delivery_sale_order.py
addons/esale_ez/esale.py
addons/esale_joomla/esale_joomla.py
addons/esale_osc/esale_osc.py
addons/hr_expense/hr_expense.py
addons/hr_timesheet/hr_timesheet.py
addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py
addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
addons/l10n_ch/v11/v11_import.py
addons/mrp/mrp.py
addons/mrp/report/price.py
addons/project/project.py
addons/project/wizard/billing.py
addons/purchase/purchase.py
addons/sale/sale.py
addons/sale/wizard/wizard_sale_line_invoice.py
addons/sale_crm/wizard/makesale.py
addons/sale_journal/sale_journal_inherit.py
addons/sale_rebate/sale.py
addons/stock/stock.py

index 354b315..5ae52dc 100644 (file)
@@ -276,7 +276,7 @@ class account_account(osv.osv):
                        if name and str(name).startswith('partner:'):
                                part_id = int(name.split(':')[1])
                                part = self.pool.get('res.partner').browse(cr, user, part_id, context)
-                               args += [('id','in', (part.property_account_payable[0],part.property_account_receivable[0]))]
+                               args += [('id','in', (part.property_account_payable.id, part.property_account_receivable.id))]
                                name = False
                        if name and str(name).startswith('type:'):
                                type = name.split(':')[1]
index 1295357..3a5188e 100644 (file)
@@ -74,12 +74,12 @@ class account_analytic_line(osv.osv):
                                rate = hunit.factor
                        product_obj = self.pool.get('product.product')
                        prod = product_obj.browse(cr, uid, prod_id)
-                       a = prod.product_tmpl_id.property_account_expense
+                       a = prod.product_tmpl_id.property_account_expense.id
                        if not a:
-                               a = prod.categ_id.property_account_expense_categ
+                               a = prod.categ_id.property_account_expense_categ.id
                        if not a:
                                raise osv.except_osv('Error !', 'There is no expense account define for this product: "%s" (id:%d)' % (prod.name, prod.id,))
-                       return {'value' : {'amount' : -round(unit_amount * prod.standard_price * rate,2), 'general_account_id':a[0]}}
+                       return {'value' : {'amount' : -round(unit_amount * prod.standard_price * rate,2), 'general_account_id':a}}
                return {}
 
 account_analytic_line()
index 930396f..a685908 100644 (file)
@@ -269,9 +269,9 @@ class account_bank_statement_line(osv.osv):
                        return {}
                part = self.pool.get('res.partner').browse(cr, uid, partner_id, context)
                if type=='supplier':
-                       account_id = part.property_account_payable[0]
+                       account_id = part.property_account_payable.id
                else:
-                       account_id =  part.property_account_receivable[0]
+                       account_id =  part.property_account_receivable.id
                cr.execute('select sum(debit-credit) from account_move_line where (reconcile_id is null) and partner_id=%d and account_id=%d', (partner_id, account_id))
                balance = cr.fetchone()[0] or 0.0
                val = {'amount': balance, 'account_id':account_id}
index bb3b345..7a4d4cc 100644 (file)
@@ -241,8 +241,8 @@ class account_move_line(osv.osv):
                if (not partner_id) or account_id:
                        return {}
                part = self.pool.get('res.partner').browse(cr, uid, partner_id)
-               id1 = part.property_account_payable[0]
-               id2 =  part.property_account_receivable[0]
+               id1 = part.property_account_payable.id
+               id2 =  part.property_account_receivable.id
                cr.execute('select sum(debit-credit) from account_move_line where (reconcile_id is null) and partner_id=%d and account_id=%d', (partner_id, id2))
                balance = cr.fetchone()[0] or 0.0
                val = {}
index b972284..f1b5cdd 100644 (file)
@@ -186,10 +186,10 @@ class account_invoice(osv.osv):
                        invoice_addr_id = res['invoice']
                        p = self.pool.get('res.partner').browse(cr, uid, partner_id)
                        if type in ('out_invoice', 'out_refund'):
-                               acc_id = p.property_account_receivable
+                               acc_id = p.property_account_receivable.id
                        else:
-                               acc_id = p.property_account_payable
-                               
+                               acc_id = p.property_account_payable.id
+
                        partner_bank_id = p.bank_ids and p.bank_ids[0] and p.bank_ids[0].id or False
                        payment_term = p.property_payment_term and p.property_payment_term or False
 
@@ -197,8 +197,8 @@ class account_invoice(osv.osv):
                                                        'account_id': acc_id,'partner_bank_id':partner_bank_id,
                                                        'payment_term':payment_term}}
 
-               if partner_id and p.property_payment_term:
-                       result['value']['payment_term'] = p.property_payment_term
+               if partner_id and p.property_payment_term.id:
+                       result['value']['payment_term'] = p.property_payment_term.id
                return result
 
        def onchange_currency_id(self, cr, uid, ids, curr_id):
@@ -692,22 +692,20 @@ class account_invoice_line(osv.osv):
                        taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_tax
                tax_obj = self.pool.get('account.tax')
                if type in ('out_invoice', 'out_refund'):
-                       if not taxep or not taxep[0]:
+                       if not taxep or not taxep.id:
                                tax_id = map(lambda x: x.id, res.taxes_id)
                        else:
-                               tax_id = [taxep[0]]
-                               tp = tax_obj.browse(cr, uid, taxep[0])
+                               tax_id = [taxep.id]
                                for t in res.taxes_id:
-                                       if not t.tax_group==tp.tax_group:
+                                       if not t.tax_group==taxep.tax_group:
                                                tax_id.append(t.id)
                else:
-                       if not taxep or not taxep[0]:
+                       if not taxep or not taxep.id:
                                tax_id = map(lambda x: x.id, res.supplier_taxes_id)
                        else:
-                               tax_id = [taxep[0]]
-                               tp = tax_obj.browse(cr, uid, taxep[0])
+                               tax_id = [taxep.id]
                                for t in res.supplier_taxes_id:
-                                       if not t.tax_group==tp.tax_group:
+                                       if not t.tax_group==taxep.tax_group:
                                                tax_id.append(t.id)
                if type in ('in_invoice', 'in_refund'):
                        result = self.product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)
@@ -718,15 +716,15 @@ class account_invoice_line(osv.osv):
                        result['name'] = res.name
 
                if type in ('out_invoice','out_refund'):
-                       a =  res.product_tmpl_id.property_account_income
+                       a =  res.product_tmpl_id.property_account_income.id
                        if not a:
-                               a = res.categ_id.property_account_income_categ
+                               a = res.categ_id.property_account_income_categ.id
                else:
-                       a =  res.product_tmpl_id.property_account_expense
+                       a =  res.product_tmpl_id.property_account_expense.id
                        if not a:
-                               a = res.categ_id.property_account_expense_categ
+                               a = res.categ_id.property_account_expense_categ.id
                if a:
-                       result['account_id'] = a[0]
+                       result['account_id'] = a
 
                domain = {}
                result['uos_id'] = uom or res.uom_id.id or False
@@ -776,12 +774,11 @@ class account_invoice_line(osv.osv):
                        return {}
                taxes = self.pool.get('account.account').browse(cr, uid, account_id).tax_ids
                taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_tax
-               if not taxep:
+               if not taxep.id:
                        return {'value': {'invoice_line_tax_id': map(lambda x: x.id, taxes or []) }}
-               res = [taxep[0]]
-               tp = self.pool.get('account.tax').browse(cr, uid, taxep[0])
+               res = [taxep.id]
                for t in taxes:
-                       if not t.tax_group==tp.tax_group:
+                       if not t.tax_group==taxep.tax_group:
                                res.append(t.id)
                r = {'value':{'invoice_line_tax_id': res}}
                return r
index 5ff3644..bb80f8c 100644 (file)
@@ -15,8 +15,8 @@ class sale_order(osv.osv):
        def onchange_partner_id(self, cr, uid, ids, part):
                result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
                if part:
-                       dtype = self.pool.get('res.partner').browse(cr, uid, part).property_delivery_carrier
-                       result['value']['carrier_id'] = dtype and dtype[0]
+                       dtype = self.pool.get('res.partner').browse(cr, uid, part).property_delivery_carrier.id
+                       result['value']['carrier_id'] = dtype
                return result
 
        def action_ship_create(self, cr, uid, ids, *args):
index 4519f58..5ad964e 100644 (file)
@@ -100,10 +100,9 @@ def _create_invoice(self, cr, uid, data, context):
                price = pool.get('delivery.grid').get_price_from_picking(cr, uid, grid_id, 
                        invoice.amount_untaxed, picking.weight,
                        picking.volume, context) or 0.0
-               a =  picking.carrier_id.product_id.product_tmpl_id.property_account_income
-               if not a:
-                       a = picking.carrier_id.product_id.categ_id.property_account_income_categ
-               account_id =  a[0]
+               account_id =  picking.carrier_id.product_id.product_tmpl_id.property_account_income.id
+               if not account_id:
+                       account_id = picking.carrier_id.product_id.categ_id.property_account_income_categ.id
                pool.get('account.invoice.line').create(cr, uid, {
                        'name':picking.carrier_id.name,
                        'invoice_id': inv_id,
index dd2ef2c..7bca6ad 100644 (file)
@@ -48,7 +48,7 @@ def _delivery_default(self, cr, uid, data, context):
        if not order.state in ('draft'):
                raise wizard.except_wizard('Order not in draft state !', 'The order state have to be draft to add delivery lines.')
 
-       carrier_id = order.partner_id.property_delivery_carrier
+       carrier_id = order.partner_id.property_delivery_carrier.id
        return {'carrier_id': carrier_id}
 
 def _delivery_set(self, cr, uid, data, context):
index fffadb6..dfa931a 100644 (file)
@@ -60,7 +60,7 @@ class esale_web(osv.osv):
        # Compute the price for one product
        #
        def price_get(self, cr, uid, product_id, product_qty, partner_id):
-               pricelist = self.pool.get('res.partner').browse(cr, uid, partner_id).property_product_pricelist[0]
+               pricelist = self.pool.get('res.partner').browse(cr, uid, partner_id).property_product_pricelist.id
                price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], product_id, product_qty)[pricelist]
                return price
 
@@ -92,7 +92,7 @@ class esale_web(osv.osv):
        #  ]})
        #
        def compute(self, cr, uid, ids, order, context={}):
-               pricelist = self.pool.get('res.partner').browse(cr, uid, order['partner_id']).property_product_pricelist[0]
+               pricelist = self.pool.get('res.partner').browse(cr, uid, order['partner_id']).property_product_pricelist.id
                subtotal = 0
                taxes = 0
                for product in order['products']:
@@ -168,7 +168,7 @@ class esale_order(osv.osv):
        def order_create(self, cr, uid, ids, context={}):
                for order in self.browse(cr, uid, ids, context):
                        addr = self.pool.get('res.partner').address_get(cr, uid, [order.partner_id.id], ['delivery','invoice','contact'])
-                       pricelist_id=order.partner_id.property_product_pricelist[0]
+                       pricelist_id=order.partner_id.property_product_pricelist.id
                        order_lines = []
                        for line in order.order_lines:
                                order_lines.append( (0,0,{
index cded449..75d4d6f 100644 (file)
@@ -222,7 +222,7 @@ class esale_joomla_order(osv.osv):
                for order in self.browse(cr, uid, ids, context):
                        if not (order.partner_id and order.partner_invoice_id and order.partner_shipping_id):
                                raise osv.except_osv('No addresses !', 'You must assign addresses before creating the order.')
-                       pricelist_id=order.partner_id.property_product_pricelist[0]
+                       pricelist_id=order.partner_id.property_product_pricelist.id
                        order_lines = []
                        for line in order.order_lines:
                                val = {
index 07db79a..4dfe0fc 100644 (file)
@@ -184,7 +184,7 @@ class esale_osc_saleorder(osv.osv):
        def order_create(self, cr, uid, ids, context={}):
                for order in self.browse(cr, uid, ids, context):
                        addr = self.pool.get('res.partner').address_get(cr, uid, [order.partner_id.id], ['delivery','invoice','contact'])
-                       pricelist_id=order.partner_id.property_product_pricelist[0]
+                       pricelist_id=order.partner_id.property_product_pricelist.id
                        order_lines = []
                        for line in order.order_lines:
                                order_lines.append( (0,0,{
index 8320923..b2e9bb0 100644 (file)
@@ -124,11 +124,9 @@ class hr_expense_expense(osv.osv):
                        for l in exp.line_ids:
                                tax_id = []
                                if l.product_id:
-                                       acc = l.product_id.product_tmpl_id.property_account_expense
+                                       acc = l.product_id.product_tmpl_id.property_account_expense.id
                                        if not acc:
-                                               acc = l.product_id.categ_id.property_account_expense_categ[0]
-                                       else:
-                                               acc = acc[0]
+                                               acc = l.product_id.categ_id.property_account_expense_categ.id
                                        tax_id = [x.id for x in l.product_id.supplier_taxes_id]
                                else:
                                        acc = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category')
@@ -144,7 +142,7 @@ class hr_expense_expense(osv.osv):
                                }))
                        if not exp.employee_id.address_id:
                                raise osv.except_osv('Error !', 'The employee must have a contact address')
-                       acc = exp.employee_id.address_id.partner_id.property_account_payable[0]
+                       acc = exp.employee_id.address_id.partner_id.property_account_payable.id
                        inv = {
                                'name': exp.name,
                                'reference': self.pool.get('ir.sequence').get(cr, uid, 'hr.expense.invoice'),
index a780f47..76a9778 100644 (file)
@@ -90,11 +90,11 @@ class hr_analytic_timesheet(osv.osv):
                if emp_id:
                        emp = self.pool.get('hr.employee').browse(cr, uid, emp_id[0], context=context)
                        if bool(emp.product_id):
-                               a =  emp.product_id.product_tmpl_id.property_account_income
+                               a =  emp.product_id.product_tmpl_id.property_account_income.id
                                if not a:
-                                       a = emp.product_id.categ_id.property_account_income_categ
+                                       a = emp.product_id.categ_id.property_account_income_categ.id
                                if a:
-                                       return a[0]
+                                       return a
                return False
 
        def _getAnalyticJournal(self, cr, uid, context):
index 1d8f6a8..b36a9b2 100644 (file)
@@ -60,8 +60,8 @@ class final_invoice_create(wizard.interface):
                                'partner_id': account.partner_id.id,
                                'address_contact_id': pool.get('res.partner').address_get(cr, uid, [account.partner_id.id], adr_pref=['contact'])['contact'],
                                'address_invoice_id': pool.get('res.partner').address_get(cr, uid, [account.partner_id.id], adr_pref=['invoice'])['invoice'],
-                               'payment_term': (partner.property_payment_term and partner.property_payment_term[0]) or False,
-                               'account_id': partner.property_account_receivable[0],
+                               'payment_term': partner.property_payment_term.id or False,
+                               'account_id': partner.property_account_receivable.id,
                                'currency_id': account.pricelist_id.currency_id.id,
                                'project_id': account.id
                        }
@@ -87,16 +87,15 @@ class final_invoice_create(wizard.interface):
 
                                taxes = product.taxes_id
                                taxep = account.partner_id.property_account_tax
-                               if not taxep:
+                               if not taxep.id:
                                        tax = [x.id for x in taxes or []]
                                else:
-                                       tax = [taxep[0]]
-                                       tp = pool.get('account.tax').browse(cr, uid, taxep[0])
+                                       tax = [taxep.id]
                                        for t in taxes:
-                                               if not t.tax_group==tp.tax_group:
+                                               if not t.tax_group==taxep.tax_group:
                                                        tax.append(t.id)
 
-                               account_id = product.product_tmpl_id.property_account_income or product.categ_id.property_account_income_categ
+                               account_id = product.product_tmpl_id.property_account_income.id or product.categ_id.property_account_income_categ.id
 
                                curr_line = {
                                        'price_unit': price,
@@ -107,7 +106,7 @@ class final_invoice_create(wizard.interface):
                                        'name': factor_name,
                                        'product_id': product_id,
                                        'uos_id': product.uom_id.id,
-                                       'account_id': account_id[0],
+                                       'account_id': account_id,
                                        'account_analytic_id': account.id,
                                }
 
@@ -145,13 +144,12 @@ class final_invoice_create(wizard.interface):
                                else:
                                        taxes = []
                                taxep = account.partner_id.property_account_tax
-                               if not taxep:
+                               if not taxep.id:
                                        tax = [x.id for x in taxes or []]
                                else:
-                                       tax = [taxep[0]]
-                                       tp = pool.get('account.tax').browse(cr, uid, taxep[0])
+                                       tax = [taxep.id]
                                        for t in taxes:
-                                               if not t.tax_group==tp.tax_group:
+                                               if not t.tax_group==taxep.tax_group:
                                                        tax.append(t.id)
 
                                curr_line = {
@@ -175,16 +173,15 @@ class final_invoice_create(wizard.interface):
 
                                        taxes = product.taxes_id
                                        taxep = account.partner_id.property_account_tax
-                                       if not taxep:
+                                       if not taxep.id:
                                                tax = [x.id for x in taxes or []]
                                        else:
-                                               tax = [taxep[0]]
-                                               tp = pool.get('account.tax').browse(cr, uid, taxep[0])
+                                               tax = [taxep.id]
                                                for t in taxes:
-                                                       if not t.tax_group==tp.tax_group:
+                                                       if not t.tax_group==taxep.tax_group:
                                                                tax.append(t.id)
        
-                                       account_id = product.product_tmpl_id.property_account_income or product.categ_id.property_account_income_categ
+                                       account_id = product.product_tmpl_id.property_account_income.id or product.categ_id.property_account_income_categ.id
 
                                        curr_line = {
                                                'price_unit': account.amount_max - amount_total,
index 053b26c..861985d 100644 (file)
@@ -60,8 +60,8 @@ class invoice_create(wizard.interface):
                                'partner_id': account.partner_id.id,
                                'address_contact_id': pool.get('res.partner').address_get(cr, uid, [account.partner_id.id], adr_pref=['contact'])['contact'],
                                'address_invoice_id': pool.get('res.partner').address_get(cr, uid, [account.partner_id.id], adr_pref=['invoice'])['invoice'],
-                               'payment_term': (partner.property_payment_term and partner.property_payment_term[0]) or False,
-                               'account_id': partner.property_account_receivable[0],
+                               'payment_term': partner.property_payment_term.id or False,
+                               'account_id': partner.property_account_receivable.id,
                                'currency_id': account.pricelist_id.currency_id.id,
                        }
                        last_invoice = pool.get('account.invoice').create(cr, uid, curr_invoice)
@@ -88,16 +88,15 @@ class invoice_create(wizard.interface):
 
                                taxes = product.taxes_id
                                taxep = account.partner_id.property_account_tax
-                               if not taxep:
+                               if not taxep.id:
                                        tax = [x.id for x in taxes or []]
                                else:
-                                       tax = [taxep[0]]
-                                       tp = pool.get('account.tax').browse(cr, uid, taxep[0])
+                                       tax = [taxep.id]
                                        for t in taxes:
-                                               if not t.tax_group==tp.tax_group:
+                                               if not t.tax_group==taxep.tax_group:
                                                        tax.append(t.id)
 
-                               account_id = product.product_tmpl_id.property_account_income or product.categ_id.property_account_income_categ
+                               account_id = product.product_tmpl_id.property_account_income.id or product.categ_id.property_account_income_categ.id
 
                                curr_line = {
                                        'price_unit': price,
@@ -109,7 +108,7 @@ class invoice_create(wizard.interface):
                                        'product_id': data['form']['product'] or product_id,
                                        'invoice_line_tax_id': [(6,0,tax)],
                                        'uos_id': product.uom_id.id,
-                                       'account_id': account_id[0],
+                                       'account_id': account_id,
                                        'account_analytic_id': account.id,
                                }
 
index e8c5c19..7264ab9 100644 (file)
@@ -176,7 +176,7 @@ def _v11_parsing(self, cr, uid, data, context):
                i = invoice_obj.browse(cr, uid, invoice_id)
 
                try:
-                       acc1 = i.partner_id.property_account_receivable[0]
+                       acc1 = i.partner_id.property_account_receivable.id
                except:
                        err_log = err_log + '\n * invoice with number '+ rec['invoice_ref'].lstrip('0') +\
                                          ' has no partner !'+ '\n  line : '+rec['line_number']
index 5edbae9..d28f577 100644 (file)
@@ -417,7 +417,7 @@ class mrp_production(osv.osv):
                                self.pool.get('stock.move').write(cr, uid, new_moves, vals)
                        else:
                                # Why is it there ? Aren't we suppose to already have a created_move ?
-                               source = production.product_id.product_tmpl_id.property_stock_production[0]
+                               source = production.product_id.product_tmpl_id.property_stock_production.id
                                vals = {
                                        'name':'PROD:'+production.name,
                                        'date_planned': production.date_planned,
@@ -505,7 +505,7 @@ class mrp_production(osv.osv):
                        if production.move_prod_id:
                                self.pool.get('stock.move').write(cr, uid, [production.move_prod_id.id], {'location_id':production.location_dest_id.id})
 
-                       source = production.product_id.product_tmpl_id.property_stock_production[0]
+                       source = production.product_id.product_tmpl_id.property_stock_production.id
                        data = {
                                'name':'PROD:'+production.name,
                                'date_planned': production.date_planned,
@@ -753,7 +753,7 @@ class mrp_procurement(osv.osv):
                                if not procurement.move_id:
                                        source = procurement.location_id.id
                                        if procurement.procure_method=='make_to_order':
-                                               source = procurement.product_id.product_tmpl_id.property_stock_procurement[0]
+                                               source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
                                        id = self.pool.get('stock.move').create(cr, uid, {
                                                'name': 'PROC:'+procurement.name,
                                                'location_id': source,
@@ -825,7 +825,7 @@ class mrp_procurement(osv.osv):
                        partner = procurement.product_id.seller_ids[0].name
                        partner_id = partner.id
                        address_id = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['delivery'])['delivery']
-                       pricelist_id = partner.property_product_pricelist_purchase[0]
+                       pricelist_id = partner.property_product_pricelist_purchase.id
 
                        uom_id = procurement.product_id.uom_po_id.id
 
index 0d34543..6c7f39e 100644 (file)
@@ -53,7 +53,7 @@ class report_custom(report_rml):
                        main_strd_price = ''
                        if prod.seller_ids and prod.seller_ids[0] :
                                main_sp_name = '<b>' + prod.seller_ids[0].name.name + '</b>\r\n'
-                               pricelist = prod.seller_ids[0].name.property_product_pricelist_purchase
+                               pricelist = prod.seller_ids[0].name.property_product_pricelist_purchase.id
                                if pricelist:
                                        pricelist_id = pricelist[0]
                                        pricelist_obj = pooler.get_pool(cr.dbname).get('product.pricelist')
@@ -71,7 +71,7 @@ class report_custom(report_rml):
                        sellers_price = ''
                        for seller_id in prod.seller_ids:
                                sellers +=  '- <i>'+ seller_id.name.name +'</i>\r\n'
-                               pricelist = seller_id.name.property_product_pricelist_purchase
+                               pricelist = seller_id.name.property_product_pricelist_purchase.id
                                if pricelist:
                                        pricelist_id = pricelist[0]
                                        pricelist_obj = pooler.get_pool(cr.dbname).get('product.pricelist')
index cd1d43b..2d0ccfc 100644 (file)
@@ -85,9 +85,8 @@ class project(osv.osv):
                if not part:
                        return {'value':{'contact_id': False, 'pricelist_id': False}}
                addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact'])
-               print part, self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist
 
-               pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist[0]
+               pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist.id
                return {'value':{'contact_id': addr['contact'], 'pricelist_id': pricelist}}
 
        _columns = {
index d8feff2..916753f 100644 (file)
@@ -92,9 +92,9 @@ def _do_orders(self, cr, uid, data, context):
                                raise wizard.except_wizard('Error !', 'No pricelist defined in the project definition.')
                        adr = pooler.get_pool(cr.dbname).get('res.partner').address_get(cr, uid, [partner.id], ['default','invoice','shipping'])
 
-                       a = partner.property_account_receivable[0]
+                       a = partner.property_account_receivable.id
                        if partner.property_payment_term:
-                               pay_term = partner.property_payment_term[0]
+                               pay_term = partner.property_payment_term.id
                        else:
                                pay_term = False
 
index 53437fc..93b4fa0 100644 (file)
@@ -120,7 +120,7 @@ class purchase_order(osv.osv):
                'invoice_method': lambda *a: 'order',
                'invoiced': lambda *a: 0,
                'partner_address_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['default'])['default'],
-               'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase[0],
+               'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase.id,
        }
        _name = "purchase.order"
        _description = "Purchase order"
@@ -133,7 +133,7 @@ class purchase_order(osv.osv):
                if not adr_id:
                        return {}
                part_id = self.pool.get('res.partner.address').read(cr, uid, [adr_id], ['partner_id'])[0]['partner_id'][0]
-               loc_id = self.pool.get('res.partner').browse(cr, uid, part_id).property_stock_customer[0]
+               loc_id = self.pool.get('res.partner').browse(cr, uid, part_id).property_stock_customer.id
                return {'value':{'location_id': loc_id, 'warehouse_id': False}}
 
        def onchange_warehouse_id(self, cr, uid, ids, warehouse_id):
@@ -146,7 +146,7 @@ class purchase_order(osv.osv):
                if not part:
                        return {'value':{'partner_address_id': False}}
                addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['default'])
-               pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist_purchase[0]
+               pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist_purchase.id
                return {'value':{'partner_address_id': addr['default'], 'pricelist_id': pricelist}}
 
        def wkf_approve_order(self, cr, uid, ids):
@@ -188,12 +188,11 @@ class purchase_order(osv.osv):
                        for ol in o.order_line:
 
                                if ol.product_id:
-                                       a = ol.product_id.product_tmpl_id.property_account_expense
+                                       a = ol.product_id.product_tmpl_id.property_account_expense.id
                                        if not a:
-                                               a = ol.product_id.categ_id.property_account_expense_categ
+                                               a = ol.product_id.categ_id.property_account_expense_categ.id
                                        if not a:
                                                raise osv.except_osv('Error !', 'There is no income account defined for this product: "%s" (id:%d)' % (line.product_id.name, line.product_id.id,))
-                                       a = a[0]
                                else:
                                        a = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category')
                                il.append((0, False, {
@@ -207,7 +206,7 @@ class purchase_order(osv.osv):
                                        'account_analytic_id': ol.account_analytic_id.id,
                                }))
 
-                       a = o.partner_id.property_account_payable[0]
+                       a = o.partner_id.property_account_payable.id
                        inv = {
                                'name': o.name,
                                'reference': "P%dPO%d" % (o.partner_id.id, o.id),
@@ -237,7 +236,7 @@ class purchase_order(osv.osv):
        def action_picking_create(self,cr, uid, ids, *args):
                picking_id = False
                for order in self.browse(cr, uid, ids):
-                       loc_id = order.partner_id.property_stock_supplier[0]
+                       loc_id = order.partner_id.property_stock_supplier.id
                        istate = 'none'
                        if order.invoice_method=='picking':
                                istate = '2binvoiced'
index ddbea97..c016bdf 100644 (file)
@@ -166,7 +166,7 @@ class sale_order(osv.osv):
                'partner_invoice_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['invoice'])['invoice'],
                'partner_order_id': lambda self, cr, uid, context: context.get('partner_id', False) and  self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['contact'])['contact'],
                'partner_shipping_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['delivery'])['delivery'],
-               'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist[0],
+               'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist.id,
        }
        _order = 'name desc'
 
@@ -198,7 +198,7 @@ class sale_order(osv.osv):
                if not part:
                        return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False}}
                addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery','invoice','contact'])
-               pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist[0]
+               pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist.id
                return {'value':{'partner_invoice_id': addr['invoice'], 'partner_order_id':addr['contact'], 'partner_shipping_id':addr['delivery'], 'pricelist_id': pricelist}}
 
        def button_dummy(self, cr, uid, ids, context={}):
@@ -217,9 +217,9 @@ class sale_order(osv.osv):
                invoice_ids = []
 
                def make_invoice(order, lines):
-                       a = order.partner_id.property_account_receivable[0]
-                       if order.partner_id and order.partner_id.property_payment_term:
-                               pay_term = order.partner_id.property_payment_term[0]
+                       a = order.partner_id.property_account_receivable.id
+                       if order.partner_id and order.partner_id.property_payment_term.id:
+                               pay_term = order.partner_id.property_payment_term.id
                        else:
                                pay_term = False
                        for preinv in order.invoice_ids:
@@ -385,7 +385,7 @@ class sale_order(osv.osv):
                                if line.product_id and line.product_id.product_tmpl_id.type in ('product', 'consu'):
                                        location_id = order.shop_id.warehouse_id.lot_stock_id.id
                                        if not picking_id:
-                                               loc_dest_id = order.partner_id.property_stock_customer[0]
+                                               loc_dest_id = order.partner_id.property_stock_customer.id
                                                picking_id = self.pool.get('stock.picking').create(cr, uid, {
                                                        'origin': order.name,
                                                        'type': 'out',
@@ -579,12 +579,11 @@ class sale_order_line(osv.osv):
                for line in self.browse(cr, uid, ids, context):
                        if not line.invoiced:
                                if line.product_id:
-                                       a =  line.product_id.product_tmpl_id.property_account_income
+                                       a =  line.product_id.product_tmpl_id.property_account_income.id
                                        if not a:
-                                               a = line.product_id.categ_id.property_account_income_categ
+                                               a = line.product_id.categ_id.property_account_income_categ.id
                                        if not a:
                                                raise osv.except_osv('Error !', 'There is no income account defined for this product: "%s" (id:%d)' % (line.product_id.name, line.product_id.id,))
-                                       a = a[0]
                                else:
                                        a = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context)
                                uosqty = _get_line_qty(line)
@@ -663,13 +662,12 @@ class sale_order_line(osv.osv):
                        taxep = None
                        if partner_id:
                                taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_tax
-                       if not taxep:
+                       if not taxep.id:
                                result['tax_id'] = res['taxes_id']
                        else:
-                               res5 = [taxep[0]]
-                               tp = self.pool.get('account.tax').browse(cr, uid, taxep[0])
+                               res5 = [taxep.id]
                                for t in taxes:
-                                       if not t.tax_group==tp.tax_group:
+                                       if not t.tax_group==taxep.tax_group:
                                                res5.append(t.id)
                                result['tax_id'] = res5
 
index eb01efd..a6ac4c3 100644 (file)
@@ -50,7 +50,7 @@ def _makeInvoices(self, cr, uid, data, context):
 
        #TODO: merge with sale.py/make_invoice
        def make_invoice(order, lines):
-               a = order.partner_id.property_account_receivable[0]
+               a = order.partner_id.property_account_receivable.id
                inv = {
                        'name': order.name,
                        'origin': 'SO:'+str(order.id)+':'+order.name,
index 3696c07..fbc54a9 100644 (file)
@@ -68,7 +68,7 @@ class make_sale(wizard.interface):
                sale = pooler.get_pool(cr.dbname).get('sale.order')
                partner_obj = pooler.get_pool(cr.dbname).get('res.partner')
                partner_addr = partner_obj.address_get(cr, uid, [data['form']['partner_id']], ['invoice', 'delivery', 'contact'])
-               pricelist = partner_obj.browse(cr, uid, data['form']['partner_id'], context).property_product_pricelist[0]
+               pricelist = partner_obj.browse(cr, uid, data['form']['partner_id'], context).property_product_pricelist.id
                vals = {
                        'origin': 'BO:%s' % str(data['ids'][0]),
                        'picking_policy': data['form']['picking_policy'],
index 38f79a4..5347890 100644 (file)
@@ -72,7 +72,7 @@ class sale(osv.osv):
        def onchange_partner_id(self, cr, uid, ids, part):
                result = super(sale, self).onchange_partner_id(cr, uid, ids, part)
                if part:
-                       itype = self.pool.get('res.partner').browse(cr, uid, part).property_invoice_type
-                       result['value']['invoice_type_id'] = itype and itype[0]
+                       itype = self.pool.get('res.partner').browse(cr, uid, part).property_invoice_type.id
+                       result['value']['invoice_type_id'] = itype
                return result
 sale()
index 290481b..13e92c7 100644 (file)
@@ -94,7 +94,7 @@ class sale_order_rebate(osv.osv):
                        return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'partner_order_id': False}}
                partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
                addr = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['delivery', 'invoice', 'contact'])
-               pricelist = partner.property_product_pricelist[0]
+               pricelist = partner.property_product_pricelist.id
                return {
                        'value': {
                                'rebate_percent': partner.rebate or 0.0, 
index 0d79817..809ce64 100644 (file)
@@ -486,9 +486,9 @@ class stock_picking(osv.osv):
                for p in self.browse(cr,uid,ids, context):
                        if p.invoice_state<>'2binvoiced':
                                continue
-                       a = p.address_id.partner_id.property_account_receivable[0]
-                       if p.address_id.partner_id and p.address_id.partner_id.property_payment_term:
-                               pay_term = p.address_id.partner_id.property_payment_term[0]
+                       a = p.address_id.partner_id.property_account_receivable.id
+                       if p.address_id.partner_id and p.address_id.partner_id.property_payment_term.id:
+                               pay_term = p.address_id.partner_id.property_payment_term.id
                        else:
                                pay_term = False
 
@@ -534,10 +534,9 @@ class stock_picking(osv.osv):
                                        tax_ids = map(lambda x: x.id, line.sale_line_id.tax_id)
                                else:
                                        tax_ids = map(lambda x: x.id, line.product_id.taxes_id)
-                               a =  line.product_id.product_tmpl_id.property_account_income
-                               if not a:
-                                       a = line.product_id.categ_id.property_account_income_categ
-                               account_id =  a[0]
+                               account_id =  line.product_id.product_tmpl_id.property_account_income.id
+                               if not account_id:
+                                       account_id = line.product_id.categ_id.property_account_income_categ.id
                                punit = line.sale_line_id and line.sale_line_id.price_unit or line.product_id.list_price
                                if type in ('in_invoice','in_refund'):
                                        punit = line.product_id.standard_price
@@ -806,22 +805,20 @@ class stock_move(osv.osv):
                                if move.product_id.categ_id:
                                        test.append( ('product.category', move.product_id.categ_id.id) )
                                if not acc_src:
-                                       a = move.product_id.product_tmpl_id.property_account_expense
-                                       if not a:
-                                               a = move.product_id.categ_id.property_account_expense_categ
-                                       if not a:
+                                       acc_src = move.product_id.product_tmpl_id.property_account_expense.id
+                                       if not acc_src:
+                                               a = move.product_id.categ_id.property_account_expense_categ.id
+                                       if not acc_src:
                                                raise osv.except_osv('Error !', 'There is no expense account defined for this product: "%s" (id:%d)' % (move.product_id.name, move.product_id.id,))
-                                       acc_src = a[0]
                                if not acc_dest:
-                                       b = move.product_id.product_tmpl_id.property_account_income
-                                       if not b:
-                                               b = move.product_id.categ_id.property_account_income_categ
-                                       if not b:
+                                       acc_dest = move.product_id.product_tmpl_id.property_account_income.id
+                                       if not acc_dest:
+                                               acc_dest = move.product_id.categ_id.property_account_income_categ.id
+                                       if not acc_dest:
                                                raise osv.except_osv('Error !', 'There is no income account defined for this product: "%s" (id:%d)' % (move.product_id.name, move.product_id.id,))
-                                       acc_dest = b[0]
-                               if not move.product_id.categ_id.property_stock_journal:
+                               if not move.product_id.categ_id.property_stock_journal.id:
                                        raise osv.except_osv('Error !', 'There is no journal define on the product category: "%s" (id:%d)' % (move.product_id.categ_id.name, move.product_id.categ_id.id,))
-                               journal_id = move.product_id.categ_id.property_stock_journal[0]
+                               journal_id = move.product_id.categ_id.property_stock_journal.id
                                if acc_src != acc_dest:
                                        ref = move.picking_id and move.picking_id.name or False
 
@@ -891,7 +888,7 @@ class stock_inventory(osv.osv):
                                amount=self.pool.get('stock.location')._product_get(cr, uid, line.location_id.id, [pid], {'uom': line.product_uom.id})[pid]
                                change=line.product_qty-amount
                                if change:
-                                       location_id = line.product_id.product_tmpl_id.property_stock_inventory[0]
+                                       location_id = line.product_id.product_tmpl_id.property_stock_inventory.id
                                        value = {
                                                'name': 'INV:'+str(line.inventory_id.id)+':'+line.inventory_id.name,
                                                'product_id': line.product_id.id,