@@ -11,10 +11,11 @@ class Asset(models.Model):
1111 _description = "Assets"
1212 _inherit = ["mail.thread" , "mail.activity.mixin" , "portal.mixin" ]
1313 _order = "purchase_date desc, name asc"
14+ _check_company_auto = True
1415
1516 @api .model
1617 def get_default_company_id (self ):
17- return self .env .user . company_id
18+ return self .env .company
1819
1920 asset_accounting_info_ids = fields .One2many (
2021 "asset.accounting.info" , "asset_id" , string = "Accounting Info"
@@ -24,6 +25,7 @@ def get_default_company_id(self):
2425 "asset.category" ,
2526 required = True ,
2627 string = "Category" ,
28+ check_company = True ,
2729 )
2830
2931 code = fields .Char (
@@ -37,6 +39,7 @@ def get_default_company_id(self):
3739 required = True ,
3840 string = "Company" ,
3941 tracking = True ,
42+ readonly = True ,
4043 )
4144
4245 currency_id = fields .Many2one (
@@ -45,12 +48,17 @@ def get_default_company_id(self):
4548 string = "Currency" ,
4649 )
4750
48- customer_id = fields .Many2one ("res.partner" , string = "Customer" )
51+ customer_id = fields .Many2one (
52+ "res.partner" ,
53+ string = "Customer" ,
54+ check_company = True ,
55+ )
4956
5057 depreciation_ids = fields .One2many (
5158 "asset.depreciation" ,
5259 "asset_id" ,
5360 string = "Depreciations" ,
61+ check_company = True ,
5462 )
5563
5664 name = fields .Char (
@@ -70,7 +78,11 @@ def get_default_company_id(self):
7078 tracking = True ,
7179 )
7280
73- purchase_move_id = fields .Many2one ("account.move" , string = "Purchase Move" )
81+ purchase_move_id = fields .Many2one (
82+ "account.move" ,
83+ string = "Purchase Move" ,
84+ check_company = True ,
85+ )
7486
7587 sale_amount = fields .Monetary (
7688 string = "Sale Value" ,
@@ -80,7 +92,11 @@ def get_default_company_id(self):
8092
8193 dismiss_date = fields .Date ()
8294
83- sale_move_id = fields .Many2one ("account.move" , string = "Sale Move" )
95+ sale_move_id = fields .Many2one (
96+ "account.move" ,
97+ string = "Sale Move" ,
98+ check_company = True ,
99+ )
84100
85101 sold = fields .Boolean (string = "Sold" )
86102 dismissed = fields .Boolean (string = "Dismissed" )
@@ -97,7 +113,11 @@ def get_default_company_id(self):
97113 string = "State" ,
98114 )
99115
100- supplier_id = fields .Many2one ("res.partner" , string = "Supplier" )
116+ supplier_id = fields .Many2one (
117+ "res.partner" ,
118+ string = "Supplier" ,
119+ check_company = True ,
120+ )
101121
102122 supplier_ref = fields .Char (string = "Supplier Ref." )
103123
@@ -175,6 +195,7 @@ def onchange_category_id(self):
175195 def onchange_company_currency (self ):
176196 if self .company_id :
177197 self .currency_id = self .company_id .currency_id
198+ self .category_id = False
178199
179200 @api .onchange ("purchase_amount" )
180201 def onchange_purchase_amount (self ):
0 commit comments