Add unique constraint on line taxes
issue10841 review366081002
This commit is contained in:
@@ -36,5 +36,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.message" id="msg_purchase_move_reset_draft">
|
||||
<field name="text">You cannot reset move "%(move)s" to draft because it was generated by a purchase.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_purchase_line_tax_unique">
|
||||
<field name="text">A tax can be added only once to a purchase line.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
+10
-1
@@ -11,7 +11,7 @@ from sql.operators import Concat
|
||||
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import Workflow, Model, ModelView, ModelSQL, fields, \
|
||||
sequence_ordered
|
||||
sequence_ordered, Unique
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.modules.company import CompanyReport
|
||||
from trytond.wizard import Wizard, StateAction, StateView, StateTransition, \
|
||||
@@ -1781,6 +1781,15 @@ class LineTax(ModelSQL):
|
||||
tax = fields.Many2One('account.tax', 'Tax', ondelete='RESTRICT',
|
||||
select=True, required=True, domain=[('parent', '=', None)])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
t = cls.__table__()
|
||||
cls._sql_constraints += [
|
||||
('line_tax_unique', Unique(t, t.line, t.tax),
|
||||
'purchase.msg_purchase_line_tax_unique'),
|
||||
]
|
||||
|
||||
|
||||
class LineIgnoredMove(ModelSQL):
|
||||
'Purchase Line - Ignored Move'
|
||||
|
||||
Reference in New Issue
Block a user