Record Rules for StockLocation model

43 views
Skip to first unread message

Khurram Shahzad

unread,
Jan 27, 2017, 11:45:07 AM1/27/17
to tryton
Dear All,

I am trying to add a record rule to user for restricting him to see one stock location only. The rule is:

[["location.id","=",2]]

But, when I click on 'Internal shipments' which use stock locations, it gives following error:
KeyError: u 'location'

Probably, the name 'location' used to refer the model 'stock.location' is not correct. Can anybody guide me what is the correct name for referring to 'stock.location'.

By the way, is there any reference/manual which should be consulted to get the names of the Models for referring them in Record Rules?

Regards,
Khurram.
Message has been deleted
Message has been deleted

Fabyc

unread,
Jan 28, 2017, 10:54:59 AM1/28/17
to tryton
Hi Khurram
You can get them in Administration->Models->Models

I hope it can to useful for you.

--
Regards

Cédric Krier

unread,
Jan 28, 2017, 5:35:08 PM1/28/17
to tryton
On 2017-01-27 08:32, Khurram Shahzad wrote:
> Dear All,
>
> I am trying to add a record rule to user for restricting him to see one
> stock location only. The rule is:
>
> [["location.id","=",2]]

It is not clear on what is the rule applied.
Could you give more information?

> But, when I click on 'Internal shipments' which use stock locations, it
> gives following error:
> KeyError: u 'location'
>
> Probably, the name 'location' used to refer the model 'stock.location' is
> not correct. Can anybody guide me what is the correct name for referring to
> 'stock.location'.

Without the full traceback, it is difficult to understand what is
happening.

But on a general side, record rules are very hard to setup correctly
because in contrary of other access rights, they are deeply enforced in
the all ORM instead of being only on the border (see issue4081). This
has to stay until issue4080 is solved.


https://bugs.tryton.org/issue4081
https://bugs.tryton.org/issue4080

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Khurram Shahzad

unread,
Jan 29, 2017, 4:05:11 PM1/29/17
to tryton


On Sunday, January 29, 2017 at 3:35:08 AM UTC+5, Cédric Krier wrote:
On 2017-01-27 08:32, Khurram Shahzad wrote:
> Dear All,
>
> I am trying to add a record rule to user for restricting him to see one
> stock location only. The rule is:
>
> [["location.id","=",2]]

It is not clear on what is the rule applied.
Could you give more information?

I have created stock locations for every Ward in the hospital. The Stock Manager of the ward will save an internal shipment for the medicine required in the ward. Then, the Warehouse Manger will issue the medicine. Now, while creating Internal Shipment, I want the Stock Manager of ward should not be able to set the 'To' location other than the location created for his ward.

To implement this, since I know the ID (that in database is 2) of the Stock Location of ward, I decided to create a Record Rule on Stock Location model which is failing.

Cédric Krier

unread,
Jan 29, 2017, 4:15:06 PM1/29/17
to tryton
On 2017-01-29 05:09, Khurram Shahzad wrote:
>
>
> On Sunday, January 29, 2017 at 3:35:08 AM UTC+5, Cédric Krier wrote:
> >
> > On 2017-01-27 08:32, Khurram Shahzad wrote:
> > > Dear All,
> > >
> > > I am trying to add a record rule to user for restricting him to see one
> > > stock location only. The rule is:
> > >
> > > [["location.id","=",2]]
> >
> > It is not clear on what is the rule applied.
> > Could you give more information?
> >
>
> I have created stock locations for every Ward in the hospital. The Stock
> Manager of the ward will save an internal shipment for the medicine
> required in the ward. Then, the Warehouse Manger will issue the medicine.
> Now, while creating Internal Shipment, I want the Stock Manager of ward
> should not be able to set the 'To' location other than the location created
> for his ward.
>
> To implement this, since I know the ID (that in database is 2) of the Stock
> Location of ward, I decided to create a Record Rule on Stock Location model
> which is failing.

This does not describe clearly the rule created.
Reply all
Reply to author
Forward
0 new messages