Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
'name': "My Awesome module Roole",
'version': '1.0',
'depends': ['base'],
'author': "roole",
'application': True,
'installable': True,
'category': 'Tutorials',
'description': """
Description text
""",
'license': 'GPL-3',
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_menus.xml'
]
}
1 change: 1 addition & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import estate_model
33 changes: 33 additions & 0 deletions estate/models/estate_model.py
Copy link
Contributor

Choose a reason for hiding this comment

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

We prevent from appending _model on every model. Since your model is estate.property it should be estate_property.py

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import datetime

from odoo import fields, models


class EstateModel(models.Model):
_name = "estate.property"
_description = "Estate description"
_property = "property"
name = fields.Char(required=True)
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(copy=False, default=datetime.datetime.now() + datetime.timedelta(days=90))
expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True, copy=False)
bedrooms = fields.Integer(default=2)
living_area = fields.Integer()
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer()
garden_orientation = fields.Selection(
string='Orientation',
selection=[('north', 'North'), ('south', 'South'), ('west', 'West'), ('east', 'East')])
active = fields.Boolean(default=True)
state = fields.Selection(
string="Estate status",
selection=[('new', 'New'), ('offer received', 'Offer Received'), ('offer accepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', 'Cancelled')],
help='This field explain the estate status.',
required=True,
copy=False,
default='new'
)
2 changes: 2 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_estate_user,estate.property,model_estate_property,base.group_user,1,1,1,1
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. the second value is the name of the ir.rule, not the name of the model. Name it like you want be be specific, name it like the id works.
  2. Missing EOL at the end of the file.

8 changes: 8 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_menu_root" name="Estate">
<menuitem id="estate_first_level_menu" name="First Level">
<menuitem id="estate_model_menu_action" action="estate_model_action"/>
</menuitem>
</menuitem>
</odoo>
Copy link
Contributor

Choose a reason for hiding this comment

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

EOL.

8 changes: 8 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_model_action" model="ir.actions.act_window">
<field name="name">Test properties</field>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<field name="name">Test properties</field>
<field name="name">Properties</field>

<field name="res_model">estate.property</field>
<field name="view_mode">list,form</field>
</record>
</odoo>