Account voucher multi-company

Bug #809558 reported by Kevin McMenamin
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 3

Bug Description

I have created a multi-company environment with holding coy (HoldCoy) and two subsidiaries A & B.
I have created 3 new users - No1 has Holdcoy as default coy with access to other 2, other 2 users have access to either A or B.
I have created a customer with no company value in Sales and Purchases tab
I have created three new journals (one per company) for debtor adjustments.

When I process a debtor adjustment using journal voucher for either A or B it works fine.
When I process for No1 in Holdcoy I get a conmpanyID error - Company must be same for its related account and period.
I have checked partner not linked to another company, user preference coy = journal coy = company = company for GL account.
The only field I cannot check is the default type field - this is a defined list. Is there anything company specific about this field (the account value generated under voucher items is for the correct company).

Any ideas or is this a bug?

Thanks
Kevin

Revision history for this message
Kevin McMenamin (kevin-mcmenamin) wrote :

After further discussion with Graeme Gellalty we have agreed that this is a bug. The issue is that the get_period function gets the first period not the period based on a combination of date & journal or company. As the period is not visible until the record is posted (at which time the journal tab appears) it is not possible for the user to correct.

I have modified the view so that the journal tab is immediately visible so the period can be fixed as an interim workaround, but the get_period function needs to be fixed properly.

Revision history for this message
Graeme Gellatly (gdgellatly) wrote : Re: [Bug 809558] [NEW] Account voucher multi-company
Download full text (4.2 KiB)

This is definitely a bug. And it is blocking as period_id is a hidden field
on that form.

    def _get_period(self, cr, uid, context=None):
        if context is None: context = {}
        if context.get('period_id', False):
            return context.get('period_id')
        periods = self.pool.get('account.period').find(cr, uid)
        return periods and periods[0] or False

    def onchange_date(self, cr, uid, ids, partner_id, journal_id, price,
currency_id, ttype, date, context=None):
        """
        @param date: latest value from user input for field date
        @param args: other arguments
        @param context: context arguments, like lang, time zone
        @return: Returns a dict which contains new values, and context
        """
        period_pool = self.pool.get('account.period')
        res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id,
price, currency_id, ttype, date, context=context)
        pids = period_pool.search(cr, uid, [('date_start', '<=', date),
('date_stop', '>=', date)])
        if pids:
            if not 'value' in res:
                res['value'] = {}
            res['value'].update({'period_id':pids[0]})
        return res

Is the problematic code - all these default and on_change functions need
reviewing. It is incorrect to simply return the first value and assume it
is correct. See bug 804991 for another example.

I recommend at the least in onchange_date passing company_id field and then
changing
pids = period_pool.search(cr, uid, [('date_start', '<=', date),
('date_stop', '>=', date), ('company_id', '=', company_id]) (Note not
tested, consider it pseudo code maybe company_id.id required there.)

On Wed, Jul 13, 2011 at 9:00 AM, Kevin McMenamin
<email address hidden>wrote:

> Public bug reported:
>
> I have created a multi-company environment with holding coy (HoldCoy) and
> two subsidiaries A & B.
> I have created 3 new users - No1 has Holdcoy as default coy with access to
> other 2, other 2 users have access to either A or B.
> I have created a customer with no company value in Sales and Purchases tab
> I have created three new journals (one per company) for debtor adjustments.
>
> When I process a debtor adjustment using journal voucher for either A or B
> it works fine.
> When I process for No1 in Holdcoy I get a conmpanyID error - Company must
> be same for its related account and period.
> I have checked partner not linked to another company, user preference coy =
> journal coy = company = company for GL account.
> The only field I cannot check is the default type field - this is a defined
> list. Is there anything company specific about this field (the account value
> generated under voucher items is for the correct company).
>
> Any ideas or is this a bug?
>
> Thanks
> Kevin
>
> ** Affects: openobject-addons
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to OpenERP
> Addons.
> https://bugs.launchpad.net/bugs/809558
>
> Title:
> Account voucher multi-company
>
> Status in OpenERP Modules (addons):
> New
>
> Bug description:
> I have created a multi-company environment with holding coy (HoldC...

Read more...

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Hello Kevin & Greame,

We have fixed the problem in lp:~openerp/openobject-addons/trunk-account-voucher-rework-qdp branch, It will be merge soon with trunk addons.
We have improved def find method to catch company_id from context and return the result by company.

Thanks,
Mustufa

Changed in openobject-addons:
status: Confirmed → Fix Committed
milestone: none → 6.1
Changed in openobject-addons:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.