8000 chapter 6 - user groups · odoo/documentation@6b03f6f · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b03f6f

Browse files
committed
chapter 6 - user groups
1 parent de6d331 commit 6b03f6f

File tree

6 files changed

+191
-82
lines changed

6 files changed

+191
-82
lines changed

content/developer/reference/backend/security.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Both mechanisms are linked to specific users through *groups*: a user belongs
1212
to any number of groups, and security mechanisms are associated to groups,
1313
thus applying security mechanisms to users.
1414

15+
.. _reference/security/groups:
16+
1517
.. class:: res.groups
1618

1719
.. attribute:: name

content/developer/tutorials/server_framework_101/02_lay_the_foundations.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,13 @@ being logged at server start-up after creating the model:
536536
.. exercise::
537537
#. Create a new :file:`ir.model.access.csv` file at the root of the `real_estate` module.
538538
#. Declare it in the manifest as you did for the :file:`real_estate_property_data.xml` file.
539-
#. Grant access to the `real.estate.property` model to all administrators of the database by
540-
adding new access rights with the following specifications:
539+
#. Grant access to the `real.estate.property` model to all users of the database by adding new
540+
access rights with the following specifications:
541541

542-
- XML ID: `real_estate_property_system`
543-
- `name`: `real.estate.property.system`
542+
- XML ID: `real_estate_property_user`
543+
- `name`: `real.estate.property.user`
544544
- `model_id`: The record ID of `model_real_estate_property`
545-
- `group_id`: The record ID of `base.group_system`
545+
- `group_id`: The record ID of `base.group_user`
546546
- `perm_read`, `perm_write`, `perm_create`, and `perm_unlink`: `1`
547547

548548
.. tip::
@@ -564,7 +564,7 @@ being logged at server start-up after creating the model:
564564
:caption: `ir.model.access.csv`
565565
566566
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
567-
real_estate_property_system,real.estate.property.system,model_real_estate_property,base.group_system,1,1,1,1
567+
real_estate_property_user,real.estate.property.user,model_real_estate_property,base.group_user,1,1,1,1
568568
569569
After restarting the server, the warning should no longer appear.
570570

content/developer/tutorials/server_framework_101/03_build_user_interface.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ field labels and values).
323323
.. code-block:: xml
324324
:caption: A list view for `product`
325325
326-
<record id="product_list" model="ir.ui.view">
326+
<record id="product.product_list" model="ir.ui.view">
327327
<field name="name">Product List</field>
328328
<field name="model">product</field>
329329
<field name="arch" type="xml">
@@ -338,7 +338,7 @@ field labels and values).
338338
.. code-block:: xml
339339
:caption: A form view for `product`
340340
341-
<record id="product_form" model="ir.ui.view">
341+
<record id="product.product_form" model="ir.ui.view">
342342
<field name="name">Product Form</field>
343343
<field name="model">product</field>
344344
<field name="arch" type="xml">
@@ -358,7 +358,7 @@ field labels and values).
358358
.. code-block:: xml
359359
:caption: A search view for `product`
360360
361-
<record id="product_search" model="ir.ui.view">
361+
<record id="product.product_search" model="ir.ui.view">
362362
<field name="name">Product Search</field>
363363
<field name="model">product</field>
364364
<field name="arch" type="xml">

content/developer/tutorials/server_framework_101/04_relational_fields.rst

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ structure guidelines** that offer several benefits:
7373
directory.
7474

7575
.. seealso::
76-
:ref:`Coding guidelines on module directories
77-
<contributing/coding_guidelines/module_structure/directories>`
76+
:ref:`Coding guidelines on module structure <contributing/coding_guidelines/module_structure>`
7877

7978
.. exercise::
8079
Restructure the `real_estate` module according to the guidelines.
@@ -248,8 +247,7 @@ managing property types.
248247
.. exercise::
249248
#. Create a new `real.estate.property.type` model.
250249

