[IMP] lunch: location multi company
closes odoo/odoo#36331 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
@@ -75,7 +75,12 @@ class LunchController(http.Controller):
|
||||
self._check_user_impersonification(user_id)
|
||||
user = request.env['res.users'].browse(user_id) if user_id else request.env.user
|
||||
|
||||
return user.last_lunch_location_id.id
|
||||
user_location = user.last_lunch_location_id
|
||||
has_multi_company_access = not user_location.company_id or user_location.company_id.id in request._context.get('allowed_company_ids', request.env.company.ids)
|
||||
|
||||
if not user_location or not has_multi_company_access:
|
||||
return request.env['lunch.location'].search([], limit=1).id
|
||||
return user_location.id
|
||||
|
||||
def _make_infos(self, user, **kwargs):
|
||||
res = dict(kwargs)
|
||||
@@ -93,9 +98,11 @@ class LunchController(http.Controller):
|
||||
'currency': {'symbol': currency.symbol, 'position': currency.position},
|
||||
})
|
||||
|
||||
if not user.last_lunch_location_id:
|
||||
user.last_lunch_location_id = request.env['lunch.location'].search([], limit=1)
|
||||
user_location = user.last_lunch_location_id
|
||||
has_multi_company_access = not user_location.company_id or user_location.company_id.id in request._context.get('allowed_company_ids', request.env.company.ids)
|
||||
|
||||
if not user_location or not has_multi_company_access:
|
||||
user.last_lunch_location_id = user_location = request.env['lunch.location'].search([], limit=1)
|
||||
|
||||
alert_domain = expression.AND([
|
||||
[('available_today', '=', True)],
|
||||
|
||||
@@ -10,3 +10,4 @@ class LunchLocation(models.Model):
|
||||
|
||||
name = fields.Char('Location Name', required=True)
|
||||
address = fields.Text('Address')
|
||||
company_id = fields.Many2one('res.company', default=lambda self: self.env.company)
|
||||
|
||||
@@ -78,5 +78,12 @@
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_rule_lunch_location_multi_company" model="ir.rule">
|
||||
<field name="name">Lunch location: Multi Company</field>
|
||||
<field name="model_id" ref="model_lunch_location"/>
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="address"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
@@ -35,6 +36,7 @@
|
||||
<tree editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="address"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user