[IMP] stock_dropshipping: move group inside the view
The goal being to get rid of the `groups_id` feature for backend views Besides, in this case, overriding `_compute_product_updatable` is actually what is already done in other modules to achieve the same goal: - https://github.com/odoo/odoo/blob/7b56fc4c7197e6dc2d7a46093c9abcb1b851db3a/addons/sale/models/sale_order_line.py#L852 - https://github.com/odoo/odoo/blob/7b56fc4c7197e6dc2d7a46093c9abcb1b851db3a/addons/sale_project/models/sale_order_line.py#L53 - https://github.com/odoo/odoo/blob/7b56fc4c7197e6dc2d7a46093c9abcb1b851db3a/addons/sale_stock/models/sale_order_line.py#L211 Part-of: odoo/odoo#98551
This commit is contained in:
@@ -49,3 +49,11 @@ class SaleOrderLine(models.Model):
|
||||
return qty
|
||||
else:
|
||||
return super(SaleOrderLine, self)._get_qty_procurement(previous_product_uom_qty=previous_product_uom_qty)
|
||||
|
||||
@api.depends('purchase_line_count')
|
||||
def _compute_product_updatable(self):
|
||||
super()._compute_product_updatable()
|
||||
if self.env.user.has_group('purchase.group_purchase_user'):
|
||||
for line in self:
|
||||
if line.purchase_line_count > 0:
|
||||
line.product_updatable = False
|
||||
|
||||
@@ -5,28 +5,17 @@
|
||||
<field name="name">sale.order.form.sale.dropshipping</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page/field[@name='order_line']/form//field[@name='product_updatable']" position="after">
|
||||
<field name="purchase_line_count" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//page/field[@name='order_line']/form//field[@name='product_id']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['|', ('product_updatable', '=', False), ('purchase_line_count', '>', 0)], 'required': [('display_type', '=', False)],}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//page/field[@name='order_line']/tree/field[@name='product_updatable']" position="after">
|
||||
<field name="purchase_line_count" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//page/field[@name='order_line']/tree/field[@name='product_id']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['|', ('product_updatable', '=', False), ('purchase_line_count', '>', 0)], 'required': [('display_type', '=', False)],}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='action_view_delivery']" position="before">
|
||||
<button type="object"
|
||||
name="action_view_dropship"
|
||||
class="oe_stat_button"
|
||||
icon="fa-truck"
|
||||
attrs="{'invisible': [('dropship_picking_count', '=', 0)]}" groups="stock.group_stock_user">
|
||||
<field name="dropship_picking_count" widget="statinfo" string="Dropship"/>
|
||||
</button>
|
||||
<t groups="purchase.group_purchase_user">
|
||||
<button type="object"
|
||||
name="action_view_dropship"
|
||||
class="oe_stat_button"
|
||||
icon="fa-truck"
|
||||
attrs="{'invisible': [('dropship_picking_count', '=', 0)]}" groups="stock.group_stock_user">
|
||||
<field name="dropship_picking_count" widget="statinfo" string="Dropship"/>
|
||||
</button>
|
||||
</t>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user