-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Technical Onboarding brbu #1428
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
Open
AarnorDeDardaliel
wants to merge
7
commits into
19.0
Choose a base branch
from
19.0-estate-brbu
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
583577d
[ADD] First commit with chapters 1 to 5
AarnorDeDardaliel 9bbe27e
[IMP] Chapters 6+7
AarnorDeDardaliel feaafd0
[IMP] Chapter 8
AarnorDeDardaliel 6f1b022
[IMP] Chapter 9
AarnorDeDardaliel 8c0bad9
[IMP] Chapter 10
AarnorDeDardaliel 57e197a
[IMP] Chapter 11
AarnorDeDardaliel 802ad04
[FIX] Style & co
AarnorDeDardaliel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| # Perso | ||
| README.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| 'name': 'My Estate', | ||
| 'version': '1.9', | ||
| 'summary': 'Test module to remember how it works mdr', | ||
| 'website': 'https://www.odoo.com/app/estate', | ||
| 'depends': [ | ||
| 'base', | ||
| ], | ||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_property_offer_views.xml', | ||
| 'views/estate_property_type_views.xml', | ||
| 'views/estate_property_tag_views.xml', | ||
| 'views/estate_menus.xml', | ||
| ], | ||
| 'installable': True, | ||
| 'application': True, | ||
| 'author': 'brbu', | ||
|
AarnorDeDardaliel marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| from odoo import models, fields, api, _ | ||
| from odoo.exceptions import UserError, ValidationError | ||
| from odoo.tools.float_utils import float_compare, float_is_zero | ||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = "estate.property" | ||
| _description = "Properties of the estate" | ||
| _order = "id desc" | ||
|
|
||
| name = fields.Char(required=True, string="Title") | ||
| description = fields.Text() | ||
| tag_ids = fields.Many2many("estate.property.tag", string="Tags") | ||
|
|
||
| property_type_id = fields.Many2one("estate.property.type", string="Property Type") | ||
| salesperson_id = fields.Many2one("res.users", default=lambda self: self.env.user) | ||
| buyer_id = fields.Many2one("res.partner", copy=False) | ||
| offer_ids = fields.One2many("estate.property.offer", "property_id", copy=False) | ||
| best_offer = fields.Float(compute="_compute_best_offer", string="Best Offer", store=True) | ||
|
|
||
| postcode = fields.Char() | ||
| date_availability = fields.Date(copy=False, string="Available From", default=lambda self: fields.Date.add(fields.Date.today(), months=3)) | ||
| expected_price = fields.Float(required=True, string="Expected Price") | ||
| selling_price = fields.Float(readonly=True, string="Selling Price", copy=False) | ||
|
|
||
| bedrooms = fields.Integer(default=2) | ||
| living_area = fields.Integer(string="Living Area (sqm)") | ||
| facade = fields.Integer(string="Façade") | ||
| garage = fields.Boolean(string="Garage") | ||
| garden = fields.Boolean(string="Garden") | ||
| garden_area = fields.Integer(string="Garden Area (sqm)") | ||
| garden_orientation = fields.Selection( | ||
| string="Garden Orientation", | ||
| selection=[("north", "North"), ("south", "South"), ("east", "East"), ("west", "West")], | ||
| ) | ||
| total_area = fields.Integer(string="Total Area (sqm)", compute="_compute_total_area", store=True) | ||
|
|
||
| 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")], | ||
| required=True, | ||
| copy=False, | ||
| default="new", | ||
| ) | ||
|
|
||
| _positive_expected_price = models.Constraint( | ||
| 'CHECK(expected_price > 0)', | ||
| 'The expected price should be strictly positive.', | ||
| ) | ||
|
|
||
| _positive_selling_price = models.Constraint( | ||
| 'CHECK(selling_price >= 0)', | ||
| 'The selling price should be strictly positive.', | ||
| ) | ||
|
|
||
| @api.constrains("selling_price", "expected_price") | ||
| def _check_selling_price(self): | ||
| for record in self: | ||
| if not float_is_zero(record.selling_price, 2) and float_compare(record.selling_price, record.expected_price * 0.9, 2) == -1: | ||
| raise ValidationError(_("The selling price must be at least 90% of the expected price !")) | ||
|
|
||
| @api.depends("living_area", "garden_area") | ||
| def _compute_total_area(self): | ||
| for record in self: | ||
| record.total_area = record.living_area + record.garden_area | ||
|
|
||
| @api.depends("offer_ids.price", "offer_ids.status") | ||
| def _compute_best_offer(self): | ||
| for record in self: | ||
| valid_offers = record.offer_ids.filtered(lambda offer: offer.status != "refused") | ||
| record.best_offer = max(valid_offers.mapped("price"), default=0) | ||
| if valid_offers and record.state=="new": | ||
| record.state = "offer_received" | ||
|
|
||
| def _update_state_from_offers(self): | ||
| for record in self: | ||
| if record.offer_ids.filtered(lambda offer: offer.status == "accepted"): | ||
| record.state = "offer_accepted" | ||
| elif any(not offer.status for offer in record.offer_ids): | ||
| record.state = "offer_received" | ||
| else: | ||
| record.state = "new" | ||
|
|
||
| @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 | ||
|
|
||
| @api.ondelete(at_uninstall=False) | ||
| def _only_if_new_or_cancelled(self): | ||
| for record in self: | ||
| if record.state != 'new' and record.state != 'cancelled': | ||
| raise UserError("Can't delete property that is not new or cancelled !") | ||
|
|
||
| def action_sold(self): | ||
| for record in self: | ||
| if record.state == "cancelled": | ||
| raise UserError("A cancelled property cannot be sold !") | ||
| record.state = "sold" | ||
| return True | ||
|
|
||
| def action_cancelled(self): | ||
| for record in self: | ||
| if record.state == "sold": | ||
| raise UserError("A sold property cannot be cancelled !") | ||
| record.state = "cancelled" | ||
| return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| from odoo import models, fields, api | ||
|
|
||
| class EstatePropertyOffer(models.Model): | ||
| _name = "estate.property.offer" | ||
| _description = "Property offers for the estate" | ||
| _order = "price desc" | ||
|
|
||
| price = fields.Float() | ||
| status = fields.Selection( | ||
| string="Status", | ||
| selection=[("accepted", "Accepted"), ("refused", "Refused")], | ||
| copy=False, | ||
| readonly=True, | ||
| ) | ||
| validity = fields.Integer(string="Validity (days)", default=7) | ||
| date_deadline = fields.Date(string="Deadline", compute="_compute_date_deadline", inverse="_inverse_date_deadline", store=True) | ||
|
|
||
| partner_id = fields.Many2one("res.partner", copy=False) | ||
| property_id = fields.Many2one("estate.property", string="Property", copy=False) | ||
| property_type_id = fields.Many2one(related="property_id.property_type_id", store=True) | ||
|
|
||
| @api.depends("create_date", "validity") | ||
| def _compute_date_deadline(self): | ||
| for record in self: | ||
| start_date = record.create_date.date() if record.create_date else fields.Date.today() | ||
| record.date_deadline = fields.Date.add(start_date, days=record.validity) | ||
|
|
||
| @api.depends("date_deadline", "create_date") | ||
| def _inverse_date_deadline(self): | ||
| for record in self: | ||
| record.validity = (record.date_deadline - record.create_date.date()).days | ||
|
|
||
| def action_accept(self): | ||
| for record in self: | ||
| for other_offer in record.property_id.offer_ids: | ||
| if other_offer.status == "accepted": | ||
| other_offer.status = False | ||
| raise Warning("An other offer acceptation was cancelled : only one offer can be accepted at a time !") | ||
| record.status = "accepted" | ||
| record.property_id.buyer_id = record.partner_id | ||
| record.property_id.selling_price = record.price | ||
| record.property_id._update_state_from_offers() | ||
| return True | ||
|
|
||
| def action_reset(self): | ||
| for record in self: | ||
| if record.status == "accepted": | ||
| record.property_id.buyer_id = False | ||
| record.property_id.selling_price = 0 | ||
| record.status = False | ||
| record.property_id._update_state_from_offers() | ||
| return True | ||
|
|
||
| def action_refuse(self): | ||
| for record in self: | ||
| if record.status == "accepted": | ||
| record.property_id.buyer_id = False | ||
| record.property_id.selling_price = 0 | ||
| record.status = "refused" | ||
| record.property_id._update_state_from_offers() | ||
| return True | ||
|
|
||
| _positive_offer_price = models.Constraint( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. try to keep the constraint bellow the field. usually we do:
|
||
| 'CHECK(price > 0)', | ||
| 'The offer prices should be strictly positive.', | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from odoo import models, fields | ||
|
|
||
| class EstatePropertyTag(models.Model): | ||
| _name = "estate.property.tag" | ||
| _description = "Property tags for the estate" | ||
| _order = "name" | ||
|
|
||
| name = fields.Char(required=True) | ||
| color = fields.Integer('Color Index', default=0) | ||
|
|
||
| _name_uniq = models.Constraint( | ||
| 'unique(name)', | ||
| 'The nae must be unique.', | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| from odoo import models, fields, api | ||
|
|
||
|
|
||
| class EstatePropertyType(models.Model): | ||
| _name = "estate.property.type" | ||
| _description = "Property types of the estate" | ||
| _order = "sequence, name" | ||
|
|
||
| name = fields.Char(required=True) | ||
| property_ids = fields.One2many("estate.property", "property_type_id", copy=False) | ||
| offer_ids = fields.One2many("estate.property.offer", "property_type_id", copy=False) | ||
| offer_count = fields.Integer(compute="_compute_offer_count", store=True) | ||
|
|
||
| sequence = fields.Integer('Sequence', default=1, help="Used to order stages. Lower is better.") | ||
|
|
||
| _name_uniq = models.Constraint( | ||
| 'unique(name)', | ||
| 'The name must be unique.', | ||
| ) | ||
|
|
||
| @api.depends("offer_ids") | ||
| def _compute_offer_count(self): | ||
| for record in self: | ||
| record.offer_count = len(record.offer_ids) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <odoo> | ||
| <menuitem id="estate_menus_root" name="Real Estate"> | ||
| <menuitem id="estate_menus_ads" name="Advertisements"> | ||
| <menuitem id="estate_menus_property_action" action="estate_property_action"/> | ||
| </menuitem> | ||
| <menuitem id="estate_menus_settings" name="Settings"> | ||
| <menuitem id="estate_menus_property_types_action" action="estate_property_type_action"/> | ||
| <menuitem id="estate_menus_property_tag_action" action="estate_property_tag_action"/> | ||
| </menuitem> | ||
| </menuitem> | ||
| </odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_offer_view_list" 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="Properties" editable="bottom" | ||
| decoration-success="status=='accepted'" | ||
| decoration-danger="status=='refused'"> | ||
| <field name="price"/> | ||
| <field name="property_type_id"/> | ||
| <field name="validity"/> | ||
| <field name="date_deadline"/> | ||
| <button name="action_reset" string="Reset" type="object" icon="fa-circle-o-notch" invisible="not status"/> | ||
| <button name="action_accept" string="Accept" type="object" icon="fa-check" invisible="status"/> | ||
| <button name="action_refuse" string="Refuse" type="object" icon="fa-times" invisible="status"/> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_offer_view_form" 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="Property Offer"> | ||
| <sheet> | ||
| <group> | ||
| <field name="price"/> | ||
| <field name="partner_id"/> | ||
| <field name="status"/> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_offer_search" model="ir.ui.view"> | ||
| <field name="name">estate.property.offer.search</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <search string="Property Offers"> | ||
| <field name="property_type_id"/> | ||
| <field name="partner_id"/> | ||
| </search> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_offer_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Offers</field> | ||
| <field name="res_model">estate.property.offer</field> | ||
| <field name="view_mode">list,form</field> | ||
| <field name="domain">[('property_type_id', '=', active_id)]</field> | ||
| </record> | ||
|
|
||
| </odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_tag_view_list" 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="Properties" editable="bottom"> | ||
| <field name="name"/> | ||
| <field name="color" widget="color_picker"/> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_tag_view_form" 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="Property Tag"> | ||
| <sheet> | ||
| <group> | ||
| <field name="name"/> | ||
| <field name="color" widget="color_picker"/> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_tag_search" 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="Estate Property Tag"> | ||
| <field name="name"/> | ||
| </search> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_tag_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Tags</field> | ||
| <field name="res_model">estate.property.tag</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| </odoo> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.