[IMP] account: usability changes

Task 2072312

* Change the label "/" by "Draft <document type>" for draft entries (change name_get() of account.move)
* New left-bar menu for a chart of account & general ledger view: Take into account the company (for multicompany, avoid having  the number 7 if the current company doesn't have 7xxxa accounts)
* New filter "Accounts With Entries" for the chart of accounts
  Show only account which has at least 1 journal entry on it
* Show the move_id on the move line tree view
This commit is contained in:
wan
2019-09-17 15:42:30 +00:00
committed by qdp-odoo
parent c3f6f1f262
commit dbd867eb8e
5 changed files with 34 additions and 7 deletions
+17 -2
View File
@@ -211,6 +211,7 @@ class AccountAccount(models.Model):
help="Forces all moves for this account to have this account currency.")
code = fields.Char(size=64, required=True, index=True)
deprecated = fields.Boolean(index=True, default=False)
used = fields.Boolean(store=False, search='_search_used')
user_type_id = fields.Many2one('account.account.type', string='Type', required=True,
help="Account Type is used for information purpose, to generate country-specific legal reports, and set the rules to close a fiscal year and generate opening entries.")
internal_type = fields.Selection(related='user_type_id.type', string="Internal Type", store=True, readonly=True)
@@ -252,6 +253,17 @@ class AccountAccount(models.Model):
for record in self:
record.root_id = record.code and (ord(record.code[0]) * 1000 + ord(record.code[1])) or False
def _search_used(self, operator, value):
if operator not in ['=', '!='] or not isinstance(value, bool):
raise UserError(_('Operation not supported'))
if operator != '=':
value = not value
self._cr.execute("""
SELECT id FROM account_account account
WHERE EXISTS (SELECT * FROM account_move_line aml WHERE aml.account_id = account.id LIMIT 1)
""")
return [('id', 'in' if value else 'not in', [r[0] for r in self._cr.fetchall()])]
@api.model
def _search_new_account_code(self, company, digits, prefix):
for num in range(1, 10000):
@@ -560,6 +572,7 @@ class AccountRoot(models.Model):
name = fields.Char()
parent_id = fields.Many2one('account.root')
company_id = fields.Many2one('res.company')
def init(self):
tools.drop_view_if_exists(self.env.cr, self._table)
@@ -567,12 +580,14 @@ class AccountRoot(models.Model):
CREATE OR REPLACE VIEW %s AS (
SELECT DISTINCT ASCII(code) * 1000 + ASCII(SUBSTRING(code,2,1)) AS id,
LEFT(code,2) AS name,
ASCII(code) AS parent_id
ASCII(code) AS parent_id,
company_id
FROM account_account WHERE code IS NOT NULL
UNION ALL
SELECT DISTINCT ASCII(code) AS id,
LEFT(code,1) AS name,
NULL::int AS parent_id
NULL::int AS parent_id,
company_id
FROM account_account WHERE code IS NOT NULL
)''' % (self._table,)
)
+3 -2
View File
@@ -1521,7 +1521,8 @@ class AccountMove(models.Model):
result = []
for move in self:
if self._context.get('name_groupby') and not (move.type == 'entry' and move.state == 'draft'):
name = '**%s**, %s' % (format_date(self.env, move.date), move.name or '')
move_name = move.name != "/" and move.name or _("Draft %s") % dict(move._fields['type']._description_selection(self.env))[move.type]
name = '**%s**, %s' % (format_date(self.env, move.date), move_name or '')
if move.ref:
name += ' (%s)' % move.ref
if move.partner_id.name:
@@ -1529,7 +1530,7 @@ class AccountMove(models.Model):
elif move.type == 'entry':
# Miscellaneous operation.
if move.state == 'draft':
name = '* %s' % str(move.id)
name = _('Draft Entry (* %s)') % str(move.id)
else:
name = move.name
else:
@@ -124,6 +124,13 @@
<field name="domain_force">['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
</record>
<record id="account_root_comp_rule" model="ir.rule">
<field name="name">Account Root multi-company</field>
<field name="model_id" ref="model_account_root"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
</record>
<record id="tax_comp_rule" model="ir.rule">
<field name="name">Tax multi-company</field>
<field name="model_id" ref="model_account_tax"/>
+2 -1
View File
@@ -135,6 +135,7 @@
<field name="arch" type="xml">
<tree string="Journal Items" create="false">
<field name="date" optional="show"/>
<field name="move_id" optional="show"/>
<field name="journal_id" options='{"no_open":True}'/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="name" optional="show"/>
@@ -163,7 +164,7 @@
<field name="model">account.move.line</field>
<field eval="1" name="priority"/>
<field name="arch" type="xml">
<tree string="Journal Items" create="false" expand="context.get('expand', False)">
<tree string="Journal Items" create="false" expand="context.get('expand', False)" default_order="credit">
<field name="date" optional="show" attrs="{'readonly':[('parent_state','=','posted')]}"/>
<field name="ref" optional="hide"/>
<field name="move_id" optional="show" readonly="1"/>
+5 -2
View File
@@ -92,6 +92,9 @@
<filter string="Liability" name="liabilityacc" domain="[('internal_group','=', 'liability')]"/>
<filter string="Income" name="incomeacc" domain="[('internal_group','=', 'income')]"/>
<filter string="Expenses" name="expensesacc" domain="[('internal_group','=', 'expense')]"/>
<separator/>
<filter string="Account with Entries" name="used" domain="[('used', '=', True)]"/>
<separator/>
<field name="user_type_id"/>
<group expand="0" string="Group By">
<filter string="Account Type" name="accounttype" domain="" context="{'group_by':'user_type_id'}"/>
@@ -962,7 +965,7 @@ action = model.setting_init_bank_account_action()
</div>
<field name="amount_from_label_regex" attrs="{'invisible': [('amount_type','!=','regex')]}"/>
<field name="decimal_separator" attrs="{'invisible': [('amount_type','!=','regex')]}"/>
<field name="journal_id" domain="[('type', '!=', 'general'), ('company_id', '=', company_id)]" widget="selection"
<field name="journal_id" domain="[('type', '=', 'general'), ('company_id', '=', company_id)]" widget="selection"
attrs="{'invisible': [('rule_type', '!=', 'writeoff_button')]}"/>
</group>
</group>
@@ -995,7 +998,7 @@ action = model.setting_init_bank_account_action()
<span class="o_form_label oe_inline" attrs="{'invisible':[('second_amount_type','!=','percentage')]}">%</span>
</div>
<field name="second_amount_from_label_regex" attrs="{'invisible': [('second_amount_type','!=','regex')]}"/>
<field name="second_journal_id" string="Journal" domain="[('type', '!=', 'general'), ('company_id', '=', company_id)]" widget="selection"
<field name="second_journal_id" string="Journal" domain="[('type', '=', 'general'), ('company_id', '=', company_id)]" widget="selection"
attrs="{'invisible': [('rule_type', '!=', 'writeoff_button')]}"/>
</group>
</group>