Order bank account per owners

Closes #13937
This commit is contained in:
Cédric Krier
2025-03-24 18:44:31 +01:00
parent d68df1a8e6
commit faca1dd187
7 changed files with 43 additions and 4 deletions
+1
View File
@@ -1,3 +1,4 @@
* Order account per owners
* Remove support for Python 3.8
* Add support for Python 3.13
+12 -1
View File
@@ -12,7 +12,8 @@ except ImportError:
from trytond.i18n import gettext
from trytond.model import (
DeactivableMixin, Exclude, ModelSQL, ModelView, fields, sequence_ordered)
DeactivableMixin, Exclude, Index, ModelSQL, ModelView, fields,
sequence_ordered)
from trytond.pool import Pool
from trytond.pyson import Eval, If
from trytond.tools import is_full_text, lstrip_wildcard
@@ -93,6 +94,7 @@ class Account(DeactivableMixin, ModelSQL, ModelView):
help="The bank where the account is open.")
owners = fields.Many2Many('bank.account-party.party', 'account', 'owner',
'Owners')
owners_sequence = fields.Integer("Owners Sequence")
currency = fields.Many2One('currency.currency', 'Currency')
numbers = fields.One2Many(
'bank.account.number', 'account', 'Numbers',
@@ -101,6 +103,15 @@ class Account(DeactivableMixin, ModelSQL, ModelView):
],
help="Add the numbers which identify the bank account.")
@classmethod
def __setup__(cls):
super().__setup__()
table = cls.__table__()
cls._sql_indexes.add(
Index(table,
(table.owners_sequence, Index.Range(order='ASC NULLS FIRST')),
(table.id, Index.Range(order='ASC'))))
def get_rec_name(self, name):
for number in self.numbers:
if number.number:
+7
View File
@@ -78,8 +78,15 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.ui.view" id="bank_account_view_list">
<field name="model">bank.account</field>
<field name="type">tree</field>
<field name="priority" eval="10"/>
<field name="name">bank_account_list</field>
</record>
<record model="ir.ui.view" id="bank_account_view_list_owners_sequence">
<field name="model">bank.account</field>
<field name="type">tree</field>
<field name="priority" eval="20"/>
<field name="name">bank_account_list_owners_sequence</field>
</record>
<record model="ir.action.act_window" id="act_bank_account_form">
<field name="name">Accounts</field>
+10 -2
View File
@@ -8,10 +8,18 @@ from trytond.transaction import Transaction
class Party(metaclass=PoolMeta):
__name__ = 'party.party'
bank_accounts = fields.Many2Many(
'bank.account-party.party', 'owner', 'account', "Bank Accounts")
'bank.account-party.party', 'owner', 'account', "Bank Accounts",
order=[
('account.owners_sequence', 'ASC NULLS FIRST'),
('account.id', 'ASC'),
])
bank_accounts_used = fields.Many2Many(
'bank.account-party.party', 'owner', 'account', "Bank Accounts Used",
filter=[('active', '=', True)])
filter=[('active', '=', True)],
order=[
('account.owners_sequence', 'ASC NULLS FIRST'),
('account.id', 'ASC'),
])
@classmethod
def search_rec_name(cls, name, clause):
+4
View File
@@ -8,7 +8,11 @@ this repository contains the full copyright notices and license terms. -->
<field name="currency"/>
<label name="active"/>
<field name="active"/>
<field name="owners" colspan="6"/>
<label name="owners_sequence"/>
<field name="owners_sequence"/>
<field name="numbers" colspan="6" pre_validate="1"
view_ids="bank.bank_account_number_view_list_sequence"/>
</form>
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree sequence="owners_sequence">
<field name="rec_name" string="Number" expand="2"/>
<field name="bank" expand="1" optional="0"/>
<field name="currency" optional="1"/>
</tree>
+1 -1
View File
@@ -4,7 +4,7 @@ this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form/notebook" position="inside">
<page string="Banking" id="banking">
<field name="bank_accounts" colspan="4" widget="one2many"/>
<field name="bank_accounts" colspan="4" widget="one2many" view_ids="bank.bank_account_view_list_owners_sequence"/>
</page>
</xpath>
</data>