Skip to content
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

[FIX] default_warehouse_from_sale_team: usability for readonly users T#79454 #1684

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 default_warehouse_from_sale_team/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"views/ir_sequence_views.xml",
"views/res_users_views.xml",
"views/stock_picking_type_views.xml",
"views/stock_picking_views.xml",
"security/res_groups_security.xml",
"security/ir_rule_security.xml",
],
Expand Down
17 changes: 16 additions & 1 deletion default_warehouse_from_sale_team/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
from odoo import fields, models
from odoo import api, fields, models


class StockPicking(models.Model):
_name = "stock.picking"
_inherit = ["default.warehouse.mixin", "stock.picking"]

warehouse_id = fields.Many2one(related="picking_type_id.warehouse_id")
is_editable = fields.Boolean(compute="_compute_is_editable")

@api.depends_context("uid")
def _compute_is_editable(self):
# Using intersection operator to keep original env
editable_records = self & self._filter_access_rules_python("write")
editable_records.is_editable = True
(self - editable_records).is_editable = False

@api.depends("is_editable")
def _compute_show_check_availability(self):
res = super()._compute_show_check_availability()
non_editable = self - self.filtered("is_editable")
non_editable.show_check_availability = False
return res
30 changes: 30 additions & 0 deletions default_warehouse_from_sale_team/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>

<record id="view_picking_form" model="ir.ui.view">
<field name="name">stock.picking.form.inherit.default.warehouse</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<field name="show_reserved" position="after">
<field name="is_editable" invisible="True" />
</field>
<button name="action_confirm" position="attributes">
<attribute name="invisible" add="not is_editable" separator=" or " />
</button>
<xpath expr="//button[@name='button_validate' and contains(@invisible, 'draft')]" position="attributes">
<attribute name="invisible" add="not is_editable" separator=" or " />
</xpath>
<xpath expr="//button[@name='button_validate' and contains(@invisible, 'waiting')]" position="attributes">
<attribute name="invisible" add="not is_editable" separator=" or " />
</xpath>
<button name="do_print_picking" position="attributes">
<attribute name="invisible" add="not is_editable" separator=" or " />
</button>
<button name="%(stock.act_stock_return_picking)d" position="attributes">
<attribute name="invisible" add="not is_editable" separator=" or " />
</button>
</field>
</record>

</odoo>
Loading