I have a method which makes me add up depending on the type of account, for example: I have the "effective" account where you have a computed field where you add everything you have and have made. Likewise, another account called "Bank" also adds the debit and credit. But I use the same method for both, however, I have them separated but I only add one and not both. edit: I realized that when creating another type of account the entire total is deleted and begins to add to the account that was reada lately, how can I solve that problem?
As shown in the image, only the sum appears in the "bank" account and not in the "cash" account Link image efective : \photo\ link\ efective\\.\\ Link\\ image\\ bank\\ \\:\\\photo view bank
class Account(models.Model): _name = 'project_rc.account' _rec_name = 'title' title = fields.Char(string="Name") total_account_debit = fields.Float(string="Total account must", compute="_ total_account_debit") total_account_credit = fields.Float(string="Total account have", compute="_ total_account_credit" @api.multi @api.depends("detail_document_ids") def _total_cuenta_debe(self): self.total_account_debit = sum(line.total_debe for line in self.detail_document_ids) if self.titulo == "Cash" else 0) @api.multi @api.depends("detail_document_ids") def _total_account_credit(self): self.total_account_credit = sum(line.total_credit for line in self.detail_document_ids) if self.title == "Cash" else 0) @api.multi @api.depends("detail_document_ids") def _total_account_debit(self): self.total_account_debit = sum(line.total_debe for line in self.detail_document_ids) if self.title == "Bank" else 0) @api.multi @api.depends("detail_document_ids") def _total_account_credit(self): self.total_account_credit = sum(line.total_credit for line in self.detail_document_ids) if self.title == "Bank" else 0)