Created
June 23, 2022 07:58
-
-
Save sehrishnaz/142d8ed964fad7c01718e8936513252e to your computer and use it in GitHub Desktop.
Dynamically Fold Kanban States (Selection Field) in Odoo8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class some_model(models.Model): | |
_name = "some.model" | |
STATES = [('Draft','Draft'),('Submit','Submit'),('Closed','Closed')] | |
# States that should be folded in Kanban view | |
# used by the `state_groups` method | |
FOLDED_STATES = [ | |
'Closed', | |
] | |
@api.model | |
def state_groups(self, present_ids, domain, **kwargs): | |
folded = {key: (key in self.FOLDED_STATES) for key, _ in self.STATES} | |
# Need to copy self.STATES list before returning it, | |
# because odoo modifies the list it gets, | |
# emptying it in the process. Bad odoo! | |
return self.STATES[:], folded | |
_group_by_full = { | |
'state': state_groups | |
} | |
state = fields.Selection(STATES, string="Status", default="Draft") | |
def _read_group_fill_results(self, cr, uid, domain, groupby, | |
remaining_groupbys, aggregated_fields, | |
count_field, read_group_result, | |
read_group_order=None, context=None): | |
""" | |
The method seems to support grouping using m2o fields only, | |
while we want to group by a simple status field. | |
Hence the code below - it replaces simple status values | |
with (value, name) tuples. | |
""" | |
if groupby == 'state': | |
STATES_DICT = dict(self.STATES) | |
for result in read_group_result: | |
state = result['state'] | |
result['state'] = (state, STATES_DICT.get(state)) | |
return super(some_model, self)._read_group_fill_results( | |
cr, uid, domain, groupby, remaining_groupbys, aggregated_fields, | |
count_field, read_group_result, read_group_order, context | |
) |
does it work for odoo 15?
No its for odoo8
…On Mon, Jul 8, 2024 at 5:26 PM JoaquinDelt ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
does it work for odoo 15?
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/sehrishnaz/142d8ed964fad7c01718e8936513252e#gistcomment-5114526>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIC2I2YSZCKR7HWQUJ47AEDZLKAONBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTCNRZHA2TKOJTU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
is there a way to do this for odoo 15? ive been looking for one, even trying to do one but i cant
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Conditionally Fold Kanban States (Selection Field) in Odoo8