← Back to team overview

openerp-india team mailing list archive

[Bug 1043857] Re: Account vouchers don't change period to the right company

 

** Changed in: openobject-addons
       Status: In Progress => Confirmed

-- 
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/1043857

Title:
  Account vouchers don't change period to the right company

Status in OpenERP Addons (modules):
  Confirmed

Bug description:
  When changing the company on a voucher it doesn't set the correct
  period for that voucher, so it will not be able to generate the
  move.lines necessary latter, I attached a patch for it (I can create a
  branch and submit a pull request if it is preferable):

  === modified file 'account_voucher/account_voucher.py'
  --- account_voucher/account_voucher.py	2012-08-28 10:58:11 +0000
  +++ account_voucher/account_voucher.py	2012-08-30 14:02:12 +0000
  @@ -705,6 +705,16 @@
                   res[key].update(vals[key])
           return res
   
  +    def onchange_company_id(self, cr, uid, ids, company_id, date, context=None):
  +        if context is None:
  +            context ={}
  +        ctx = context.copy()
  +        ctx.update({'company_id': company_id})
  +        period_pool = self.pool.get('account.period')
  +        pids = period_pool.find(cr, uid, date, context=ctx)
  +        if pids:
  +            return {'value': {'period_id': pids[0]}}
  +
       def onchange_date(self, cr, uid, ids, date, currency_id, payment_rate_currency_id, amount, company_id, context=None):
           """
           @param date: latest value from user input for field date

  === modified file 'account_voucher/account_voucher_view.xml'
  --- account_voucher/account_voucher_view.xml	2012-01-31 13:36:57 +0000
  +++ account_voucher/account_voucher_view.xml	2012-08-28 22:27:44 +0000
  @@ -47,7 +47,7 @@
                           <field name="journal_id" widget="selection" select="1" on_change="onchange_journal_voucher(line_ids, tax_id, amount, partner_id, journal_id, type)"/>
                           <field name="type" required="1"/>
                           <field name="name" colspan="2"/>
  -                        <field name="company_id" widget="selection" groups="base.group_multi_company"/>
  +                        <field name="company_id" widget="selection" on_change="onchange_company_id(company_id, date)" groups="base.group_multi_company"/>
                           <field name="reference" select="1"/>
                           <field name="account_id" widget="selection" invisible="True"/>
                       </group>

  === modified file 'account_voucher/voucher_payment_receipt_view.xml'
  --- account_voucher/voucher_payment_receipt_view.xml	2012-01-31 13:36:57 +0000
  +++ account_voucher/voucher_payment_receipt_view.xml	2012-08-28 22:50:47 +0000
  @@ -156,7 +156,7 @@
                           <field name="date" select="1" invisible="context.get('line_type', False)" on_change="onchange_date(date, currency_id, payment_rate_currency_id, amount, company_id, context)"/>
                           <field name="reference" select="1" invisible="context.get('line_type', False)" string="Payment Ref"/>
                           <field name="name" colspan="2" invisible="context.get('line_type', False)"/>
  -                        <field name="company_id" widget="selection" groups="base.group_multi_company"/>
  +                        <field name="company_id" widget="selection" groups="base.group_multi_company" on_change="onchange_company_id(company_id, date)"/>
                           <field name="account_id"
                               widget="selection"
                               invisible="True"/>
  @@ -309,7 +309,7 @@
                           <field name="date" select="1" invisible="context.get('line_type', False)" on_change="onchange_date(date, currency_id, payment_rate_currency_id, amount, company_id, context)"/>
                           <field name="reference" select="1" invisible="context.get('line_type', False)" string="Payment Ref"/>
                           <field name="name" colspan="2" invisible="context.get('line_type', False)"/>
  -                        <field name="company_id" widget="selection" groups="base.group_multi_company"/>
  +                        <field name="company_id" widget="selection" groups="base.group_multi_company" on_change="onchange_company_id(company_id, date)"/>
                           <field name="account_id"
                               widget="selection"
                               invisible="True"/>

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


References