Skip to Content

Contributors

Help wanted with contributing first (very stupid) module

Hi all,

Feeling motivated by the OCA Days, I'm thinking of contributing a
(rather incredibly stupid, but moderately handy) module to the OCA.
I've been contributing through PRs and reviews, but I've not yet pushed
any of my own modules.

The module in question is ``company_today``[1], and its description is
as follows:

Store today's date on the company model. A cronjob makes sure this field stays
up-to-date.

The use-case for this module is as follows. Imagine you have two regular fields
and a computed field::

    amount = fields.Monetary()
    payment_date = fields.Date()
    cost_per_day = fields.Monetary(compute="_compute_cost_per_day")

    @api.depends("amount", "payment_date")
    def _compute_cost_per_day(self):
        today = fields.Date.today()
        for record in self:
            delta = today - record.payment_date
            record.cost_per_day = record.amount / delta.days

When the next day arrives, ``cost_per_day`` should be re-computed, but it won't
be, because none of the dependencies have changed.

With this module, you can add a dependency on "company_id.today" (assuming that
your model has a res.company field, which is trivial to add). This way, you get
all the benefits of having a compute cache, and your field will be recomputed
when the date changes.

---

It's a rather silly module, but I've found it useful and charming.

1. How would I find a good repository to contribute this module to?
There are _heaps_.

2. Because I'm testing the waters; is this sort of module the sort of
module that has a right to live within the OCA?

Gratefully, and with collaborative regards,
Carmen


[1]: https://github.com/coopiteasy/addons/tree/12.0/company_today

by Carmen Bianca Bakker - 04:51 - 12 Oct 2022

Follow-Ups

  • Re: Help wanted with contributing first (very stupid) module
    Loving this spirit - yes, please contribute!

    Of course, in OCA, there are some very opinionated nerds around, and I am no exception, so I would definitely give you some very polite review comments on this module :-D

    But that is what the OCA is for and that is how we learn from each other.

    With this module, you can add a dependency on "company_id.today" (assuming that
    your model has a res.company field, which is trivial to add). This way, you get
    all the benefits of having a compute cache, and your field will be recomputed
    when the date changes.
    
    ---
    
    It's a rather silly module, but I've found it useful and charming.
    
    1. How would I find a good repository to contribute this module to?
    There are _heaps_.

    In the beginning days, this would have been "server-tools", since that is the repository where all the things belong that are so generic that you can't really categorize them anywhere. It hosts other such modules such as "datetime_formatter", you can also use that anywhere.

    But because it became too big it was split up in "server-auth", "server-ux" and maybe another one that I forgot. It's not one of those either though, since your module does not specifically have to do with authentication or UX. So I would just do server-tools.

    When in doubt, just propose it somewhere, you can always close the PR and propose it in the right place later.

    
    2. Because I'm testing the waters; is this sort of module the sort of
    module that has a right to live within the OCA?

    "This kind of module" - yes sure! There are a lot of modules already in OCA and especially in server-tools that don't help end users directly, but it helps programmers, and this could fit there nicely.

    "This particular module" - well let's see after review :-D I'm not 100% sure if there are not better ways to solve this problem.



    by Tom Blauwendraat - 05:11 - 12 Oct 2022