Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Aca faltaria la version

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

añadida la versión!!

"name": "Bienes Raíces", # name of the module
"version": "19.0.1.0.0", # version of the module
"author": "ADHOC SA", # author of the module
"license": "AGPL-3", # license of the module
"depends": ["base"], # dependency on the base module
"application": True, # this module is an application
"data": [
"security/ir.model.access.csv", # access control list
"views/estate_property_views.xml", # views for estate properties
"views/estate_property_type_views.xml", # views for estate property types
"views/estate_property_tag_views.xml", # views for estate property tags
"views/estate_property_offer_views.xml", # views for estate property offers
"views/estate_property_menus.xml", # menu items for estate properties
],
}
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_offer
from . import estate_property_tag
from . import estate_property_type
70 changes: 70 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from odoo import api, fields, models

# import pdb


class EstateProperty(models.Model):
_name = "estate.property" # Name of the model
_description = "Propiedades inmobiliarias" # Description of the model

name = fields.Char(required=True, string="Nombre")
description = fields.Text(string="Descripción")
postcode = fields.Char(string="Código Postal")
date_availability = fields.Date(
copy=False,
default=fields.Date.add(fields.Date.today(), months=3),
string="Fecha de Disponibilidad",
)
expected_price = fields.Float(required=True, string="Precio Esperado")
selling_price = fields.Float(readonly=True, copy=False, string="Precio de Venta")
bedrooms = fields.Integer(default=2, string="Dormitorios")
living_area = fields.Integer(string="Área Habitable sqm")
facades = fields.Integer(string="Fachadas")
garage = fields.Boolean(string="Garaje")
garden = fields.Boolean(string="Jardín")
garden_area = fields.Integer(string="Área del Jardín sqm")
garden_orientation = fields.Selection(
[("north", "Norte"), ("south", "Sur"), ("east", "Este"), ("west", "Oeste")],
string="Orientación del Jardín",
)
active = fields.Boolean(default=True, string="Activo") # Reserved field
state = fields.Selection(
[
("new", "Nuevo"),
("offer_received", "Oferta recibida"),
("offer_accepted", "Oferta aceptada"),
("sold", "Vendido"),
("canceled", "Cancelado"),
],
required=True,
copy=False,
default="new",
string="Estado",
)
property_type_id = fields.Many2one("estate.property.type", string="Tipo de Propiedad")
buyer_id = fields.Many2one("res.partner", copy=False, string="Comprador")
salesperson_id = fields.Many2one("res.users", default=lambda self: self.env.user, string="Vendedor")
tag_ids = fields.Many2many("estate.property.tag", string="Etiquetas")
offer_ids = fields.One2many("estate.property.offer", "property_id", string="Ofertas")
total_area = fields.Integer(compute="_compute_total_area", string="Área Total")
best_price = fields.Float(compute="_compute_best_price", string="Mejor Oferta")

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

@api.depends("offer_ids.price")
def _compute_best_price(self):
for record in self:
record.best_price = max(record.offer_ids.mapped("price")) if record.offer_ids else 0.0

@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 = False
37 changes: 37 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models


class EstatePropertyOffer(models.Model):
_name = "estate.property.offer" # Name of the model
_description = "Ofertas de Propiedades Inmobiliarias" # Description of the model

price = fields.Float(string="Precio")
status = fields.Selection(
[("accepted", "Aceptada"), ("refused", "Rechazada")],
string="Estado",
copy=False,
)
partner_id = fields.Many2one("res.partner", string="Comprador", required=True)
property_id = fields.Many2one("estate.property", string="Propiedad", required=True)
validity = fields.Integer(string="Validez (días)", default=7)
date_deadline = fields.Date(
compute="_compute_date_deadline",
inverse="_inverse_date_deadline",
string="Fecha Límite",
)

@api.depends("validity")
def _compute_date_deadline(self):
for record in self:
if record.create_date:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Aca desde odoo usamos mas el relativedelta, si queres buscate algunos ejemplos en le codigo, sino lo vemos

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Pude ver algunos ejemplos, espero que me digas si usé correctamente la librería :)

record.date_deadline = record.create_date + relativedelta(days=record.validity)
else:
record.date_deadline = False

def _inverse_date_deadline(self):
for record in self:
if record.date_deadline and record.create_date:
record.validity = (record.date_deadline - record.create_date.date()).days
else:
record.validity = 0
8 changes: 8 additions & 0 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import fields, models


class EstatePropertyTag(models.Model):
_name = "estate.property.tag" # Name of the model
_description = "Etiquetas de Propiedades Inmobiliarias" # Description of the model

name = fields.Char(required=True, string="Nombre")
8 changes: 8 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import fields, models


class EstatePropertyType(models.Model):
_name = "estate.property.type" # Name of the model
_description = "Tipos de Propiedades Inmobiliarias" # Description of the model

