Add ir.message and use custom exceptions
issue3672
This commit is contained in:
1 parent
c83796c673
commit
29ca99133a
4 files changed
+19
-12
No files matched your search
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data group="1">
|
||||
<record model="ir.message" id="msg_asset_line_overlap">
|
||||
<field name="text">The lines "%(line1)s" and "%(line2)s" overlap, you must use different dates.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -2,7 +2,9 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from sql import Null
|
||||
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import fields, ModelSQL, ModelView, Workflow
|
||||
from trytond.model.exceptions import ValidationError
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pyson import Eval, If, Bool
|
||||
from trytond.tools import grouped_slice, reduce_ids
|
||||
@@ -99,12 +101,6 @@ class SubscriptionLine(metaclass=PoolMeta):
|
||||
]
|
||||
cls.quantity.depends.append('asset_lot')
|
||||
|
||||
cls._error_messages.update({
|
||||
'asset_overlapping_dates': (
|
||||
'The lines "%(line1)s" and "%(line2)s" '
|
||||
'for the same lot overlap.'),
|
||||
})
|
||||
|
||||
@fields.depends('service')
|
||||
def on_change_with_asset_lot_required(self, name=None):
|
||||
if not self.service:
|
||||
@@ -161,7 +157,7 @@ class SubscriptionLine(metaclass=PoolMeta):
|
||||
overlapping = cursor.fetchone()
|
||||
if overlapping:
|
||||
sline1, sline2 = cls.browse(overlapping)
|
||||
cls.raise_user_error('asset_overlapping_dates', {
|
||||
'line1': sline1.rec_name,
|
||||
'line2': sline2.rec_name,
|
||||
})
|
||||
raise ValidationError(
|
||||
gettext('sale_subscription_asset.msg_asset_line_overlap',
|
||||
line1=sline1.rec_name,
|
||||
line2=sline2.rec_name))
|
||||
@@ -104,7 +104,7 @@ Subscribe::
|
||||
>>> subscription.click('run') # doctest: +IGNORE_EXCEPTION_DETAIL
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
UserError: ...
|
||||
RequiredValidationError: ...
|
||||
|
||||
>>> subscription.click('draft')
|
||||
>>> line, = subscription.lines
|
||||
@@ -137,7 +137,7 @@ Creating an overlapping line won't work::
|
||||
>>> overlapping.save() # doctest: +IGNORE_EXCEPTION_DETAIL
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
UserError: ....
|
||||
DomainValidationError: ....
|
||||
|
||||
Cancelling the subscription will remove lot from the lines thus making it
|
||||
available again::
|
||||
|
||||
@@ -7,3 +7,4 @@ depends:
|
||||
xml:
|
||||
sale.xml
|
||||
stock.xml
|
||||
message.xml
|
||||
Reference in new issue
Block a user