|
1 | | -from datetime import timedelta |
2 | | -from os import read |
3 | | -from odoo.tools import date_utils |
4 | | - |
| 1 | +from datetime import timedelta |
| 2 | + |
5 | 3 | from odoo import models, fields, api |
6 | 4 | from odoo.exceptions import ValidationError |
7 | 5 | from odoo.tools.float_utils import float_compare, float_is_zero |
@@ -76,30 +74,30 @@ def _compute_date_deadline(self): |
76 | 74 | if hasattr(create_date, "date"): |
77 | 75 | create_date = create_date.date() |
78 | 76 | record.date_deadline = create_date + timedelta(days=record.validity_days) |
79 | | - |
| 77 | + |
80 | 78 | def _inverse_date_deadline(self): |
81 | 79 | for record in self: |
82 | 80 | create_date = record.create_date or fields.Date.today() |
83 | 81 | if hasattr(create_date, "date"): |
84 | 82 | create_date = create_date.date() |
85 | 83 | delta = (record.date_deadline - create_date).days if record.date_deadline else 0 |
86 | 84 | record.validity_days = delta |
87 | | - |
| 85 | + |
88 | 86 | @api.constrains('selling_price', 'expected_price') |
89 | 87 | def _check_selling_price(self): |
90 | 88 | for record in self: |
91 | 89 | if not float_is_zero(record.selling_price, precision_digits=2): |
92 | 90 | if float_compare(record.selling_price, 0.9 * record.expected_price, precision_digits=2) < 0: |
93 | 91 | raise ValidationError("The selling price cannot be lower than 90% of the expected price.") |
94 | | - |
| 92 | + |
95 | 93 | @api.onchange("garden") |
96 | 94 | def _onchange_garden(self): |
97 | | - if self.garden: |
98 | | - self.garden_area = 10 |
99 | | - self.garden_orientation = "north" |
100 | | - else: |
101 | | - self.garden_area = 0 |
102 | | - self.garden_orientation = False |
| 95 | + if self.garden: |
| 96 | + self.garden_area = 10 |
| 97 | + self.garden_orientation = "north" |
| 98 | + else: |
| 99 | + self.garden_area = 0 |
| 100 | + self.garden_orientation = False |
103 | 101 |
|
104 | 102 | @api.model |
105 | 103 | def create(self, vals): |
|
0 commit comments