Hello, I created some custom actions, most of them to perform actions for multiple objects. On root user everything works fine, but when other users try to perform the actions, they get an Access Error. I tried to manage permissions, but there isn't anything about the custom actions.
As an example, users get the following error when trying to perform an actions for multiple inventory adjustments:
Sorry, you are not allowed to create this kind of document. Please contact your system administrator if you think this is an error.
(Document model: stock.inventory.update.vtex)
The actions has the following view:
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_stock_update_vtex_inventory" model="ir.ui.view">
<field name="name">Atualizar Vtex</field>
<field name="model">stock.inventory.update.vtex</field>
<field name="arch" type="xml">
<form string="Atualizar Vtex">
<p>
Tem certeza de que dejesa atualizar os estoques selecionados?
</p>
<footer>
<button
name="update_vtex"
string="Confirmar"
type="object"
class="btn-primary"
/>
<button string="Cancel" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_view_stock_update_vtex_inventory" model="ir.actions.act_window">
<field name="name">Atualizar Inventário VTEX</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.inventory.update.vtex</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="stock.model_stock_inventory" />
</record>
</odoo>
And the model has the following code:
classUpdateVtexInventory(models.Model):
_name ="stock.inventory.update.vtex"
@api.multi
def update_vtex(self):
inventory_obj =self.env['stock.inventory']
warehouse_obj =self.env['stock.warehouse']
stock_qnt_obj =self.env['stock.quant']
location_obj =self.env['stock.location']
inventories = inventory_obj.browse(self._context.get('active_ids', []))
for inventory in inventories:
location_id = inventory['location_id']
warehouse_id = warehouse_obj.search([('lot_stock_id', '=', location_id.id)])
if warehouse_id['vtex_id']:
for product_line in inventory['line_ids']:
parent_loc = location_obj.search([('name', '=', warehouse_id.code)])
location_id = location_obj.search([('location_id', '=', parent_loc.id)])[0]
quanties = stock_qnt_obj._gather(product_line['product_id'], location_id)
sku = product_line['product_id']['sku']
qty = quanties.quantity - quanties.reserved_quantity
qty =max([qty, 0])
url ='https://logistics.'+self.vtexEnvironment +'.com.br/api/logistics/pvt/inventory/skus/'+str(sku) +'/warehouses/'+str(warehouse_id['vtex_id']) +'?an='+self.vtexAccountName
payload = {
"unlimitedQuantity": False,
"dateUtcOnBalanceSystem": None,
"quantity": int(qty)
}
response = requests.request("PUT", url, data=json.dumps(payload), headers=self.headers)Is there something I am missing, in order to allow other users to perform these actions?