Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V18.0 training hyhe #239

Open
wants to merge 9 commits into
base: 18.0
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
'license': 'LGPL-3',
'name': 'Real Estate',
'depends': ['base'],
'application': True,
'data': ['./data/security/ir.model.access.csv', './data/views/house_views.xml', './data/views/menus.xml']
}
3 changes: 3 additions & 0 deletions estate/data/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_house,access_house,model_house,base.group_user,1,1,1,1

88 changes: 88 additions & 0 deletions estate/data/views/house_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="house_action" model="ir.actions.act_window">
<field name="name">Houses</field>
<field name="res_model">house</field>
<field name="view_mode">list,form,kanban</field>
</record>

<record id="estate_house_tree" model="ir.ui.view">
<field name="name">estate_house_tree</field>
<field name="model">house</field>
<field name="arch" type="xml">
<list>
<field name="name" string="Title" />
<field name="postcode" />
<field name="bedrooms" />
<field name="living_area" string="Living Area (sqm)" />
<field name="expected_price" />
<field name="selling_price" />
<field name="date_availability" string="Available From" />
</list>
</field>
</record>

<record id="estate_house_form" model="ir.ui.view">
<field name="name">estate_house_form</field>
<field name="model">house</field>
<field name="arch" type="xml">
<form>
<sheet>
<h1>
<field name="name" />
</h1>
<group>
<group>
<field name="postcode" />
<field name="date_availability" />
</group>
<group>
<field name="expected_price" />
<field name="selling_price" />
</group>
</group>
<notebook>
<page string="Description">
<group>
<field name="description" />
<field name="bedrooms" />
<field name="living_area" string="Living Area (sqm)" />
<field name="facades" />
<field name="garage" />
<field name="garden" />
<field name="garden_area" string="Garden Area (sqm)" />
<field name="garden_orientation" />
</group>
</page>
<page string="Other Information">
<group>
<field name="buyer_id" />
<field name="seller_id" />
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="estate_house_search" model="ir.ui.view">
<field name="name">estate_house_search</field>
<field name="model">house</field>
<field name="arch" type="xml">
<search>
<field name="name" string="Title" />
<field name="postcode" />
<field name="expected_price" />
<field name="bedrooms" />
<field name="living_area" string="Living Area (sqm)" />
<field name="facades" />

<filter name="estate_house_availability_filter" string="Available"
domain = "['|', ('state', '=', 'New'), ('state', '=', 'Offer Received')]"/>
<filter name="estate_house_postcode_grouping_filter" string="Postcode"
context="{'group_by': 'postcode'}" />
</search>
</field>
</record>
</odoo>
8 changes: 8 additions & 0 deletions estate/data/views/menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<menuitem id="root_estate_menu" name="Real Estate">
<menuitem id="top_level_estate_menu" name="Estates">
<menuitem id="estate_action_menu" action="house_action" />
</menuitem>
</menuitem>
</odoo>
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 house
36 changes: 36 additions & 0 deletions estate/models/house.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from odoo import models, fields

class house(models.Model):
_name = 'house'

name = fields.Char(string='House Name', required=True, default='Unknown')
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(copy=False, default=lambda self : self.get_availability_date())
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(selection=[('S', 'South'),
('N', 'North'),
('W', 'West'),
('E', 'East')])
active = fields.Boolean(default=True)
state = fields.Selection(string='Status', selection=[
('New', 'New'),
('Offer Received', 'Offer Received'),
('Offer Accepted', 'Offer Accepted'),
('Sold', 'Sold'),
('Cancelled', 'Cancelled'),
], default='New', required=True)
buyer_id = fields.Many2one('res.users', string='Buyer')
seller_id = fields.Many2one('res.users', string='Salesperson')


def get_availability_date(self):
current_date = fields.Date.today()
return fields.Date.add(current_date, month=3)