mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] wizard button standard & QTY readonly if no access
This commit is contained in:
committed by
Joan Sisquella
parent
9c943b7726
commit
1a9094fa24
@@ -24,6 +24,14 @@ class StockWarehouseOrderpoint(models.Model):
|
||||
compute="_compute_procure_recommended",
|
||||
)
|
||||
|
||||
def _prepare_procurement_values(self, product_qty, date=False,
|
||||
group=False):
|
||||
res = super(StockWarehouseOrderpoint,
|
||||
self)._prepare_procurement_values(product_qty, date=date,
|
||||
group=group)
|
||||
res.update({'qty': product_qty})
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def _get_procure_recommended_qty(self, virtual_qty, op_qtys):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -18,6 +18,7 @@ class MakeProcurementOrderpoint(models.TransientModel):
|
||||
def _prepare_item(self, orderpoint):
|
||||
return {
|
||||
'qty': orderpoint.procure_recommended_qty,
|
||||
'qty_without_security': orderpoint.procure_recommended_qty,
|
||||
'uom_id': orderpoint.product_uom.id,
|
||||
'orderpoint_id': orderpoint.id,
|
||||
'product_id': orderpoint.product_id.id,
|
||||
@@ -25,6 +26,18 @@ class MakeProcurementOrderpoint(models.TransientModel):
|
||||
'location_id': orderpoint.location_id.id
|
||||
}
|
||||
|
||||
@api.model
|
||||
def fields_view_get(self, view_id=None, view_type='form', toolbar=False,
|
||||
submenu=False):
|
||||
if not self.user_has_groups(
|
||||
"stock_orderpoint_manual_procurement.group_change_orderpoint_procure_qty"): # noqa
|
||||
# Redirect to readonly qty form view
|
||||
view_id = self.env.ref(
|
||||
'stock_orderpoint_manual_procurement.view_make_procure_without_security').id # noqa
|
||||
return super(MakeProcurementOrderpoint, self).fields_view_get(
|
||||
view_id=view_id, view_type=view_type, toolbar=toolbar,
|
||||
submenu=submenu)
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super(MakeProcurementOrderpoint, self).default_get(fields)
|
||||
@@ -57,7 +70,7 @@ class MakeProcurementOrderpoint(models.TransientModel):
|
||||
try:
|
||||
self.env['procurement.group'].run(
|
||||
item.orderpoint_id.product_id,
|
||||
item.qty,
|
||||
values.get('qty'),
|
||||
item.orderpoint_id.product_uom,
|
||||
item.orderpoint_id.location_id,
|
||||
item.orderpoint_id.name,
|
||||
@@ -68,7 +81,6 @@ class MakeProcurementOrderpoint(models.TransientModel):
|
||||
errors.append(error.name)
|
||||
if errors:
|
||||
raise UserError('\n'.join(errors))
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
||||
@@ -80,7 +92,8 @@ class MakeProcurementOrderpointItem(models.TransientModel):
|
||||
'make.procurement.orderpoint', string='Wizard', required=True,
|
||||
ondelete='cascade', readonly=True)
|
||||
|
||||
qty = fields.Float(string='Quantity', required=True)
|
||||
qty = fields.Float(string='Quantity')
|
||||
qty_without_security = fields.Float(string='Quantity')
|
||||
|
||||
uom_id = fields.Many2one(string='Unit of Measure',
|
||||
comodel_name='product.uom')
|
||||
@@ -104,5 +117,4 @@ class MakeProcurementOrderpointItem(models.TransientModel):
|
||||
def onchange_uom_id(self):
|
||||
for rec in self:
|
||||
rec.qty = rec.orderpoint_id.product_uom._compute_quantity(
|
||||
rec.orderpoint_id.procure_recommended_qty,
|
||||
rec.uom_id)
|
||||
rec.orderpoint_id.procure_recommended_qty, rec.uom_id)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Make Procurement -->
|
||||
|
||||
<!-- Make Procurement with security access right -->
|
||||
<record id="view_make_procurment_buffer_wizard" model="ir.ui.view">
|
||||
<field name="name">Request Procurement</field>
|
||||
<field name="model">make.procurement.orderpoint</field>
|
||||
@@ -21,21 +20,52 @@
|
||||
<field name="warehouse_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="product_id"/>
|
||||
<field name="qty" groups="stock_orderpoint_manual_procurement.group_change_orderpoint_procure_qty"/>
|
||||
<field name="qty"/>
|
||||
<field name="qty_without_security" invisible="1"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="make_procurement" string="Execute"
|
||||
type="object" class="oe_highlight" />
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
<button string="Execute" name="make_procurement" type="object" class="btn-primary"/>
|
||||
<button string="Cancel" class="btn-default" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Make Procurement without security access right -->
|
||||
<record id="view_make_procure_without_security" model="ir.ui.view">
|
||||
<field name="name">Request Procurement</field>
|
||||
<field name="model">make.procurement.orderpoint</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Procurement Request">
|
||||
<p class="oe_gray">
|
||||
Use this assistant to generate a procurement request for this
|
||||
stock buffer. According to the product configuration,
|
||||
this may trigger a draft purchase order, a manufacturing
|
||||
order or a transfer picking.
|
||||
</p>
|
||||
<group name="items" string="Items">
|
||||
<field name="item_ids" nolabel="1">
|
||||
<tree string="Items" nocreate="1" editable="top">
|
||||
<field name="orderpoint_id" invisible="True"/>
|
||||
<field name="warehouse_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="product_id"/>
|
||||
<field name="qty" invisible="1"/>
|
||||
<field name="qty_without_security" readonly="1"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Execute" name="make_procurement" type="object" class="btn-primary"/>
|
||||
<button string="Cancel" class="btn-default" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window"
|
||||
id="act_make_procurement_from_orderpoint">
|
||||
|
||||
Reference in New Issue
Block a user