[IMP] account: improve list and search view of account move line

Task 2008956

* Remove the sequence from the default order of account.move.line as it
  is only needed in the list view of the invoice form view; add it
  there.
* Allow to order by date on the grouped list view of account.move.line by
  setting an aggregate function
This commit is contained in:
wan
2019-09-04 09:00:03 +00:00
parent 737eaf9333
commit 0a5955bff6
3 changed files with 10 additions and 5 deletions
+2 -2
View File
@@ -2123,14 +2123,14 @@ class AccountMove(models.Model):
class AccountMoveLine(models.Model):
_name = "account.move.line"
_description = "Journal Item"
_order = "sequence, date desc, move_name desc, id"
_order = "date desc, move_name desc, id"
# ==== Business fields ====
move_id = fields.Many2one('account.move', string='Journal Entry',
index=True, required=True, auto_join=True, ondelete="cascade",
help="The move of this entry line.")
move_name = fields.Char(string='Number', related='move_id.name', store=True, index=True)
date = fields.Date(related='move_id.date', store=True, readonly=True, index=True, copy=False)
date = fields.Date(related='move_id.date', store=True, readonly=True, index=True, copy=False, group_operator='min')
ref = fields.Char(related='move_id.ref', store=True, copy=False, index=True, readonly=False)
parent_state = fields.Selection(related='move_id.state', store=True, readonly=True)
journal_id = fields.Many2one(related='move_id.journal_id', store=True, readonly=False, index=True, copy=False)
+7 -3
View File
@@ -649,7 +649,7 @@
widget="section_and_note_one2many"
mode="tree,kanban"
context="{'journal_id': journal_id, 'default_partner_id': commercial_partner_id, 'default_currency_id': currency_id != company_currency_id and currency_id or False}">
<tree editable="bottom" string="Journal Items">
<tree editable="bottom" string="Journal Items" default_order="sequence, date desc, move_name desc, id">
<control>
<create name="add_line_control" string="Add a line"/>
<create name="add_section_control" string="Add a section" context="{'default_display_type': 'line_section'}"/>
@@ -658,8 +658,9 @@
<!-- Displayed fields -->
<field name="sequence" widget="handle"/>
<field name="move_name" invisible="1"/>
<field name="product_id" optional="show" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/>
<field name="name" widget="section_and_note_text" required="1"/>
<field name="name" widget="section_and_note_text" attrs="{'required': [('parent.type', 'not in', ('in_invoice', 'in_refund','in_receipt'))]}"/>
<field name="account_id"
groups="account.group_account_user"
domain="[('deprecated', '=', False), ('user_type_id.type', 'not in', ('receivable', 'payable')), ('company_id', '=', parent.company_id)]"
@@ -695,6 +696,7 @@
<field name="currency_id" invisible="1"/>
<field name="debit" invisible="1"/>
<field name="credit" invisible="1"/>
<field name="date" invisible="1"/>
<field name="date_maturity" invisible="1"/>
<field name="tax_line_id" invisible="1"/>
@@ -738,7 +740,7 @@
<page id="aml_tab" string="Journal Items" groups="account.group_account_user">
<field name="line_ids"
context="{'line_ids': line_ids, 'journal_id': journal_id, 'default_partner_id': commercial_partner_id, 'default_currency_id': currency_id != company_currency_id and currency_id or False}">
<tree editable="bottom" string="Journal Items" decoration-muted="display_type in ('line_section', 'line_note')">
<tree editable="bottom" string="Journal Items" decoration-muted="display_type in ('line_section', 'line_note')" default_order="sequence, date desc, move_name desc, id">
<!-- Displayed fields -->
<field name="account_id"
attrs="{
@@ -802,6 +804,8 @@
<field name="price_total" invisible="1"/>
<field name="sequence" invisible="1"/>
<field name="move_name" invisible="1"/>
<field name="date" invisible="1"/>
<field name="tax_line_id" invisible="1"/>
<field name="tax_group_id" invisible="1"/>
<field name="tax_repartition_line_id" invisible="1"/>
@@ -195,6 +195,7 @@
</group>
</group>
</sheet>
<div class="o_attachment_preview"/>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="activity_ids" widget="mail_activity"/>