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

18.0 tutorials alan #179

Open
wants to merge 5 commits into
base: 18.0
Choose a base branch
from
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ dmypy.json

# Pyre type checker
.pyre/
.idea
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
21 changes: 21 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
'name': 'Estate',
'version': '1.8',
'category': '',
'Author': 'Odoo S.A.',
'summary': '',
'description': 'This is the module for the training',
'depends': ['base', 'base_address_extended'],
'data': [
'security/ir.model.access.csv',
'views/estate_properties_view.xml',
'views/estate_menu.xml',
'views/res_users_view.xml',
'data/res.city.csv',
'data/estate.property.csv',
],
'demo': [],
'application': True,
'installable': True,
'license': 'LGPL-3',
}
301 changes: 301 additions & 0 deletions estate/data/estate.property.csv

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions estate/data/res.city.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
id,country_id:id,name
estate.city.0,base.pr,Adjuntas
estate.city.1,base.pr,Juana Diaz
estate.city.2,base.pr,Ponce
estate.city.3,base.pr,Mayaguez
estate.city.4,base.pr,San Sebastian
estate.city.5,base.pr,Ciales
estate.city.6,base.pr,Las Marias
estate.city.7,base.pr,Isabela
estate.city.8,base.pr,Lares
estate.city.9,base.pr,Utuado
estate.city.10,base.pr,Yauco
estate.city.11,base.pr,Anasco
estate.city.12,base.pr,Moca
estate.city.13,base.pr,Coamo
estate.city.14,base.pr,Guayanilla
estate.city.15,base.pr,Manati
estate.city.16,base.pr,Villalba
estate.city.17,base.pr,Santa Isabel
estate.city.18,base.pr,Penuelas
estate.city.19,base.pr,Hatillo
estate.city.20,base.pr,Aguada
estate.city.21,base.pr,Rincon
estate.city.22,base.pr,Aguadilla
estate.city.23,base.pr,Maricao
estate.city.24,base.pr,Hormigueros
estate.city.25,base.pr,Guanica
estate.city.26,base.pr,Cabo Rojo
estate.city.27,base.pr,San German
estate.city.28,base.pr,Lajas
estate.city.29,base.pr,Arecibo
estate.city.30,base.pr,Camuy
estate.city.31,base.pr,Morovis
estate.city.32,base.pr,Barceloneta
estate.city.33,base.pr,Quebradillas
estate.city.34,base.pr,Vega Baja
estate.city.35,base.pr,Caguas
estate.city.36,base.pr,Dorado
estate.city.37,base.pr,Toa Baja
estate.city.38,base.pr,Toa Alta
estate.city.39,base.pr,Vega Alta
estate.city.40,base.pr,Corozal
estate.city.41,base.pr,Naranjito
estate.city.42,base.pr,Boqueron
3 changes: 3 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import res_users
from . import estate
from . import estate_city
22 changes: 22 additions & 0 deletions estate/models/estate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from odoo import api, fields, models


class Property(models.Model):
_name = "estate.property"
_description = "This is the estate model."

address = fields.Char(compute="_compute_address")
owner_id = fields.Many2one("res.users")
status_id = fields.Many2one("estate.status")
price = fields.Float()
bed = fields.Integer()
bath = fields.Integer()
street = fields.Char(required=True)
city_id = fields.Many2one("res.city", required=True)
house_size = fields.Float()
is_archived = fields.Boolean(default=False)

@api.depends("street", "city_id")
def _compute_address(self):
for record in self:
record.address = f"{record.street}, {record.city_id.name}, {record.city_id.country_id.name}"
7 changes: 7 additions & 0 deletions estate/models/estate_city.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import fields, models


class EstateCity(models.Model):
_inherit = "res.city"

estate_ids = fields.One2many("estate.property", inverse_name="city_id")
7 changes: 7 additions & 0 deletions estate/models/res_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import fields, models


class ResUsers(models.Model):
_inherit = "res.users"

