Cant process picking in multi-company environment

Bug #804991 reported by Eric Caudal - www.elico-corp.com
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 3

Bug Description

In 6.02
With 2 companies A and B, 2 charts of account and 2 periods set, one for each company.
Creating a purchase order and then I try to process the "incoming shipment".
When click in "Process", then in subform in "Validate" I receive the following message:
Error occurred while validating the field(s) company_id: Company must be same for its related account and period.

This is due to the fact that no periods are passed in stock_partial_move.do_partial()
And then in account._get_period(), all periods are returned and the first period is chosen instead of chosing the one corresponding to the user.
Maybe change in _get_period()
       periods = self.pool.get('account.period').find(cr, uid)
and add a filter according to the user

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

I have tried on 6.0.02 and works fine - are you sure that the company under user/preferences was the same as the PO you were receipting?

Revision history for this message
Eric Caudal - www.elico-corp.com (elicoidal) wrote : Re: [Bug 804991] Re: Cant process picking in multi-company environment

Yes, the user is in the same company as the PO.
It depends on the order in which you create the periods in database. for
example: create first the periods for company A in the database (then B)
and try to receive an incoming shipment for company B
_get_periods gives you the first period id it finds in the table.

Eric CAUDAL
<email address hidden> <mailto:<email address hidden>>
Cell phone: + 86 186 2136 1670

Elico Corp, Shanghai
OpenERP Ready Partner
http://www.elico-corp.com

On 04/07/2011 04:44, Kevin McMenamin wrote:
> I have tried on 6.0.02 and works fine - are you sure that the company
> under user/preferences was the same as the PO you were receipting?
>

Revision history for this message
Graeme Gellatly (gdgellatly) wrote :
Download full text (3.3 KiB)

There are lots of examples of this in the code. It was OK when things
weren't multicompany but it probably needs wider addressing and correcting
for 6.1. There are many related and reported bugs to this one. And the
thing in common is returning the first search result, when the user has
multicompany access and is working with a company that was not created
first.

As examples, Balance Sheet and P &L wizards return first entries, which
often mismatch periods, charts and fiscals if the user has access to more
than one company. The crazy thing is that the default functions for those
wizards all handle getting their defaults so differently that all the
defaults in my setup actually belong to 3 different companies.

What makes it harder, is that these default values (most often journals, and
periods, sometimes fiscal years), selection widgets all refer to entries
with the same name. e.g. period names are identical, journal names are
identical, journal codes are identical, fiscal years are identical making it
very very hard for the user to tell what is going on. In my module
account_account_extension_o4sb I rewrote many of those functions to return
sensible defaults, and also updated the configuration wizard to
differentiate on names for journals. I think the greek localisation module
has done other related improvements

On Mon, Jul 4, 2011 at 10:24 AM, Eric Caudal - www.elico-corp.com <
<email address hidden>> wrote:

> Yes, the user is in the same company as the PO.
> It depends on the order in which you create the periods in database. for
> example: create first the periods for company A in the database (then B)
> and try to receive an incoming shipment for company B
> _get_periods gives you the first period id it finds in the table.
>
> Eric CAUDAL
> <email address hidden> <mailto:<email address hidden>>
> Cell phone: + 86 186 2136 1670
>
> Elico Corp, Shanghai
> OpenERP Ready Partner
> http://www.elico-corp.com
>
>
> On 04/07/2011 04:44, Kevin McMenamin wrote:
> > I have tried on 6.0.02 and works fine - are you sure that the company
> > under user/preferences was the same as the PO you were receipting?
> >
>
> --
> You received this bug notification because you are subscribed to OpenERP
> Addons.
> https://bugs.launchpad.net/bugs/804991
>
> Title:
> Cant process picking in multi-company environment
>
> Status in OpenERP Modules (addons):
> New
>
> Bug description:
> In 6.02
> With 2 companies A and B, 2 charts of account and 2 periods set, one for
> each company.
> Creating a purchase order and then I try to process the "incoming
> shipment".
> When click in "Process", then in subform in "Validate" I receive the
> following message:
> Error occurred while validating the field(s) company_id: Company must be
> same for its related account and period.
>
> This is due to the fact that no periods are passed in
> stock_partial_move.do_partial()
> And then in account._get_period(), all periods are returned and the first
> period is chosen instead of chosing the one corresponding to the user.
> Maybe change in _get_period()
> periods = self.pool.get('account.period').find(cr, uid)
> and add a filter according to t...

Read more...

Revision history for this message
Eric Caudal - www.elico-corp.com (elicoidal) wrote :

This is indeed a situation that was "acceptable" in v5 but is clearly
not anymore in v6 that claims to be fully multi-company.

Now we should think about improving this feature.
What should be the rules to implement?
eg:
- if there is in the database a record for the company and another one
without company, how the system should deal with that?
- if no record found, what is the result?
- if multiple record?
by default in this kind of function the company should be passed as arg
and a second argument should be passed to get the proper result
or
we get back a list of tuples (eg: period and company_id) and let the
caller function decide

Which functions are to be changed ? In my opinion all _get_xxx for
default should be analyzed

Eric CAUDAL

Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Ashvin Rathod (OpenERP) (ara-tinyerp) wrote :

Hello,

The period related problem is already fixed in lp:~openerp-dev/openobject-addons/account_voucher_rework_ara branch.

But I have faced the another problem at picking time for multi-company which is stock journal property field doesn't set company properly.

The Stock journal property field created from demo data and the related company doesn't set properly.

So whenever we have process the picking for multi-company we will faced the same constraint message.

That's why I would like to suggest community team they can assign this bug to related team for this problem.

Thanks,
ara

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Ashvin,

You are right, the same problem is still persist because of Stock journal property field which you have described in above comment.

But the bug reporter posted a bug for problem of _get_period() method and I have posted a new bug lp:828505 for your comment#5

So please do not consider this bug affect to the stock module and take the appropriate decision at your side.

Thanks.

Changed in openobject-addons:
status: In Progress → Fix Committed
Changed in openobject-addons:
status: Fix Committed → Fix Released
milestone: none → 6.1
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.