changeset b3c9a61a669b in modules/account_dunning:default
details:
https://hg.tryton.org/modules/account_dunning?cmd=changeset&node=b3c9a61a669b
description:
Use declarative index definition for ModelSQL
issue5757
review361251002
diffstat:
dunning.py | 18 +++++++++++-------
party.py | 2 +-
2 files changed, 12 insertions(+), 8 deletions(-)
diffs (61 lines):
diff -r dcca193245f5 -r b3c9a61a669b dunning.py
--- a/dunning.py Mon May 02 16:51:42 2022 +0200
+++ b/dunning.py Tue Oct 11 00:44:49 2022 +0200
@@ -7,7 +7,7 @@
from sql import Literal, Null
from trytond.model import (
- Model, ModelSQL, ModelView, Unique, fields, sequence_ordered)
+ Index, Model, ModelSQL, ModelView, Unique, fields, sequence_ordered)
from trytond.modules.currency.fields import Monetary
from trytond.pool import Pool
from trytond.pyson import Eval
@@ -32,8 +32,8 @@
class Level(sequence_ordered(), ModelSQL, ModelView):
'Account Dunning Level'
__name__ = 'account.dunning.level'
- procedure = fields.Many2One('account.dunning.procedure', 'Procedure',
- required=True, select=True)
+ procedure = fields.Many2One(
+ 'account.dunning.procedure', "Procedure", required=True)
overdue = fields.TimeDelta('Overdue',
help="When the level should be applied.")
@@ -76,10 +76,9 @@
class Dunning(ModelSQL, ModelView):
'Account Dunning'
__name__ = 'account.dunning'
- company = fields.Many2One('company.company', 'Company', required=True,
- help="Make the dunning belong to the company.",
- select=True,
- states=_STATES)
+ company = fields.Many2One(
+ 'company.company', "Company", required=True, states=_STATES,
+ help="Make the dunning belong to the company.")
line = fields.Many2One('account.move.line', 'Line', required=True,
help="The receivable line to dun for.",
domain=[
@@ -152,6 +151,11 @@
('line_unique', Unique(table, table.line),
'account_dunning.msg_dunning_line_unique'),
]
+ cls._sql_indexes.add(
+ Index(
+ table,
+ (table.state, Index.Equality()),
+ where=table.state.in_(['draft', 'waiting'])))
cls._active_field = 'active'
cls._buttons.update({
'reschedule': {
diff -r dcca193245f5 -r b3c9a61a669b party.py
--- a/party.py Mon May 02 16:51:42 2022 +0200
+++ b/party.py Tue Oct 11 00:44:49 2022 +0200
@@ -29,7 +29,7 @@
"Party Dunning Procedure"
__name__ = 'party.party.dunning_procedure'
party = fields.Many2One(
- 'party.party', "Party", ondelete='CASCADE', select=True)
+ 'party.party', "Party", ondelete='CASCADE')
dunning_procedure = dunning_procedure
@classmethod