-
Notifications
You must be signed in to change notification settings - Fork 2.6k
MALER Onboarding #995
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
MatteoLeroy
wants to merge
24
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-onboarding-maler
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
MALER Onboarding #995
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4b94903
[ADD] chapter 2
MatteoLeroy 732cd24
[ADD] estate: chapter 3
MatteoLeroy abf17f4
[ADD] estate: author and license for chapter 2
MatteoLeroy 755ef94
[ADD] estate: chapter 4
MatteoLeroy 77b28ab
[ADD] estate: chapter 5
MatteoLeroy f790264
[FIX] estate errors runbot
MatteoLeroy 2ca3c10
[FIX] estate errors runbot 2
MatteoLeroy 5108d34
[ADD] estate: default value to state
MatteoLeroy 950aa6a
[ADD] chapter 6
MatteoLeroy ebd00a8
[ADD] chapter 7
MatteoLeroy eab30ee
[FIX] style check for chapter 7
MatteoLeroy bfdee5e
[IMP] Chapter 8
MatteoLeroy 91f5f42
[FIX] style check for chapter 8
MatteoLeroy dd92e48
[IMP] Chapter 9
MatteoLeroy b327775
[FIX] style check for chapter 9
MatteoLeroy fe1800b
[FIX] style check for chapter 9
MatteoLeroy 5124c90
[IMP] Chapter 10
MatteoLeroy 31dfe65
[FIX] style check for chapter 10
MatteoLeroy 155c968
[IMP] Chapter 11
MatteoLeroy a315476
[IMP] Chapter 12
MatteoLeroy 5b0378c
[FIX] style check for Chapter 12
MatteoLeroy 83fd657
[IMP] chapter 13
MatteoLeroy 452451c
[FIX] style check for chapter 13
MatteoLeroy b808568
[IMP] Chapter 14
MatteoLeroy 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 |
---|---|---|
@@ -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,19 @@ | ||
{ | ||
'name': 'estate', | ||
'depends': [ | ||
'base', | ||
], | ||
'application': 'True', | ||
'author': 'Odoo S.A.', | ||
'license': 'LGPL-3', | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
|
||
'views/estate_property_offer_views.xml', | ||
'views/estate_property_tag_views.xml', | ||
'views/estate_property_type_views.xml', | ||
'views/estate_property_views.xml', | ||
'views/inherited_user_views.xml', | ||
'views/estate_menus.xml', | ||
], | ||
} |
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 @@ | ||
from . import estate_property | ||
from . import estate_property_type | ||
from . import estate_property_tag | ||
from . import estate_property_offer | ||
from . import inherited_user |
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,101 @@ | ||
from odoo import api, models, fields | ||
from odoo.exceptions import UserError | ||
import datetime | ||
from dateutil.relativedelta import relativedelta | ||
from odoo.tools.float_utils import float_compare | ||
|
||
|
||
class EstateProperty(models.Model): | ||
_name = "estate.property" | ||
_description = "test description" | ||
_order = "id desc" | ||
|
||
name = fields.Char('Name', required=True) | ||
description = fields.Text('Description') | ||
postcode = fields.Char('Postcode') | ||
date_availability = fields.Date('Date availability', copy=False, default=datetime.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='Orientation', | ||
selection=[('north', 'North'), ('east', 'East'), ('south', 'South'), ('west', 'West')], | ||
) | ||
active = fields.Boolean('Active', default=True) | ||
state = fields.Selection( | ||
string='state', | ||
selection=[('new', 'New'), ('offerreceived', 'Offer Received'), ('offeraccepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', 'Cancelled')], | ||
default='new', | ||
) | ||
total_area = fields.Integer('Total area (sqm)', compute='_compute_total_area') | ||
best_offer = fields.Float('Best price', compute='_compute_best_offer') | ||
property_type_id = fields.Many2one('estate.property.type', string="Property Type") | ||
salesperson_id = fields.Many2one('res.users', string='Salesman', default=lambda self: self.env.user) | ||
buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False) | ||
tag_ids = fields.Many2many('estate.property.tag', string="Property Tags") | ||
offer_ids = fields.One2many('estate.property.offer', 'property_id', string="Offers") | ||
|
||
@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') | ||
def _compute_best_offer(self): | ||
for record in self: | ||
record.best_offer = max(record.offer_ids.mapped('price')) if record.offer_ids else 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 = None | ||
|
||
def action_set_cancelled(self): | ||
for record in self: | ||
if record.state == 'sold': | ||
raise UserError('A sold property cannot be cancelled') | ||
else: | ||
record.state = 'cancelled' | ||
return True | ||
|
||
def action_set_sold(self): | ||
for record in self: | ||
if record.state == 'cancelled': | ||
raise UserError('A cancelled property cannot be sold') | ||
else: | ||
record.state = 'sold' | ||
return True | ||
|
||
_check_expected_price = models.Constraint( | ||
'CHECK(expected_price > 0)', | ||
'The expected price must be striclty positive', | ||
) | ||
|
||
_check_selling_price = models.Constraint( | ||
'CHECK(selling_price >= 0)', | ||
'The selling price must be positive', | ||
) | ||
|
||
@api.constrains('selling_price') | ||
def check_selling_price(self): | ||
for record in self: | ||
expected_minimum = record.expected_price * 0.9 | ||
if float_compare(record.selling_price, expected_minimum, precision_digits=2) < 0: | ||
raise UserError(r'The selling price should be at least 90% of the expexted price') | ||
else: | ||
record.state = "offeraccepted" | ||
|
||
@api.ondelete(at_uninstall=False) | ||
def unlink_property(self): | ||
for record in self: | ||
if record.state != 'new' and record.state != 'canceled': | ||
raise UserError("Only new and canceled properties can be deleted") |
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,64 @@ | ||
from odoo import api, models, fields | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class EstatePropertyOffer(models.Model): | ||
_name = "estate.property.offer" | ||
_description = "test description" | ||
_order = "price desc" | ||
|
||
price = fields.Float('Price') | ||
status = fields.Selection( | ||
string='Status', | ||
selection=[('accepted', 'Accepted'), ('refused', 'Refused')], | ||
copy=False, | ||
) | ||
partner_id = fields.Many2one('res.partner', string='Partner', required=True) | ||
property_id = fields.Many2one('estate.property', string='Property', required=True) | ||
validity = fields.Integer('Validity', default=7) | ||
date_deadline = fields.Date('Deadline', compute='_compute_deadline', inverse='inverse_deadline') | ||
property_type_id = fields.Many2one(related='property_id.property_type_id', store=True) | ||
|
||
@api.depends('validity') | ||
def _compute_deadline(self): | ||
for records in self: | ||
records.date_deadline = fields.Datetime.add(fields.Date.today(), days=records.validity) | ||
|
||
def inverse_deadline(self): | ||
for records in self: | ||
records.validity = (records.date_deadline - fields.Date.today()).days | ||
|
||
def action_accept(self): | ||
for record in self: | ||
record.status = 'accepted' | ||
if not record.property_id.buyer_id: | ||
record.property_id.buyer_id = record.partner_id | ||
record.property_id.selling_price = record.price | ||
else: | ||
raise UserError('An offer has already been accepted') | ||
return True | ||
|
||
def action_decline(self): | ||
for record in self: | ||
if record.status == 'accepted': | ||
raise UserError('This offer has already been accepted') | ||
else: | ||
record.status = 'refused' | ||
return True | ||
|
||
_check_offer_price = models.Constraint( | ||
'CHECK(price > 0)', | ||
'The offer price must be strictly positive' | ||
) | ||
|
||
@api.model | ||
def create(self, vals): | ||
for val in vals: | ||
property_id = self.env['estate.property'].browse(val['property_id']) | ||
for offer in property_id.offer_ids: | ||
if offer.price > val['price']: | ||
raise UserError("You can't create a lower offer than the highest one") | ||
offers = super().create(vals) | ||
offers.property_id.state = 'offerreceived' | ||
|
||
return offers |
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,15 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class EstatePropertyTag(models.Model): | ||
_name = "estate.property.tag" | ||
_description = "test description" | ||
_order = "name" | ||
|
||
name = fields.Char('Name', required=True) | ||
color = fields.Integer('Color') | ||
|
||
_check_name = models.Constraint( | ||
'UNIQUE (name)', | ||
'The name 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,23 @@ | ||
from odoo import api, fields, models | ||
|
||
|
||
class EstatePropertyType(models.Model): | ||
_name = "estate.property.type" | ||
_description = "test description" | ||
_order = "sequence, name" | ||
|
||
name = fields.Char('Name', required=True) | ||
sequence = fields.Integer('Sequence', default=1, help="Used to order stages.") | ||
property_ids = fields.One2many('estate.property', 'property_type_id', string="Properties") | ||
offer_ids = fields.One2many('estate.property.offer', 'property_type_id', string="Offers") | ||
offer_count = fields.Integer('Number of offers', compute='_compute_offers') | ||
|
||
@api.depends('offer_ids') | ||
def _compute_offers(self): | ||
for record in self: | ||
record.offer_count = len(record.offer_ids) | ||
|
||
_check_name = models.Constraint( | ||
'UNIQUE (name)', | ||
'The name 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,7 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class InheritedUser(models.Model): | ||
_inherit = "res.users" | ||
|
||
property_ids = fields.One2many('estate.property', 'salesperson_id', string="Related Properties", domain=[('state', 'in', ['new', 'offerreceived'])]) |
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"?> | ||
<odoo> | ||
<menuitem id="estate_root_menu" name="Estate"> | ||
<menuitem id="estate_first_level_menu" name="Menu"> | ||
<menuitem id="estate_model_menu_action" action="estate_property_action"/> | ||
</menuitem> | ||
<menuitem id="estate_settings_menu" name="Settings"> | ||
<menuitem id="estate_type_menu_action" action="estate_property_type_action"/> | ||
<menuitem id="estate_tag_menu_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,24 @@ | ||
<?xml version="1.0"?> | ||
<odoo> | ||
<record id="estate_property_offer_action" model="ir.actions.act_window"> | ||
<field name="name">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> | ||
|
||
<record id="estate_property_offer_view" model="ir.ui.view"> | ||
<field name="name">property type offer</field> | ||
<field name="model">estate.property.offer</field> | ||
<field name="arch" type="xml"> | ||
<list editable="bottom" decoration-success="status=='accepted'" decoration-danger="status=='refused'"> | ||
<field name="price"/> | ||
<field name="partner_id"/> | ||
<field name="validity"/> | ||
<field name="date_deadline"/> | ||
<button name="action_accept" string="Accept" type="object" icon="fa-check" invisible="status in ('accepted', 'refused')"/> | ||
<button name="action_decline" string="Refuse" type="object" icon="fa-times" invisible="status in ('accepted', 'refused')"/> | ||
</list> | ||
</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,18 @@ | ||
<?xml version="1.0"?> | ||
<odoo> | ||
<record id="estate_property_tag_action" model="ir.actions.act_window"> | ||
<field name="name">Tags</field> | ||
<field name="res_model">estate.property.tag</field> | ||
<field name="view_mode">list,form</field> | ||
</record> | ||
|
||
<record id="estate_property_tag_view_list" model="ir.ui.view"> | ||
<field name="name">tags.list</field> | ||
<field name="model">estate.property.tag</field> | ||
<field name="arch" type="xml"> | ||
<list editable="bottom"> | ||
<field name="name"/> | ||
</list> | ||
</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,56 @@ | ||
<?xml version="1.0"?> | ||
<odoo> | ||
<record id="estate_property_type_action" model="ir.actions.act_window"> | ||
<field name="name">property types</field> | ||
<field name="res_model">estate.property.type</field> | ||
<field name="view_mode">list,form</field> | ||
</record> | ||
|
||
<record id="estate_property_type_view_form" 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="Estate Property Types"> | ||
<sheet> | ||
<div class="oe_button_box" name="button_box"> | ||
<button class="oe_stat_button" name="%(estate_property_offer_action)d" | ||
type="action" icon="fa-bars"> | ||
<div class="o_stat_info"> | ||
<span class="o_stat_text"> | ||
Offres | ||
</span> | ||
</div> | ||
</button> | ||
</div> | ||
<group> | ||
<field name="name"/> | ||
</group> | ||
<notebook> | ||
<page string="Properties"> | ||
<group> | ||
<field name="property_ids"> | ||
<list string="Channel"> | ||
<field name="name"/> | ||
<field name="expected_price"/> | ||
<field name="state"/> | ||
</list> | ||
</field> | ||
</group> | ||
</page> | ||
</notebook> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="estate_property_type_view_list" model="ir.ui.view"> | ||
<field name="name">estate.property.list</field> | ||
<field name="model">estate.property.type</field> | ||
<field name="arch" type="xml"> | ||
<list string="Channel"> | ||
<field name="sequence" widget="handle"/> | ||
<field name="name"/> | ||
</list> | ||
</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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A blank line is missing here. You should have two blank lines above a class. It is a python convention coming from the pip8.