property_ids = fields.One2many("estate.property", inverse_name="owner_id")
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
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
5 changes: 5 additions & 0 deletions estate/views/estate_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="estate_estate_root" name="Estate"/>
<menuitem id="estate_estate" name="Estate" parent="estate_estate_root" action="estate.estate_property_action"/>
</odoo>
93 changes: 93 additions & 0 deletions estate/views/estate_properties_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="estate_property_view_search" model="ir.ui.view">
<field name="name">estate.property.view.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search>
<field name="city_id"/>
<filter string="Unarchived" name="unarchived" domain="[('is_archived', '=', False)]"/>
</search>
</field>
</record>

<record id="estate_property_action" model="ir.actions.act_window">
<field name="name">Estate</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list,form,graph</field>
<field name="search_view_id" ref="estate.estate_property_view_search"/>
<field name="context">
{'search_default_unarchived': True}
</field>
</record>

<record id="estate_property_view_list" model="ir.ui.view">
<field name="name">estate.property.view.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Estate">
<field name="address"/>
<field name="price"/>
</list>
</field>
</record>

<record id="estate_property_view_form" model="ir.ui.view">
<field name="name">estate.property.view.form</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<form>
<header></header>
<sheet>
<div class="oe_title">
<h1>
<field name="address"/>
</h1>
</div>
<notebook>
<page name="general_data" string="General data">
<group>
<field name="owner_id"/>
<field name="price"/>
<field name="house_size"/>
</group>
</page>
<page name="address" string="Address">
<group>
<group>
<field name="street"/>
</group>
<group>
<field name="city_id"/>
</group>
</group>
</page>
<page name="rooms" string="Rooms">
<group>
<group>
<field name="bath"></field>
</group>
<group>
<field name="bed"></field>
</group>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="estate_property_view_graph" model="ir.ui.view">
<field name="name">estate.property.view.graph</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<graph>
<field name="city_id"/>
</graph>
</field>
</record>

</odoo>


22 changes: 22 additions & 0 deletions estate/views/res_users_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="inherit_base_view_users_form" model="ir.ui.view">
<field name="name">inherit.base.view.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='preferences']" position="after">
<page name="estate.property" string="Estate property">
<field name="property_ids">
<list>
<field name="address"/>
<field name="price"/>
</list>
</field>
</page>
</xpath>
</field>
</record>

</odoo>
1 change: 1 addition & 0 deletions estate_account/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions estate_account/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
'name': 'Estate Account',
'version': '1.8',
'category': '',
'Author': 'Odoo S.A.',
'summary': '',
'description': '',
'depends': ['account', 'estate_offer'],
'data': [],
'demo': [],
'installable': True,
'license': 'LGPL-3',
}
1 change: 1 addition & 0 deletions estate_account/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import estate_property
23 changes: 23 additions & 0 deletions estate_account/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from odoo import Command, models


class Property(models.Model):
_inherit = ["estate.property"]

def action_sell(self):
offer_id = self.offer_ids.search([("is_accepted", "=", True)], limit=1)
self.env["account.move"].create(
{
"name": "c_est_l_heure_de_payer",
"partner_id": offer_id.buyer_id.id,
"move_type": "out_invoice",
"invoice_line_ids": [
Command.create({
"name": self.address,
"quantity": 1,
"price_unit": offer_id.amount
})
],
}
)
return super().action_sell()
1 change: 1 addition & 0 deletions estate_offer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions estate_offer/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
'name': 'Estate Offer',
'version': '1.8',
'category': '',
'Author': 'Odoo S.A.',
'summary': '',
'description': '',
'depends': ['estate', 'mail'],
'data': [
'security/ir.model.access.csv',
'data/estate.stage.csv',
'views/estate_properties_view.xml'
],
'demo': [],
'installable': True,
'license': 'LGPL-3'
}
4 changes: 4 additions & 0 deletions estate_offer/data/estate.stage.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,reference,order
estate.stage.to_publish,To publish,to_publish,1
estate.stage.negotiation,Negotiation,negotiation,2
estate.stage.sell,Sell,sell,3
1 change: 1 addition & 0 deletions estate_offer/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import estate_offer
Loading