- hello world
+
+
+
+
+
+
+
+
+
+
+
+
+ Sum:
+
+
diff --git a/awesome_owl/static/src/todo/TodoItem.js b/awesome_owl/static/src/todo/TodoItem.js
new file mode 100644
index 00000000000..e25db7ed27d
--- /dev/null
+++ b/awesome_owl/static/src/todo/TodoItem.js
@@ -0,0 +1,30 @@
+import { Component } from "@odoo/owl";
+
+export class TodoItem extends Component{
+ static template = "awesome_owl.TodoItem"
+
+ static props = {
+ todo: {
+ type: Object,
+ shape: {
+ id: Number,
+ description: String,
+ isCompleted: Boolean,
+ },
+ },
+ onChange: {
+ type: Function,
+ },
+ onRemove: {
+ type: Function,
+ },
+ }
+
+ change(){
+ this.props.onChange();
+ }
+
+ remove(){
+ this.props.onRemove();
+ }
+};
\ No newline at end of file
diff --git a/awesome_owl/static/src/todo/TodoItem.xml b/awesome_owl/static/src/todo/TodoItem.xml
new file mode 100644
index 00000000000..6fecadaa685
--- /dev/null
+++ b/awesome_owl/static/src/todo/TodoItem.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/todo/TodoList.js b/awesome_owl/static/src/todo/TodoList.js
new file mode 100644
index 00000000000..5003944b9c3
--- /dev/null
+++ b/awesome_owl/static/src/todo/TodoList.js
@@ -0,0 +1,39 @@
+import { Component, useState } from "@odoo/owl";
+import { TodoItem } from "./TodoItem";
+import { useAutofocus } from "../utils";
+
+export class TodoList extends Component{
+ static template = "awesome_owl.TodoList"
+
+ static components = { TodoItem }
+
+ setup(){
+ this.todoItems = useState([]);
+ this.nextId = 0;
+ useAutofocus("todoInput");
+ }
+
+ addTodo(event){
+ if(event.keyCode === 13){
+ const description = event.target.value.trim();
+ if(description.length){
+ this.todoItems.push({id: this.nextId++, description: description, isCompleted: false})
+ event.target.value = ""
+ }
+ }
+ }
+
+ toggleState(todoId){
+ const todo = this.todoItems.find(item => item.id === todoId);
+
+ todo.isCompleted = !todo.isCompleted;
+ }
+
+ removeTodo(todoId) {
+ const index = this.todoItems.findIndex(todo => todo.id === todoId);
+
+ if (index >= 0) {
+ this.todoItems.splice(index, 1);
+ }
+ }
+};
\ No newline at end of file
diff --git a/awesome_owl/static/src/todo/TodoList.xml b/awesome_owl/static/src/todo/TodoList.xml
new file mode 100644
index 00000000000..46a070cec41
--- /dev/null
+++ b/awesome_owl/static/src/todo/TodoList.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js
new file mode 100644
index 00000000000..df2c2f0cfe1
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,9 @@
+import { useRef, useEffect } from "@odoo/owl"
+
+export function useAutofocus(name){
+ let ref = useRef(name);
+ useEffect (
+ (el) => el & el.focus(),
+ () => [ref.el]
+ )
+}
\ No newline at end of file
diff --git a/awesome_owl/views/templates.xml b/awesome_owl/views/templates.xml
index aa54c1a7241..3df6b44bd5b 100644
--- a/awesome_owl/views/templates.xml
+++ b/awesome_owl/views/templates.xml
@@ -5,6 +5,7 @@
+
diff --git a/estate/__init__.py b/estate/__init__.py
new file mode 100644
index 00000000000..0650744f6bc
--- /dev/null
+++ b/estate/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/estate/__manifest__.py b/estate/__manifest__.py
new file mode 100644
index 00000000000..00fbb41cb6b
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,28 @@
+{
+ 'name': 'Real Estate',
+ 'category': 'Real Estate/Brokerage',
+ 'depends': [
+ 'base'
+ ],
+ 'application': True,
+ 'installable': True,
+ 'data': [
+ 'security/security.xml',
+ 'security/ir.model.access.csv',
+
+ 'data/estate.property.type.csv',
+
+ 'views/estate_property_views.xml',
+ 'views/estate_property_offer_views.xml',
+ 'views/estate_property_types_views.xml',
+ 'views/estate_property_tags_views.xml',
+ 'views/res_user_views.xml',
+ 'views/estate_menus.xml',
+ ],
+ 'demo': [
+ 'demo/estate_properties_demo.xml',
+ 'demo/estate_offers_demo.xml',
+ ],
+ 'author': 'Odoo S.A.',
+ 'license': 'AGPL-3'
+}
diff --git a/estate/data/estate.property.type.csv b/estate/data/estate.property.type.csv
new file mode 100644
index 00000000000..ff0886c87f0
--- /dev/null
+++ b/estate/data/estate.property.type.csv
@@ -0,0 +1,5 @@
+id,name,sequence,offer_count,property_ids,offer_ids
+property_type_0,Residential,,,,
+property_type_1,Commercial,,,,
+property_type_2,Industrial,,,,
+property_type_3,Land,,,,
\ No newline at end of file
diff --git a/estate/demo/estate_offers_demo.xml b/estate/demo/estate_offers_demo.xml
new file mode 100644
index 00000000000..98aed901193
--- /dev/null
+++ b/estate/demo/estate_offers_demo.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+ 10000
+ 14
+
+
+
+
+
+ 1500000
+ 14
+
+
+
+
+
+ 1500001
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/demo/estate_properties_demo.xml b/estate/demo/estate_properties_demo.xml
new file mode 100644
index 00000000000..cf04d459359
--- /dev/null
+++ b/estate/demo/estate_properties_demo.xml
@@ -0,0 +1,56 @@
+
+
+
+
+ Big Villa
+ new
+ A nice and big villa
+ 12345
+ 2020-02-02
+ 1600000
+ 6
+ 100
+ 4
+ True
+ True
+ 100000
+ south
+
+
+
+ Trailer home
+ cancelled
+ Home in a trailer park
+ 54321
+ 1970-01-01
+ 100000
+ 120000
+ 1
+ 10
+ 4
+ False
+
+
+
+ Great home
+ new
+ Home in a great place
+ 15243
+ 1998-10-01
+ 150000
+ 4
+ 50
+ 4
+ False
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 00000000000..9a2189b6382
--- /dev/null
+++ b/estate/models/__init__.py
@@ -0,0 +1,5 @@
+from . import estate_property
+from . import estate_property_type
+from . import estate_property_tag
+from . import estate_property_offer
+from . import res_users
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 00000000000..9352e2d9102
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,92 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError, ValidationError
+from odoo.tools import float_is_zero
+
+
+class EstateProperty(models.Model):
+ _name = 'estate.property'
+ _description = "Estate properties"
+ _order = 'id desc'
+
+ name = fields.Char(string='Name', required=True)
+ description = fields.Char(string='Description')
+ postcode = fields.Char(string='Post Code')
+ bedrooms = fields.Integer(string='Bedrooms', default=2)
+ living_area = fields.Integer(string='Living Area')
+ facades = fields.Integer(string='Facades')
+ garden_area = fields.Integer(string='Garden Area')
+ total_area = fields.Integer(string='Total Area', compute='_compute_total_area')
+ expected_price = fields.Float(string='Expected Price', required=True)
+ selling_price = fields.Float(string='Selling Price', readonly=True, copy=False)
+ best_price = fields.Float(string='Best Offer', compute='_compute_best_price')
+ garage = fields.Boolean(string='Garage')
+ garden = fields.Boolean(string='Garden')
+ active = fields.Boolean(string='Active', default=True)
+ date_availability = fields.Date(string='Available From', copy=False, default=lambda x: fields.Date.add(fields.Date.today(), months=3))
+ garden_orientation = fields.Selection(
+ string='Garden Orientation',
+ selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')])
+ state = fields.Selection(
+ string='State',
+ selection=[('new', 'New'), ('offer_received', 'Offer Received'), ('offer_accepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', 'Cancelled')],
+ required=True,
+ copy=False,
+ default='new')
+ property_type_id = fields.Many2one(comodel_name='estate.property.type', string='Type')
+ buyer_id = fields.Many2one(comodel_name='res.partner', string='Buyer')
+ salesman_id = fields.Many2one(comodel_name='res.users', string='Salesman', default=lambda self: self.env.user)
+ company_id = fields.Many2one(comodel_name='res.company', string='Company', required=True, default=lambda self: self.env.company)
+ tag_ids = fields.Many2many(comodel_name='estate.property.tag', string='Tags')
+ offer_ids = fields.One2many(comodel_name='estate.property.offer', inverse_name='property_id', string='Offers')
+
+ _check_name = models.Constraint('UNIQUE(name)', 'Property name must be unique')
+ _check_expected_price = models.Constraint('CHECK(expected_price > 0)', 'Expected price must be positive')
+ _check_selling_price = models.Constraint('CHECK(selling_price >= 0)', 'Selling price cannot be negative')
+ _check_bedrooms = models.Constraint('CHECK(bedrooms >= 0)', 'Bedrooms cannot be negative')
+ _check_living_area = models.Constraint('CHECK(living_area >= 0)', 'Living area cannot be negative')
+ _check_facades = models.Constraint('CHECK(facades >= 0)', 'Facades cannot be negative')
+ _check_garden_area = models.Constraint('CHECK(garden_area >= 0)', 'Garden area cannot be negative')
+
+ @api.constrains('selling_price')
+ def _check_selling_price(self):
+ for record in self:
+ if not float_is_zero(record.selling_price, 2) and record.selling_price < 0.9 * record.expected_price:
+ raise ValidationError("Selling price cannot be lower than 90% of the expected price")
+
+ @api.depends('garden_area', 'living_area')
+ def _compute_total_area(self):
+ for record in self:
+ record.total_area = record.garden_area + record.living_area
+
+ @api.depends('offer_ids')
+ def _compute_best_price(self):
+ for record in self:
+ record.best_price = max(record.offer_ids.mapped('price'), default=0.0)
+
+ @api.onchange('garden')
+ def _onchange_garden(self):
+ for record in self:
+ record.garden_area = (10 if record.garden else 0)
+ record.garden_orientation = ('north' if record.garden else None)
+
+ @api.ondelete(at_uninstall=False)
+ def _property_delete(self):
+ if self.state != 'new' and self.state != 'cancelled':
+ raise UserError("Cannot delete property with a state other than 'New' or 'Cancelled'")
+ self.offer_ids.unlink()
+
+ def action_change_state_to_sold(self):
+ for record in self:
+ if record.state == 'cancelled':
+ raise UserError("This property was already cancelled")
+ if record.state != 'offer_accepted':
+ raise UserError("Please accept an offer before selling the property")
+ record.state = 'sold'
+ return True
+
+ def action_change_state_to_cancelled(self):
+ for record in self:
+ if record.state == 'sold':
+ raise UserError("This property was already sold")
+ record.state = 'cancelled'
+ return True
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..7be19177683
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,69 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+
+
+class EstatePropertyOffer(models.Model):
+ _name = 'estate.property.offer'
+ _description = "An offer placed on some property"
+ _order = 'price desc'
+
+ validity = fields.Integer(string='Validity (days)', default=7)
+ price = fields.Float(string='Price')
+ date_deadline = fields.Date(string='Deadline', compute='_compute_deadline', inverse='_compute_validity')
+ status = fields.Selection(
+ string='Status',
+ selection=[('accepted', 'Accepted'), ('refused', 'Refused')],
+ copy=False
+ )
+ partner_id = fields.Many2one('res.partner', required=True)
+ property_id = fields.Many2one('estate.property', required=True)
+ property_type_id = fields.Many2one(comodel_name='estate.property.type', related='property_id.property_type_id', store=True)
+
+ _check_price = models.Constraint('CHECK(price > 0)', 'Price must be positive')
+
+ @api.depends('validity')
+ def _compute_deadline(self):
+ for record in self:
+ if record.create_date:
+ record.date_deadline = fields.Date.add(record.create_date, days=record.validity)
+
+ def _compute_validity(self):
+ for record in self:
+ if record.create_date and record.date_deadline:
+ record.validity = (record.date_deadline - fields.Date.to_date(record.create_date)).days
+
+ @api.model_create_multi
+ def create(self, vals):
+ for offer in vals:
+ property_id = offer.get('property_id')
+ property = self.env['estate.property'].browse(property_id)
+
+ if offer.get('price') <= max(property.mapped('best_price')):
+ raise UserError("The offer price must be higher than the previous offers")
+ if property.state == 'sold':
+ raise UserError("This property was already sold")
+
+ if property.state == 'new':
+ property.state = 'offer_received'
+ return super().create(vals)
+
+ def action_accept_offer(self):
+ for record in self:
+ if record.status == 'refused':
+ raise UserError("This offer was already refused")
+ if fields.Date.today() > record.date_deadline:
+ raise UserError("This offer has already expired")
+ if record.property_id.buyer_id:
+ raise UserError("An offer has already been accepted")
+ record.property_id.buyer_id = record.partner_id
+ record.property_id.selling_price = record.price
+ record.property_id.state = 'offer_accepted'
+ record.status = 'accepted'
+ return True
+
+ def action_reject_offer(self):
+ for record in self:
+ if record.status == 'accepted':
+ raise UserError("This offer was already accepted")
+ record.status = 'refused'
+ return True
diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py
new file mode 100644
index 00000000000..37e76797896
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,12 @@
+from odoo import fields, models
+
+
+class EstatePropertyTag(models.Model):
+ _name = 'estate.property.tag'
+ _description = "Real estate property tags"
+ _order = 'name'
+
+ name = fields.Char(string='Name', required=True)
+ color = fields.Integer(string='Color')
+
+ _check_name = models.Constraint('UNIQUE(name)', 'Tag name must be unique')
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 00000000000..59aaf992c75
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,20 @@
+from odoo import api, fields, models
+
+
+class EstatePropertyType(models.Model):
+ _name = 'estate.property.type'
+ _description = "The types available for properties/real estates"
+ _order = 'name'
+
+ name = fields.Char(string='Name', required=True)
+ sequence = fields.Integer(string='Sequence', default=1)
+ offer_count = fields.Integer(string='Offers Count', compute='_compute_offer_count')
+ property_ids = fields.One2many(comodel_name='estate.property', inverse_name='property_type_id')
+ offer_ids = fields.One2many(comodel_name='estate.property.offer', inverse_name='property_type_id')
+
+ _check_name = models.Constraint('UNIQUE(name)', 'Property type name must be unique')
+
+ @api.depends('offer_ids')
+ def _compute_offer_count(self):
+ for record in self:
+ record.offer_count = len(record.offer_ids)
diff --git a/estate/models/res_users.py b/estate/models/res_users.py
new file mode 100644
index 00000000000..bd4bd993e60
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,7 @@
+from odoo import fields, models
+
+
+class ResUsers(models.Model):
+ _inherit = 'res.users'
+
+ property_ids = fields.One2many(comodel_name='estate.property', inverse_name='salesman_id', domain=['|', ('state', '=', 'new'), ('state', '=', 'offer_received')])
diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv
new file mode 100644
index 00000000000..3eceb639cf8
--- /dev/null
+++ b/estate/security/ir.model.access.csv
@@ -0,0 +1,9 @@
+id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
+access_estate_property_manager,access_estate_property_user,model_estate_property,estate_group_manager,1,1,1,1
+access_estate_property_agent,access_estate_property_user,model_estate_property,estate_group_user,1,1,1,0
+access_estate_property_type_manager,access_estate_property_type_user,model_estate_property_type,estate_group_manager,1,1,1,1
+access_estate_property_type_agent,access_estate_property_type_user,model_estate_property_type,estate_group_user,1,0,0,0
+access_estate_property_tag_manager,access_estate_property_tag_user,model_estate_property_tag,estate_group_manager,1,1,1,1
+access_estate_property_tag_agent,access_estate_property_tag_user,model_estate_property_tag,estate_group_user,1,0,0,0
+access_estate_property_offer_manager,access_estate_property_offer_user,model_estate_property_offer,estate_group_manager,1,1,1,1
+access_estate_property_offer_agent,access_estate_property_offer_user,model_estate_property_offer,estate_group_user,1,1,1,0
\ No newline at end of file
diff --git a/estate/security/security.xml b/estate/security/security.xml
new file mode 100644
index 00000000000..40b8c07da36
--- /dev/null
+++ b/estate/security/security.xml
@@ -0,0 +1,39 @@
+
+
+
+ Real Estate
+
+
+
+
+ Agent
+
+
+
+
+ Manager
+
+
+
+
+ Limit agents to only see or modify properties with no salesperson assigned
+
+
+ [
+ '|', ('salesman_id', '=', user.id),
+ ('salesman_id', '=', False)
+ ]
+
+
+ Bypass for the managers to see all properties
+
+
+ [(1, '=', 1)]
+
+
+ Limit agents to only see or modify properties with a company that they work for
+
+
+ [('company_id', 'in', company_ids)]
+
+
\ No newline at end of file
diff --git a/estate/tests/__init__.py b/estate/tests/__init__.py
new file mode 100644
index 00000000000..dfd37f0be11
--- /dev/null
+++ b/estate/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_estate
diff --git a/estate/tests/test_estate.py b/estate/tests/test_estate.py
new file mode 100644
index 00000000000..2ddacdbac2c
--- /dev/null
+++ b/estate/tests/test_estate.py
@@ -0,0 +1,51 @@
+from odoo.tests.common import TransactionCase
+from odoo.exceptions import UserError
+from odoo.tests import tagged
+
+
+@tagged('post_install', '-at_install')
+class EstateTestCase(TransactionCase):
+
+ @classmethod
+ def setUpClass(self):
+ super().setUpClass()
+
+ self.properties = self.env['estate.property'].create([
+ {
+ 'name': 'Test Villa',
+ 'expected_price': 15,
+ 'postcode': '12345',
+ 'bedrooms': 3,
+ }
+ ])
+
+ self.offers = self.env['estate.property.offer'].create([
+ {
+ 'partner_id': self.env.ref('base.main_partner').id,
+ 'property_id': self.properties.id,
+ 'price': 14,
+ }
+ ])
+
+ def test_offer_sold_property(self):
+ self.offers.action_accept_offer()
+
+ self.properties.action_change_state_to_sold()
+
+ with self.assertRaises(UserError):
+ self.env['estate.property.offer'].create({
+ 'partner_id': self.env.ref('base.main_partner').id,
+ 'property_id': self.properties.id,
+ 'price': 15,
+ })
+
+ def test_sell_with_no_accept(self):
+ with self.assertRaises(UserError):
+ self.properties.action_change_state_to_sold()
+
+ def test_property_state(self):
+ self.offers.action_accept_offer()
+
+ self.properties.action_change_state_to_sold()
+
+ self.assertEqual(self.properties.state, 'sold')
diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml
new file mode 100644
index 00000000000..36b2e44127b
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml
new file mode 100644
index 00000000000..aece4db1f51
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,40 @@
+
+
+ real.estate.offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
+ real.estate.offer.form
+ estate.property.offer
+
+
+
+
+
+
+ Real Estate Offers
+ estate.property.offer
+ list
+ [("property_type_id", "=", active_id)]
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_tags_views.xml b/estate/views/estate_property_tags_views.xml
new file mode 100644
index 00000000000..aef5e944cf3
--- /dev/null
+++ b/estate/views/estate_property_tags_views.xml
@@ -0,0 +1,17 @@
+
+
+ Real Estate Tags
+ estate.property.tag
+
+
+
+
+
+
+
+
+ Real Estate Tags
+ estate.property.tag
+ list,form
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_types_views.xml b/estate/views/estate_property_types_views.xml
new file mode 100644
index 00000000000..e42a36c1676
--- /dev/null
+++ b/estate/views/estate_property_types_views.xml
@@ -0,0 +1,51 @@
+
+
+ Real Estate Types
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ Real Estate Types
+ estate.property.type
+
+
+
+
+
+
+ Real Estate Types
+ estate.property.type
+ list,form
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml
new file mode 100644
index 00000000000..e722ff1ed4d
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,130 @@
+
+
+ real.estate.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ real.estate.form
+ estate.property
+
+
+
+
+
+
+ real.estate.kanban
+ estate.property
+
+
+
+
+
+
+
+ Expected Price:
+
+
+
+ Best Offer:
+
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+
+ real.estate.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Real Estates
+ estate.property
+ list,kanban,form
+ {"search_default_available": True}
+
+
\ No newline at end of file
diff --git a/estate/views/res_user_views.xml b/estate/views/res_user_views.xml
new file mode 100644
index 00000000000..f1f10520f4b
--- /dev/null
+++ b/estate/views/res_user_views.xml
@@ -0,0 +1,14 @@
+
+
+ res.users.view.form.inherit.estate
+ res.users
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate_account/__init__.py b/estate_account/__init__.py
new file mode 100644
index 00000000000..0650744f6bc
--- /dev/null
+++ b/estate_account/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/estate_account/__manifest__.py b/estate_account/__manifest__.py
new file mode 100644
index 00000000000..f6245a07e54
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,12 @@
+{
+ 'name': 'Real Estate Account',
+ 'category': 'Tutorials',
+ 'depends': [
+ 'estate',
+ 'account',
+ ],
+ 'application': True,
+ 'installable': True,
+ 'author': 'Odoo S.A.',
+ 'license': 'AGPL-3'
+}
diff --git a/estate_account/models/__init__.py b/estate_account/models/__init__.py
new file mode 100644
index 00000000000..5e1963c9d2f
--- /dev/null
+++ b/estate_account/models/__init__.py
@@ -0,0 +1 @@
+from . import estate_property
diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py
new file mode 100644
index 00000000000..112e77c9801
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,34 @@
+from odoo import models, Command
+
+
+class EstateProperty(models.Model):
+ _inherit = 'estate.property'
+
+ def action_change_state_to_sold(self):
+ try:
+ self.check_access('write')
+ except AccessError:
+ print("You aren't allowed to edit this!")
+ res = super().action_change_state_to_sold()
+ self.env['account.move'].sudo().create({
+ 'partner_id': self.buyer_id.id,
+ 'move_type': 'out_invoice',
+ 'line_ids': [
+ Command.create({
+ 'name': self.name,
+ 'quantity': 1,
+ 'price_unit': self.selling_price
+ }),
+ Command.create({
+ 'name': 'Administrative Fees',
+ 'quantity': 1,
+ 'price_unit': 100.00
+ }),
+ Command.create({
+ 'name': 'Additional Costs',
+ 'quantity': 1,
+ 'price_unit': 0.06 * self.selling_price
+ }),
+ ],
+ })
+ return res