def _reconciled(self, cr, uid, ids, name, args, context=None):
res = {}
- for id in ids:
- res[id] = self.test_paid(cr, uid, [id])
+ wf_service = netsvc.LocalService("workflow")
+ for inv in self.browse(cr, uid, ids, context=context):
+ res[inv.id] = self.test_paid(cr, uid, [inv.id])
+ if not res[inv.id] and inv.state == 'paid':
+ wf_service.trg_validate(uid, 'account.invoice', inv.id, 'open_test', cr)
return res
def _get_reference_type(self, cr, uid, context=None):
return map(lambda x: (0,0,x), lines)
def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None):
- invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment',\
- 'date_due', 'partner_id', 'address_contact_id',\
- 'address_invoice_id', 'partner_contact',\
- 'partner_insite', 'partner_ref', 'payment_term',\
- 'account_id', 'currency_id', 'invoice_line',\
- 'tax_line', 'journal_id', 'user_id', 'fiscal_position'])
+ invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'address_invoice_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id', 'user_id', 'fiscal_position'])
obj_invoice_line = self.pool.get('account.invoice.line')
obj_invoice_tax = self.pool.get('account.invoice.tax')
obj_journal = self.pool.get('account.journal')
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.category,'+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.category,'+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: