← 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

 

** Changed in: openobject-addons
       Status: Fix Committed => Fix Released

-- 
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):
  Fix Released

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