[Boxwise - fair donations distribution for refugees] 2 new features + tiny bugfix

in #utopian-io5 years ago (edited)

Project introduction

Repository

https://github.com/boxwise/boxwise_WMS

What is Boxwise?

As stated in project's README file, Boxwise is a web-app, which makes it easy for organisations to source, store and distribute donated goods to people in need in a fair and dignified way.

How it works?

I'd just repeat myself here as I've already did my best to sum it up in couple of sentences in my first contribution post. You can find it HERE

Here is the video where you can see how DiH volunteers use the DropApp :)

Why did I join the project?

I've explained this also in my previous post. Again, just click HERE to find out.


DropApp in it's current form (Basic HTML, bit of CSS & Javascript and custom PHP framework developed by former volunteer which only 3 poeple in this world understand :D)

text16.png

Tech talk

I've lately creaeted 3 tiny pull request which is actually always a success with Odoo. I somehow can't get my head around this tech so far..

  • Random box ID generator
  • User groups and settings to hide not needed menus from users
  • "First created box" message shown twice

Task1: Random box ID

  • My pull request: HERE
  • Detailed task description: Feature request #24
  • Language: Python
  • Commits: 2
  • My additions: 70 (cumulative commit by commit - 77)
  • My deletions: 0 (cumulative commit by commit - 15)
  • Comment: This pull request was approve while guys were in Greece. James also found the way how to modify the domain_force field of a record - read: force my new random Id to be a default option for packages . He added ir.sequence.xml which does the job (line 18 is the important one)

As last time, I guess the best way how to show what I've done is GIF, right?

Peek 2019-03-13 23-57.gif
Before, packages IDs were generated incementally. You can see how I change the setting to my new random ID and generated IDs are completely random

As always with Odoo, it was an adventure. But on the other side, I've also understood why modularity of Odoo is such a cool and useful thing. Packages we're using are actually coming from ir.stock package and package id is implemented in ir.sequence class. I knew I'll have to extend the ir.sequence class. I've opened ir.stock package code and quickly find out how to inherit from their classes and added my own random ID option to the dropdown.

_inherit = 'ir.sequence'
implementation = fields.Selection([('standard', 'Standard'), ('no_gap', 'No gap'), ('random_id', 'Random ID')],
Inheriting and extending ir.sequency in boxwise_sequency.py

The real question was which methods do I need to overwrite. There was _next(), _nextId(), _doNext() and some more with similar names. Chrome DevTools came to my rescue once again :D In Network tab, I've checked which requests and server methods are called upon creating a new package and seen that _next() is the method which is responsible for deciding which type of id should be generated.

def _next(self):
if self.implementation == 'random_id':
  return self.generate_random_id()    #generate our own random ID
else:
  return super(CustomPackageSequence, self)._next() #fallback to superclass sequence 
Overwriting method to check if random Id should be generated or ir.stock package should create "their" id.

Once I was able to steer the execution to my code generation method, the actuall random ID creation was pretty straightforward. I just needed to ensure it's not already used and if so, just try again. Also, adding prefix and suffix (if configured) should not be forgotten.

image.png

Actual random ID creation, 50 tries, check for not being already used, adding prefix and suffix

Task2: Create user roles & permissions + hide extra menus

  • My pull request: HERE
  • Detailed task description: Feature request #24
  • Language: XML
  • Commits: 2
  • My additions: 58
  • My deletions: 0
  • Comment: Again, the PR was adjusted according to Pampiraiki implementation as some onsite unexpected changes were needed

Peek 2019-03-15 14-23.gif
You can see how after unchecking the new "Show all menus" User permission, most of menus and submenus disappeared. Also new Coordinator and Volunteer group checkbox can be seen

Crucial knowledge here was to find out how to remove permissions from user groups. I've basically found all needed information on this Odoo forum thread. There are 6 various options for adding/replacing values in many2many and one2many fields (permissions are stored as many2many relationships between user groups and permissions)

After finding this out, all I had to do was to define my own 3 groups (Coordinator, Volunteer, Show all menus) and add particular relationships to the menu/submenu items.


Groups


Permissions (menu item relationships)

Task3: Created and fixed Issue #83

Hah I'm adding this one just so it looks I've done a looot of work altogether. The issue here was that the else logic for user message was not correctly placed. I've found it by total coincidence soo created the issue and immediately also fixed it.

Here's how the bug looked like:

Next steps for Boxwise team

  1. Continue implementing basic DropApp functionality into Boxwise for the next 3 weeks
  2. Fly to Athens on first week of April to test new features and get more feedback from volunteers in Pampiraiki warehouse (I'm flying this time as well :O)

GitHub Account

https://github.com/DurkoMatko

Sort:  
  • Good article with images, animated gifs, code samples and explanations
  • Code could use a lot more comments.
  • Your Task#2 PR got closed, were your two commits cherry picked into another PR?

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Yepp I think so. The files I've created were merged to master in this PR (https://github.com/boxwise/boxwise_wms/pull/46). I'm not sure why and what happened there. It was during that week when guys were in greece and I was at work almost 24/7 cuz of the release.

But yeah, if you click on the link of the PR above, you can see the first 2 commits are mine. Probably got cherry picked. I'm not sure as all I know about cherry picking is that I sometimes cherry pick the whole pull-request merged into develop to merge it also to master. But I do this at work with Microsoft TFS in browse and it actually also generates "cherry-picking commit". Not sure what exactly happened here :) I just know that the file data/user_groups.xml was created by me :D.

Thanks for the review!

Thank you for your review, @helo! Keep up the good work!

Hi, @matkodurko!

You just got a 0.65% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Wow this is an amazing initiative, @matkodurko ! I love the idea so much ! To be able to distribute donations in a dignified way is an incredible idea <3 I am not tech minded but I wish you all the best with this :)

Happy to follow your moves on this mission! Good luck and thanks for sharing!

Hi @matkodurko!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.034
BTC 64058.80
ETH 3150.15
USDT 1.00
SBD 3.99