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

I need to know how to put on a production order, an stock location by default that I've created, I see the use of "_src_id_default" function, but I don't know how to add the second parameter (xml_id) of "get_object_reference" function, any solution?

Greetings

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

Hi,

One option is to override the "_src_id_default" function, to get your desired location as default source location.

For that you just need to redefine the field and function in your custom module python file. Just put the following code in your .py file. Replace the search term by your location name. Hope you are working in v8.

class mrp_production(models.Model):
_inherit = 'mrp.production'


def _src_id_default(self):

location_id = self.env['stock.location'].search([('name', '=', 'My Location')])
if location_id.id:
return location_id.id
else:
return False

location_src_id = fields.Many2one('stock.location', string = 'Raw Materials Location', required=True,
readonly=True, states={'draft': [('readonly', False)]},
help="Location where the system will look for components.", default=_src_id_default)
Ảnh đại diện
Huỷ bỏ
Tác giả

thanks Akhil, I have tried the solution and it is working perfectly.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 11 24
1167
0
thg 7 23
4436
2
thg 9 22
2472
0
thg 12 21
1621
1
thg 12 21
3539