Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2360 Lượt xem

This is the Repair app. Odoo V14, but I think it happens also in subsequent versions.

When creating a repair order.

There is a tab that is called "Parts". It's a list. If I click to "Add a line", the second column is the product, which I enter. There is a column called "source location", and I have a default location "Warehouse A". The parts for repairs are always taken from another location called "Repair Parts Location".

There is also a "Dest. location". It has "Production" as location. I also want to change this default location.

How can I change these two default locations?

I have tried Studio but it's not clear how to change these locations.

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Create an automated action to update field

The destiation location is 'Production' as the part is being consumed during the repair. You might want to ensure that your destination location Type is set as 'Production'

When parts are removed during repair source location is production and destination location is scrap (Inventory loss)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

There is an onchange function (onchange_operation_type) in Addons, which change the Source location and Destination Location when changing the field type. You can override this function to set the default values.@api.onchange('type')
    def onchange_operation_type(self):
        """ On change of operation type it sets source location, destination location
        and to invoice field.
        @param product: Changed operation type.
        @param guarantee_limit: Guarantee limit of current record.
        @return: Dictionary of values.
        """
        if not self.type:
            self.location_id = False
            self.location_dest_id = False
        elif self.type == 'add':
            self.onchange_product_id()
            args = self.repair_id.company_id and [('company_id', '=', self.repair_id.company_id.id)] or []
            warehouse = self.env['stock.warehouse'].search(args, limit=1)
            self.location_id = < Desired location you prefer>
            self.location_dest_id = < Desired location you prefer>
        else:
            self.price_unit = 0.0
            self.tax_id = False
            self.location_id = < Desired location you prefer>
            self.location_dest_id = < Desired location you prefer>
By overriding this Onchange function, you can simply set the desired location according to you

Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 11 19
9981
1
thg 11 24
4918
1
thg 9 24
1786
1
thg 9 24
1560
2
thg 9 24
2113