In Odoo 15, you can pass a value from a custom field in the stock.move.line model to the stock.quant model by using the create() method of the stock.quant model and setting the value of the custom field as an argument.
Here's an example of how you might do this:
Copy code
# Import the necessary models
from odoo import models, fields
class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
# Add a custom field
custom_field = fields.Char(string='Custom Field')
class StockQuant(models.Model):
_inherit = 'stock.quant'
# Add a field to receive the value of the custom field
custom_field_value = fields.Char(string='Custom Field Value')
def create(self, vals):
# Set the value of the custom field
vals['custom_field_value'] = vals['custom_field']
return super(StockQuant, self).create(vals)
In this example, we have added a custom field custom_field to the stock.move.line model and a field custom_field_value to the stock.quant model to receive the value of the custom field. We have also overridden the create() method of the stock.quant model to set the value of custom_field_value to the value of custom_field when creating a new stock.quant record.
I hope this helps! Let me know if you have any other questions