mirror of
https://gitlab.com/flectra-hq/flectra.git
synced 2026-08-19 01:34:43 -05:00
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
|
|
|
from flectra import models, fields
|
|
|
|
|
|
class Users(models.Model):
|
|
_inherit = ['res.users']
|
|
|
|
property_warehouse_id = fields.Many2one('stock.warehouse', string='Default Warehouse', company_dependent=True, check_company=True)
|
|
|
|
def _get_default_warehouse_id(self):
|
|
if self.property_warehouse_id:
|
|
return self.property_warehouse_id
|
|
# !!! Any change to the following search domain should probably
|
|
# be also applied in sale_stock/models/sale_order.py/_init_column.
|
|
return self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1)
|
|
|
|
def __init__(self, pool, cr):
|
|
""" Override of __init__ to add access rights.
|
|
Access rights are disabled by default, but allowed
|
|
on some specific fields defined in self.SELF_{READ/WRITE}ABLE_FIELDS.
|
|
"""
|
|
|
|
sale_stock_writeable_fields = [
|
|
'property_warehouse_id',
|
|
]
|
|
|
|
init_res = super().__init__(pool, cr)
|
|
# duplicate list to avoid modifying the original reference
|
|
pool[self._name].SELF_READABLE_FIELDS = pool[self._name].SELF_READABLE_FIELDS + sale_stock_writeable_fields
|
|
pool[self._name].SELF_WRITEABLE_FIELDS = pool[self._name].SELF_WRITEABLE_FIELDS + sale_stock_writeable_fields
|
|
return init_res
|