콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

Hello,


I created a custom (many to one) field in the BOM > Work Order > Operation. When I create a manufacturing order and select a BOM, the value in that custom field must automatically appear just like the other operation details.


I know I need to create a python code on form modification, but I cant figure out the python code.


Thank you to anyone who will answer!





아바타
취소

As you are using odoo online, you can write an onchange function from the user interface using the automated action, see: https://www.youtube.com/watch?v=psQF5jOrd48

작성자

Thank you! The video is helpful. I just dont understand which model I should reference to because the custom field is inside the operation line of the BOM?

you have to specify the main model, were the field exists

작성자

The new field is stored in Work Center Usage. I created the automated action:
Model : Work Order
Trigger Field: Operation (Work Order) (operation_id)
Data to write: New field (Work Order) = record.operation_id.x_studio_newfield

Its still wrong, how do I call the Work Center Usage model?

베스트 답변

Hi ,

You can create related field bom_id.your m2o field


아바타
취소
작성자

Hello! Using a related field will make it uneditable. I want to have the flexibility to change it if needed, just like the work center.

베스트 답변

Hi,

Create a onchange function in the manufacturing order model based on the bom field.

For an example

@api.onchange('bom')
def get_changing_value(self):
    if self.bom:
     value = self.bom.need_value
     self.field = value

Regards

아바타
취소
작성자

Hello thank you! We're using SaaS tho, so the coding is a bit different?

관련 게시물 답글 화면 활동
1
5월 23
3543
1
1월 23
2386
2
12월 20
3196
1
5월 22
1726
4
12월 23
7570