'move_lines':fields.function(_get_lines, method=True, type='many2many', relation='account.move.line', string='Entry Lines'),
'residual': fields.function(_amount_residual, method=True, digits_compute=dp.get_precision('Account'), string='Residual',
store={
- 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 50),
+ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line','move_id'], 50),
'account.invoice.tax': (_get_invoice_tax, None, 50),
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 50),
'account.move.line': (_get_invoice_from_line, None, 50),
'move_id':False,
'move_name':False,
'internal_number': False,
+ 'period_id': False
})
if 'date_invoice' not in default:
default.update({
t = t - (p * l[2].get('quantity'))
taxes = l[2].get('invoice_line_tax_id')
if len(taxes[0]) >= 3 and taxes[0][2]:
- taxes = tax_obj.browse(cr, uid, taxes[0][2])
+ taxes = tax_obj.browse(cr, uid, list(taxes[0][2]))
for tax in tax_obj.compute_all(cr, uid, taxes, p,l[2].get('quantity'), context.get('address_invoice_id', False), l[2].get('product_id', False), context.get('partner_id', False))['taxes']:
t = t - tax['amount']
return t
if not partner_id:
raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") )
if not product:
- if type in ('in_invoice', 'in_refund'):
- return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}}
- else:
- return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}}
+ return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}}
part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
fpos_obj = self.pool.get('account.fiscal.position')
fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id, context=context) or False
result = {}
res = self.pool.get('product.product').browse(cr, uid, product, context=context)
- if company_id:
- property_obj = self.pool.get('ir.property')
- account_obj = self.pool.get('account.account')
- in_pro_id = property_obj.search(cr, uid, [('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
- if not in_pro_id:
- in_pro_id = property_obj.search(cr, uid, [('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
- exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
- if not exp_pro_id:
- exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
-
- if not in_pro_id:
- in_acc = res.product_tmpl_id.property_account_income
- in_acc_cate = res.categ_id.property_account_income_categ
- if in_acc:
- app_acc_in = in_acc
- else:
- app_acc_in = in_acc_cate
- else:
- # Get the fields from the ir.property record
- my_value = property_obj.read(cr,uid,in_pro_id,['name','value_reference','res_id'])
- # Parse the value_reference field to get the ID of the account.account record
- account_id = int (my_value[0]["value_reference"].split(",")[1])
- # Use the ID of the account.account record in the browse for the account.account record
- app_acc_in = account_obj.browse(cr, uid, account_id, context=context)
- if not exp_pro_id:
- ex_acc = res.product_tmpl_id.property_account_expense
- ex_acc_cate = res.categ_id.property_account_expense_categ
- if ex_acc:
- app_acc_exp = ex_acc
- else:
- app_acc_exp = ex_acc_cate
- else:
- app_acc_exp = account_obj.browse(cr, uid, exp_pro_id, context=context)[0]
- if not in_pro_id and not exp_pro_id:
- in_acc = res.product_tmpl_id.property_account_income
- in_acc_cate = res.categ_id.property_account_income_categ
- ex_acc = res.product_tmpl_id.property_account_expense
- ex_acc_cate = res.categ_id.property_account_expense_categ
- if in_acc or ex_acc:
- app_acc_in = in_acc
- app_acc_exp = ex_acc
- else:
- app_acc_in = in_acc_cate
- app_acc_exp = ex_acc_cate
- if app_acc_in and app_acc_in.company_id.id != company_id and app_acc_exp and app_acc_exp.company_id.id != company_id:
- in_res_id = account_obj.search(cr, uid, [('name','=',app_acc_in.name),('company_id','=',company_id)])
- exp_res_id = account_obj.search(cr, uid, [('name','=',app_acc_exp.name),('company_id','=',company_id)])
- if not in_res_id and not exp_res_id:
- raise osv.except_osv(_('Configuration Error !'),
- _('Can not find account chart for this company, Please Create account.'))
- in_obj_acc = account_obj.browse(cr, uid, in_res_id, context=context)
- exp_obj_acc = account_obj.browse(cr, uid, exp_res_id, context=context)
- if in_acc or ex_acc:
- res.product_tmpl_id.property_account_income = in_obj_acc[0]
- res.product_tmpl_id.property_account_expense = exp_obj_acc[0]
- else:
- res.categ_id.property_account_income_categ = in_obj_acc[0]
- res.categ_id.property_account_expense_categ = exp_obj_acc[0]
-
if type in ('out_invoice','out_refund'):
a = res.product_tmpl_id.property_account_income.id
if not a: