[Boxwise - fair donations distribution to refugees] Generating packages in bulk - new feature

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 (in a nutshell)?

Handing out the donations can get very hectic. And especially without proper warehouse management tool. That's why Drop in the Ocean NGO implemented so called DropAppin several of its camps. It helps coordinators to sort and easily store all incoming boxes full of donations based on clothes size, clothes type and gender in the "big warehouse". It also tracks which clothes types are being asked for the most and therefore can coodinators react accordingly and bring to the camp more pieces of particular items. App also grants every camp resident (refugee) X amount of "drops" every moth which a "virtual currency" used to buy clothes from the donations. This is very important as this gives refugees the control over what they wear and how they identify themselves. It's a very important psycho-social activity which they lost!

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

Why did I join the project?

During my 12 days of volunteering in Greece this January in Drop in the Ocean(DiH) Skaramagas camp, I've been using DropApp daily and realized how amazing this tool is. I got to know it was developed by former volunteers last year and I contacted them on Facebook. During a quick Google Hangouts we had, they explained me the issues of the application (unscalability -> every camp needs their own web server and tech person) and the reason why Boxwise was created. It's basically a DropApp 2.0. Better, more stable and scalable version ( hopefully ;) ).


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

Odoo

We are using the open source ERP system called Odoo as the base for Boxwise. It's a modular system which allows to add various modules into the environment and there are already several modules which address the exact same area - warehouse management.
Sounds great right? The only problem is, the whole team which is currently 4 people have almost zero experience in Odoo. Ok, let's be honest..not almost zero...zero :D

Anyway, let's not lose more time and get into the nitty-gritty. My task was:

New Feature - generate packages in bulk

  • My pull request: HERE
  • Detailed task description: Feature request #9
  • Language: Python, XML
  • Commits: 6
  • Additions: 64 (cumulative commit by commit - 100)
  • Deletions: 2 (cumulative commit by commit - 40)
  • Time spent: good 12 hours!! (don't laugh, first time Odoo user here, I've read at least 70 pages of Odoo Essensials book to get required knowledge how to do this + we still didn't have a debugger last week)

Usecase of the new feature: We're using GitHub issues as a list of feature requests as well, so you the more detailed description can be found in the link above. It's a crucial feature used by coordinators (warehouse volunteers) daily. Donation boxes don't come one by one but in bulks. Each box gets labeled by unique QR label which leads to form where coordinator fills parameters of items in the box (gender, size, clothes type, items count). Generating these packages (QR codes/labels) in bulk saves ton of time daily! For better understanding, watch the Youtube video linked above :)

Placement of the feature in the whole workflow for better understanding :)

Ok, I guess GIF makes up for thousand of various workflows and schemes right? Well then, here you go, the process in the old DropApp (Javascript + PHP) which I recreated in Boxwise (Odoo + XML + Python)

DropApp.gif
DropApp 1.0

And my implementation in Odoo for Boxwise :) Ohhh I love it :D

boxwise.gif
Boxwise (DropApp 2.0) - we've agreed that QR codes shouldn't be displayed to the coordinator (he needs to download & print them anyway) but write it down as an issue because it'd require to return 2 actions from server and we don't know how to do it yet :)

Implementation & Code

Step 1: How to register python classes in Odoo

3 minutes into it, I knew I'm screwed. I had no idea where and how to start. Hans has managed to add the "Generate QR labels" option to menu with XML (which I later changed) and then passed it to me. I needed a way how to get input from user back to server side. Googling..googling...and then I've found this 380 pages long PDF :D What a nice weekend ahead of me :) Eventually, I started to make some microsteps..

from . import wizards
Register new folder in odoo root __init__.py
from . import generate_qr_count_wizard 
Add __init__.py in new folder and import everything from new class

Till now it all makes sense. Standard python right? But creating the class (so called model) has some specific Odoo rules . It has to inherit from model.Model class or some other submodels..Eventually, my dummy class "Book" was in and I could move on :)

Step 2: Get user input, trigger server action & change menu item from Hans

After I've managed to link my dummy test model (class) to Odoo, it was time to create some real models. User popup (simple alert in Javascript) is called wizard in Odoo. It can be implemented with a class which has to have a TransientModel as a superclass.

class QrGenerateWizard(models.TransientModel):
    _name = 'boxwise_wms.qr.generate.wizard'
    _description = 'Number of QR codes to be generated'
    number = fields.Char(string='Number of labels', required=True, default=0)
Overriding superclass variables is done by underscore, new user-defined variables start with small letters

Details are in commit #7031f2301d0eab437f33aff54521847a23b67eb5

Step 3: Submit wizard and generate packages

This one was pretty straightforward as I already knew a bit about Odoo wizards at this point. Method annotated by @api.multi with the same name as the wizard button was needed.

< footer>
   < button name="mass_generate" type="object" string="Generate" 
     class="oe_highlight"/>
   < button special="cancel" string="Cancel"/>
< /footer>


 @api.multi
 def mass_generate(self):
     _logger.debug('Starting batch QR codes generation')
     package_model = self.env['stock.quant.package']
     number_of_packages = int(self.number)
     created_packages = []  
     for _ in range(number_of_packages):
        created_packages.append(package_model.create({}))

