← Back to team overview

credativ team mailing list archive

Re: [Bug 909243] Re: Default property account search function incorrect for invoices

 

*** This bug is a duplicate of bug 900266 ***
    https://bugs.launchpad.net/bugs/900266

Hi Ferdinand,
I fully agree with you. I did focus on accounts for purchasing because I 
could not get basic invoices done properly.
I did pass another bug about purchase order creation with wrong accounts 
so I assume there must be other issues all over the code :

https://bugs.launchpad.net/bugs/909248


Problems with properties is that there is no context given if you try to 
read directly the property (like 
ol.product_tmpl_id.property_account_expense.id) which is completely 
improper for multi-company management.
I just checked the sale/sale.py and we do have the same nasty 
construction...
in _make_invoice:
         a = order.partner_id.property_account_receivable.id

Actually, the best would probably be to call a method in invoice.py 
anytime we need to create an invoice and invoice lines. That way we 
would make sure that accounts are properly recovered



*Eric CAUDAL*, CEO
eric.caudal@xxxxxxxxxxxxxx  <mailto:eric.caudal@xxxxxxxxxxxxxx>
Cell: + 86 186 2136 1670
*Elico Corp - OpenERP Ready Partner, Shanghai.*
http://www.openerp.net.cn

-- 
You received this bug notification because you are a member of OpenERP
Framework Experts, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/909243

Title:
  Default property account search function incorrect for invoices

Status in OpenERP Addons (modules):
  New

Bug description:
  Several error in the product_id_change function that fails in multi-company environment.
  1. account/invoice.py Line 1346 (+/-)
                  app_acc_exp = account_obj.browse(cr, uid, exp_pro_id, context=context)[0]
  is a pointer to a ir_property object instead of a account_account object

  I propose to change the code to 
                  my_value = property_obj.read(cr,uid,exp_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_exp = account_obj.browse(cr, uid, account_id, context=context)

  2. In line 1313-1376 (+/-) code search for account according to company. 
  nevertheless later in account/invoice.py/line 1378
          if type in ('out_invoice','out_refund'):
              a = res.product_tmpl_id.property_account_income.id
              if not a:
                  a = res.categ_id.property_account_income_categ.id
          else:
              a = res.product_tmpl_id.property_account_expense.id
              if not a:
                  a = res.categ_id.property_account_expense_categ.id

  This piece of code search again the account id without company_id (and it is proposing an account id for another company which is incorrect).
  I propose to change the code as follow:
          if company_id:
  [....]
              if type in ('out_invoice','out_refund'):
                  a = app_acc_in.id
              else:
                  a = app_acc_exp.id
          else:#no company_id
              if type in ('out_invoice','out_refund'):
                  a = res.product_tmpl_id.property_account_income.id
                  if not a:
                      a = res.categ_id.property_account_income_categ.id
              else:
                  a = res.product_tmpl_id.property_account_expense.id
                  if not a:
                      a = res.categ_id.property_account_expense_categ.id
          a = fpos_obj.map_account(cr, uid, fpos, a)

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/909243/+subscriptions


References