Manage readonly wizard

readonly wizards do not check for write access on the active model.

Closes #13989
This commit is contained in:
Cédric Krier
2025-04-29 09:31:05 +02:00
parent ea26652f45
commit b0f7d45254
14 changed files with 28 additions and 8 deletions
+2
View File
@@ -421,6 +421,7 @@ class Type(
class OpenType(Wizard):
__name__ = 'account.account.open_type'
_readonly = True
start = StateTransition()
account = StateAction('account.act_account_balance_sheet')
ledger_account = StateAction('account.act_account_general_ledger')
@@ -2306,6 +2307,7 @@ class GeneralLedgerAccountParty(_GeneralLedgerAccount):
class OpenGeneralLedgerAccountParty(Wizard):
__name__ = 'account.general_ledger.account.party.open'
start_state = 'open'
_readonly = True
open = StateAction('account.act_general_ledger_line_form')
def do_open(self, action):
-4
View File
@@ -462,10 +462,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="model">account.account.type,-1</field>
<field name="action" ref="act_open_type"/>
</record>
<record model="ir.action-res.group" id="act_open_type_account">
<field name="action" ref="act_open_type"/>
<field name="group" ref="group_account"/>
</record>
<record model="ir.ui.view" id="account_view_tree_chart">
<field name="model">account.account</field>
+2
View File
@@ -1934,6 +1934,7 @@ class OpenJournalAsk(ModelView):
class OpenJournal(Wizard):
__name__ = 'account.move.open_journal'
_readonly = True
start = StateTransition()
ask = StateView('account.move.open_journal.ask',
'account.open_journal_ask_view_form', [
@@ -2003,6 +2004,7 @@ class OpenJournal(Wizard):
class OpenAccount(Wizard):
__name__ = 'account.move.open_account'
start_state = 'open_'
_readonly = True
open_ = StateAction('account.act_move_line_form')
def do_open_(self, action):
+1
View File
@@ -1841,6 +1841,7 @@ class TaxRuleLine(sequence_ordered(), ModelSQL, ModelView, MatchMixin):
class OpenTaxCode(Wizard):
__name__ = 'account.tax.open_code'
start_state = 'open_'
_readonly = True
open_ = StateAction('account.act_tax_line_form')
def do_open_(self, action):
@@ -250,6 +250,7 @@ class MoveLineGroup_MoveLine(ModelSQL):
class OpenAccount(metaclass=PoolMeta):
__name__ = 'account.move.open_account'
_readonly = True
def do_open_(self, action):
pool = Pool()
+1
View File
@@ -273,6 +273,7 @@ class MoveLine(metaclass=PoolMeta):
class OpenAccount(Wizard):
__name__ = 'analytic_account.line.open_account'
start_state = 'open_'
_readonly = True
open_ = StateAction('analytic_account.act_line_form')
def do_open_(self, action):
+1
View File
@@ -318,6 +318,7 @@ class OpenBOMTreeTree(ModelView):
class OpenBOMTree(Wizard):
__name__ = 'production.bom.tree.open'
_readonly = True
start = StateView('production.bom.tree.open.start',
'production.bom_tree_open_start_view_form', [
+1
View File
@@ -673,6 +673,7 @@ class WorkInvoicedProgress(ModelView, ModelSQL):
class OpenInvoice(Wizard):
__name__ = 'project.open_invoice'
start_state = 'open_'
_readonly = True
open_ = StateAction('account_invoice.act_invoice_form')
def do_open_(self, action):
+1
View File
@@ -2564,6 +2564,7 @@ class ModifyHeader(Wizard):
class OpenProduct(Wizard):
__name__ = 'sale.open_product'
_readonly = True
start = StateAction('sale.act_product')
+2
View File
@@ -910,6 +910,7 @@ class RegionTree(ModelSQL, ModelView):
class OpenRegionTree(Wizard):
__name__ = 'sale.reporting.region.tree.open'
_readonly = True
start = StateAction('sale.act_reporting_country_tree')
@@ -1051,6 +1052,7 @@ class CountryTree(UnionMixin, Abstract, ModelView):
class OpenCountryTree(Wizard):
__name__ = 'sale.reporting.country.tree.open'
_readonly = True
start = StateTransition()
country = StateAction('sale.act_reporting_country_time_series')
+2
View File
@@ -576,6 +576,7 @@ class ProductByLocationContext(ModelView):
class OpenProductQuantitiesByWarehouse(Wizard):
__name__ = 'stock.product_quantities_warehouse.open'
start_state = 'open_'
_readonly = True
open_ = StateAction('stock.act_product_quantities_warehouse')
def do_open_(self, action):
@@ -869,6 +870,7 @@ class ProductQuantitiesByWarehouseContext(ModelView):
class OpenProductQuantitiesByWarehouseMove(Wizard):
__name__ = 'stock.product_quantities_warehouse.move.open'
start_state = 'open_'
_readonly = True
open_ = StateAction('stock.act_product_quantities_warehouse_move')
def do_open_(self, action):
+1
View File
@@ -1,3 +1,4 @@
* Manage readonly wizard
* Export Many2One and Reference using record name
* Support import of one2many as list of name
* Support export of xxx2many fields as list of name
+7
View File
@@ -37,6 +37,13 @@ Class attributes are:
deletion of the wizard and it may return one of the :ref:`client side action
keywords <topics-views-client-actions>`.
.. attribute:: Wizard._readonly
A boolean to set :attr:`trytond.transaction.Transaction.readonly` when
executing the wizard.
When set to ``True``, ``write`` access on the ``active_model`` is not
needed.
.. attribute:: Wizard.__rpc__
Same as :attr:`trytond.model.Model.__rpc__`.
+6 -4
View File
@@ -198,6 +198,7 @@ class Wizard(URLMixin, PoolBase):
__no_slots__ = True # To allow setting State
start_state = 'start'
end_state = 'end'
_readonly = False
@classmethod
def __setup__(cls):
@@ -205,7 +206,7 @@ class Wizard(URLMixin, PoolBase):
cls.__rpc__ = {
'create': RPC(readonly=False),
'delete': RPC(readonly=False),
'execute': RPC(readonly=False, check_access=False),
'execute': RPC(readonly=cls._readonly, check_access=False),
}
# Copy states
@@ -248,9 +249,10 @@ class Wizard(URLMixin, PoolBase):
ActionWizard = pool.get('ir.action.wizard')
User = pool.get('res.user')
Group = pool.get('res.group')
context = Transaction().context
transaction = Transaction()
context = transaction.context
if Transaction().user == 0:
if transaction.user == 0:
return
with check_access():
@@ -284,7 +286,7 @@ class Wizard(URLMixin, PoolBase):
gettext(
'ir.msg_context_groups',
groups=', '.join(g.rec_name for g in groups)))
elif model and model != 'ir.ui.menu':
elif model and model != 'ir.ui.menu' and not transaction.readonly:
if (not callable(getattr(Model, 'table_query', None))
or Model.write.__func__ != ModelSQL.write.__func__):
ModelAccess.check(model, 'write')