@@ -27,7 +27,7 @@ class PosConfig(models.Model):
2727 autostart_longpolling = fields .Boolean (default = False )
2828 fiscal_position_ids = fields .Many2many (related = 'multi_session_id.fiscal_position_ids' )
2929 company_id = fields .Many2one (related = 'multi_session_id.company_id' , store = True , default = lambda self : self .env .user .company_id )
30- stock_location_id = fields .Many2one (related = 'multi_session_id.stock_location_id' , store = True )
30+ # stock_location_id = fields.Many2one(related='multi_session_id.stock_location_id', store=True)
3131
3232 def _search_current_session_state (self , operator , value ):
3333 ids = map (lambda x : x .id , self .env ["pos.config" ].search ([]))
@@ -59,30 +59,27 @@ def _get_default_location(self):
5959 "It's used to prevent synchronization of old orders" )
6060 fiscal_position_ids = fields .Many2many ('account.fiscal.position' , string = 'Fiscal Positions' , ondelete = "restrict" )
6161 company_id = fields .Many2one ('res.company' , string = 'Company' , required = True , default = lambda self : self .env .user .company_id )
62- stock_location_id = fields .Many2one (
63- 'stock.location' , string = 'Stock Location' ,
64- domain = [('usage' , '=' , 'internal' )], required = True , default = _get_default_location )
6562
6663 @api .model
6764 def action_set_default_multi_session (self ):
6865 """
69- during installation of the module set default multi-sessions (separate default multi-session for every company)
70- for all POSes for which multi_session_id is not specified
66+ during installation of the module set default multi-sessions
67+ (separate default multi-session for each company)
68+ for all POSes with not set multi_session_id
7169 """
7270 companies = self .env ['res.company' ].search ([])
7371 for company in companies :
7472 configs = self .env ['pos.config' ].search ([('multi_session_id' , '=' , False ), ('company_id' , '=' , company .id )])
7573
76- # If exist POSes with the company then we need to create default multi-session
74+ # If there are POSes with the company then we need to create default multi-session
7775 if configs :
7876 # Create default multi-session for current company
79- stock_location = self .env ['stock.warehouse' ].search ([('company_id' , '=' , company .id )], limit = 1 ).lot_stock_id
8077 multi_session = self .create ({
8178 'name' : 'Default Multi Session (%s)' % company .name ,
8279 'multi_session_active' : False ,
8380 'company_id' : company .id ,
84- 'stock_location_id' : stock_location .id
8581 })
82+ # odoo.exceptions.ValidationError: ('Error while validating constraint\n\nExpected singleton: pos.config(1, 2, 3)', None)
8683 for c in configs :
8784 c .write ({
8885 'multi_session_id' : multi_session .id
0 commit comments