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

Simple Commit for Creating a PR #192

Open
wants to merge 23 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 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
36 changes: 36 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#2a4d34", // Dark green for active background
"activityBar.background": "#2a4d34", // Dark green for background
"sash.hoverBorder": "#2a4d34", // Dark green hover border
"statusBar.background": "#1b362e", // Darker green for status bar
"statusBarItem.hoverBackground": "#2a4d34", // Dark green hover for status bar item
"statusBarItem.remoteBackground": "#1b362e", // Darker green for remote status bar item
"titleBar.activeBackground": "#1b362e", // Dark green for active title bar
"titleBar.inactiveBackground": "#1b362e99", // Dark green for inactive title bar with transparency
"tab.activeBorder": "#2a4d34", // Dark green active tab border
"activityBarBadge.background": "#b32d4f", // Retained red badge background
"activityBarBadge.foreground": "#e7e7e7", // White badge text
"activityBar.foreground": "#e7e7e7", // White activity bar text
"activityBar.inactiveForeground": "#e7e7e799", // Faded white for inactive activity bar
"commandCenter.border": "#e7e7e799", // Light grey border for command center
"statusBar.foreground": "#e7e7e7", // White text for status bar
"statusBarItem.remoteForeground": "#e7e7e7", // White text for remote status bar item
"titleBar.activeForeground": "#e7e7e7", // White text for active title bar
"titleBar.inactiveForeground": "#e7e7e799", // Faded white for inactive title bar
"statusBar.debuggingBackground": "#3a2c21", // Dark brownish-green for debugging status bar
"statusBar.debuggingForeground": "#e7e7e7", // White text for debugging status bar
"editorGroup.border": "#2a4d34", // Dark green for editor group border
"panel.border": "#2a4d34", // Dark green for panel border
"sideBar.border": "#2a4d34", // Dark green for sidebar border
"statusBar.border": "#1b362e", // Dark green for status bar border
"statusBar.debuggingBorder": "#3a2c21", // Dark brownish-green border for debugging status bar
"titleBar.border": "#1b362e", // Dark green for title bar border
"folderPathColor.custom1": "#4a6c34", // Dark olive green for custom folder path 1
"folderPathColor.custom2": "#8d5f3f", // Earthy brown for custom folder path 2
"folderPathColor.custom3": "#557e47", // Medium dark green for custom folder path 3
"folderPathColor.custom4": "#5a7d58", // Muted green for custom folder path 4
"folderPathColor.custom5": "#4c9f85" // Teal green for custom folder path 5
}

}
Copy link

Choose a reason for hiding this comment

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

IDE-specific configurations are user-dependent and should not be included in the codebase.

Suggested change
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#2a4d34", // Dark green for active background
"activityBar.background": "#2a4d34", // Dark green for background
"sash.hoverBorder": "#2a4d34", // Dark green hover border
"statusBar.background": "#1b362e", // Darker green for status bar
"statusBarItem.hoverBackground": "#2a4d34", // Dark green hover for status bar item
"statusBarItem.remoteBackground": "#1b362e", // Darker green for remote status bar item
"titleBar.activeBackground": "#1b362e", // Dark green for active title bar
"titleBar.inactiveBackground": "#1b362e99", // Dark green for inactive title bar with transparency
"tab.activeBorder": "#2a4d34", // Dark green active tab border
"activityBarBadge.background": "#b32d4f", // Retained red badge background
"activityBarBadge.foreground": "#e7e7e7", // White badge text
"activityBar.foreground": "#e7e7e7", // White activity bar text
"activityBar.inactiveForeground": "#e7e7e799", // Faded white for inactive activity bar
"commandCenter.border": "#e7e7e799", // Light grey border for command center
"statusBar.foreground": "#e7e7e7", // White text for status bar
"statusBarItem.remoteForeground": "#e7e7e7", // White text for remote status bar item
"titleBar.activeForeground": "#e7e7e7", // White text for active title bar
"titleBar.inactiveForeground": "#e7e7e799", // Faded white for inactive title bar
"statusBar.debuggingBackground": "#3a2c21", // Dark brownish-green for debugging status bar
"statusBar.debuggingForeground": "#e7e7e7", // White text for debugging status bar
"editorGroup.border": "#2a4d34", // Dark green for editor group border
"panel.border": "#2a4d34", // Dark green for panel border
"sideBar.border": "#2a4d34", // Dark green for sidebar border
"statusBar.border": "#1b362e", // Dark green for status bar border
"statusBar.debuggingBorder": "#3a2c21", // Dark brownish-green border for debugging status bar
"titleBar.border": "#1b362e", // Dark green for title bar border
"folderPathColor.custom1": "#4a6c34", // Dark olive green for custom folder path 1
"folderPathColor.custom2": "#8d5f3f", // Earthy brown for custom folder path 2
"folderPathColor.custom3": "#557e47", // Medium dark green for custom folder path 3
"folderPathColor.custom4": "#5a7d58", // Muted green for custom folder path 4
"folderPathColor.custom5": "#4c9f85" // Teal green for custom folder path 5
}
}

