Allow statement line with amount of zero
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Allow line with amount of zero
|
||||
* Remove support for Python 3.7
|
||||
* Add support for Python 3.11
|
||||
|
||||
|
||||
@@ -36,9 +36,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.message" id="msg_statement_post_pending_amount">
|
||||
<field name="text">To post statement "%(statement)s" you must create lines for pending %(amount)s of origin "%(origin)s".</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_line_amount_non_zero">
|
||||
<field name="text">Statement line amount cannot be zero.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_post_statement_move">
|
||||
<field name="text">To post the move "%(move)s" you must post the statement "%(statement)s".</field>
|
||||
</record>
|
||||
|
||||
@@ -12,7 +12,7 @@ from sql.operators import Concat
|
||||
from trytond.config import config
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import (
|
||||
Check, DictSchemaMixin, Index, ModelSQL, ModelView, Workflow, fields,
|
||||
DictSchemaMixin, Index, ModelSQL, ModelView, Workflow, fields,
|
||||
sequence_ordered)
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.modules.company import CompanyReport
|
||||
@@ -554,6 +554,8 @@ class Statement(Workflow, ModelSQL, ModelView):
|
||||
amount_second_currency = 0
|
||||
for line in lines:
|
||||
move_line = line.get_move_line()
|
||||
if not move_line:
|
||||
continue
|
||||
move_line.move = move
|
||||
amount += move_line.debit - move_line.credit
|
||||
if move_line.amount_second_currency:
|
||||
@@ -798,11 +800,6 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView):
|
||||
'required': (Eval('party_required', False)
|
||||
& (Eval('statement_state') == 'draft')),
|
||||
}
|
||||
t = cls.__table__()
|
||||
cls._sql_constraints += [
|
||||
('check_statement_line_amount', Check(t, t.amount != 0),
|
||||
'account_statement.msg_line_amount_non_zero'),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module):
|
||||
@@ -821,6 +818,9 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView):
|
||||
where=table.invoice != Null))
|
||||
table_h.drop_column('invoice')
|
||||
|
||||
# Migration from 6.6: Allow amount of zero
|
||||
table_h.drop_constraint('check_statement_line_amount')
|
||||
|
||||
@property
|
||||
@fields.depends('related_to')
|
||||
def invoice(self):
|
||||
@@ -1043,6 +1043,8 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView):
|
||||
MoveLine = pool.get('account.move.line')
|
||||
Currency = Pool().get('currency.currency')
|
||||
zero = Decimal("0.0")
|
||||
if not self.amount:
|
||||
return
|
||||
with Transaction().set_context(date=self.date):
|
||||
amount = Currency.compute(self.statement.journal.currency,
|
||||
self.amount, self.statement.company.currency)
|
||||
|
||||
Reference in New Issue
Block a user