name = fields.Char(required=True, string="Nombre")
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
11 changes: 11 additions & 0 deletions estate/views/estate_property_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<odoo>
<menuitem id="estate_menu_root" name="Bienes Raíces">
<menuitem id="estate_menu_advertisements" name="Anuncios">
<menuitem id="estate_menu_property" action="estate_property_action"/>
</menuitem>
<menuitem id="estate_menu_settings" name="Configuración" sequence="100">
<menuitem id="estate_menu_property_type" action="estate_property_type_action"/>
<menuitem id="estate_menu_property_tag" action="estate_property_tag_action"/>
</menuitem>
</menuitem>
</odoo>
33 changes: 33 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<odoo>
<record id="estate_property_offer_list_view" model="ir.ui.view">
<field name="name">estate.property.offer.list</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<list string="Propiedades">
<field name="price"/>
<field name="partner_id"/>
<field name="status"/>
<field name="date_deadline"/>
<field name="validity"/>
</list>
</field>
</record>

<record id="estate_property_offer_form_view" model="ir.ui.view">
<field name="name">estate.property.offer.form</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<form string="Propiedad">
<sheet>
<group>
<field name="price"/>
<field name="partner_id"/>
<field name="validity"/>
<field name="date_deadline"/>
<field name="status"/>
</group>
</sheet>
</form>
</field>
</record>
</odoo>
41 changes: 41 additions & 0 deletions estate/views/estate_property_tag_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<odoo>
<record id="estate_property_tag_action" model="ir.actions.act_window">
<field name="name">Etiquetas de Propiedades</field>
<field name="res_model">estate.property.tag</field>
<field name="view_mode">list,form</field>
</record>

<record id="estate_property_tag_list_view" model="ir.ui.view">
<field name="name">estate.property.tag.list</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<list string="Etiquetas de Propiedades">
<field name="name"/>
</list>
</field>
</record>

<record id="estate_property_tag_form_view" model="ir.ui.view">
<field name="name">estate.property.tag.form</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<form string="Propiedad">
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>

<record id="estate_property_tag_search_view" model="ir.ui.view">
<field name="name">estate.property.tag.search</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<search string="Etiquetas de Propiedades">
<field name="name"/>
</search>
</field>
</record>
</odoo>
41 changes: 41 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<odoo>
<record id="estate_property_type_action" model="ir.actions.act_window">
<field name="name">Tipos de Propiedades</field>
<field name="res_model">estate.property.type</field>
<field name="view_mode">list,form</field>
</record>

<record id="estate_property_type_list_view" model="ir.ui.view">
<field name="name">estate.property.type.list</field>
<field name="model">estate.property.type</field>
<field name="arch" type="xml">
<list string="Propiedades">
<field name="name"/>
</list>
</field>
</record>

<record id="estate_property_type_form_view" model="ir.ui.view">
<field name="name">estate.property.type.form</field>
<field name="model">estate.property.type</field>
<field name="arch" type="xml">
<form string="Propiedad">
<sheet>
<h1>
<field name="name" placeholder="Tipo"/>
</h1>
</sheet>
</form>
</field>
</record>

<record id="estate_property_type_search_view" model="ir.ui.view">
<field name="name">estate.property.type.search</field>
<field name="model">estate.property.type</field>
<field name="arch" type="xml">
<search string="Propiedades">
<field name="name"/>
</search>
</field>
</record>
</odoo>
99 changes: 99 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<odoo>
<record id="estate_property_action" model="ir.actions.act_window">
<field name="name">Propiedades</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list,form</field>
</record>

<record id="estate_property_list_view" model="ir.ui.view">
<field name="name">estate.property.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Propiedades">
<field name="name"/>
<field name="postcode"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="expected_price"/>
<field name="selling_price"/>
<field name="date_availability"/>
<field name="property_type_id"/>
<field name="tag_ids" widget="many2many_tags"/>
</list>
</field>
</record>

<record id="estate_property_form_view" model="ir.ui.view">
<field name="name">estate.property.form</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<form string="Propiedad">
<field name="active" invisible="1"/>
<sheet>
<widget name="web_ribbon" title="Archivada" bg_color="text-bg-danger" invisible="active"/>
<div class="oe_title">
<h1>
<field name="name" placeholder="Nombre"/>
</h1>
<field name="tag_ids" widget="many2many_tags" placeholder="Etiquetas"/>
</div>
<group>
<group>
<field name="postcode"/>
<field name="date_availability"/>
<field name="property_type_id"/>
</group>
<group>
<field name="expected_price"/>
<field name="best_price"/>
<field name="selling_price"/>
<field name="state"/>
</group>
</group>
<notebook>
<page string="Descripción" name="description">
<group name="description">
<field name="description"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="facades"/>
<field name="garage"/>
<field name="garden"/>
<field name="garden_area"/>
<field name="garden_orientation"/>
<field name="total_area"/>
</group>
</page>
<page string="Ofertas" name="offers">
<field name="offer_ids"/>
</page>
<page string="Más información" name="other_info">
<group name="other_info">
<field name="salesperson_id"/>
<field name="buyer_id"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="estate_property_search_view" model="ir.ui.view">
<field name="name">estate.property.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search string="Propiedades">
<field name="name"/>
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="facades"/>
<field name="property_type_id"/>
<filter string="Disponible" name="available" domain="[('state', 'in', ['new', 'offer_received'])]"/>
<filter string="Código Postal" name="group_by_postcode" context="{'group_by': 'postcode'}"/>
</search>
</field>
</record>
</odoo>
Loading