Skip to content

Commit 50d4671

Browse files
committed
[ADD] Chapter 13 sawer
[FIX] style fix for runbot
1 parent f0ba0ef commit 50d4671

File tree

6 files changed

+61
-12
lines changed

6 files changed

+61
-12
lines changed

estate/models/estate_property.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ class EstateProperty(models.Model):
7272
####################################################
7373

7474
def cancel_property_button(self):
75-
for record in self:
76-
if record.state != "sold":
77-
record.state = "canceled"
78-
else:
79-
raise exceptions.UserError("Sold properties cannot be canceled")
75+
self.ensure_one()
76+
if self.state != "sold":
77+
self.state = "canceled"
78+
else:
79+
raise exceptions.UserError("Sold properties cannot be canceled")
8080
return True
8181

8282
def sold_property_button(self):
83-
for record in self:
84-
if record.state != "canceled":
85-
record.state = "sold"
86-
else:
87-
raise exceptions.UserError("Canceled properties cannot be sold")
83+
self.ensure_one()
84+
if self.state != "canceled":
85+
self.state = "sold"
86+
else:
87+
raise exceptions.UserError("Canceled properties cannot be sold")
8888
return True
8989

9090
@api.depends("garden_area", "living_area")

estate/models/users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from odoo import models, fields
22

33

4-
class EstatePropertyOffer(models.Model):
4+
class UsersExtension(models.Model):
55
_inherit = 'res.users'
66

7-
property_ids = fields.One2many("estate.property", "user_id")
7+
property_ids = fields.One2many("estate.property", "user_id", domain=[('state', 'in', ['new', 'offer_received'])])

estate_account/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

estate_account/__manifest__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
'name': "Estate Account",
3+
'depends': [
4+
'base',
5+
'estate',
6+
'account'
7+
],
8+
'data': [
9+
],
10+
'application': False,
11+
'author': "Odoo S.A.",
12+
'license': "LGPL-3",
13+
}

estate_account/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import estate_property
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from odoo import models, Command
2+
3+
4+
class EstatePropertyExtension(models.Model):
5+
_inherit = 'estate.property'
6+
7+
def sold_property_button(self):
8+
""" When an invoice linked to a sales order selling registrations is
9+
paid confirm attendees. Attendees should indeed not be confirmed before
10+
full payment. """
11+
# Set the create function parameters
12+
values = {"partner_id": self.partner_id.id,
13+
"move_type": "out_invoice",
14+
"line_ids": [
15+
Command.create({
16+
"name": self.name,
17+
"quantity": 1,
18+
"price_unit": self.selling_price
19+
}),
20+
Command.create({
21+
"name": r"6% malus for being ugly",
22+
"quantity": 1,
23+
"price_unit": 0.06 * self.selling_price
24+
}),
25+
Command.create({
26+
"name": "Administrative fees",
27+
"quantity": 1,
28+
"price_unit": 100
29+
})
30+
],
31+
}
32+
# Create the invoice
33+
self.env['account.move'].create(values)
34+
return super().sold_property_button()

0 commit comments

Comments
 (0)