changeset a59ad15c8b62 in modules/account_payment_sepa:default
details:
https://hg.tryton.org/modules/account_payment_sepa?cmd=changeset;node=a59ad15c8b62
description:
Store directly sequence type to sequence
issue10122
review351381002
diffstat:
account.py | 8 +++++---
payment.py | 4 +---
payment.xml | 1 -
tests/test_account_payment_sepa.py | 7 +++++--
4 files changed, 11 insertions(+), 9 deletions(-)
diffs (88 lines):
diff -r 4039f71221d1 -r a59ad15c8b62 account.py
--- a/account.py Fri Mar 05 15:49:19 2021 +0100
+++ b/account.py Thu Mar 11 23:00:10 2021 +0100
@@ -3,7 +3,7 @@
from trytond import backend
from trytond.pool import PoolMeta
from trytond.model import ModelSQL, fields
-from trytond.pyson import Eval
+from trytond.pyson import Eval, Id
from trytond.tools.multivalue import migrate_property
from trytond.modules.company.model import CompanyValueMixin
@@ -13,7 +13,8 @@
sepa_mandate_sequence = fields.MultiValue(fields.Many2One(
'ir.sequence', "SEPA Mandate Sequence",
domain=[
- ('code', '=', 'account.payment.sepa.mandate'),
+ ('sequence_type', '=', Id(
+ 'account_payment_sepa', 'sequence_type_mandate')),
('company', 'in', [Eval('context', {}).get('company', -1),
None]),
]))
@@ -25,7 +26,8 @@
sepa_mandate_sequence = fields.Many2One(
'ir.sequence', "SEPA Mandate Sequence",
domain=[
- ('code', '=', 'account.payment.sepa.mandate'),
+ ('sequence_type', '=', Id(
+ 'account_payment_sepa', 'sequence_type_mandate')),
('company', 'in', [Eval('company', -1), None]),
],
depends=['company'])
diff -r 4039f71221d1 -r a59ad15c8b62 payment.py
--- a/payment.py Fri Mar 05 15:49:19 2021 +0100
+++ b/payment.py Thu Mar 11 23:00:10 2021 +0100
@@ -585,7 +585,6 @@
@classmethod
def create(cls, vlist):
pool = Pool()
- Sequence = pool.get('ir.sequence')
Configuration = pool.get('account.configuration')
config = Configuration(1)
@@ -593,8 +592,7 @@
for values in vlist:
if (config.sepa_mandate_sequence
and not values.get('identification')):
- values['identification'] = Sequence.get_id(
- config.sepa_mandate_sequence.id)
+ values['identification'] = config.sepa_mandate_sequence.get()
# Prevent raising false unique constraint
if values.get('identification') == '':
values['identification'] = None
diff -r 4039f71221d1 -r a59ad15c8b62 payment.xml
--- a/payment.xml Fri Mar 05 15:49:19 2021 +0100
+++ b/payment.xml Thu Mar 11 23:00:10 2021 +0100
@@ -152,7 +152,6 @@
<record model="ir.sequence.type" id="sequence_type_mandate">
<field name="name">SEPA Mandate</field>
- <field name="code">account.payment.sepa.mandate</field>
</record>
<record model="ir.sequence.type-res.group"
diff -r 4039f71221d1 -r a59ad15c8b62 tests/test_account_payment_sepa.py
--- a/tests/test_account_payment_sepa.py Fri Mar 05 15:49:19 2021 +0100
+++ b/tests/test_account_payment_sepa.py Thu Mar 11 23:00:10 2021 +0100
@@ -188,6 +188,7 @@
pool = Pool()
Configuration = pool.get('account.configuration')
Sequence = pool.get('ir.sequence')
+ SequenceType = pool.get('ir.sequence.type')
Party = pool.get('party.party')
Mandate = pool.get('account.payment.sepa.mandate')
@@ -200,8 +201,10 @@
mandate.save()
self.assertFalse(mandate.identification)
- sequence = Sequence(name='Test',
- code='account.payment.sepa.mandate')
+ sequence_type, = SequenceType.search([
+ ('name', '=', "SEPA Mandate"),
+ ], limit=1)
+ sequence = Sequence(name="Test", sequence_type=sequence_type)
sequence.save()
config = Configuration(1)
config.sepa_mandate_sequence = sequence