Compare commits

...

2 Commits

Author SHA1 Message Date
Kevin.roche
6416957ad1 [IMP] sale_usability: access to sale orders from invoice view 2021-10-21 16:16:43 +02:00
clementmbr
05374c4b4a [FIX] mrp_usability: button action for BoMs needs _for_xml_id()
Avoiding blocking access for users without Admin rigts
2021-10-11 22:16:59 +02:00
2 changed files with 29 additions and 23 deletions

View File

@@ -12,16 +12,20 @@ class ProductTemplate(models.Model):
only one BoM form or a list of BoMs."""
self.ensure_one()
if self.bom_count == 1:
action = self.env.ref("mrp.mrp_bom_form_action").read()[0]
action_xml_id = "mrp.mrp_bom_form_action"
action = self.env["ir.actions.actions"]._for_xml_id(action_xml_id)
bom = self.env["mrp.bom"].search([("product_tmpl_id", "=", self.id)])
action.update({
action.update(
{
"context": {"default_product_tmpl_id": self.id},
"views": False,
"view_mode": "form,tree",
"res_id": bom.id,
})
}
)
else:
action = self.env.ref("mrp.template_open_bom").read()[0]
action_xml_id = "mrp.template_open_bom"
action = self.env["ir.actions.actions"]._for_xml_id(action_xml_id)
return action
@@ -32,9 +36,11 @@ class ProductProduct(models.Model):
action = super().action_view_bom()
bom_target_ids = self.env["mrp.bom"].search(action["domain"])
if len(bom_target_ids) == 1:
action.update({
action.update(
{
"views": False,
"view_mode": "form,tree",
"res_id": bom_target_ids[0].id,
})
}
)
return action

View File

@@ -7,24 +7,24 @@
<odoo>
<!--
<record id="account_invoice_form" model="ir.ui.view">
<field name="name">sale_usability.customer.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="sale.account_invoice_form"/>
<field name="model">account.move</field>
<field name="inherit_id" ref="sale.account_invoice_form" />
<field name="groups_id" eval="[(4, ref('sales_team.group_sale_manager'))]" />
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button name="show_sale_orders"
<button
name="show_sale_orders"
type="object"
class="oe_stat_button"
icon="fa-pencil-square-o"
attrs="{'invisible': [('sale_count', '=', 0)]}">
<field name="sale_count" widget="statinfo" string="Sale Orders"/>
<field name="sale_count" widget="statinfo" string="Sale Orders" />
</button>
</div>
</field>
</record>
-->
<record id="view_move_form" model="ir.ui.view">
<field name="name">sale_usability.account.move.form</field>