Details are in commit #e03800020918c00dd4bcf0b16c3c6239004fbdee

Step 4: Navigate back to packages tree view

It's little bit counterintuitive (at least for me) but the way navigation from server is done in Odoo is that you basically just return the act_window action with result model set to packages. The same one which is bound to menu item. Return is called from method which generates packages (obviously). If Odoo model method starts with underscore, it's private. It looks like this:

return self._open_packages_list()

 @api.model    
 def _open_packages_list(self):
    return {
        'type':'ir.actions.act_window',
        'res_model':'stock.quant.package',
        'view_type':'list',
        'view_mode':'list',
        'target':'current'
     }
 

Details are in commit #e03800020918c00dd4bcf0b16c3c6239004fbdee

Step 5: Cleanup according to Odoo best practices

Nothing special here. I've replaced camelCasing to snake_casing which is the good practice in all Odoo modules for common variables.

Details are in commit #d9adbdfec3f90c340fb340280abfb594488be084

Bonus commit: Removing unneeded table header alignment

This one came pretty handy as I was struggling with Odoo for couple of hours at this point and then I've noticed this completely random right alignment CSS which had nothing to do there :) Boom, delete :) Finally something to commit haha :D
Details are in commit #0d5ba1dd19009f294aa772214777112f86eb0b34

text16.png

Next steps for Boxwise team

  1. Continue implementing basic DropApp functionality into Boxwise for the next 2 weeks
  2. In two weeks, Hans and James are flying over to Athens to test our first version in local warehouse in Pampiraiki
  3. Month of development
  4. Flying back to Greece from 3rd to 8th April and hopefully implement Boxwise in one of Drop in the Ocean camps. I'm flying this time as well :)

GitHub Account

https://github.com/DurkoMatko

Sort:  

Sounds like a very interesting project (with a great goal) - it's really great to see projects like this on here! Your way of describing the steps you went through to add this feature resulted in a very interesting read (and funny - the 380 pages PDF sounds daunting lol). Also the picture of the workflow and the added GIFs really made it easy to understand what you actually implemented - great work with that.

Since I have never used Odoo myself, I don't really have any feedback to give about that, but here are some thoughts about the code:

  • This can be converted to a one-liner (list comprehension) created_packages = [package_model.create({}) for _ in range(number_of_packages)].

I'm definitely looking forward to seeing more contributions to this project!


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]

Hmm nice, I'll add that one liner next time I'll be editing that file (which will be soon as we want to automatically download the pdf with those QR codes)..

And regarding Odoo...I'm not really too happy with it, I've searched a bit and it doesn't seem to be widely used ...so there won't be a huuuge benefit from being familiar with it...but yeah, that warehouse management module which is already implemented for Odoo comes in handy and saved us lot of work.

Edit: Also, thx for the review! :D

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

Ello Ello :)

The New 20k Delegation poll is out. It would be wonderful if you would support our @steemitbloggers community with your vote.

https://dpoll.xyz/detail/@theycallmedan/which-steem-project-should-i-delegate-20k-steempower-to-for-1-year/

Thanks a mil.

xxx

Roger that! :D

Also ready to start using our special footers :P

Whoop Whoop Gangnam Style!! Thank you xxxxx MWAH!!!

Just a good guy! I have no idea about the spaghetti talk here, but we are also in the business of distributing donated goods to poor areas in the country. We do it the old fashioned way by collecting and delivering. 423 Tons of goods thus far over the past 17 years of Papillon's existence.
Great to see that you are involved in a good cause my friend! Blessings!

Haha spaghetti talk :D I first thought youre going to talk sh*t about my code haha :D there's a term for shitty not nicely structured code - "spaghetti code" :D

Wow man, well you're doingmuch more than I do, that's for sure...17 years :O..keep it up :)

Glad that you saw that I wasn't saying anything bad about your code, as I am sure that it is expertly done, but I meant that it was "spaghetti talk" to me personally, as the only thing that I know is punctuation marks in normal language. In code the punctuation marks take on a strange life of their own and they swirl all over the place, the same as trying to get spaghetti on a desert spoon. Blessings!

You are amazing! This is an great project of real value. Resteeming so a few more people can see it. Too bad I don't understand all the technical stuff, but it's obvious that you do, and that it's for a good cause!

Hah, thanks but hey, I've just joined the team, there are other guys who have been working on it much longer :) this was my first contribution only :D soo don't think im a hero :D

Posted using Partiko Android

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

Decentralized solutions for decentralized people! I love this idea and the implementation looks to be well underway. Please keep us updated on the project from time to time. A few individual's stories could go a long way to garner interest, and financial support, for your project.

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.

That's really cool man! I've never heard or thought about something like that. Thanks for posting about it!

Hello!

This is the first time that I have heard of boxwise but, thank you for the info.

App also grants every camp resident (refugee) X amount of "drops" every moth which a "virtual currency" used to buy clothes from the donations. This is very important as this gives refugees the control over what they wear and how they identify themselves. It's a very important psycho-social activity which they lost!

This is important as some people especially those fleeing from war or famine felt that they lost everything including their dignity as a human being. Giving them choices and control liberates them in some way.

Hey, @matkodurko!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.029
BTC 66703.61
ETH 3518.80
USDT 1.00
SBD 2.68