Skip to content

Commit fb559d6

Browse files
committed
[REF] estate, estate_account: change names according to the coding guideline and clear some typos
This commit will refactor estate_property in estate.property as recommended. Some file name especially those who deals with inhertiance are changed accoridng to the guideline.
1 parent 05db246 commit fb559d6

13 files changed

+30
-31
lines changed

estate/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
'base'
55
],
66
'data': [
7-
'views/estate_property_offer.xml',
7+
'views/estate_property_offer_views.xml',
88
'views/estate_property_type_views.xml',
99
'views/estate_property_tag_views.xml',
1010
'views/estate_property_views.xml',
1111
'views/estate_menus.xml',
12-
'views/inherited_user.xml',
12+
'views/res_user.xml',
1313
'security/ir.model.access.csv',
1414
],
1515
'application': True

estate/models/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from . import estate_property_type
22
from . import estate_property_tag
33
from . import estate_property_offer
4-
from . import estate_properties
5-
from . import inherited_user
4+
from . import estate_property
5+
from . import res_user

estate/models/estate_properties.py renamed to estate/models/estate_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class Properties(models.Model):
9-
_name = "estate_property"
9+
_name = "estate.property"
1010
_description = "Properties of the estate model"
1111
_order = "id desc"
1212

@@ -91,7 +91,7 @@ def action_cancel(self):
9191
def _check_minimum_sell_price(self):
9292
for a_property in self:
9393
if float_compare(a_property.selling_price, a_property.expected_price * 0.9, 2) == -1:
94-
raise ValidationError("The seling prce can not be lower than 90% of the expected price")
94+
raise ValidationError("The selling price can not be lower than 90% of the expected price")
9595

9696
@api.ondelete(at_uninstall=False)
9797
def _unlink_if_new_or_cancelled(self):

estate/models/estate_property_offer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PropertyOffer(models.Model):
1111
price = fields.Float("price")
1212
status = fields.Selection(copy=False, selection=[('accepted', 'Accepted'), ('refused', 'Refused')])
1313
partner_id = fields.Many2one("res.partner", required=True)
14-
property_id = fields.Many2one("estate_property", required=True)
14+
property_id = fields.Many2one("estate.property", required=True)
1515
date_deadline = fields.Date(default=fields.Date.today() + relativedelta(days=7), compute="_compute_deadline", inverse="_update_validity")
1616
validity = fields.Integer(default=7)
1717
property_type_id = fields.Many2one(related="property_id.property_type_id", store=True)
@@ -58,10 +58,10 @@ def action_cancel(self):
5858
return True
5959

6060
@api.model
61-
def create(self, vals):
62-
property_id = self.env["estate_property"].browse(vals["property_id"])
61+
def create_multi(self, vals):
62+
property_id = self.env["estate.property"].browse(vals["property_id"])
6363
if property_id.state == "new":
6464
property_id.state = "offer received"
6565
if property_id.best_price > vals["price"]:
6666
raise UserError("The price of a new offer can't be below the price of an already existing offer.")
67-
return super().create(vals)
67+
return super().create_multi(vals)

estate/models/estate_property_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class PropertyType(models.Model):
77
_order = "sequence,name desc"
88

99
name = fields.Char("Type", required=True)
10-
property_ids = fields.One2many("estate_property", "property_type_id")
10+
property_ids = fields.One2many("estate.property", "property_type_id")
1111
sequence = fields.Integer()
1212
offer_ids = fields.One2many("estate.property.offer", "property_type_id")
1313
offer_count = fields.Integer(compute="_count_offer")

estate/models/inherited_user.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

estate/models/res_user.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from odoo import fields, models
2+
3+
4+
class User(models.Model):
5+
_inherit = "res.users"
6+
7+
property_ids = fields.One2many("estate.property", inverse_name="salesperson")

estate/views/estate_menus.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<odoo>
33
<menuitem id="estate_menu_root" name="Estate">
4-
<menuitem id="estate_first_level_menu" name="First Level">
4+
<menuitem id="estate_first_level_menu" name="Property">
55
<menuitem id="estate_menu_action" action="estate_property_action"/>
66
</menuitem>
77
<menuitem id="estate_type_first_level_menu" name="Estate Types">

