Skip to Content
Menu
This question has been flagged

Hi,

I have created some custom fields in stock.quant (settings>>Technicals>>Database>>Model>>stock.quant) and then updated same in edit:view list,  now I can see the custom field but now on updating quantity I am getting something "User Error:  Quant's creation is restricted, you can't do this operation."

Avatar
Discard
Best Answer

In the create method of 'stock.quant' , they define a static list of allowed_fields. (see here)

You need to inherit _get_inventory_fields_write() method and add your custom fields

@api.model
def _get_inventory_fields_write(self):    
    fields = super(StockQuant, self)._get_inventory_fields_write()     
    return fields + ['custom_field1', 'custom_field2', ..]
Avatar
Discard

can you show us how you declarate the module to make this? because when i try

fields = super(StockQuant, self)._get_inventory_fields_write()

it throws me this error 'super' object has no attribute '_get_inventory_fields_write'

additionally I import StockQuant with from odoo.addons.stock.models.stock_quant import StockQuant because i don't find the way to get the model

Sorry for the very late reply !!

StockQuant is just the name of your class where you inherit 'stock.quant', you can call it wherever you want, or you can directly do:

fields = super()._get_inventory_fields_write()

Related Posts Replies Views Activity
3
Sep 24
1269
0
Jan 23
738
1
Mar 20
4398
1
Mar 15
4794
1
Mar 15
5679