Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2367 Widoki

I need to fetch data from two fields from sales module: 

amount_total = fields.Monetary(string="Total", store=True, compute='_compute_amounts', tracking=4)

and 

date_order = fields.Datetime()

Then translate the data to text into another module and display it  "on the fly" in another custom made one (test). And it should be done in one custom module, no additional modules is allowed.

test = fields.Char(string="test", default=lambda x: random.randint(1, 10), states=readonly_fields_states)

This sounds trivial but i have no idea how to achive this.

Awatar
Odrzuć

you can use related field concept into third module.

Najlepsza odpowiedź

Hi,

We will use compute method for setting the value to the field, At first we need to fetch the sale order that we want to get the amount_total and date order from, to do that we will use the 'search' method and specify the domain for the record,

Try this code in the custom module:

test = fields.Char(compute='compute_test')

def compute_test(self):
"""Enter your domain in place of 'your_domain' """
for rec in self:
record = rec.env['sale.order'].search([your_domain])
amount_total = record.amount_total
date_order = record.date_order
rec.test = str(amount_total)+str(date_order)

Regards 

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
lut 21
1985
0
wrz 24
140
5
kwi 16
5384
3
maj 25
881
1
kwi 25
745