estate/views/estate_property_offer.xml renamed to estate/views/estate_property_offer_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<odoo>
33

4-
<record id="estate_property_offer_filter_action" model="ir.actions.act_window">
4+
<record id="estate_property_offer_action_filter" model="ir.actions.act_window">
55
<field name="name">Offer</field>
66
<field name="res_model">estate.property.offer</field>
77
<!-- <field name="domain">[('property_type_id', '=', active_id)]</field> -->

estate/views/estate_property_type_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<sheet>
4040
<div name="button_box">
4141
<button class="oe_stat_button"
42-
name="estate.estate_property_offer_filter_action"
42+
name="estate.estate_property_offer_action_filter"
4343
type="action" string="test">
4444
<!--
4545
<div class="o_field_widget o_stat_info">

estate/views/estate_property_views.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<record id="estate_property_view_search" model="ir.ui.view">
55
<field name="name">estate.property.view.search</field>
6-
<field name="model">estate_property</field>
6+
<field name="model">estate.property</field>
77
<field name="arch" type="xml">
88
<search>
99
<field string="Title" name="name"/>
@@ -20,15 +20,15 @@
2020

2121
<record id="estate_property_action" model="ir.actions.act_window">
2222
<field name="name">Estate property</field>
23-
<field name="res_model">estate_property</field>
23+
<field name="res_model">estate.property</field>
2424
<field name="view_mode">list,kanban,form</field>
2525
<field name="context">{'search_default_state_availability_filter': True}</field>
2626
</record>
2727

2828
<!-- list view -->
2929
<record id="estate_property_view_tree" model="ir.ui.view">
3030
<field name="name">estate.property.list</field>
31-
<field name="model">estate_property</field>
31+
<field name="model">estate.property</field>
3232
<field name="arch" type="xml">
3333
<list string="Channel" decoration-success="state in ['offer received','offer accepted']" decoration-bf="state == 'offer accepted'" decoration-muted="state == 'sold'">
3434
<field name="name"/>
@@ -52,7 +52,7 @@
5252
<!-- Form view -->
5353
<record id="estate_property_view_form" model="ir.ui.view">
5454
<field name="name">estate.property.form</field>
55-
<field name="model">estate_property</field>
55+
<field name="model">estate.property</field>
5656
<field name="arch" type="xml">
5757
<form string="Property">
5858
<header>
@@ -86,7 +86,6 @@
8686
<field name="garden"/>
8787
<field name="garden_area" invisible="not garden"/>
8888
<field name="garden_orientation" invisible="not garden"/>
89-
<field name="state"/>
9089
<field name="total_area"/>
9190
</group>
9291
</page>
@@ -117,7 +116,7 @@
117116
<!-- Kanban View -->
118117
<record id="estate_property_view_kanban" model="ir.ui.view">
119118
<field name="name">estate.property.kanban</field>
120-
<field name="model">estate_property</field>
119+
<field name="model">estate.property</field>
121120
<field name="arch" type="xml">
122121
<kanban default_group_by="state" records_draggable="False">
123122
<templates>

estate/views/inherited_user.xml renamed to estate/views/res_user.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<odoo>
3-
<record id="inherited_user_estate_view_form" model="ir.ui.view">
4-
<field name="name">inherited.base.view_users_form</field>
3+
<record id="view_users_form" model="ir.ui.view">
4+
<field name="name">res.user.view.form.inherit.estate.property</field>
55
<field name="model">res.users</field>
66
<field name="inherit_id" ref="base.view_users_form"/>
77
<field name="arch" type="xml">

estate_account/models/estate_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from odoo import models, Command
22

33

4-
class InheritedProperty(models.Model):
5-
_inherit = "estate_property"
4+
class Property(models.Model):
5+
_inherit = "estate.property"
66

77
def action_sold(self):
88
res = super().action_sold()

0 commit comments

Comments
 (0)