I'm trying to set the default value of
warehouse_ids in sale.order.line model to the value of the default_sales_order_location in the res.user modell
else it will be the value of the warehouse of the product that is selected in order line
but it doesn't work
the code:
from odoo import models , fields,api,_
class SaleOrder(models.Model):
_inherit = 'sale.order'
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
warehouse_ids = fields.Many2one('stock.warehouse',string="Warehouse " ,default=lambda self: self.default_warehouse())
def default_warehouse(self):
if self.env.user.default_sales_order_location:
return self.env.user.default_sales_order_location
else:
return super.product_id.warehouse_ids
class ProductTemplate(models.Model):
_inherit = 'product.template'
warehouse_ids = fields.Many2one('stock.warehouse', string="Default Warehouse location ")
class ProductProduct(models.Model):
_inherit = 'product.product'
warehouse_ids = fields.Many2one('stock.warehouse',string="Default Warehouse location ")
class ResUsers(models.Model):
_inherit = 'res.users'
default_sales_order_location=fields.Many2one('stock.warehouse',string="Default_Sale_Order_Location ")
1- IF THE USER HAVE DEFUALT SALES ORDER LOCATION ALL THE ITEMS IN SALES LINE WILL DELIVER FROM THAT LOCATION .
2- IF THE USER NOT HAVE DEFULAT SALES ORDER LOCATION EACH ITEM IN SALES KINE WILL GET THE DELIVER LOCATION FROM THE PRODUCT SALES LOCATION.