changeset ff70bcb3e894 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset;node=ff70bcb3e894
description:
        Update sequence name in renew fiscal year

        issue7967
        review269941002
diffstat:

 CHANGELOG                           |   1 +
 fiscalyear.py                       |   7 ++++++-
 tests/scenario_renew_fiscalyear.rst |  16 ++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletions(-)

diffs (48 lines):

diff -r 649405436fe2 -r ff70bcb3e894 CHANGELOG
--- a/CHANGELOG Fri Jul 26 09:36:25 2019 +0200
+++ b/CHANGELOG Fri Jul 26 09:39:29 2019 +0200
@@ -1,3 +1,4 @@
+* Update sequence name in renew fiscal year
 * Make tax required on tax line
 * Use today as default date when inside the period
 
diff -r 649405436fe2 -r ff70bcb3e894 fiscalyear.py
--- a/fiscalyear.py     Fri Jul 26 09:36:25 2019 +0200
+++ b/fiscalyear.py     Fri Jul 26 09:39:29 2019 +0200
@@ -550,7 +550,12 @@
             'periods': [],
             }
         previous_sequence = self.start.previous_fiscalyear.post_move_sequence
-        sequence, = Sequence.copy([previous_sequence])
+        sequence, = Sequence.copy([previous_sequence],
+            default={
+                'name': lambda data: data['name'].replace(
+                    self.start.previous_fiscalyear.name,
+                    self.start.name)
+                })
         if self.start.reset_sequences:
             sequence.number_next = 1
         else:
diff -r 649405436fe2 -r ff70bcb3e894 tests/scenario_renew_fiscalyear.rst
--- a/tests/scenario_renew_fiscalyear.rst       Fri Jul 26 09:36:25 2019 +0200
+++ b/tests/scenario_renew_fiscalyear.rst       Fri Jul 26 09:39:29 2019 +0200
@@ -60,3 +60,19 @@
     >>> new_fiscalyear, = renew_fiscalyear.actions[0]
     >>> int(new_fiscalyear.post_move_sequence.number_next)
     1
+
+Set the sequence name::
+
+    >>> sequence = new_fiscalyear.post_move_sequence
+    >>> sequence.name = 'Sequence %s' % 
new_fiscalyear.start_date.strftime('%Y')
+    >>> sequence.save()
+
+Renew fiscalyear and test sequence name is updated::
+
+    >>> renew_fiscalyear = Wizard('account.fiscalyear.renew')
+    >>> renew_fiscalyear.form.reset_sequences = True
+    >>> renew_fiscalyear.execute('create_')
+    >>> new_fiscalyear, = renew_fiscalyear.actions[0]
+    >>> new_fiscalyear.post_move_sequence.name == (
+    ...     'Sequence %s' % new_fiscalyear.start_date.strftime('%Y'))
+    True

Reply via email to