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

Thank you very much for your atention, before hand.


How can I copy the value of a computed custom field in the current Sell Order invoice, to the price of one Service present in that invoice? 

This action must be executed every time the invoice is updated. 

Im using Odoo 17 Enterprise.


Thanks again.


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

Hello, I think I can help you! From what I understand the need is to calculate the value of a field in another module. 

I realized that it works like this:


  • Access the module you need to fetch the data
    • Ex. ​x_studio_modulo_x
  • Then access the field within the module
    • Ex. x_studio_modulo_x.campo_do modulo_x​


This way you have access to the fields within another module and can manipulate them according to your needs

In this code below I am looking for a "Line" field within another module and calculating all lines that have the "check" field as true to return a total value of the "value" field. This occurs every time there is an update on the line.


Dependence:
x_studio_module_x, x_studio_module_x.x_studio_fields_module_x

value = 0
for record in self:
​for line in self.x_studio_module_x:
​if line.x_studio_field_check_module_x == True:
​value = value + line.x_studio_field_value_module_x
​​record['x_studio_module_y'] = value



Ảnh đại diện
Huỷ bỏ
Tác giả

Thank very much Weverton.
Im having troubles reading fields from one model to another.

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 9 24
1697
automated action Đã xử lý
1
thg 9 24
1487
0
thg 9 24
22
1
thg 7 25
494
1
thg 12 24
2691