The user farms are now taken into consideration when choosing a farm

This commit is contained in:
Sergi Carol 2017-05-31 11:52:25 +02:00
parent a79952a4da
commit 366d4c566f
6 changed files with 25 additions and 1 deletions

View File

@ -1,3 +1,6 @@
@ 2017-05-31
* Tryton now only allows the current user to use the user specified farms.
* Removed deliveries from semen extraction event
* Move farrowing group when moving a lactating female

View File

@ -54,6 +54,7 @@ class AbstractEvent(ModelSQL, ModelView, Workflow):
states=_STATES_WRITE_DRAFT, depends=_DEPENDS_WRITE_DRAFT,
domain=[
('type', '=', 'warehouse'),
('id', 'in', Eval('context', {}).get('farms', [])),
],
context={
'restrict_by_specie_animal_type': True,

View File

@ -19,7 +19,18 @@
<field name="type">tree</field>
<field name="name">farm_event_list_editable</field>
</record>
<!-- Rule Group -->
<record model="ir.rule.group" id="rule_group_farms">
<field name="model" search="[('model', '=', 'farm.event')]"/>
<field name="global_p" eval="False"/>
<field name="default_p" eval="True"/>
</record>
<record model="ir.rule" id="rule_farms">
<field name="domain">[('farm', 'in', [c.id for c in user.farms])]</field>
<field name="rule_group" ref="rule_group_farms"/>
</record>
<!--
<record model="ir.model.button" id="farm_event_cancel_button">
<field name="name">cancel</field>

View File

@ -74,6 +74,7 @@ class EventOrder(ModelSQL, ModelView, Workflow):
farm = fields.Many2One('stock.location', 'Farm', required=True,
domain=[
('type', '=', 'warehouse'),
('id', 'in', Eval('context', {}).get('farms', [])),
],
context={
'restrict_by_specie_animal_type': True,

View File

@ -379,6 +379,7 @@ class FeedInventoryMixin(object):
location = fields.Many2One('stock.location', 'Silo', required=True,
domain=[
('silo', '=', True),
('parent', 'child_of', Eval('context', {}).get('farms', [])),
],
states=_STATES_WRITE_DRAFT, depends=_DEPENDS_WRITE_DRAFT)
dest_locations = fields.Many2Many('farm.feed.inventory-stock.location',

View File

@ -22,6 +22,13 @@ class User:
help="Farms to which this user is assigned. Determine animals that "
"he/she can manage.")
@classmethod
def __setup__(cls):
super(User, cls).__setup__()
cls._preferences_fields.extend([
'farms'])
cls._context_fields.insert(0, 'farms')
class UserLocation(ModelSQL):
'User - Location'