251-
- Update the :file:`ir.model.access.csv` file to grant all database administrators access to
252-
the model.
250+
- Update the :file:`ir.model.access.csv` file to grant all database users access to the model.
253251
- Replace the dummy :guilabel:`Settings` menu item with a new :menuselection:`Configuration
254252
--> Property Types` menu item.
255253
- Create a window action to browse property types only in list view.
@@ -296,8 +294,8 @@ managing property types.
296294
:emphasize-lines: 3
297295
298296
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
299-
real_estate_property_system,real.estate.property.system,model_real_estate_property,base.group_system,1,1,1,1
300-
real_estate_property_type_system,real.estate.property.type.system,model_real_estate_property_type,base.group_system,1,1,1,1
297+
real_estate_property_user,real.estate.property.user,model_real_estate_property,base.group_user,1,1,1,1
298+
real_estate_property_type_user,real.estate.property.type.user,model_real_estate_property_type,base.group_user,1,1,1,1
301299
302300
.. code-block:: xml
303301
:caption: `menus.xml`
@@ -673,8 +671,6 @@ to a list of offers received from potential buyers.
673671
#. Modify the form view of properties to display offers in a new notebook page titled
674672
:guilabel:`Offers`.
675673

676-
677-
678674
.. spoiler:: Solution
679675