30 changes: 14 additions & 16 deletions awesome_kanban/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# -*- coding: utf-8 -*-
{
'name': "Awesome Kanban",
'summary': """
"name": "Awesome Kanban",
"summary": """
Starting module for "Master the Odoo web framework, chapter 4: Customize a kanban view"
""",

'description': """
"description": """
Starting module for "Master the Odoo web framework, chapter 4: Customize a kanban view.
""",

'version': '0.1',
'application': True,
'category': 'Tutorials/AwesomeKanban',
'installable': True,
'depends': ['web', 'crm'],
'data': [
'views/views.xml',
"version": "0.1",
"application": True,
"category": "Tutorials/AwesomeKanban",
"installable": True,
"depends": ["web", "crm"],
"data": [
"views/views.xml",
],
'assets': {
'web.assets_backend': [
'awesome_kanban/static/src/**/*',
"assets": {
"web.assets_backend": [
"awesome_kanban/static/src/**/*",
],
},
'license': 'AGPL-3'
"license": "AGPL-3",
}
Copy link

Choose a reason for hiding this comment

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

Consider avoiding formatting-only changes in a file, as they can clutter the commit history and increase the likelihood of merge conflicts.

2 changes: 2 additions & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
from . import models
28 changes: 28 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
{
"name": "Estate",
"summary": """
Tutorial starting module
""",
"description": """
Tutorial starting module
""",
"author": "Cemal Faruk Guney",
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
"category": "Tutorials/Estate",
"version": "0.1",
# any module necessary for this one to work correctly
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
"depends": ["base"],
"application": True,
"data": [
"security/ir.model.access.csv",
"views/estate_property_tag_views.xml",
"views/estate_property_type_views.xml",
"views/estate_property_views.xml",
"views/estate_property_offer_views.xml",
"views/estate_menus.xml",
],
"license": "AGPL-3",
}
4 changes: 4 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
143 changes: 143 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
from odoo import fields, models, api
from dateutil.relativedelta import relativedelta
from odoo.exceptions import UserError, ValidationError
from odoo.tools import float_compare, float_is_zero


class EstateProperty(models.Model):
_name = "estate.property"
_description = "Estate Property"

name = fields.Char("Title", required=True)

description = fields.Text("Description")

postcode = fields.Char("Postcode")

date_availability = fields.Date(
"Available From",
copy=False,
default=lambda self: fields.Date.today() + relativedelta(months=3),
)

expected_price = fields.Float("Expected Price", required=True)

selling_price = fields.Float("Selling Price", readonly=True, copy=False)

bedrooms = fields.Integer("Bedrooms", default=2)

living_area = fields.Integer("Living Area (sqm)")

facades = fields.Integer("Facades")

garage = fields.Boolean("Garage")

garden = fields.Boolean("Garden")

garden_area = fields.Integer("Garden Area (sqm)")

garden_orientation = fields.Selection(
string="Garden Orientation",
selection=[
("north", "North"),
("south", "South"),
("east", "East"),
("west", "West"),
],
)

state = fields.Selection(
string="Status",
required=True,
copy=False,
default="new",
selection=[
("new", "New"),
("received", "Offer Received"),
("accepted", "Offer Accepted"),
("sold", "Sold"),
("cancelled", "Cancelled"),
],
)

active = fields.Boolean("Active", default=True)

property_type_id = fields.Many2one("estate.property.type", "Property Type")

buyer_id = fields.Many2one("res.partner", "Buyer", copy=False)

salesperson_id = fields.Many2one(
"res.users", "Salesperson", default=lambda self: self.env.user
)

tag_ids = fields.Many2many("estate.property.tag")

offer_ids = fields.One2many("estate.property.offer", "property_id")

total_area = fields.Float(string="Total Area (sqm)", compute="_compute_total_area")

best_price = fields.Float(string="Best Price", compute="_compute_best_price")

_sql_constraints = [
(
"check_expected_price_strictly_positive",
"CHECK(expected_price > 0)",
"The expected price should be strictly positive.",
),
(
"check_selling_price_positive",
"CHECK(selling_price >= 0)",
"The selling price should be positive.",
),
]
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved

@api.depends("living_area", "garden_area")
def _compute_total_area(self):
for record in self:
record.total_area = record.garden_area + record.living_area

@api.depends("offer_ids.price")
def _compute_best_price(self):
for record in self:
record.best_price = min(record.offer_ids.mapped("price"), default=0)
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved

@api.onchange("garden")
def _onchange_garden(self):
if self.garden:
self.garden_area = 10
self.garden_orientation = "north"
else:
self.garden_area = 0
self.garden_orientation = ""

def action_sold(self):
for record in self:
if record.state == "cancelled":
raise UserError("Cancelled properties cannot be sold!")
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
else:
record.state = "sold"
return True

def action_cancel(self):
for record in self:
if record.state == "sold":
raise UserError("Sold properties cannot be cancelled!")
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
else:
record.state = "cancelled"
return True

@api.constrains("selling_price")
def _check_compare_selling_price_to_expected_price(self):
for record in self:
if (
not float_is_zero(record.selling_price, precision_digits=5)
and float_compare(
record.selling_price,
record.expected_price * 0.9,
precision_digits=5,
)
< 0
):
raise ValidationError(
"Selling price of a property must not be less than 90 percent of the expected price."
)
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
60 changes: 60 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from odoo import models, fields, api
from datetime import date, timedelta
from odoo.exceptions import UserError


class EstatePropertyOffer(models.Model):
_name = "estate.property.offer"
_description = "Estate Property Offer"

price = fields.Float("Price")
status = fields.Selection(
[("accepted", "Accepted"), ("refused", "Refused")], copy=False
)
partner_id = fields.Many2one("res.partner", "Partner", required=True)
property_id = fields.Many2one("estate.property", "Property", required=True)
validity = fields.Integer("Validity (days)", default=7)
date_deadline = fields.Date(
string="Deadline",
compute="_compute_date_deadline",
inverse="_inverse_date_deadline",
)

@api.depends("validity")
def _compute_date_deadline(self):
for record in self:
if record.create_date:
record.date_deadline = record.create_date + timedelta(
days=record.validity
)
else:
record.date_deadline = date.today() + timedelta(days=record.validity)
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved

def _inverse_date_deadline(self):
for record in self:
td = record.date_deadline - record.create_date.date()
record.validity = td.days

def action_refuse(self):
for record in self:
if record.status == "accepted":
record.property_id.selling_price = None
record.property_id.buyer_id = None
record.status = "refused"

def action_accept(self):
for record in self:
if record.property_id.selling_price:
raise UserError("There is already an accepted offer for this property.")
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
else:
record.status = "accepted"
record.property_id.buyer_id = record.partner_id
record.property_id.selling_price = record.price

_sql_constraints = [
(
"check_price_positive",
"CHECK(price > 0)",
"An offer price must be strictly positive.",
)
]
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 12 additions & 0 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import models, fields


class EstatePropertyTag(models.Model):
_name = "estate.property.tag"
_description = "Estate Property Tag"

name = fields.Char("Name", required=True)

_sql_constraints = [
("unique_tag_name", "UNIQUE(name)", "Property tag name must be unique.")
]
12 changes: 12 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import fields, models


class EstatePropertyType(models.Model):
_name = "estate.property.type"
_description = "Estate Property Type"

name = fields.Char("Type", required=True)

_sql_constraints = [
("unique_type_name", "UNIQUE(name)", "Property type name must be unique.")
]
5 changes: 5 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1
access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1
access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 12 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_menu_root" name="Estate">
<menuitem id="estate_first_level_menu" name="Advertisements">
<menuitem id="estate_menu_action" action="estate_property_action"/>
</menuitem>
<menuitem id="estate_settings_menu" name="Settings">
<menuitem id="estate_settings_menu_type_action" action="estate_property_type_action"/>
<menuitem id="estate_settings_menu_tag_action" action="estate_property_tag_action"/>
</menuitem>
</menuitem>
</odoo>
cgun-odoo marked this conversation as resolved.
Show resolved Hide resolved
Loading