add field 'target' for category/cashbook in list view
This commit is contained in:
parent
acc8911a8d
commit
be92110ae1
5 changed files with 59 additions and 7 deletions
35
planner.py
35
planner.py
|
@ -148,6 +148,9 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
|||
wfcheck = fields.Boolean(
|
||||
string="Set to 'Checked'",
|
||||
help="Switches the booking to the 'Verified' state.")
|
||||
booking_target = fields.Function(fields.Reference(
|
||||
string='Target', selection='get_booking_modelnames', readonly=True),
|
||||
'on_change_with_booking_target')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -249,6 +252,38 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
|||
break
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def get_booking_modelnames(cls):
|
||||
""" get list of model for field 'booking_target
|
||||
|
||||
Returns:
|
||||
list: list of tuple: (model_name, Description)
|
||||
"""
|
||||
Model = Pool().get('ir.model')
|
||||
return [
|
||||
(x.model, x.name)
|
||||
for x in Model.search([
|
||||
('model', 'in', ['cashbook.book', 'cashbook.category'])])]
|
||||
|
||||
@fields.depends('bookingtype', 'category', 'booktransf')
|
||||
def on_change_with_booking_target(self, name=None):
|
||||
""" get category of target-cashbook
|
||||
|
||||
Args:
|
||||
name (str, optional): name of field. Defaults to None.
|
||||
|
||||
Returns:
|
||||
tuple: tuple with model-name and id of booking-target
|
||||
"""
|
||||
if self.bookingtype in ['in', 'out']:
|
||||
if self.category:
|
||||
return '%s,%d' % (
|
||||
self.category.__name__, self.category.id)
|
||||
elif self.bookingtype in ['mvin', 'mvout']:
|
||||
if self.booktransf:
|
||||
return '%s,%d' % (
|
||||
self.booktransf.__name__, self.booktransf.id)
|
||||
|
||||
@fields.depends('cashbook', '_parent_cashbook.currency')
|
||||
def on_change_with_currency_cashbook(self, name=None):
|
||||
""" get currency of selected cashbook
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue