← Back to team overview

openerp-community team mailing list archive

Re: Suggestion for OCA conventions

 

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*.

Regards.

2014-10-17 22:36 GMT+02:00 Sandy Carter <sandy.carter@xxxxxxxxxxxxxxxxxxxx>:

> If a module is picked up, it is nice for the dev to be able to see
> directly without openening the files what models have been affected.
>
> The product example might start with a single field, but there is no
> guarentee that it won't grow with additions of on_change methods or
> simple overwrites which end up growing the file in line numbers.
>
> In that case would should we advocate splitting the product.py into
> product_category.py? At which point do we make that transition, and how
> do we make sure that the code is properly factored and won't regress?
>
>
> Le 2014-10-17 16:23, David Beal a écrit :
> > Hi Sandy,
> >
> > If we do like this with an example on a module:
> > 2 models modified: 'product.product' and 'product.category' with adding a
> > new field for each
> > It takes 5 or 20 lines by model. Having 2 files for this could be a lot.
> > I prefer one file named 'product.py'.
> >
> > And if the code grows too much, the file can be split in 2
> >
> > Maybe the limitation could be the file lines number ?
> >
> > What do you think ?
> >
> > Should odoo small modules takes java convention ? I don't think.
> >
> >
> >
> >
> > David BEAL - Akretion
> > Odoo Development / Integration
> > +33 (0)6 67 22 86 89 - +33 (0)4 82 53 84 60
> >
> > 2014-10-17 21:40 GMT+02:00 Sandy Carter <
> sandy.carter@xxxxxxxxxxxxxxxxxxxx>:
> >
> >> Hi,
> >>
> >> I would like propose adding the following to the Module section in
> >> http://odoo-community.org/page/website.how-to
> >>
> >> Each XML and python script should be separated and named by model.
> >>
> >> example:
> >>
> >> _name = 'sale.order'  # goes in a file named sale_order.py and the class
> >> name should be SaleOrder
> >>
> >> _inherit = 'sale.order.line'  # goes in a file named sale_order_line.py
> >> and the class name should be SaleOrderLine
> >>
> >> <!-- Goes in a file named res_partner_data.xml -->
> >> <!-- Or goes in a file named res_partner_demo.xml -->
> >> <record name="example_partner" model="res.partner">...</record>
> >>
> >> <!-- Goes in a file named res_company_view.xml -->
> >> <record id="res_company_form" model="ir.ui.view">
> >>   <field name="model">res.company</field>
> >>   ...
> >> </record>
> >>
> >> <!-- Goes in a file named purchase_order_workflow.xml -->
> >> <record id="purchase_order_workflow" model="ir.ui.view">
> >>   <field name="osv">purchase.order</field>
> >>   ...
> >> </record>
> >>
> >> <!-- Goes in a file named payment_order_report.xml -->
> >> <report id="payment_order_report"
> >>         model="payment.order"
> >>         ...
> >>         />
> >>
> >>
> >> _______________________________________________
> >> 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