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

Hello,


I would like to add a field in the product form that defauld uses the sales price and the costprice to calculate the margin. However only when the salesprice and the costprice are set (>0). In that case the Margin field should be read only. So far so good. I got that far by setting the next script:

for record in self:
if record['list_price'] > 0 and record['standard_price']>0: 
record['x_studio_marge'] = (record['list_price'] - record['standard_price']) / record['standard_price']

However next I also want to be able to compute the sales price if the margin and the costprice are set. In which case the salesprice should be readonly and the margin should be writeable. This so users can deside if the salesprice should be fixed or the margin.

Like this:

for record in self:    
if record['x_studio_marge'] > 0 and record['standard_price']>0:
  record['list_price'] = record['standard_price'] * (1 + record['x_studio_marge'])

However when I try to remove the readonly check box from my new margin field. Odoo places it back. When I try to add a filter to the readonly property of the Margin field I get an error:

Error on validating view near:


                
Field 'standard_price' used in attrs ({"readonly": ["&",["list_price",">",0],["standard_price",">",0]]}) is restricted to the group(s) base.group_user.

Is what I want possible in Odoo studio or is backend editing mandotary in this case?

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
kwi 20
2565
1
mar 18
6371
2
cze 23
4532
1
cze 25
15237
1
lip 25
1165