Skip to content

Commit

Permalink
Merge pull request #1885 from VoicuStefan2001/17.0
Browse files Browse the repository at this point in the history
[17.0][UPD] record_type confirmation rights
  • Loading branch information
VoicuStefan2001 authored Jan 17, 2025
2 parents 0fd76c6 + 0594916 commit 92fdbc2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 36 deletions.
2 changes: 1 addition & 1 deletion deltatech_record_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Terrabit - Record Type",
"summary": "Manage multiple record types",
"version": "17.0.1.1.1",
"version": "17.0.1.1.2",
"author": "Terrabit, Voicu Stefan",
"website": "https://www.terrabit.ro",
"category": "Generic Modules/Other",
Expand Down
28 changes: 11 additions & 17 deletions deltatech_record_type/i18n/ro.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-17 13:47+0000\n"
"PO-Revision-Date: 2025-01-17 13:47+0000\n"
"POT-Creation-Date: 2025-01-17 20:25+0000\n"
"PO-Revision-Date: 2025-01-17 20:25+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -26,9 +26,9 @@ msgid "Boolean"
msgstr ""

#. module: deltatech_record_type
#: model:res.groups,name:deltatech_record_type.group_create_order_without_record_type
msgid "Can Create Orders Without Record Type"
msgstr "Poate crea comenzi fără tip comandă"
#: model:res.groups,name:deltatech_record_type.group_confirm_order_without_record_type
msgid "Can Confirm Orders Without Record Type"
msgstr "Poate confirma comenzi fără tip comandă"

#. module: deltatech_record_type
#: model:ir.model.fields.selection,name:deltatech_record_type.selection__record_type_default_values__field_type__char
Expand Down Expand Up @@ -132,7 +132,7 @@ msgstr "Tipuri comandă"
#: model:ir.model,name:deltatech_record_type.model_purchase_order
#: model:ir.model.fields.selection,name:deltatech_record_type.selection__record_type__model__purchase_order
msgid "Purchase Order"
msgstr "Comandă de achiziție"
msgstr "Comandă achiziție"

#. module: deltatech_record_type
#: model:ir.model,name:deltatech_record_type.model_record_type
Expand All @@ -154,7 +154,7 @@ msgstr ""
#. module: deltatech_record_type
#: model:ir.model.fields.selection,name:deltatech_record_type.selection__record_type__model__sale_order
msgid "Sale Order"
msgstr "Comandă de vânzare"
msgstr "Comandă vânzare"

#. module: deltatech_record_type
#: model:ir.model,name:deltatech_record_type.model_record_type_default_values
Expand All @@ -164,21 +164,15 @@ msgstr "Valori implicite tip comandă de vânzare"
#. module: deltatech_record_type
#: model:ir.model,name:deltatech_record_type.model_sale_order
msgid "Sales Order"
msgstr "Comandă de vânzare"
msgstr "Comandă vânzare"

#. module: deltatech_record_type
#. odoo-python
#: code:addons/deltatech_record_type/models/sale.py:0
#, python-format
msgid ""
"You do not have the rights to create an order without specifying an Order "
"You do not have the rights to confirm an order without specifying an Order "
"Type."
msgstr ""
"Nu aveți drepturi pentru a crea o comandă fără a specifica un Tip comanda"

#. module: deltatech_record_type
#. odoo-python
#: code:addons/deltatech_record_type/models/sale.py:0
#, python-format
msgid "You do not have the rights to remove the Order Type from an order."
msgstr "Nu aveți drepturi pentru a elimina tipul de comandă dintr-o comandă"
"Nu aveți drepturi pentru a confirma o comandă fără a specifica un tip de "
"comandă."
20 changes: 6 additions & 14 deletions deltatech_record_type/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@ class SaleOrder(models.Model):

so_type = fields.Many2one("record.type", string="Order Type", tracking=True)

@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if not self.env.user.has_group("deltatech_record_type.group_create_order_without_record_type"):
if not vals.get("so_type"):
def action_confirm(self):
for order in self:
if not self.env.user.has_group("deltatech_record_type.group_confirm_order_without_record_type"):
if not order.so_type:
raise exceptions.UserError(
_("You do not have the rights to create an order without specifying an Order Type.")
_("You do not have the rights to confirm an order without specifying an Order Type.")
)
return super().create(vals_list)

def write(self, vals):
for order in self:
if not self.env.user.has_group("deltatech_record_type.group_create_order_without_record_type"):
if "so_type" not in vals and not order.so_type:
raise exceptions.UserError(_("You do not have the rights to remove the Order Type from an order."))
return super().write(vals)
return super().action_confirm()

@api.onchange("so_type")
def _onchange_so_type(self):
Expand Down
11 changes: 7 additions & 4 deletions deltatech_record_type/security/record_type_security.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="group_create_order_without_record_type" model="res.groups">
<field name="name">Can Create Orders Without Record Type</field>
<odoo>
<record id="group_confirm_order_without_record_type" model="res.groups">
<field name="name">Can Confirm Orders Without Record Type</field>
<field name="category_id" ref="base.module_category_hidden" />
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]" />
<field
name="users"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin')), (4, ref('base.group_user'))]"
/>
</record>

</odoo>

0 comments on commit 92fdbc2

Please sign in to comment.