diff --git a/locale/es.po b/locale/es.po index 129ae7b..0bbe4c7 100644 --- a/locale/es.po +++ b/locale/es.po @@ -2,7 +2,7 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "error:sale.line.quick_action:" +msgctxt "model:ir.message,text:msg_wrong_state" msgid "Sale must be in Draft state." msgstr "Venta debe estar en estado Borrador." diff --git a/message.xml b/message.xml new file mode 100644 index 0000000..55a26a9 --- /dev/null +++ b/message.xml @@ -0,0 +1,10 @@ + + + + + + Sale must be in Draft state. + + + diff --git a/sale.py b/sale.py index 0a28858..d4b7ddf 100644 --- a/sale.py +++ b/sale.py @@ -5,9 +5,8 @@ from trytond.pool import PoolMeta, Pool from trytond.pyson import Eval from trytond.transaction import Transaction from trytond.wizard import Wizard, StateTransition, StateView, Button - -__all__ = ['SaleLine', 'SaleLineQuickAction', 'SaleLineQuickActionSplit', - 'SaleLineQuickActionMove', 'SaleLineQuickActionDuplicate'] +from trytond.exceptions import UserError +from trytond.i18n import gettext class SaleLine(metaclass=PoolMeta): @@ -166,20 +165,14 @@ class SaleLineQuickAction(Wizard): ) do_move = StateTransition() - @classmethod - def __setup__(cls): - super().__setup__() - cls._error_messages.update({ - 'wrong_state': 'Sale must be in Draft state.' - }) - def transition_start(self): pool = Pool() SaleLine = pool.get('sale.line') records = SaleLine.browse(Transaction().context['active_ids']) if any(r.sale_state != 'draft' for r in records): - self.raise_user_error('wrong_state') + raise UserError(gettext( + 'sale_line_quick_actions.msg_wrong_state')) action_id = Transaction().context['action_id'] return self._get_action_state()[action_id] diff --git a/tests/scenario_sale_line_quick_actions.rst b/tests/scenario_sale_line_quick_actions.rst index 1752bba..c799b0f 100644 --- a/tests/scenario_sale_line_quick_actions.rst +++ b/tests/scenario_sale_line_quick_actions.rst @@ -89,7 +89,6 @@ Create product:: >>> template.name = 'product' >>> template.default_uom = unit >>> template.type = 'goods' - >>> template.purchasable = True >>> template.salable = True >>> template.list_price = Decimal('10') >>> template.account_category = account_category_tax diff --git a/tryton.cfg b/tryton.cfg index 9517208..65fcdf7 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -7,3 +7,4 @@ depends: xml: sale.xml + message.xml