Odoo 도움말


2 응답

Paresh Wagh India

--Paresh Wagh--

| 4 2 5
Navi Mumbai, India
--Paresh Wagh--
Paresh Wagh India
19. 7. 16. 오전 8:09

Hi Thomas:

You can define the default value for x_break as follows:

  • Activate developer mode.

  • Go to the view/form where you have added the field.

  • Click on create to open a blank record and type 0.75 into the field.

  • Go into "Open Developer Tools" (the bug symbol at the top right of the screen) and choose "Set Defaults". Select "<name of x_break> = 0.75" and "All users" and click on "Save Default". This will save 0.75 as the default value for all users.

For the second step (assuming you have added another field called x_netto_hours), you can set the following in the Advanced Settings section of the field:

  • Dependencies: worked_hours,x_break

  • Compute:

for record in self:
    if record['worked_hours'] and record['x_break']:
        record['x_netto_hours'] = record['worked_hours'] - record['x_break']

Thomas Blum Germany
19. 7. 16. 오전 9:02

Hi Paresh,

thank you very much for your quick answer. Setting the default value for the break works like a charm :)

But calculating the diff_hours gives this error when saving the model:

ValueError: <class 'AttributeError'>: "'hr.attendance' object has no attribute 'get'" while evaluating"for record in self:\n    record['x_netto_hours'] = record.get('worked_hours',0) - record.get('x_break',0)\n"

I've made a screenshot of the field definition, you can see it here: https://ibb.co/FsjcHxT

Do you have an idea how I can resolve this?

Kind regards 


3 의견
Paresh Wagh India
19. 7. 16. 오전 9:08

Try removing the space between the comma and x_break in "Dependencies".

Paresh Wagh India
19. 7. 16. 오전 9:11

I have also updated the code part of the solution since you got an error on the "get".

Thomas Blum Germany
19. 7. 16. 오전 9:17

Wow, Paresh, thank you again, now it works, I'm happy and motivated learning a bit of python, it seems to me, it would not be bad.

Keep Informed
1 팔로워
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now