@@ -15,7 +15,9 @@ class AccountMoveLine(models.Model):
1515 full_reconcile_id = fields .Many2one (index = True )
1616 other_balance = fields .Monetary (
1717 string = 'Other Balance' ,
18- default = 0.0 )
18+ compute = "_compute_other_balance" ,
19+ store = True
20+ )
1921 search_year = fields .Char (
2022 string = 'Year (Search)' , compute = '_compute_date_search' ,
2123 multi = '_date_search' , store = True , index = True )
@@ -26,30 +28,11 @@ class AccountMoveLine(models.Model):
2628 string = 'Day (Search)' , compute = '_compute_date_search' ,
2729 multi = '_date_search' , store = True , index = True )
2830
29- @api .model
30- def create (self , vals ):
31- debit = vals .get ('debit' , 0 )
32- credit = vals .get ('credit' , 0 )
33- vals .update ({
34- 'other_balance' : credit - debit ,
35- })
36- return super (AccountMoveLine , self ).create (vals )
37-
38- @api .multi
39- def write (self , vals ):
40- self .calculate_orther_balance (vals )
41- return super (AccountMoveLine , self ).write (vals )
42-
4331 @api .multi
44- def calculate_orther_balance (self , vals ):
32+ @api .depends ("credit" , "debit" )
33+ def _compute_other_balance (self ):
4534 for record in self :
46- if 'debit' in vals or 'credit' in vals :
47- debit = vals .get ('debit' , record .debit )
48- credit = vals .get ('credit' , record .credit )
49- vals .update ({
50- 'other_balance' : credit - debit ,
51- })
52- return True
35+ record .other_balance = record .credit - record .debit
5336
5437 @api .multi
5538 @api .constrains ('move_id' , 'account_id' )
0 commit comments