680676
.. code-block:: python
@@ -720,9 +716,9 @@ to a list of offers received from potential buyers.
720716
:emphasize-lines: 2
721717
722718
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
723-
real_estate_offer_system,real.estate.offer.system,model_real_estate_offer,base.group_system,1,1,1,1
724-
real_estate_property_system,real.estate.property.system,model_real_estate_property,base.group_system,1,1,1,1
725-
real_estate_property_type_system,real.estate.property.type.system,model_real_estate_property_type,base.group_system,1,1,1,1
719+
real_estate_offer_user,real.estate.offer.user,model_real_estate_offer,base.group_user,1,1,1,1
720+
real_estate_property_user,real.estate.property.user,model_real_estate_property,base.group_user,1,1,1,1
721+
real_estate_property_type_user,real.estate.property.type.user,model_real_estate_property_type,base.group_user,1,1,1,1
726722
727723
.. code-block:: xml
728724
:caption: `real_estate_offer_views.xml`
@@ -819,7 +815,7 @@ convention, `Many2many` field names end with the `_ids` suffix, like for `One2ma
819815

820816
.. example::
821817
In the example below, a many-to-many relationship is established between the `product` model and
822-
the `res.partner` model, which is used to represent sellers offering products for sale.
818+
the `res.partner` model, which is used to represent suppliers offering products for sale.
823819

824820
.. code-block:: python
825821
@@ -831,11 +827,11 @@ convention, `Many2many` field names end with the `_ids` suffix, like for `One2ma
831827
_description = "Storable Product"
832828
833829
[...]
834-
seller_ids = fields.Many2many(
835-
string="Sellers",
836-
help="The sellers offering the product for sale.",
830+
supplier_ids = fields.Many2many(
831+
string="Suppliers",
832+
help="The suppliers offering the product for sale.",
837833
comodel_name='res.partner',
838-
relation='product_seller_rel',
834+
relation='product_supplier_rel',
839835
column1='product_id',
840836
column2='partner_id',
841837
)
@@ -899,7 +895,7 @@ with each property.
899895
900896
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
901897
[...]
902-
real_estate_tag_system,real.estate.tag.system,model_real_estate_tag,base.group_system,1,1,1,1
898+
real_estate_tag_user,real.estate.tag.user,model_real_estate_tag,base.group_user,1,1,1,1
903899
904900
.. code-block:: xml
905901
:caption: `real_estate_tag_data.xml`

content/developer/tutorials/server_framework_101/05_connect_the_dots.rst

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ through `self`. If field values are modified, the changes are automatically refl
581581
.. example::
582582
In the following example, onchange methods are implemented to:
583583

584-
- unpublish products when all sellers are removed;
584+
- unpublish products when all suppliers are removed;
585585
- warn the user if changing the sales price would result in a negative margin;
586586
- raise a blocking user error if the category is changed after sales have been made.
587587

@@ -594,9 +594,9 @@ through `self`. If field values are modified, the changes are automatically refl
594594
class Product(models.Model):
595595
is_published = fields.Boolean(string="Published")
596596
597-
@api.onchange('seller_ids')
598-
def _onchange_seller_ids_unpublish_if_no_sellers(self):
599-
if not self.seller_ids:
597+
@api.onchange('supplier_ids')
598+
def _onchange_supplier_ids_unpublish_if_no_suppliers(self):
599+
if not self.supplier_ids:
600600
self.is_published = False
601601
602602
@api.onchange('price')
@@ -1183,7 +1183,7 @@ action, add a `button` element to the view, with its `type` attribute set to `ac
11831183

11841184
.. code-block:: xml
11851185
1186-
<record id="view_similar_products_action" model="ir.actions.act_window">
1186+
<record id="product.view_similar_products_action" model="ir.actions.act_window">
11871187
<field name="name">Products</field>
11881188
<field name="res_model">product</field>
11891189
<field name="domain">
@@ -1192,7 +1192,7 @@ action, add a `button` element to the view, with its `type` attribute set to `ac
11921192
<field name="view_mode">list,form</field>
11931193
</record>
11941194
1195-
<record id="product_form" model="ir.ui.view">
1195+
<record id="product.product_form" model="ir.ui.view">
11961196
<form>
11971197
<sheet>
11981198
<div name="button_box">
@@ -1490,11 +1490,11 @@ desired business logic. Creating a scheduled action is simply a matter of adding
14901490

14911491
.. example::
14921492
The following example implements a scheduled action that automatically reassigns inactive
1493-
products or products without sellers to the default seller.
1493+
products or products without suppliers to the default supplier.
14941494

14951495
.. code-block:: xml
14961496
1497-
<record id="reassign_inactive_products_cron" model="ir.cron">
1497+
<record id="product.reassign_inactive_products_cron" model="ir.cron">
14981498
<field name="name">Reassign Inactive Products</field>
14991499
<field name="model_id" ref="model_product"/>
15001500
<field name="code">model._reassign_inactive_products()</field>
@@ -1504,27 +1504,27 @@ desired business logic. Creating a scheduled action is simply a matter of adding
15041504
15051505
.. code-block:: python
15061506
1507-
from odoo import api, models
1508-
from odoo.fields import Command
1507+
from odoo import api, models
1508+
from odoo.fields import Command
15091509
15101510
1511-
class Product(models.Model):
1511+
class Product(models.Model):
15121512
1513-
@api.model
1514-
def _reassign_inactive_products(self):
1515-
# Clear sellers from underperfoming products.
1516-
underperforming_products = self.search([('sales_count', '<', 10)])
1517-
underperforming_products.write({
1518-
'seller_ids': [Command.clear()], # Remove all sellers.
1519-
})
1513+
@api.model
1514+
def _reassign_inactive_products(self):
1515+
# Clear suppliers from underperfoming products.
1516+
underperforming_products = self.search([('sales_count', '<', 10)])
1517+
underperforming_products.write({
1518+
'supplier_ids': [Command.clear()], # Remove all suppliers.
1519+
})
15201520
1521-
# Assign the default seller to products without sellers.
1522-
products_without_sellers = self.search([('seller_ids', '=', False)])
1523-
if products_without_sellers:
1524-
default_seller = self.env.ref('product.default_seller')
1525-
products_without_sellers.write({
1526-
'seller_ids': [Command.set(default_seller.ids)] # Replace with default seller.
1527-
})
1521+
# Assign the default supplier to products without suppliers.
1522+
products_without_suppliers = self.search([('supplier_ids', '=', False)])
1523+
if products_without_suppliers:
1524+
default_supplier = self.env.ref('product.default_supplier')
1525+
products_without_suppliers.write({
1526+
'supplier_ids': [Command.set(default_supplier.ids)] # Replace with default supplier.
1527+
})
15281528
15291529
.. note::
15301530
- The cron is scheduled to run weekly thanks to `interval_number=1` and

0 commit comments

Comments
 (0)
0