- hello world
+
+
Welcome everyone
+
Click the button below and be amazed!
+
+ As you can see next to this card is a counter, don't hesitate to use it.
+
+
+
+
+
+
+
The sum of the counters is:
+
+
diff --git a/awesome_owl/static/src/todo/todo_item.js b/awesome_owl/static/src/todo/todo_item.js
new file mode 100644
index 00000000000..e2fa22b835b
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_item.js
@@ -0,0 +1,11 @@
+import {Component} from "@odoo/owl"
+
+export class TodoItem extends Component{
+ static template = "awesome_owl.todo_item"
+ static props = {
+ todo: {type: {id: Number, description: String, isCompleted: Boolean}},
+ toggleCompleted: {type: Function, optional:true},
+ deleteTodo: {type: Function, optional:true},
+ }
+
+}
\ No newline at end of file
diff --git a/awesome_owl/static/src/todo/todo_item.xml b/awesome_owl/static/src/todo/todo_item.xml
new file mode 100644
index 00000000000..a9000a9df1a
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_item.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+ .
+
+
+
+
+
+
\ No newline at end of file
diff --git a/awesome_owl/static/src/todo/todo_list.js b/awesome_owl/static/src/todo/todo_list.js
new file mode 100644
index 00000000000..64b83446f0d
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_list.js
@@ -0,0 +1,52 @@
+import {Component, useState, useRef, onMounted} from '@odoo/owl'
+import {TodoItem} from "./todo_item";
+import {useAutofocus} from "../utils";
+
+export class TodoList extends Component {
+ static template = "awesome_owl.todo_list";
+ static props = {};
+
+ setup() {
+ this.state = useState({
+ todos: [],
+ ids: 1
+ })
+ useAutofocus("input");
+
+ this.addTodo = this.addTodo.bind(this);
+ this.toggleCompleted = this.toggleCompleted.bind(this);
+ this.deleteTodo = this.deleteTodo.bind(this);
+ }
+
+ addTodo(event) {
+ if (event.keyCode === 13) {
+ this.state.todos.push({id: this.state.ids, description: event.target.value, isCompleted: false});
+ this.state.ids++;
+ event.target.value = "";
+ }
+ }
+
+ toggleCompleted(todo_id){
+ const todo_pos = this.findTodo(todo_id);
+ if (todo_pos < 0) return;
+ const todo = this.state.todos[todo_pos]
+ todo.isCompleted = !todo.isCompleted;
+ }
+
+ deleteTodo(todo_id){
+ const todo_pos = this.findTodo(todo_id);
+ if (todo_pos < 0) return
+ this.state.todos.splice(todo_pos, 1);
+ }
+
+ findTodo(todo_id){
+ let i = 0;
+ const num_todos = this.state.todos.length;
+ while (i < num_todos && this.state.todos[i].id !== todo_id) i += 1;
+ if (i === num_todos) return -1;
+
+ return i;
+ }
+
+ static components = {TodoItem};
+}
\ No newline at end of file
diff --git a/awesome_owl/static/src/todo/todo_list.xml b/awesome_owl/static/src/todo/todo_list.xml
new file mode 100644
index 00000000000..b3f1b586980
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_list.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
Todo List
+
+
+
+
+
+
+
+
+
\ 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..921fc11b52c
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,8 @@
+import {useRef, onMounted} from "@odoo/owl"
+
+export function useAutofocus(reference) {
+ const myRef = useRef(reference)
+ onMounted(() => {
+ myRef.el.focus()
+ });
+}
\ No newline at end of file
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..992b85ee631
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,26 @@
+{
+ 'name': 'Estate',
+ 'version': '19.0.1.1.0',
+ 'depends': [
+ 'base',
+ ],
+ 'author': 'Stef Ossé',
+ 'license': 'LGPL-3',
+ 'category': 'Category',
+ 'description': '''
+ A specialized application for **estate management**.
+ ''',
+ # data files always loaded at installation
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'views/estate_property_views.xml',
+ 'views/estate_property_offer_views.xml',
+ 'views/estate_property_type_views.xml',
+ 'views/estate_property_tag_views.xml',
+ 'views/res_users_views.xml',
+ 'views/estate_menus.xml',
+ ],
+ # data files containing optionally loaded demonstration data
+ 'demo': [],
+ 'application': True
+}
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..254b01444ed
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,128 @@
+from odoo import models, fields, api
+import odoo.tools.date_utils as date_utils
+from odoo.exceptions import UserError, ValidationError
+from odoo.tools import float_utils
+
+
+class Property(models.Model):
+ # Private attributes
+ _name = "estate.property"
+ _description = "Estate Property"
+ _order = "id desc"
+
+ # Field declarations
+ name = fields.Char(string="Title", required=True)
+ description = fields.Text()
+ tag_ids = fields.Many2many("estate.property.tag")
+ type_id = fields.Many2one("estate.property.type")
+ postcode = fields.Char()
+ bedrooms = fields.Integer(default=2)
+ living_area = fields.Integer()
+ facades = fields.Integer()
+ garage = fields.Boolean()
+ total_area = fields.Integer(compute="_compute_total_area")
+ garden = fields.Boolean()
+ garden_area = fields.Integer()
+ garden_orientation = fields.Selection(
+ selection=[
+ ("north", "North"),
+ ("south", "South"),
+ ("east", "East"),
+ ("west", "West"),
+ ],
+ default='south'
+ )
+ date_availability = fields.Date(
+ copy=False,
+ default=lambda x: fields.Date.today() + date_utils.relativedelta(months=3),
+ )
+ offer_ids = fields.One2many("estate.property.offer", "property_id")
+ expected_price = fields.Float(required=True)
+ best_offer = fields.Integer(compute="_compute_best_offer")
+ selling_price = fields.Float(readonly=True, copy=False)
+ buyer_id = fields.Many2one("res.partner", copy=False, readonly=True)
+ salesman_id = fields.Many2one(
+ "res.users",
+ default=lambda self: self.env.user.id,
+ )
+ state = fields.Selection(
+ selection=[
+ ("new", "New"),
+ ("offer_received", "Offer Received"),
+ ("offer_accepted", "Offer Accepted"),
+ ("sold", "Sold"),
+ ("cancelled", "Cancelled"),
+ ],
+ default="new",
+ )
+ active = fields.Boolean(default=True)
+
+ # SQL constraints and indexes
+ _check_expected_price = models.Constraint(
+ "CHECK(expected_price > 0)", "The expected price should be a positive number."
+ )
+
+ _check_selling_price = models.Constraint(
+ "CHECK(selling_price > 0)", "The selling_price should be a positive number."
+ )
+
+ # Compute, inverse and search methods
+ @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.price")
+ def _compute_best_offer(self):
+ for record in self:
+ offers = record.offer_ids.filtered(lambda offer: offer.status != "refused")
+ record.best_offer = max(offers.mapped("price"), default=0)
+
+ # Constrains methods and onchange methods
+ @api.constrains("selling_price")
+ def _check_selling_price(self):
+ for record in self:
+ if (
+ not float_utils.float_is_zero(record.selling_price, precision_digits=2)
+ and float_utils.float_compare(
+ record.selling_price,
+ record.expected_price * 0.9,
+ precision_digits=2,
+ )
+ == -1
+ ):
+ raise ValidationError(
+ "A selling price must be at least 90% of the expected_price"
+ )
+
+ @api.onchange("garden")
+ def _onchange_garden(self):
+ for record in self:
+ if record.garden:
+ record.garden_area = 10
+ record.garden_orientation = "north"
+ else:
+ record.garden_area = 0
+ record.garden_orientation = None
+
+ # CRUD methods
+ @api.ondelete(at_uninstall=False)
+ def _delete(self):
+ for record in self:
+ if record.state not in ["new", "cancelled"]:
+ raise UserError("Only new and cancelled properties can be deleted.")
+ return super().unlink()
+
+ # Action methods
+ def action_sold(self):
+ for record in self:
+ if record.state == "cancelled":
+ raise UserError("A cancelled property cannot be sold")
+ record.state = "sold"
+
+ def action_cancel(self):
+ for record in self:
+ if record.state == "sold":
+ raise UserError("A sold property cannot be cancelled")
+
+ record.state = "cancelled"
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..8699121436f
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,115 @@
+import datetime
+
+from odoo import models, fields, api
+from odoo.exceptions import UserError, AccessError
+from odoo.tools import float_utils
+
+
+class PropertyOffer(models.Model):
+ # Private attributes
+ _name = "estate.property.offer"
+ _description = "Estate Property Offer"
+ _order = "price desc"
+
+ # Field declarations
+ create_date = fields.Date(default=lambda self: datetime.date.today())
+ price = fields.Float()
+ status = fields.Selection(
+ [
+ ("proposed", "Proposed"),
+ ("accepted", "Accepted"),
+ ("refused", "Refused"),
+ ],
+ default="proposed",
+ copy=False,
+ )
+ validity = fields.Integer(default=7)
+ deadline = fields.Date(compute="_compute_deadline", inverse="_inverse_deadline")
+ partner_id = fields.Many2one("res.partner", required=True)
+ property_id = fields.Many2one("estate.property", required=True)
+ actions_visible = fields.Boolean(compute="_compute_actions_visible")
+ property_type_id = fields.Many2one(
+ related="property_id.type_id", comodel_name="estate.property.type"
+ )
+
+ # SQL constraints and indexes
+ _check_price = models.Constraint(
+ "CHECK(price > 0)", "The price should be positive."
+ )
+
+ # Compute, inverse and search methods
+ @api.depends("validity", "create_date")
+ def _compute_deadline(self):
+ for record in self:
+ create_date = (
+ record.create_date if record.create_date else datetime.date.today()
+ )
+ record.deadline = create_date + datetime.timedelta(days=record.validity)
+
+ def _inverse_deadline(self):
+ for record in self:
+ create_date = (
+ record.create_date if record.create_date else datetime.date.today()
+ )
+ record.validity = (record.deadline - create_date).days
+
+ @api.depends("property_id.state")
+ def _compute_actions_visible(self):
+ for record in self:
+ record.actions_visible = (
+ record.property_id.state not in ["sold", "offer_accepted", "cancelled"]
+ and record.status == "proposed"
+ )
+
+ # Constrains methods and onchange methods
+ # CRUD methods
+ def create(self, vals):
+ properties = self.env["estate.property"].browse(record["property_id"] for record in vals)
+
+ if any(properties.mapped(lambda x: x.state in ["sold", "offer_accepted", "cancelled"])):
+ raise AccessError("You cannot create an offer on a sold/cancelled property or when there\'s already an offer accepted.")
+
+ for property, record in zip(properties, vals):
+ best_price = float(max(property.offer_ids.mapped("price"), default=0.0))
+
+ if "price" not in record or float_utils.float_compare(float(record["price"]), best_price, precision_digits=2) < 0:
+ raise UserError("You cannot go under the price of the current best offer")
+
+ property.state = "offer_received"
+
+ return super().create(vals)
+
+ def write(self, vals):
+ if "price" in vals:
+ for record in self:
+ best_price = float(max(record.property_id.offer_ids.mapped("price"), default=0.0))
+
+ if float_utils.float_compare(float(vals["price"]), best_price, precision_digits=2) < 0:
+ raise UserError("You cannot go under the price of the current best offer")
+
+ if record.property_id.state not in ["sold", "cancelled"]:
+ record.property_id.state = "offer_received"
+ else:
+ raise AccessError("You cannot create an offer on a sold or cancelled property.")
+
+ return super().write(vals)
+
+ # Action methods
+ def action_accept(self):
+ for record in self:
+ if record.status == "refused" or record.property_id.state in ['cancelled', 'sold']:
+ raise UserError("Can\'t accept a refused offer or accept an offer on a sold/cancelled property.")
+
+ if float_utils.float_compare(record.price, record.property_id.expected_price, precision_digits=2) < 0:
+ raise UserError("You can\'t buy below the expected price")
+
+ record.status = "accepted"
+ record.property_id.buyer_id = record.partner_id
+ record.property_id.selling_price = record.price
+ record.property_id.state = "offer_accepted"
+
+ def action_refuse(self):
+ for record in self:
+ if record.status == "accepted" or record.property_id.state in ["cancelled", "sold"]:
+ raise UserError("Can\'t refuse an accepted offer or refuse an offer on a sold/cancelled property.")
+ record.status = "refused"
diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py
new file mode 100644
index 00000000000..bb25d247299
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,17 @@
+from odoo import models, fields
+
+
+class PropertyTag(models.Model):
+ # Private attributes
+ _name = 'estate.property.tag'
+ _description = 'Estate Property Tag'
+ _order = 'name'
+
+ # Field declarations
+ name = fields.Char(required=True)
+ color = fields.Integer()
+
+ # SQL constraints and indexes
+ _check_name = models.Constraint(
+ "unique(name)", "Tag name should be unique"
+ )
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 00000000000..a7797c00da2
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,26 @@
+from odoo import models, fields, api
+
+
+class PropertyType(models.Model):
+ # Private attributes
+ _name = 'estate.property.type'
+ _description = 'Estate Property Type'
+ _order = 'sequence'
+
+ # Field declarations
+ name = fields.Char(string="Type", required=True)
+ sequence = fields.Integer()
+ properties_id = fields.One2many(comodel_name="estate.property", inverse_name="type_id")
+ offer_ids = fields.One2many(comodel_name="estate.property.offer", inverse_name="property_type_id")
+ offer_count = fields.Integer(compute="_compute_offer_count")
+
+ # SQL constraints and indexes
+ _check_name = models.Constraint(
+ 'unique(name)', "The property type name should be unique"
+ )
+
+ # Compute, inverse and search methods
+ @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..a94ade46a75
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,13 @@
+from odoo import models, fields
+
+
+class ResUsers(models.Model):
+ # Private attributes
+ _inherit = "res.users"
+
+ # Field declarations
+ property_ids = fields.One2many(
+ "estate.property",
+ "salesman_id",
+ domain=[("state", "not in", ["sold", "cancelled"])]
+ )
diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv
new file mode 100644
index 00000000000..a76733405b1
--- /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
+estate_property_access_manager,estate.property.manager,model_estate_property,base.group_system,1,1,1,1
+estate_property_access_user,estate.property.user,model_estate_property,base.group_user,1,1,1,0
+estate_property_type_access_manager,estate.property.type.manager,model_estate_property_type,base.group_system,1,1,1,1
+estate_property_type_access_user,estate.property.type.user,model_estate_property_type,base.group_user,1,0,0,0
+estate_property_tag_access_manager,estate.property.tag.manager,model_estate_property_tag,base.group_system,1,1,1,1
+estate_property_tag_access_user,estate.property.tag.user,model_estate_property_tag,base.group_user,1,1,1,0
+estate_property_offer_access_manager,estate.property.offer.manager,model_estate_property_offer,base.group_system,1,1,1,1
+estate_property_offer_access_user,estate.property.offer.user,model_estate_property_offer,base.group_user,1,1,1,0
diff --git a/estate/tests/__init__.py b/estate/tests/__init__.py
new file mode 100644
index 00000000000..576617cccff
--- /dev/null
+++ b/estate/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_estate_property
diff --git a/estate/tests/test_estate_property.py b/estate/tests/test_estate_property.py
new file mode 100644
index 00000000000..87805eb87d6
--- /dev/null
+++ b/estate/tests/test_estate_property.py
@@ -0,0 +1,42 @@
+from odoo.exceptions import UserError
+from odoo.tests import TransactionCase
+from odoo import Command
+
+
+class TestEstateProperty(TransactionCase):
+
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ cls.estate = cls.env['estate.property'].create({
+ 'name': 'Super test estate',
+ 'expected_price': 100000.0,
+ 'state': 'new',
+ })
+ cls.test_partner = cls.env['res.partner'].create({
+ 'name': 'Maman ours',
+ })
+
+ def test_estate_best_offer(self):
+ '''
+ Ensure best price is correctly updated when an offer is received.
+ '''
+ self.assertEqual(self.estate.best_offer, 0.0)
+ self.estate.offer_ids = [Command.create({
+ 'price': 125000.0,
+ 'partner_id': self.test_partner.id,
+ })]
+ self.assertEqual(self.estate.best_offer, 125000.0)
+
+ def test_accept_offer_south_facing_garden(self):
+ '''
+ Ensure offers for estates with south-facing gardens can only be accepted if above expected
+ price.
+ '''
+ self.estate.expected_price = 500000
+ self.estate.offer_ids = [Command.create({
+ 'price': 475000.0,
+ 'partner_id': self.test_partner.id,
+ })]
+ with self.assertRaises(UserError):
+ self.estate.offer_ids.action_accept()
diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml
new file mode 100644
index 00000000000..10adff8f39c
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml
new file mode 100644
index 00000000000..61a9eb08198
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,41 @@
+
+
+
+ Offers
+ estate.property.offer
+ [('property_type_id', '=', active_id)]
+ list,form
+
+
+
+ estate.property.offer.view.form
+ estate.property.offer
+
+
+
+
+
+
+ estate.property.offer.view.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_tag_views.xml b/estate/views/estate_property_tag_views.xml
new file mode 100644
index 00000000000..aeb218fbf8f
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,33 @@
+
+
+
+ Property Tag
+ estate.property.tag
+ list,form
+
+
+
+ estate.property.tag.view.form
+ estate.property.tag
+
+
+
+
+
+
+ estate.property.tag.view.list
+ estate.property.tag
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_type_views.xml b/estate/views/estate_property_type_views.xml
new file mode 100644
index 00000000000..f613387e7a3
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,58 @@
+
+
+
+ Property Type
+ estate.property.type
+ list,form
+
+
+
+ estate.property.type.view.form
+ estate.property.type
+
+
+
+
+
+
+ estate.property.type.view.list
+ estate.property.type
+
+
+
+
+
+
+
+
+
+
\ 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..9d89a3b84d5
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,167 @@
+
+
+
+ All Properties
+ estate.property
+ list,kanban,form
+
+
+
+ estate.property.view.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.kanban
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Expected Price: €
+
+
+
+ Best Offer: €
+
+
+
+
+ Selling Price: €
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.view.form
+ estate.property
+
+
+
+
+
+
+
+ estate.property.view.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml
new file mode 100644
index 00000000000..ad876c6fe16
--- /dev/null
+++ b/estate/views/res_users_views.xml
@@ -0,0 +1,15 @@
+
+
+
+ res.users.form.estate.extention
+ 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..b6c39be4d83
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,20 @@
+{
+ 'name': 'Estate Accounts',
+ 'version': '19.0.1.1.0',
+ 'depends': [
+ 'base',
+ 'account',
+ ],
+ 'author': 'Stef Ossé',
+ 'license': 'LGPL-3',
+ 'category': 'Category',
+ 'description': '''
+ An extention for the application for **estate management**.
+ ''',
+ # data files always loaded at installation
+ 'data': [
+ ],
+ # data files containing optionally loaded demonstration data
+ 'demo': [],
+ 'application': True
+}
diff --git a/estate_account/models/__init__.py b/estate_account/models/__init__.py
new file mode 100644
index 00000000000..02b688798a3
--- /dev/null
+++ b/estate_account/models/__init__.py
@@ -0,0 +1 @@
+from . import estate_account
diff --git a/estate_account/models/estate_account.py b/estate_account/models/estate_account.py
new file mode 100644
index 00000000000..2201bbb5dcc
--- /dev/null
+++ b/estate_account/models/estate_account.py
@@ -0,0 +1,42 @@
+from odoo import models
+from odoo.exceptions import UserError
+from odoo.orm.commands import Command
+
+
+class EstateAccount(models.Model):
+ _inherit = "estate.property"
+
+ def sold_action(self):
+ for order in self:
+ best_offer = order.offer_ids.filtered(lambda x: x.status == "accepted").sorted("price DESC")[:1]
+
+ if not best_offer:
+ raise UserError("You cannot sell without an accepted offer")
+
+ buyer_id = best_offer[0].buyer_id
+ selling_price = best_offer[0].selling_price
+
+ invoice_vals = {
+ "move_type": "out_invoice",
+ "partner_id": buyer_id.id,
+ "invoice_line_ids": [
+ Command.create(
+ {
+ "name": "Down Payment (6% of the selling price)",
+ "quantity": 1,
+ "price_unit": 0.06 * selling_price,
+ }
+ ),
+ Command.create(
+ {
+ "name": "Administrative Fees",
+ "quantity": 1,
+ "price_unit": 100,
+ }
+ ),
+ ],
+ }
+
+ self.env["account.move"].create(invoice_vals)
+
+ return super().sold_action()