summaryrefslogtreecommitdiff
path: root/addons/account/models/account_account.py
diff options
context:
space:
mode:
authorwilliam <wan@odoo.com>2020-06-11 09:19:14 +0000
committerwilliam <wan@odoo.com>2020-06-12 13:28:40 +0000
commit394e9fa4aaafbb518b95f03d12a487e9759893a1 (patch)
tree20632c6f680234a21e43991d14f6b47d941c4537 /addons/account/models/account_account.py
parent2d10bcb9b0064f6a0e1320b63d9c474bbd58ad78 (diff)
[IMP] account: small improvements before 13.4
Task 2274998 1/ In the accounting dashboard, maximum one primary button per box 2/ In all boxes : "Sample data" must be removed. (Too obvious) 3/ In the configuration of Accounting Periods * Opening date and fiscal year end must be on a same line. * Remove the button "Configure your tax accounts". 4/ "Configure your tax accounts" is still available in the settings. * But also make it available while doing the Tax Report Entry, if an error message pops up. 5/ Chart of Account (list view) * Captital D for opening Debit/Credit * Rename "Name" into "Account Name" 6/ While génerating an Invoice * Rename "Post" button into "Confirm" * Check that the incremental number is added as a suffix of the name of the bill ; not as a prefix 7/ Vendor Bill (list view) * Status must appear as a Tag ; like it is already done in "Payment State" * Rename "Payment State" into "Payment Status" 8/ Bank journals * On the bank journal level, if bank feed is set to synchronization, then while selecting that journal from the accounting dashboard, then directly go to the statement lines rather than the bank statement itself. * In the bank statement's account moves, remove the button duplicate. It is enough to have it in the actions. closes odoo/odoo#52818 Related: odoo/enterprise#11081 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Diffstat (limited to 'addons/account/models/account_account.py')
-rw-r--r--addons/account/models/account_account.py35
1 files changed, 22 insertions, 13 deletions
diff --git a/addons/account/models/account_account.py b/addons/account/models/account_account.py
index d4d630bbc82..68a903b2760 100644
--- a/addons/account/models/account_account.py
+++ b/addons/account/models/account_account.py
@@ -54,7 +54,7 @@ class AccountAccount(models.Model):
('user_type_id', '=', data_unaffected_earnings.id)])
raise ValidationError(_('You cannot have more than one account with "Current Year Earnings" as type. (accounts: %s)') % [a.code for a in account_unaffected_earnings])
- name = fields.Char(required=True, index=True)
+ name = fields.Char(string="Account Name", required=True, index=True)
currency_id = fields.Many2one('res.currency', string='Account Currency',
help="Forces all moves for this account to have this account currency.")
code = fields.Char(size=64, required=True, index=True)
@@ -80,8 +80,9 @@ class AccountAccount(models.Model):
root_id = fields.Many2one('account.root', compute='_compute_account_root', store=True)
allowed_journal_ids = fields.Many2many('account.journal', string="Allowed Journals", help="Define in which journals this account can be used. If empty, can be used in all journals.")
- opening_debit = fields.Monetary(string="Opening debit", compute='_compute_opening_debit_credit', inverse='_set_opening_debit', help="Opening debit value for this account.")
- opening_credit = fields.Monetary(string="Opening credit", compute='_compute_opening_debit_credit', inverse='_set_opening_credit', help="Opening credit value for this account.")
+ opening_debit = fields.Monetary(string="Opening Debit", compute='_compute_opening_debit_credit', inverse='_set_opening_debit', help="Opening debit value for this account.")
+ opening_credit = fields.Monetary(string="Opening Credit", compute='_compute_opening_debit_credit', inverse='_set_opening_credit', help="Opening credit value for this account.")
+ opening_balance = fields.Monetary(string="Opening Balance", compute='_compute_opening_debit_credit', help="Opening balance value for this account.")
_sql_constraints = [
('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !')
@@ -220,17 +221,25 @@ class AccountAccount(models.Model):
raise UserError(_('Cannot generate an unused account code.'))
def _compute_opening_debit_credit(self):
+ if not self:
+ return
+ self.env.cr.execute("""
+ SELECT line.account_id,
+ SUM(line.balance) AS balance,
+ SUM(line.debit) AS debit,
+ SUM(line.credit) AS credit
+ FROM account_move_line line
+ JOIN res_company comp ON comp.id = line.company_id
+ WHERE line.move_id = comp.account_opening_move_id
+ AND line.account_id IN %s
+ GROUP BY line.account_id
+ """, [tuple(self.ids)])
+ result = {r['account_id']: r for r in self.env.cr.dictfetchall()}
for record in self:
- opening_debit = opening_credit = 0.0
- if record.company_id.account_opening_move_id:
- for line in self.env['account.move.line'].search([('account_id', '=', record.id),
- ('move_id','=', record.company_id.account_opening_move_id.id)]):
- if line.debit:
- opening_debit += line.debit
- elif line.credit:
- opening_credit += line.credit
- record.opening_debit = opening_debit
- record.opening_credit = opening_credit
+ res = result.get(record.id) or {'debit': 0, 'credit': 0, 'balance': 0}
+ record.opening_debit = res['debit']
+ record.opening_credit = res['credit']
+ record.opening_balance = res['balance']
def _set_opening_debit(self):
self._set_opening_debit_credit(self.opening_debit, 'debit')