line: amount darf negativ sein + test, constrain gelöscht
This commit is contained in:
parent
e3887debe9
commit
9732fe11e9
5 changed files with 154 additions and 19 deletions
16
line.py
16
line.py
|
@ -91,8 +91,7 @@ class Line(Workflow, ModelSQL, ModelView):
|
|||
STATES['readonly'],
|
||||
Eval('bookingtype', '').in_(['spin', 'spout']),
|
||||
),
|
||||
}, depends=DEPENDS+['currency_digits', 'bookingtype'],
|
||||
domain=[('amount', '>=', Decimal('0.0'))])
|
||||
}, depends=DEPENDS+['currency_digits', 'bookingtype'])
|
||||
debit = fields.Numeric(string='Debit', digits=(16, Eval('currency_digits', 2)),
|
||||
required=True, readonly=True, depends=['currency_digits'])
|
||||
credit = fields.Numeric(string='Credit', digits=(16, Eval('currency_digits', 2)),
|
||||
|
@ -174,6 +173,13 @@ class Line(Workflow, ModelSQL, ModelView):
|
|||
|
||||
#image = fields.Binary...
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
super(Line, cls).__register__(module_name)
|
||||
|
||||
table = cls.__table_handler__(module_name)
|
||||
table.drop_constraint('amount_val')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Line, cls).__setup__()
|
||||
|
@ -184,9 +190,6 @@ class Line(Workflow, ModelSQL, ModelView):
|
|||
('state_val',
|
||||
Check(t, t.state.in_(['edit', 'check', 'done'])),
|
||||
'cashbook.msg_line_wrong_state_value'),
|
||||
('amount_val',
|
||||
Check(t, t.amount >= Decimal('0.0')),
|
||||
'cashbook.msg_line_must_positive'),
|
||||
])
|
||||
cls._transitions |= set((
|
||||
('edit', 'check'),
|
||||
|
@ -351,11 +354,10 @@ class Line(Workflow, ModelSQL, ModelView):
|
|||
def search_rec_name(cls, name, clause):
|
||||
""" search in description +...
|
||||
"""
|
||||
l1 = cls.search_payee(name, clause) + [
|
||||
return cls.search_payee(name, clause) + [
|
||||
('description',) + tuple(clause[1:]),
|
||||
('category.rec_name',) + tuple(clause[1:]),
|
||||
]
|
||||
return l1
|
||||
|
||||
def get_rec_name(self, name):
|
||||
""" short + name
|
||||
|
|
|
@ -150,10 +150,6 @@ msgctxt "model:ir.message,text:msg_line_invalid_category"
|
|||
msgid "The category of the booking line '%(recname)s' does not match the posting type '%(booktype)s'."
|
||||
msgstr "Die Kategorie der Buchungszeile '%(recname)s' paßt nicht zum Buchungstyp '%(booktype)s'."
|
||||
|
||||
msgctxt "model:ir.message,text:msg_line_must_positive"
|
||||
msgid "The amount must be positive."
|
||||
msgstr "Der Betrag muß positiv sein."
|
||||
|
||||
|
||||
#############
|
||||
# res.group #
|
||||
|
|
124
locale/en.po
124
locale/en.po
|
@ -146,10 +146,6 @@ msgctxt "model:ir.message,text:msg_line_invalid_category"
|
|||
msgid "The category of the booking line '%(recname)s' does not match the posting type '%(booktype)s'."
|
||||
msgstr "The category of the booking line '%(recname)s' does not match the posting type '%(booktype)s'."
|
||||
|
||||
msgctxt "model:ir.message,text:msg_line_must_positive"
|
||||
msgid "The amount must be positive."
|
||||
msgstr "The amount must be positive."
|
||||
|
||||
msgctxt "model:res.group,name:group_cashbook"
|
||||
msgid "Cashbook"
|
||||
msgstr "Cashbook"
|
||||
|
@ -262,6 +258,10 @@ msgctxt "model:ir.ui.menu,name:act_category_view"
|
|||
msgid "Category"
|
||||
msgstr "Category"
|
||||
|
||||
msgctxt "model:ir.ui.menu,name:menu_enter_booking"
|
||||
msgid "Enter Booking"
|
||||
msgstr "Enter Booking"
|
||||
|
||||
msgctxt "model:ir.action,name:act_book_view"
|
||||
msgid "Cashbook"
|
||||
msgstr "Cashbook"
|
||||
|
@ -286,6 +286,10 @@ msgctxt "model:ir.action,name:act_wizard_report"
|
|||
msgid "Cashbook Report"
|
||||
msgstr "Cashbook Report"
|
||||
|
||||
msgctxt "model:ir.action,name:act_enterbooking_wiz"
|
||||
msgid "Enter Booking"
|
||||
msgstr "Enter Booking"
|
||||
|
||||
msgctxt "model:ir.action.act_window.domain,name:act_line_domain_current"
|
||||
msgid "Current Month"
|
||||
msgstr "Current Month"
|
||||
|
@ -922,6 +926,10 @@ msgctxt "model:cashbook.configuration,name:"
|
|||
msgid "Configuration"
|
||||
msgstr "Configuration"
|
||||
|
||||
msgctxt "view:cashbook.configuration:"
|
||||
msgid "Enter Booking Wizard"
|
||||
msgstr "Enter Booking Wizard"
|
||||
|
||||
msgctxt "view:cashbook.configuration:"
|
||||
msgid "Open Cashbook Wizard"
|
||||
msgstr "Open Cashbook Wizard"
|
||||
|
@ -930,6 +938,14 @@ msgctxt "view:cashbook.configuration:"
|
|||
msgid "Cashbook"
|
||||
msgstr "Cashbook"
|
||||
|
||||
msgctxt "field:cashbook.configuration,defbook:"
|
||||
msgid "Default Cashbook"
|
||||
msgstr "Default Cashbook"
|
||||
|
||||
msgctxt "help:cashbook.configuration,defbook:"
|
||||
msgid "The default cashbook is selected when you open the booking wizard."
|
||||
msgstr "The default cashbook is selected when you open the booking wizard."
|
||||
|
||||
msgctxt "field:cashbook.configuration,date_from:"
|
||||
msgid "Start Date"
|
||||
msgstr "Start Date"
|
||||
|
@ -998,6 +1014,14 @@ msgctxt "help:cashbook.configuration_user,catnamelong:"
|
|||
msgid "Shows the long name of the category in the Category field of a cash book line."
|
||||
msgstr "Shows the long name of the category in the Category field of a cash book line."
|
||||
|
||||
msgctxt "field:cashbook.configuration_user,defbook:"
|
||||
msgid "Default Cashbook"
|
||||
msgstr "Default Cashbook"
|
||||
|
||||
msgctxt "help:cashbook.configuration_user,defbook:"
|
||||
msgid "The default cashbook is selected when you open the booking wizard."
|
||||
msgstr "The default cashbook is selected when you open the booking wizard."
|
||||
|
||||
msgctxt "model:cashbook.recon,name:"
|
||||
msgid "Cashbook Reconciliation"
|
||||
msgstr "Cashbook Reconciliation"
|
||||
|
@ -1166,3 +1190,95 @@ msgctxt "report:cashbook.reprecon:"
|
|||
msgid "Total"
|
||||
msgstr "Total"
|
||||
|
||||
msgctxt "report:cashbook.reprecon:"
|
||||
msgid "Payee"
|
||||
msgstr "Payee"
|
||||
|
||||
msgctxt "model:cashbook.enterbooking.start,name:"
|
||||
msgid "Enter Booking"
|
||||
msgstr "Enter Booking"
|
||||
|
||||
msgctxt "view:cashbook.enterbooking.start:"
|
||||
msgid "Description"
|
||||
msgstr "Description"
|
||||
|
||||
msgctxt "view:cashbook.enterbooking.start:"
|
||||
msgid "Booking"
|
||||
msgstr "Booking"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,cashbook:"
|
||||
msgid "Cashbook"
|
||||
msgstr "Cashbook"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,cashbooks:"
|
||||
msgid "Cashbooks"
|
||||
msgstr "Cashbooks"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,currency_digits:"
|
||||
msgid "Currency Digits"
|
||||
msgstr "Currency Digits"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,currency:"
|
||||
msgid "Currency"
|
||||
msgstr "Currency"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,bookingtype:"
|
||||
msgid "Type"
|
||||
msgstr "Type"
|
||||
|
||||
msgctxt "selection:cashbook.enterbooking.start,bookingtype:"
|
||||
msgid "Revenue"
|
||||
msgstr "Revenue"
|
||||
|
||||
msgctxt "selection:cashbook.enterbooking.start,bookingtype:"
|
||||
msgid "Revenue Splitbooking"
|
||||
msgstr "Revenue Splitbooking"
|
||||
|
||||
msgctxt "selection:cashbook.enterbooking.start,bookingtype:"
|
||||
msgid "Expense"
|
||||
msgstr "Expense"
|
||||
|
||||
msgctxt "selection:cashbook.enterbooking.start,bookingtype:"
|
||||
msgid "Expense Splitbooking"
|
||||
msgstr "Expense Splitbooking"
|
||||
|
||||
msgctxt "selection:cashbook.enterbooking.start,bookingtype:"
|
||||
msgid "Transfer from"
|
||||
msgstr "Transfer from"
|
||||
|
||||
msgctxt "selection:cashbook.enterbooking.start,bookingtype:"
|
||||
msgid "Transfer to"
|
||||
msgstr "Transfer to"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,amount:"
|
||||
msgid "Amount"
|
||||
msgstr "Amount"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,owner_cashbook:"
|
||||
msgid "Owner"
|
||||
msgstr "Owner"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,category:"
|
||||
msgid "Category"
|
||||
msgstr "Category"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,booktransf:"
|
||||
msgid "Source/Dest"
|
||||
msgstr "Source/Dest"
|
||||
|
||||
msgctxt "field:cashbook.enterbooking.start,party:"
|
||||
msgid "Party"
|
||||
msgstr "Party"
|
||||
|
||||
msgctxt "model:cashbook.enterbooking,name:"
|
||||
msgid "Enter Booking"
|
||||
msgstr "Enter Booking"
|
||||
|
||||
msgctxt "wizard_button:cashbook.enterbooking,start,end:"
|
||||
msgid "Cancel"
|
||||
msgstr "Cancel"
|
||||
|
||||
msgctxt "wizard_button:cashbook.enterbooking,start,save_:"
|
||||
msgid "Save"
|
||||
msgstr "Save"
|
||||
|
||||
|
|
|
@ -113,9 +113,6 @@ full copyright notices and license terms. -->
|
|||
<record model="ir.message" id="msg_line_invalid_category">
|
||||
<field name="text">The category of the booking line '%(recname)s' does not match the posting type '%(booktype)s'.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_line_must_positive">
|
||||
<field name="text">The amount must be positive.</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -870,11 +870,25 @@ class LineTestCase(ModuleTestCase):
|
|||
'bookingtype': 'mvout',
|
||||
'amount': Decimal('1.0'),
|
||||
'booktransf': book2.id,
|
||||
}, {
|
||||
'date': date(2022, 6, 1), # in-category, return
|
||||
'description': 'in-return', # amount negative
|
||||
'category': category_in.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('-1.0'),
|
||||
'booktransf': book2.id,
|
||||
}, {
|
||||
'date': date(2022, 6, 1), # out-category, return
|
||||
'description': 'out-return', # amount negative
|
||||
'category': category_out.id,
|
||||
'bookingtype': 'out',
|
||||
'amount': Decimal('-1.0'),
|
||||
'booktransf': book2.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 4)
|
||||
self.assertEqual(len(book.lines), 6)
|
||||
|
||||
self.assertEqual(book.lines[0].amount, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].bookingtype, 'in')
|
||||
|
@ -901,6 +915,16 @@ class LineTestCase(ModuleTestCase):
|
|||
self.assertEqual(book.lines[3].credit, Decimal('0.0'))
|
||||
self.assertEqual(book.lines[3].debit, Decimal('1.0'))
|
||||
|
||||
self.assertEqual(book.lines[4].amount, Decimal('-1.0'))
|
||||
self.assertEqual(book.lines[4].bookingtype, 'in')
|
||||
self.assertEqual(book.lines[4].credit, Decimal('-1.0'))
|
||||
self.assertEqual(book.lines[4].debit, Decimal('0.0'))
|
||||
|
||||
self.assertEqual(book.lines[5].amount, Decimal('-1.0'))
|
||||
self.assertEqual(book.lines[5].bookingtype, 'out')
|
||||
self.assertEqual(book.lines[5].credit, Decimal('0.0'))
|
||||
self.assertEqual(book.lines[5].debit, Decimal('-1.0'))
|
||||
|
||||
Line.write(*[
|
||||
[book.lines[0]],
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue