| 
						
						
							
								
							
						
						
					 | 
					@ -23,6 +23,7 @@ import io | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import json | 
					 | 
					 | 
					import json | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import xlsxwriter | 
					 | 
					 | 
					import xlsxwriter | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from odoo import fields, models | 
					 | 
					 | 
					from odoo import fields, models | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					from odoo.exceptions import ValidationError | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from odoo.tools import date_utils | 
					 | 
					 | 
					from odoo.tools import date_utils | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -75,31 +76,31 @@ class StockValuationReport(models.TransientModel): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if self.product_id and self.company_id: | 
					 | 
					 | 
					        if self.product_id and self.company_id: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute( | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                """{}where product_product.id='{}' and stock_valuation_layer.company_id | 
					 | 
					 | 
					                """{}where product_product.id='{}' and stock_valuation_layer.company_id | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                 ='{}' and stock_valuation_layer.create_date >='{}'  | 
					 | 
					 | 
					                 ='{}'""".format( | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                 and stock_valuation_layer.create_date<'{}'""".format( | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                    query, product_id, company_id, | 
					 | 
					 | 
					                    query, product_id, company_id, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    from_date, | 
					 | 
					 | 
					                )) | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                    to_date)) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        elif self.product_id and self.company_id: | 
					 | 
					 | 
					        elif self.product_id and self.company_id: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute( | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                """{}where product_product.id='{}' and  | 
					 | 
					 | 
					                """{}where product_product.id='{}' and  | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.company_id ='{}' and  | 
					 | 
					 | 
					                stock_valuation_layer.company_id ='{}'""".format( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.create_date >='{}' and  | 
					 | 
					 | 
					                    query, product_id, company_id)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                stock_valuation_layer.create_date<'{}'""".format( | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    query, product_id, company_id, from_date, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    to_date)) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        elif self.product_id: | 
					 | 
					 | 
					        elif self.product_id: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute( | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                """{}where product_product.id='{}' and  | 
					 | 
					 | 
					                """{}where product_product.id='{}'""".format( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.create_date >='{}' and  | 
					 | 
					 | 
					                    query, product_id)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                stock_valuation_layer.create_date<'{}'""".format( | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    query, product_id, from_date, to_date)) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        elif self.company_id: | 
					 | 
					 | 
					        elif self.company_id: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute( | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                """{} where stock_valuation_layer.company_id='{}' and  | 
					 | 
					 | 
					                """{} where stock_valuation_layer.company_id='{}' """.format( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.create_date >='{}' and  | 
					 | 
					 | 
					                    query, company_id)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.create_date<'{}'""".format( | 
					 | 
					 | 
					        elif self.from_Date: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    query, company_id, from_date, to_date)) | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                """{} where stock_valuation_layer.create_date >= '{}' """.format(query, from_date)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        elif self.to_date: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                """{} where stock_valuation_layer.create_date <= '{}' """.format(query, to_date)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if from_date and to_date: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            if to_date < from_date: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                raise ValidationError('Sorry, To Date Must be greater Than From Date...') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        else: | 
					 | 
					 | 
					        else: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute("""{}""".format(query)) | 
					 | 
					 | 
					            self.env.cr.execute("""{}""".format(query)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        stock_valuation = self.env.cr.dictfetchall() | 
					 | 
					 | 
					        stock_valuation = self.env.cr.dictfetchall() | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -146,31 +147,31 @@ class StockValuationReport(models.TransientModel): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if self.product_id and self.company_id: | 
					 | 
					 | 
					        if self.product_id and self.company_id: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute( | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                """{}where product_product.id='{}' and stock_valuation_layer.company_id | 
					 | 
					 | 
					                """{}where product_product.id='{}' and stock_valuation_layer.company_id | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                 ='{}' and stock_valuation_layer.create_date >='{}'  | 
					 | 
					 | 
					                 ='{}'""".format( | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                 and stock_valuation_layer.create_date<'{}'""".format( | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                    query, product_id, company_id, | 
					 | 
					 | 
					                    query, product_id, company_id, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    from_date, | 
					 | 
					 | 
					                )) | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                    to_date)) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        elif self.product_id and self.company_id: | 
					 | 
					 | 
					        elif self.product_id and self.company_id: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute( | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                """{}where product_product.id='{}' and  | 
					 | 
					 | 
					                """{}where product_product.id='{}' and  | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.company_id ='{}' and  | 
					 | 
					 | 
					                stock_valuation_layer.company_id ='{}'""".format( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.create_date >='{}' and  | 
					 | 
					 | 
					                    query, product_id, company_id)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                stock_valuation_layer.create_date<'{}'""".format( | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    query, product_id, company_id, from_date, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    to_date)) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        elif self.product_id: | 
					 | 
					 | 
					        elif self.product_id: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute( | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                """{}where product_product.id='{}' and  | 
					 | 
					 | 
					                """{}where product_product.id='{}'""".format( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.create_date >='{}' and  | 
					 | 
					 | 
					                    query, product_id)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                stock_valuation_layer.create_date<'{}'""".format( | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    query, product_id, from_date, to_date)) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        elif self.company_id: | 
					 | 
					 | 
					        elif self.company_id: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute( | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                """{} where stock_valuation_layer.company_id='{}' and  | 
					 | 
					 | 
					                """{} where stock_valuation_layer.company_id='{}' """.format( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.create_date >='{}' and  | 
					 | 
					 | 
					                    query, company_id)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                stock_valuation_layer.create_date<'{}'""".format( | 
					 | 
					 | 
					        elif self.from_Date: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    query, company_id, from_date, to_date)) | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                """{} where stock_valuation_layer.create_date >= '{}' """.format(query, from_date)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        elif self.to_date: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            self.env.cr.execute( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                """{} where stock_valuation_layer.create_date <= '{}' """.format(query, to_date)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if from_date and to_date: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            if to_date < from_date: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                raise ValidationError('Sorry, To Date Must be greater Than From Date...') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        else: | 
					 | 
					 | 
					        else: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            self.env.cr.execute("""{}""".format(query)) | 
					 | 
					 | 
					            self.env.cr.execute("""{}""".format(query)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        stock_valuation = self.env.cr.dictfetchall() | 
					 | 
					 | 
					        stock_valuation = self.env.cr.dictfetchall() | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |