Skip to content

Conversation

@simahawk
Copy link

CMS Form

Basic website contents form framework. Allows to define front-end forms for every models in a simple way.

If you are tired of re-defining every time an edit form or a search form for your odoo website,
this is the module you are looking for.

Features

  • automatic form generation (create, write, search)

  • automatic route generation (create, write, search)

  • automatic machinery based on fields' type:

    • widget rendering
    • field value load (from existing instance or from request)
    • field value extraction (from request)
    • field value write (to existing instance)
  • highly customizable

  • works with every odoo model

  • works also without any model

  • add handy attributes to models inheriting from website.published.mixin:

    • cms_add_url: lead to create form view. By default /cms/form/create/my.model
    • cms_edit_url: lead to edit form view. By default /cms/form/edit/my.model/model_id
    • cms_search_url: lead to search form view. By default /cms/form/search/my.model

(extracted from official README)

@coveralls
Copy link

Coverage Status

Coverage decreased (-10.3%) to 84.748% when pulling 3d73c7b on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-10.3%) to 84.748% when pulling 3d73c7b on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

@simahawk
Copy link
Author

@lasley @yajo as usual, when you have time.... :)

PS: is it possible to configure test coverage checks to ignore some stuff, like cms_form_example module?

@lasley lasley added this to the 9.0 milestone Feb 16, 2017
@lasley
Copy link

lasley commented Feb 17, 2017

PS: is it possible to configure test coverage checks to ignore some stuff, like cms_form_example module?

Few different ways - in your instance prolly the coveragerc file would be best.

My warning is to not go excluding things all over the place because it's really just covering up a problem. Anything not tested is a ticking timebomb IMO.

That said, we're definitely fine ignoring an example module.

@coveralls
Copy link

coveralls commented Feb 17, 2017

Coverage Status

Coverage decreased (-10.3%) to 84.748% when pulling 1144cd1 on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

.coveragerc Outdated
@@ -0,0 +1,4 @@
[run]
Copy link

@lasley lasley Feb 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, the docs do not mention [report] here https://coverage.readthedocs.io/en/coverage-4.2/source.html#execution
anyway, I updated it as per your example, but is still looking for cms_form_example.
Better look at this tomorrow, instead of checking it in the middle of my baby's bath 😄

Copy link

@lasley lasley Feb 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked further and it looks like coveragerc isn't an option because the template is being used instead. It would probably be best to just use

# pragma: no cover

near the top of the python files then 😦

@coveralls
Copy link

coveralls commented Feb 17, 2017

Coverage Status

Coverage decreased (-10.3%) to 84.748% when pulling 05f2816 on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

@lasley
Copy link

lasley commented Feb 28, 2017

@tedsalmon please review

Copy link

@tedsalmon tedsalmon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Awesome work! I have some minor review items, mostly import related stuff that caught my eye :)

# Copyright 2017 Simone Orsi
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little nit picky but these imports are not ordered alphabetically as OCA guidelines ask. Perhaps you'd consider importing in a single line?

from openerp import _, exceptions, models

from ..utils import DEFAULT_LOADERS, DEFAULT_EXTRACTORS
from ..import widgets

import inspect

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These imports should be above the Odoo import

value = extractor(self, fname, value, **request_values)
if value is None:
# we assume we do not want to override the field value.
# a tipical example is an image field.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/tipical/typical

def form_search_domain(self, search_values):
"""Build search domain.

TODO...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's TODO here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well: explain how we build domain and maybe improve it a little bit.

# Copyright 2017 Simone Orsi
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetical import order, again :)

from . import test_form_search
from . import test_form_render
from . import test_loaders
from . import test_controllers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import alphabetically :)

from .common import fake_request
from .common import FormHttpTestCase
from ..controllers import main
import mock

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be above your local imports

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tedsalmon tnx! I'll go trough them.

@coveralls
Copy link

Coverage Status

Coverage decreased (-10.2%) to 84.82% when pulling 26ed9c4 on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-10.2%) to 84.82% when pulling 26ed9c4 on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

@coveralls
Copy link

coveralls commented Mar 2, 2017

Coverage Status

Coverage decreased (-10.2%) to 84.82% when pulling 26ed9c4 on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

@coveralls
Copy link

coveralls commented Mar 6, 2017

Coverage Status

Coverage decreased (-10.4%) to 84.579% when pulling 7dc324b on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

Copy link
Member

@guewen guewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow

if extra_values.get('notify_partner'):
# do what you want here...

``notifiy_partner`` will be included into the form but it will be discarded on create and write.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/notifiy/notify/g

@coveralls
Copy link

Coverage Status

Coverage decreased (-10.4%) to 84.579% when pulling 3546f26 on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-10.4%) to 84.579% when pulling 3546f26 on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

@coveralls
Copy link

coveralls commented Mar 10, 2017

Coverage Status

Coverage decreased (-10.4%) to 84.579% when pulling 3546f26 on simahawk:add-cms_form-PR into 4514cbe on OCA:9.0.

@lasley
Copy link

lasley commented Mar 10, 2017

@simahawk - Did you have any plans to up the test coverage?

@lasley
Copy link

lasley commented May 15, 2017

@simahawk - I set this to WIP because commits are still being added. Let us know when it's ready for review again.

@simahawk
Copy link
Author

@lasley yes pls :) I'm still cleaning/fixing/adding small improvements and I'll move widgets to models.
Hopefully we can close this during or after the sprint in Barcelona (I will attend remotely).

@simahawk
Copy link
Author

@lasley I'd say that after this 6f7a594 we can rebase and merge :)
About coverage: I'd like to improve it during the sprint next week but to ease partecipation is better to merge this before so that we already have a "kinda stable" starting point.

@simahawk
Copy link
Author

BTW I'll re-license already merged modules in a separated PR

@simahawk
Copy link
Author

simahawk commented May 29, 2017

@pedrobaeza would you mind hit the button here? I'll improve test cov later, probably tomorrow.
Needs rebase of course...

@pedrobaeza pedrobaeza merged commit 8258504 into OCA:9.0 May 29, 2017
@simahawk simahawk deleted the add-cms_form-PR branch May 30, 2017 13:04
simahawk added a commit to simahawk/website-cms that referenced this pull request Oct 2, 2017
simahawk added a commit to simahawk/website-cms that referenced this pull request Oct 2, 2017
simahawk added a commit to simahawk/website-cms that referenced this pull request Oct 2, 2017
simahawk added a commit to simahawk/website-cms that referenced this pull request Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants