-
Notifications
You must be signed in to change notification settings - Fork 2.3k
XAFR - Technical Training #740
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
base: 18.0
Are you sure you want to change the base?
Changes from 1 commit
c33277d
7bbe040
6c39232
c398bbf
bcdabc8
a8cf2ae
82d7ec7
92195f6
a5ea174
93b7190
b517f01
6ee2a07
a4863d5
1742244
3ebcdc6
6a42330
7e14dac
92ffc6d
27cf297
4e78b9f
05a315d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Add the sprinkles Fixes according to review comments
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,10 @@ | |
class EstatePropertyOffer(models.Model): | ||
_name = 'estate.property.offer' | ||
_description = 'Estate property offer' | ||
_order = "price desc" | ||
|
||
_check_positive_offer_price = (models.Constraint("""CHECK (price >= 0)""", | ||
"The property offer price must be positive.")) | ||
|
||
price = fields.Float() | ||
status = fields.Selection( | ||
|
@@ -13,6 +17,7 @@ class EstatePropertyOffer(models.Model): | |
property_id = fields.Many2one("estate.property", string="Offer", required=True) | ||
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. That's a nasty copy paste (string still indicates it's an Offer 😄). Same for these Many2ones 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. I actually named it |
||
validity = fields.Integer(default=7) | ||
date_deadline = fields.Date(compute="_compute_deadline", inverse="_inverse_deadline", default=fields.Date.add(fields.Date.today(), days=7)) | ||
property_type_id = fields.Many2one(related='property_id.property_type_id') | ||
|
||
@api.depends("create_date", "validity") | ||
def _compute_deadline(self): | ||
|
@@ -34,6 +39,3 @@ def action_btn_refuse(self): | |
for record in self: | ||
record.status = "refused" | ||
return True | ||
|
||
_check_positive_offer_price = (models.Constraint("""CHECK (price >= 0)""", | ||
"The property offer price must be positive.")) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
from odoo import fields, models | ||
from odoo import fields, models, api | ||
|
||
|
||
class EstatePropertyType(models.Model): | ||
_name = 'estate.property.type' | ||
_description = 'Estate property type' | ||
|
||
name = fields.Char('Title', required=True, translate=True) | ||
_order = "manual_ordering asc, name asc" | ||
|
||
_type_name_uniq = (models.Constraint("""UNIQUE (name)""", | ||
"The type name must be unique.")) | ||
|
||
name = fields.Char('Title', required=True, translate=True) | ||
line_ids = fields.One2many("estate.property", "property_type_id") | ||
manual_ordering = fields.Integer('Sequence', default=1, help="Used to order stages. Lower is better.") | ||
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. Normally we'd call the field 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. Noted and corrected :) |
||
offer_ids = fields.One2many("estate.property.offer", "property_type_id") | ||
offer_count = fields.Integer(compute='_compute_offers') | ||
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. By convention the compute should include the name of the computed field.
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. Noted and fixed |
||
|
||
@api.depends("offer_ids") | ||
def _compute_offers(self): | ||
for record in self: | ||
record.offer_count = len(record.offer_ids) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,24 +4,26 @@ | |
<field name="name">Properties</field> | ||
<field name="res_model">estate.property</field> | ||
<field name="view_mode">list,form</field> | ||
<field name="context">{'search_default_availability': True}</field> | ||
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. Guess that eludes my review on that part 😄 |
||
</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="Channel" editable="bottom"> | ||
<field name="name"/> | ||
<list string="Channel" decoration-success="state in ['offer_received', 'offer_accepted']" decoration-muted="state=='sold'"> | ||
<field name="name" decoration-success="state in ['offer_received', 'offer_accepted']" decoration-bf="state=='offer_accepted'" decoration-muted="state=='sold'"/> | ||
<field name="bedrooms"/> | ||
<field name="postcode"/> | ||
<field name="living_area"/> | ||
<field name="expected_price"/> | ||
<field name="selling_price"/> | ||
<field name="date_availability"/> | ||
<field name="date_availability" optional="hide"/> | ||
<field name="salesman_id"/> | ||
<field name="buyer_id"/> | ||
<field name="property_type_id"/> | ||
<field name="tag_ids" widget="many2many_tags"/> | ||
<field name="property_type_id" widget="many2one" options="{'no_create': True}"/> | ||
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/> | ||
<field name="state"/> | ||
</list> | ||
</field> | ||
</record> | ||
|
@@ -30,20 +32,20 @@ | |
<field name="name">estate.property.form</field> | ||
<field name="model">estate.property</field> | ||
<field name="arch" type="xml"> | ||
<form string="Properties"> | ||
<form string="Properties" decoration-success="state in ['offer_received', 'offer_accepted']" decoration-muted="state=='sold'"> | ||
<header> | ||
<button name="action_btn_sold" type="object" string="Sold"/> | ||
<button name="action_btn_cancel" string="Cancel" type="object" class="oe_highlight"/> | ||
<button name="action_btn_sold" type="object" string="Sold" invisible="state=='cancelled' or state=='sold'"/> | ||
<button name="action_btn_cancel" string="Cancel" type="object" class="oe_highlight" invisible="state=='cancelled' or state=='sold'"/> | ||
<field name="state" widget="statusbar" statusbar_visible="new,offer_received,offer_accepted,sold"/> | ||
</header> | ||
<sheet> | ||
<h1> | ||
<field name="name"/> | ||
<field name="tag_ids" widget="many2many_tags"/> | ||
</h1> | ||
<group> | ||
<group> | ||
<field name="state"/> | ||
<field name="property_type_id"/> | ||
<field name="property_type_id" options="{'no_create': True}"/> | ||
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/> | ||
<field name="postcode"/> | ||
<field name="date_availability"/> | ||
</group> | ||
|
@@ -62,13 +64,13 @@ | |
<field name="facades"/> | ||
<field name="garage"/> | ||
<field name="garden"/> | ||
<field name="garden_area"/> | ||
<field name="garden_orientation"/> | ||
<field name="garden_area" invisible="not garden"/> | ||
<field name="garden_orientation" invisible="not garden"/> | ||
<field name="total_area"/> | ||
</group> | ||
</page> | ||
<page string="Offers"> | ||
<field name="offer_ids"/> | ||
<field name="offer_ids" readonly="state in ['offer_accepted', 'sold', 'cancelled']"/> | ||
</page> | ||
<page string="Other Info"> | ||
<group> | ||
|
@@ -93,8 +95,9 @@ | |
<field name="bedrooms" string="Bathrooms"/> | ||
<field name="facades" string="Facades"/> | ||
<field name="property_type_id"/> | ||
<field name="living_area" filter_domain="[('living_area', '>=', self)]"/> | ||
|
||
<filter string="Available" name="state" domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]"/> | ||
<filter string="Available" name="availability" domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]" help="Shows only available properties."/> | ||
<group expand="1" string="Group By"> | ||
<filter string="Postcode" name="postcode" context="{'group_by':'postcode'}"/> | ||
</group> | ||
|
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.
But why? At least put Odoo if you have to fill something
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.
I just wanted to get rid of the warning messages but yeah should have put odoo. I'm changing it now.