← Back to team overview

openerp-community team mailing list archive

Re: Suggestion for OCA conventions

 

Hi,

While having a sale order line modification in the same file as sale order
makes some sense, these can become big files and it's nice to see them
split, but then in addon modules maybe not.  But for me this comes down to
personal preference, not sure it needs to be a convention.  Sometimes it
makes sense to go one way, sometimes the other and usually I think it is
fairly obvious.  Often refactors are about moving functionality between
models (e.g. call one write on parent, or create separate function in
submodel) and I find it much easier when they are one file, but then
sometimes two models are so closely related, e.g. product_template and
product_product and so verbose that I find having them separated is
easier.  With wizards, normally the code is reasonably short and does a
specific thing, so I put all models in one file for that wizard.  But then
again for the xml files I find myself in complete agreement.  If you just
did for xml you would know anyway the models affected.  So maybe I'd like
the rule for xml files, but for python files a bit more common sense.
While it might be nice for the person looking at the list of files for the
first time, I'd rather we gave preference to the people writing and
maintaining the code and let them choose.

I've taken support off the mail, I don't really need 2 copies of every mail.

On Mon, Oct 20, 2014 at 8:15 AM, Sylvain LE GAL <sylvain.legal@xxxxxxxxx>
wrote:

> Hi,
>
> I agree with Sandy's suggestion.
>
> About the sale_order and sale_order_line files, I would prefer two files.
> It avoid to have an exception on the basic rule "one model, one file", that
> is maybe not perfect, but like all rules...
>
> Note:
> Once that is decided, we can imagine a script to check that rules, (such
> as checking pep8) and report result in Travis.
>
> Regards.
>
>
> *Sylvain LE GAL*
>
> * Service informatiqueGroupement Régional Alimentaire de Proximité*
> 3 Grande rue des feuillants 69001 Lyon
> *Bureau : *(+33) 09.72.32.33.17
> *Astreinte :* (+33) 06.81.85.61.43
> *Site Web** : *www.grap.coop
> *Twitter : *@legalsylvain* <https://twitter.com/legalsylvain>*
>
> 2014-10-19 15:45 GMT+02:00 Daniel Reis <dgreis@xxxxxxx>:
>
>>
>> On 18-10-2014 09:12, Pedro Manuel Baeza Romero wrote:
>>
>>> Hi, I'm with Sandy that splitting each model in a class is a win
>>> strategy, but with a middle term: if you have models that comes from a
>>> one2many field, I prefer having these classes also in the same file as the
>>> main class. For example, I would put sale.order and sale.order.line in the
>>> same file, /sale_order.py/, but res.partner in another file called /
>>> res_partner.py/.
>>>
>> +1 for Pedro. Most of the time "lines" are just a "part" of parent model
>> and it can make sense to keep them together.
>>
>> DR
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~openerp-community
>> Post to     : openerp-community@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~openerp-community
>> More help   : https://help.launchpad.net/ListHelp
>>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-community
> Post to     : openerp-community@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~openerp-community
> More help   : https://help.launchpad.net/ListHelp
>
>

Follow ups

References