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]
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()
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}
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 = {}
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
'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):
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)
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
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
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):
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,
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):
# 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
# ]})
#
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']:
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,{
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 = {
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,{
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')
}))
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'),
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):
'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
}
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,
'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,
}
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 = {
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,
'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)
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,
'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,
}
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']
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,
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,
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,
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
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')
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')
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 = {
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
'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"
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):
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):
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, {
'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),
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'
'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'
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={}):
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:
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',
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)
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
#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,
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'],
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()
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,
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
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
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
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,