Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ce16fab
[ADD] estate: copy estate from 19.0-tutorial-trcaz branch
trcazier Sep 15, 2025
d31e6b3
[IMP] estate: add CSV data file for property type
trcazier Oct 1, 2025
d1be6e1
[IMP] estate: add default property data
trcazier Oct 1, 2025
e065871
[IMP] estate: add offer data & change property data ids
trcazier Oct 1, 2025
6b6d7c3
[IMP] estate: renamed property type data id for clarity
trcazier Oct 1, 2025
0c9993b
[FIX] estate: modify data to comply with estate model constraints
trcazier Oct 1, 2025
b043d1a
[FIX] estate: add xml file missing in manifest
trcazier Oct 1, 2025
c3bed90
[IMP] estate: improve 90% offer error message
trcazier Oct 1, 2025
a127540
[IMP] estate: add property type to property data
trcazier Oct 1, 2025
002dfba
[FIX] estate: fix runbot warning for string
trcazier Oct 1, 2025
44f4e3e
[IMP] estate: modify date to be evaluated based on module installatio…
trcazier Oct 1, 2025
c0f4786
[IMP] estate: accept 1 data offer and refuse 2 + fix same id
trcazier Oct 1, 2025
193323b
[IMP] estate: add new property with offers created inside the field
trcazier Oct 1, 2025
244c35d
[FIX] estate: modify _ format parameters for runbot style
trcazier Oct 1, 2025
a07d26c
[ADD] x_estate: add new importable module x_estate
trcazier Oct 2, 2025
1e82b73
[IMP] x_estate: add property_type model, views, menu, and add many2on…
trcazier Oct 2, 2025
bdb9f65
[IMP] x_estate: add property tags model, view, menu and property fiel…
trcazier Oct 2, 2025
6def407
[CLN] x_estate: add empty line at the end of files
trcazier Oct 2, 2025
0b05411
[IMP] x_estate: add offer model, view and add it to property model an…
trcazier Oct 2, 2025
a5a4058
[FIX] x_estate: change offer buyer relation from user to partner
trcazier Oct 3, 2025
8cb6ed6
[IMP] x_estate: add selling price field to property model
trcazier Oct 3, 2025
f368391
[IMP] x_estate: add offer action to accept offer in list view
trcazier Oct 3, 2025
94f4a3c
[IMP] x_estate: add total area computed field to property
trcazier Oct 3, 2025
9bc6f35
[IMP] x_estate: add json route to get properties as a public user
trcazier Oct 3, 2025
3e89bd5
[CLN] x_estate: reduce the number of lines
trcazier Oct 3, 2025
bad506f
[CLN] x_estate: reduce the number of lines
trcazier Oct 3, 2025
47d5056
[CLN] x_estate: add empty line at the end of file
trcazier Oct 3, 2025
4348d79
[IMP] x_estate: remove optional=disabled from date availability
trcazier Oct 3, 2025
d9cc923
[IMP] estate: make test data relative and remove optional
trcazier Oct 6, 2025
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 x_estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'depends': [
'base',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every module depends on base, so base is only mentioned if there is no other.

Suggested change
'base',

'base_import_module',
'website',
],
'version': '19.0.0.0',
'author': "Odoo S.A.",
Expand Down
57 changes: 57 additions & 0 deletions x_estate/models/x_real_estate_property_fields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,61 @@ for property in self:
<field name="relation">x_estate.property.offer</field>
<field name="relation_field">x_property_id</field>
</record>

<record id="field_real_estate_property_api_published" model="ir.model.fields">
<field name="model_id" ref="real_estate_property_model"/>
<field name="name">x_api_published</field>
<field name="field_description">API published</field>
<field name="ttype">boolean</field>
<field name="required">True</field>
</record>

<record id="default_real_estate_property_api_published" model="ir.default">
<field name="field_id" ref="field_real_estate_property_api_published"/>
<field name="json_value">true</field>
</record>

<!-- Actions -->

<record id="api_public_write_rule" model="ir.rule">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have a security folder, this record should be there

<field name="name">Public users can't write</field>
<field name="model_id" ref="real_estate_property_model"/>
<field name="domain_force">[(0, '=', 1)]</field>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of this rule?
the domain is false for all instances right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the tutorial said to allow read and write on the route (to allow the server action to be executed), but restrict the write user access with this domain

add an access right record to allow public users to read and write the model

prevent any write from the public user by adding a record rule for the write operation with an impossible domain (e.g. [('id', '=', False)])

<field name="groups" eval="[Command.link(ref('base.group_public'))]"/>
<field name="perm_read" eval="False"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>

<record id="api_public_write_rule" model="ir.rule">
<field name="name">Public users can read x_api_published properties</field>
<field name="model_id" ref="real_estate_property_model"/>
<field name="domain_force">[('x_api_published', '=', True)]</field>
<field name="groups" eval="[Command.link(ref('base.group_public'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>

<record id="server_action_estate_list" model="ir.actions.server">
<field name="name">Estate List Controller</field>
<field name="model_id" ref="real_estate_property_model" />
<field name="website_published">True</field>
<field name="website_path">estate</field>
<field name="state">code</field>
<field name="code"><![CDATA[
records = request.env['x_estate.property'].search([('x_api_published', '=', True)])
data = []
# only these fields because the others are 403
fields = ['x_name', 'x_expected_price', 'x_selling_price', 'x_bedrooms', 'x_living_area', 'x_facades', 'x_garage', 'x_garden', 'x_garden_area', 'x_garden_orientation', 'x_total_area']
for record in records:
datum = {}
for field in fields:
datum[field] = record[field]
data.append(datum)
response = request.make_json_response(data, headers=None, cookies=None, status=200)
]]></field>
</record>
</odoo>
10 changes: 10 additions & 0 deletions x_estate/models/x_real_estate_property_model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@
<field name="name">Real Estate Property</field>
<field name="model">x_estate.property</field>
</record>

<record model="ir.model.access" id="access_real_estate_property_public">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, should be in security/

<field name="name">Estate: deny create/unlink for public (need write for server action)</field>
<field name="model_id" ref="real_estate_property_model"/>
<field name="group_id" ref="base.group_public"/>
<field name="perm_read">1</field>
<field name="perm_write">1</field>
<field name="perm_create">0</field>
<field name="perm_unlink">0</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions x_estate/views/x_real_estate_property_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<field name="x_garden_area" invisible="not x_garden"/>
<field name="x_garden_orientation" invisible="not x_garden"/>
<field name="x_total_area"/>
<field name="x_api_published"/>
</group>
</page>
<page string="Offers">
Expand Down