|
|
### Idea
|
|
|
|
|
|
Implement a way to store weather observation and show aggregated measurements on website.
|
|
|
In this case we have following entities:
|
|
|
- *Measurement Point* that could be placed on some address
|
|
|
- *Measurement* record temperature measured on date at *Measurement Point*
|
|
|
For simplicity we will track only temperature
|
|
|
|
|
|
### To Do
|
|
|
|
|
|
#### Create addon `weather_measurement`
|
|
|
- [ ] Add dependencies
|
|
|
- mail
|
|
|
- base_address_city
|
|
|
- [ ] Create groups
|
|
|
- *Weather / User*
|
|
|
- *Weather / Manager*
|
|
|
- `implied_ids`: *Weather / User* ([example](https://github.com/odoo/odoo/blob/8057b739af28484a7b30c2d985244347dca74006/addons/stock/security/stock_security.xml#L15))
|
|
|
- [ ] Automatically add this group to[Superuser](https://github.com/odoo/odoo/blob/8057b739af28484a7b30c2d985244347dca74006/addons/crm/security/crm_security.xml#L11) and [Administrator](https://github.com/odoo/odoo/blob/8057b739af28484a7b30c2d985244347dca74006/addons/crm/security/crm_security.xml#L15)
|
|
|
- [ ] Create top-level menu *Weather*
|
|
|
|
|
|
#### Create model `weather.measurement.point`
|
|
|
- [ ] `_inherit`:
|
|
|
- `mail.thread`
|
|
|
- `mail.activity.mixin`
|
|
|
- [ ] Add `_description`
|
|
|
- [ ] fields
|
|
|
- `name`: Char(required, index, translate)
|
|
|
- `code`: Char(required, index)
|
|
|
- `user_id`: M2o('res.users', 'Responsible', required)
|
|
|
- `city_id`: M2o('res.city', required)
|
|
|
- `state_id`: M2o('res.country.state', related(city), readonly, store=True)
|
|
|
- `country_id`: M2o('res.country', related(city), readonly, store=True)
|
|
|
- `street`: Char()
|
|
|
- `description`: Text()
|
|
|
- `active`: Boolean(default=True, index)
|
|
|
- [ ] Add unique constraint on field `code`
|
|
|
- [ ] Add unique constraint on field `name`
|
|
|
- [ ] Add *ASCII-only* constraint on field code
|
|
|
- Allow only following symbols `a-z`, `A-Z`, `0-9`, `-`, `_`
|
|
|
- [ ] Automatically set field `code` when field `name` is changed in UI
|
|
|
- Use onchange
|
|
|
- Use `odoo.addons.http_routing.models.ir_http.slugify` function to generate `code` based on `name`
|
|
|
- [ ] Overwrite [name_get](https://www.odoo.com/documentation/12.0/reference/orm.html#odoo.models.Model.name_get) method to compute [display_name](https://odoo-new-api-guide-line.readthedocs.io/en/latest/environment.html#displayed-name-of-record) as `<name> <user_id.display_name>`
|
|
|
- [ ] Add method `action_register_measurement`
|
|
|
- return dict describing action to open wizard *Register Measurement*
|
|
|
- `self.ensure_one()`
|
|
|
- pass in conext `default_measurement_point_id=self.id`
|
|
|
- [ ] Create `tree` view
|
|
|
- `name`
|
|
|
- `code`
|
|
|
- `user_id`
|
|
|
- `city_id`
|
|
|
- `state_id`
|
|
|
- `country_id`
|
|
|
- `active`
|
|
|
- [ ] Create `form` view
|
|
|
- header
|
|
|
- button *Register Measurement*
|
|
|
- Opens wizard *Register Measurement* specifying default measurement point (this)
|
|
|
- call `action_register_measurement`
|
|
|
- Described later
|
|
|
- [button_box](https://www.odoo.com/documentation/12.0/reference/views.html#button-box)
|
|
|
- *toggle active* ([example](https://github.com/odoo/odoo/blob/8057b739af28484a7b30c2d985244347dca74006/addons/product/views/product_views.xml#L23))
|
|
|
- *Measurements* - open list ofe measurements of this point
|
|
|
- oe_title ([example](https://github.com/odoo/odoo/blob/8057b739af28484a7b30c2d985244347dca74006/addons/product/views/product_views.xml#L30))
|
|
|
- h1: name
|
|
|
- with placeholder
|
|
|
- h2: code
|
|
|
- with placeholder
|
|
|
- group
|
|
|
- group
|
|
|
- address ([see example](https://github.com/odoo/odoo/blob/8057b739af28484a7b30c2d985244347dca74006/addons/crm/views/crm_lead_views.xml#L76))
|
|
|
- street
|
|
|
- city
|
|
|
- state
|
|
|
- country
|
|
|
- group
|
|
|
- user_id
|
|
|
- `description` (colspan=4, nolabel=1, placeholder=*Description*)
|
|
|
- [ ] Create `search` view
|
|
|
- [ ] search by
|
|
|
- `name`
|
|
|
- `code`
|
|
|
- `city_id`
|
|
|
- `user_id`
|
|
|
- [ ] filters
|
|
|
- *Archived* (active=False)
|
|
|
- Active
|
|
|
- [ ] group by
|
|
|
- City
|
|
|
- State
|
|
|
- Country
|
|
|
- Responsible
|
|
|
- [ ] Create menu *Weather / Measurement Points*
|
|
|
- visible only for group *Weather / User*
|
|
|
- [ ] Add access rights for *Weather / User* group
|
|
|
- [ ] readonly
|
|
|
- [ ] see only own measurement points ([example](https://github.com/odoo/odoo/blob/8057b739af28484a7b30c2d985244347dca74006/addons/crm/security/crm_security.xml#L28))
|
|
|
- [ ] Add access rights for *Weather / Manager* group
|
|
|
- [ ] full access
|
|
|
- [ ] See all *Measurement Points*
|
|
|
|
|
|
|
|
|
#### Create model `weather.measurement`
|
|
|
|
|
|
- [ ] Add `_description`
|
|
|
- [ ] fields
|
|
|
- date: Datetime(required, default=now, index, readonly)
|
|
|
- user_id: M2o(required, default=current_user, index, readonly)
|
|
|
- measurement_point_id: M2o(required, index, readonly)
|
|
|
- temperature: Float(readonly)
|
|
|
- humidity: Float
|
|
|
- readonly
|
|
|
- widget: percentage
|
|
|
- [ ] Add tree view:
|
|
|
- date
|
|
|
- measurement_point_id
|
|
|
- user_id
|
|
|
- temperature
|
|
|
- [ ] aggregate in list by average
|
|
|
- humidity
|
|
|
- [ ] aggregate in list by average
|
|
|
- [ ] Add form view
|
|
|
- oe_title
|
|
|
- h1: display_name
|
|
|
- group
|
|
|
- group
|
|
|
- date
|
|
|
- measurement_point_id
|
|
|
- user_id
|
|
|
- group
|
|
|
- temperature
|
|
|
- humidity
|
|
|
- [ ] Add search view
|
|
|
- search_by:
|
|
|
- measurement_point_id
|
|
|
- user_id
|
|
|
- filters:
|
|
|
- Today (show only measurements made today)
|
|
|
- group_by:
|
|
|
- date
|
|
|
- measurement_point
|
|
|
- user_id
|
|
|
- [ ] Create menu *Weather / Measurements*
|
|
|
- visible only for group *Weather / User*
|
|
|
- [ ] Add access rights for *Weather / User* group
|
|
|
- [ ] read,write,create
|
|
|
- [ ] see only own measurements ([example](https://github.com/odoo/odoo/blob/8057b739af28484a7b30c2d985244347dca74006/addons/crm/security/crm_security.xml#L28)) or measurements related to *measurement point* he is responsible for
|
|
|
- [ ] Add access rights for *Weather / Manager* group
|
|
|
- [ ] full access
|
|
|
- [ ] See all *Measurements*
|
|
|
|
|
|
#### Create model `weather.wizard.register.measurement`
|
|
|
|
|
|
- [ ] Make it transient
|
|
|
- [ ] Add _description
|
|
|
- [ ] fields
|
|
|
- measurement_point_id: M2o(required)
|
|
|
- temperature
|
|
|
- humidity
|
|
|
- [ ] Add form view
|
|
|
- measurement_point_id
|
|
|
- invisible
|
|
|
- it is expected that it will available in context as `default_measurement_point_id`
|
|
|
- temperature
|
|
|
- humidity
|
|
|
- [ ] Add action *Save*
|
|
|
- create new measurement (use current date and current user)
|
|
|
|
|
|
#### Create model `weather.report.measurements`
|
|
|
|
|
|
- [ ] add `_description`
|
|
|
- [ ] Use `_auto = False` to disable automatic creation of table for this model
|
|
|
- [ ] Use postgresql view to create virtual table
|
|
|
- [ ] Followin fields have to be available
|
|
|
- measurement_point_id
|
|
|
- city_id
|
|
|
- state_id
|
|
|
- country_id
|
|
|
- date: Date
|
|
|
- temperature_min
|
|
|
- temperature_max
|
|
|
- temperature_avg
|
|
|
- humidity_min
|
|
|
- humidity_max
|
|
|
- humidity_avg
|
|
|
- [ ] All fields readonly
|
|
|
- [ ] Add views
|
|
|
- pivot
|
|
|
- graph
|
|
|
- tree
|
|
|
- [ ] Create menu *Weather / Report*
|
|
|
- Only *Weather / Manager* can see this menu
|
|
|
- [ ] Access rights:
|
|
|
- Readonly for *Weather / Manager* |