← Back to team overview

openerp-india team mailing list archive

[Bug 1239666] Re: In Purchase receipt account is not autopopulated if partner is not selected

 

Hi,

In basic_onchange_partner function
 
 res = {'value': {'account_id': False}}
 if not partner_id or not journal_id:
            return res
 # Means if partner_id or journal_id is not available then it will return account_id =False. But according to me it should be
if not partner_id and not journal_id:
       return res
Because partner_id is not a required field in purchase receipt then account_id should return base on journal_id but due to this if condition it is returning account_id =False

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

Title:
  In Purchase receipt account is not autopopulated if partner is not
  selected

Status in OpenERP Addons (modules):
  Confirmed

Bug description:
  Hi All,

  In Purchase Receipt form if we will not select partner (partner is not
  a required field) then we can not validate it will show account field
  is invalid.

  Solution:
  1. Either account field should be visible so we can select account value.

  2. Or we have to define default account field value base on journal_id
  and also need to change basic_onchange_partner function in
  account.voucher class

  # If we didnt select partner then account_id will be false according
  to below function

  def basic_onchange_partner(self, cr, uid, ids, partner_id, journal_id, ttype, context=None):
          partner_pool = self.pool.get('res.partner')
          journal_pool = self.pool.get('account.journal')
          res = {'value': {'account_id': False}}
          if not partner_id or not journal_id:
              return res

          journal = journal_pool.browse(cr, uid, journal_id, context=context)
          partner = partner_pool.browse(cr, uid, partner_id, context=context)
          account_id = False
          if journal.type in ('sale','sale_refund'):
              account_id = partner.property_account_receivable.id

          elif journal.type in ('purchase',
  'purchase_refund','expense'):

              account_id = partner.property_account_payable.id
          else:
              account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id

          res['value']['account_id'] = account_id
          return res

  so we need to change below line
  if partner_id and journal.type in ('sale','sale_refund'):
              account_id = partner.property_account_receivable.id

          elif patner_id and journal.type in ('purchase',
  'purchase_refund','expense'):

              account_id = partner.property_account_payable.id

  
  plateform : ubuntu
  version openerp 7.0

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