-
Notifications
You must be signed in to change notification settings - Fork 2.6k
trcaz - Industry onboarding #986
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: 19.0
Are you sure you want to change the base?
Changes from 1 commit
ce16fab
d31e6b3
d1be6e1
e065871
6b6d7c3
0c9993b
b043d1a
c3bed90
a127540
002dfba
44f4e3e
c0f4786
193323b
244c35d
a07d26c
1e82b73
bdb9f65
6def407
0b05411
a5a4058
8cb6ed6
f368391
94f4a3c
9bc6f35
3e89bd5
bad506f
47d5056
4348d79
d9cc923
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"> | ||
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. 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> | ||
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. what is the purpose of this rule? 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. 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
|
||
<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) | ||
trcazier marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
]]></field> | ||
</record> | ||
</odoo> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"> | ||
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. 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> | ||
trcazier marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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.
Every module depends on
base
, sobase
is only mentioned if there is no other.