Rename split lines into reschedule lines

issue11069
review387661002
This commit is contained in:
David Blanco Bautista committed 2022-01-26 00:32:20 +01:00
1 parent 2bcb9da7c2
commit 0126a08462
12 files changed
+99 -97

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Rename split lines into reschedule lines
* Add optional credit type on account
* Always require a date to compute taxes
* Add support for Python 3.10
+4 -4
View File
@@ -59,9 +59,9 @@ def register():
move.ReconcileShow,
move.CancelMovesDefault,
move.GroupLinesStart,
move.SplitLinesStart,
move.SplitLinesPreview,
move.SplitLinesTerm,
move.RescheduleLinesStart,
move.RescheduleLinesPreview,
move.RescheduleLinesTerm,
tax.TaxGroup,
tax.TaxCodeTemplate,
tax.TaxCode,
@@ -102,7 +102,7 @@ def register():
move.Reconcile,
move.CancelMoves,
move.GroupLines,
move.SplitLines,
move.RescheduleLines,
move_template.CreateMove,
tax.OpenChartTaxCode,
tax.OpenTaxCode,
+6 -5
View File
@@ -97,13 +97,14 @@ line is created for the net amount of the grouped lines.
The maturity date used for the newly created account move line is the
earliest maturity date from the lines that were grouped together.
.. _wizard-account.move.line.split:
.. _wizard-account.move.line.reschedule:
Split Lines
^^^^^^^^^^^
Reschedule Lines
^^^^^^^^^^^^^^^^
The *Split Lines* wizard allows to reschedule payable or receivable *Account
Move Lines* by creating an account move line for each new maturity date.
The *Reschedule Lines* wizard allows to reschedule payable or receivable
*Account Move Lines* by creating an account move line for each new maturity
date.
.. _wizard-account.move.reconcile_lines:
+1 -1
View File
@@ -93,5 +93,5 @@ class GroupLineError(UserError):
pass
class SplitLineError(UserError):
class RescheduleLineError(UserError):
pass
+10 -10
View File
@@ -202,20 +202,20 @@ You may need to cancel its move "%(move)s".</field>
<record model="ir.message" id="msg_group_line_maximum_account">
<field name="text">You cannot group lines from more than 2 different accounts.</field>
</record>
<record model="ir.message" id="msg_split_line_same_origins">
<field name="text">You cannot split lines with different origins.</field>
<record model="ir.message" id="msg_reschedule_line_same_origins">
<field name="text">You cannot reschedule lines with different origins.</field>
</record>
<record model="ir.message" id="msg_split_line_same_currency">
<field name="text">You cannot split lines with different currencies.</field>
<record model="ir.message" id="msg_reschedule_line_same_currency">
<field name="text">You cannot reschedule lines with different currencies.</field>
</record>
<record model="ir.message" id="msg_split_line_same_account">
<field name="text">You cannot split lines with different accounts.</field>
<record model="ir.message" id="msg_reschedule_line_same_account">
<field name="text">You cannot reschedule lines with different accounts.</field>
</record>
<record model="ir.message" id="msg_split_line_same_party">
<field name="text">You cannot split lines with different parties.</field>
<record model="ir.message" id="msg_reschedule_line_same_party">
<field name="text">You cannot reschedule lines with different parties.</field>
</record>
<record model="ir.message" id="msg_split_line_wrong_amount">
<field name="text">To split the lines you must change the terms to have a total amount of %(total_amount)s instead of %(amount)s.</field>
<record model="ir.message" id="msg_reschedule_line_wrong_amount">
<field name="text">To reschedule the lines you must change the terms to have a total amount of %(total_amount)s instead of %(amount)s.</field>
</record>
<record model="ir.message" id="msg_cancel_line_delegated">
<field name="text">The moves "%(moves)s" contain grouped lines, cancelling them will ungroup the lines.</field>
+35 -35
View File
@@ -29,7 +29,7 @@ from trytond.wizard import (
from .exceptions import (
CancelDelegatedWarning, CancelWarning, DeleteDelegatedWarning,
GroupLineError, MoveDatesError, PostError, ReconciliationError,
SplitLineError)
RescheduleLineError)
_MOVE_STATES = {
'readonly': Eval('state') == 'posted',
@@ -2182,28 +2182,28 @@ class GroupLinesStart(ModelView):
description = fields.Char("Description")
class SplitLines(Wizard):
"Split Lines"
__name__ = 'account.move.line.split'
start = StateView('account.move.line.split.start',
'account.move_line_split_start_view_form', [
class RescheduleLines(Wizard):
"Reschedule Lines"
__name__ = 'account.move.line.reschedule'
start = StateView('account.move.line.reschedule.start',
'account.move_line_reschedule_start_view_form', [
Button("Cancel", 'end', 'tryton-cancel'),
Button("Preview", 'preview', 'tryton-ok',
validate=False, default=True),
])
preview = StateView('account.move.line.split.preview',
'account.move_line_split_preview_view_form', [
preview = StateView('account.move.line.reschedule.preview',
'account.move_line_reschedule_preview_view_form', [
Button("Cancel", 'end', 'tryton-cancel'),
Button("Split", 'split', 'tryton-ok', default=True),
Button("Reschedule", 'reschedule', 'tryton-ok', default=True),
])
split = StateAction('account.act_move_form_splitting')
reschedule = StateAction('account.act_move_form_rescheduling')
def get_origin(self):
try:
origin, = {r.move.origin for r in self.records}
except ValueError:
raise SplitLineError(
gettext('account.msg_split_line_same_origins'))
raise RescheduleLineError(
gettext('account.msg_reschedule_line_same_origins'))
return origin
@classmethod
@@ -2211,8 +2211,8 @@ class SplitLines(Wizard):
try:
currency, = {l.amount_currency for l in lines}
except ValueError:
raise SplitLineError(
gettext('account.msg_split_line_same_currency'))
raise RescheduleLineError(
gettext('account.msg_reschedule_line_same_currency'))
return currency
@classmethod
@@ -2220,8 +2220,8 @@ class SplitLines(Wizard):
try:
account, = {l.account for l in lines}
except ValueError:
raise SplitLineError(
gettext('account.msg_split_line_same_account'))
raise RescheduleLineError(
gettext('account.msg_reschedule_line_same_account'))
return account
@classmethod
@@ -2229,8 +2229,8 @@ class SplitLines(Wizard):
try:
party, = {l.party for l in lines}
except ValueError:
raise SplitLineError(
gettext('account.msg_split_line_same_party'))
raise RescheduleLineError(
gettext('account.msg_reschedule_line_same_party'))
return party
@classmethod
@@ -2298,8 +2298,8 @@ class SplitLines(Wizard):
terms[-1]['amount'] += remaining
return values
def do_split(self, action):
move, balance_line = self.split_lines(
def do_reschedule(self, action):
move, balance_line = self.reschedule_lines(
self.records, self.preview.journal, self.preview.terms)
move.origin = self.get_origin()
move.description = self.preview.description
@@ -2320,7 +2320,7 @@ class SplitLines(Wizard):
}
@classmethod
def split_lines(cls, lines, journal, terms):
def reschedule_lines(cls, lines, journal, terms):
pool = Pool()
Lang = pool.get('ir.lang')
Line = pool.get('account.move.line')
@@ -2330,15 +2330,15 @@ class SplitLines(Wizard):
if amount != total_amount:
lang = Lang.get()
currency = cls.get_currency(lines)
raise SplitLineError(
gettext('account.msg_split_line_wrong_amount',
raise RescheduleLineError(
gettext('account.msg_reschedule_line_wrong_amount',
total_amount=lang.currency(total_amount, currency),
amount=lang.currency(amount, currency)))
balance = cls.get_balance(lines)
line_values = cls._line_values(lines)
account = line_values['account']
move, balance_line = cls.get_split_move(
move, balance_line = cls.get_reschedule_move(
amount, balance, journal, terms, **line_values)
move.save()
balance_line.move = move
@@ -2349,7 +2349,7 @@ class SplitLines(Wizard):
return move, balance_line
@classmethod
def get_split_move(
def get_reschedule_move(
cls, amount, balance, journal, terms, account, date=None,
**line_values):
pool = Pool()
@@ -2408,9 +2408,9 @@ class SplitLines(Wizard):
return move, balance_line
class SplitLinesStart(ModelView):
"Split Lines"
__name__ = 'account.move.line.split.start'
class RescheduleLinesStart(ModelView):
"Reschedule Lines"
__name__ = 'account.move.line.reschedule.start'
start_date = fields.Date("Start Date", required=True)
frequency = fields.Selection([
('monthly', "Monthly"),
@@ -2474,13 +2474,13 @@ class SplitLinesStart(ModelView):
self.interval = self.frequency_intervals()[self.frequency]
class SplitLinesPreview(ModelView):
"Split Lines"
__name__ = 'account.move.line.split.preview'
class RescheduleLinesPreview(ModelView):
"Reschedule Lines"
__name__ = 'account.move.line.reschedule.preview'
journal = fields.Many2One('account.journal', "Journal", required=True)
description = fields.Char("Description")
terms = fields.One2Many(
'account.move.line.split.term', None, "Terms",
'account.move.line.reschedule.term', None, "Terms",
domain=[
('currency', '=', Eval('currency', -1)),
],
@@ -2488,9 +2488,9 @@ class SplitLinesPreview(ModelView):
currency = fields.Many2One('currency.currency', "Currency", readonly=True)
class SplitLinesTerm(ModelView):
"Split Lines"
__name__ = 'account.move.line.split.term'
class RescheduleLinesTerm(ModelView):
"Reschedule Lines"
__name__ = 'account.move.line.reschedule.term'
date = fields.Date("Date", required=True)
amount = Monetary(
"Amount", currency='currency', digits='currency', required=True)
+18 -18
View File
@@ -452,43 +452,43 @@ this repository contains the full copyright notices and license terms. -->
<field name="act_window" ref="act_move_form_grouping"/>
</record>
<record model="ir.action.wizard" id="act_split_lines_wizard">
<field name="name">Split Lines</field>
<field name="wiz_name">account.move.line.split</field>
<record model="ir.action.wizard" id="act_reschedule_lines_wizard">
<field name="name">Reschedule Lines</field>
<field name="wiz_name">account.move.line.reschedule</field>
<field name="model">account.move.line</field>
</record>
<record model="ir.action.keyword" id="act_split_lines_keyword1">
<record model="ir.action.keyword" id="act_reschedule_lines_keyword1">
<field name="keyword">form_action</field>
<field name="model">account.move.line,-1</field>
<field name="action" ref="act_split_lines_wizard"/>
<field name="action" ref="act_reschedule_lines_wizard"/>
</record>
<record model="ir.ui.view" id="move_line_split_start_view_form">
<field name="model">account.move.line.split.start</field>
<record model="ir.ui.view" id="move_line_reschedule_start_view_form">
<field name="model">account.move.line.reschedule.start</field>
<field name="type">form</field>
<field name="name">move_line_split_start_form</field>
<field name="name">move_line_reschedule_start_form</field>
</record>
<record model="ir.ui.view" id="move_line_split_preview_view_form">
<field name="model">account.move.line.split.preview</field>
<record model="ir.ui.view" id="move_line_reschedule_preview_view_form">
<field name="model">account.move.line.reschedule.preview</field>
<field name="type">form</field>
<field name="name">move_line_split_preview_form</field>
<field name="name">move_line_reschedule_preview_form</field>
</record>
<record model="ir.ui.view" id="move_line_split_term_view_list">
<field name="model">account.move.line.split.term</field>
<record model="ir.ui.view" id="move_line_reschedule_term_view_list">
<field name="model">account.move.line.reschedule.term</field>
<field name="type">tree</field>
<field name="name">move_line_split_term_list</field>
<field name="name">move_line_reschedule_term_list</field>
</record>
<record model="ir.action.act_window" id="act_move_form_splitting">
<field name="name">Split Account Move</field>
<record model="ir.action.act_window" id="act_move_form_rescheduling">
<field name="name">Reschedule Account Move</field>
<field name="res_model">account.move</field>
</record>
<record model="ir.action.act_window.view" id="act_move_form_splitting_view1">
<record model="ir.action.act_window.view" id="act_move_form_rescheduling_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="move_view_form"/>
<field name="act_window" ref="act_move_form_splitting"/>
<field name="act_window" ref="act_move_form_rescheduling"/>
</record>
<record model="ir.action.report" id="report_general_journal">
@@ -1,6 +1,6 @@
====================
Split Lines Scenario
====================
=========================
Reschedule Lines Scenario
=========================
Imports::
@@ -51,7 +51,7 @@ Create parties::
>>> party = Party(name="Party")
>>> party.save()
Create Lines to split::
Create Lines to reschedule::
>>> journal_revenue, = Journal.find([
... ('code', '=', 'REV'),
@@ -79,16 +79,16 @@ Create Lines to split::
Split line by amount::
>>> split = Wizard('account.move.line.split', [line])
>>> split.form.total_amount
>>> reschedule = Wizard('account.move.line.reschedule', [line])
>>> reschedule.form.total_amount
Decimal('100.00')
>>> split.form.start_date = period.end_date
>>> split.form.frequency = 'other'
>>> split.form.interval = 2
>>> split.form.amount = Decimal('30.00')
>>> split.execute('preview')
>>> reschedule.form.start_date = period.end_date
>>> reschedule.form.frequency = 'other'
>>> reschedule.form.interval = 2
>>> reschedule.form.amount = Decimal('30.00')
>>> reschedule.execute('preview')
>>> term1, term2, term3, term4 = split.form.terms
>>> term1, term2, term3, term4 = reschedule.form.terms
>>> term1.date == period.end_date
True
>>> term2.date == period.end_date + relativedelta(months=2)
@@ -102,16 +102,16 @@ Split line by amount::
Split line by number::
>>> split = Wizard('account.move.line.split', [line])
>>> split.form.total_amount
>>> reschedule = Wizard('account.move.line.reschedule', [line])
>>> reschedule.form.total_amount
Decimal('100.00')
>>> split.form.start_date = period.end_date
>>> split.form.frequency = 'monthly'
>>> split.form.number = 3
>>> split.execute('preview')
>>> reschedule.form.start_date = period.end_date
>>> reschedule.form.frequency = 'monthly'
>>> reschedule.form.number = 3
>>> reschedule.execute('preview')
>>> split.form.description = "Split 3 months"
>>> term1, term2, term3 = split.form.terms
>>> reschedule.form.description = "Split 3 months"
>>> term1, term2, term3 = reschedule.form.terms
>>> term1.date == period.end_date
True
>>> term2.date == period.end_date + relativedelta(months=1)
@@ -124,9 +124,9 @@ Split line by number::
>>> term2.amount = term3.amount = Decimal('30.00')
>>> term3.date += relativedelta(months=1)
>>> split.execute('split')
>>> split_move, = split.actions[0]
>>> split_move.description
>>> reschedule.execute('reschedule')
>>> reschedule_move, = reschedule.actions[0]
>>> reschedule_move.description
'Split 3 months'
Check receivable::
+1 -1
View File
@@ -1725,7 +1725,7 @@ def suite():
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
suite.addTests(doctest.DocFileSuite(
'scenario_move_line_split.rst',
'scenario_move_line_reschedule.rst',
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
File renamed without changes.
File renamed without changes.