diff --git a/awesome_dashboard/controllers/controllers.py b/awesome_dashboard/controllers/controllers.py index 56d4a051287..eafba6ffbd0 100644 --- a/awesome_dashboard/controllers/controllers.py +++ b/awesome_dashboard/controllers/controllers.py @@ -33,4 +33,3 @@ def get_statistics(self): }, 'total_amount': random.randint(100, 1000) } - diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index c4fb245621b..07eda57d0aa 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -1,8 +1,35 @@ -import { Component } from "@odoo/owl"; -import { registry } from "@web/core/registry"; +import {Component, onWillStart, useState} from "@odoo/owl"; +import {registry} from "@web/core/registry"; +import {Layout} from "@web/search/layout"; +import {useService} from "@web/core/utils/hooks" +import {_t} from "@web/core/l10n/translation"; +import {DashboardItem} from "./dashboard_item/dashboard_item"; +import {PieChart} from "./pie_chart/pie_chart"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; + static components = { Layout, DashboardItem, PieChart }; + + setup() { + this.action = useService("action"); + this.statistics = useState(useService("awesome_dashboard.statistics")); + this.stat_data = this.statistics['orders_by_size']; + } + + openCustomers() { + this.action.doAction("base.action_partner_form") + } + + openLeads() { + this.action.doAction({ + type: 'ir.actions.act_window', + name: _t('CRM Leads'), + target: 'current', + res_model: 'crm.lead', + views: [[false, 'list'],[false, 'form']], + }) + } + } registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard.scss b/awesome_dashboard/static/src/dashboard.scss new file mode 100644 index 00000000000..b62d31952a1 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard.scss @@ -0,0 +1,3 @@ +.o_dashboard { + background-color: slategrey; +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 1a2ac9a2fed..ba15a05c567 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -2,7 +2,51 @@ - hello dashboard + + + + + + + +
+ + + New orders + + + + + + + + + Total amount + + + + + + + + + Average time + + + + + + + + + Orders by size + + + + +
+ +
diff --git a/awesome_dashboard/static/src/dashboard_item/dashboard_item.js b/awesome_dashboard/static/src/dashboard_item/dashboard_item.js new file mode 100644 index 00000000000..a6ca17abf1e --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_item/dashboard_item.js @@ -0,0 +1,18 @@ +import { Component } from "@odoo/owl"; + +export class DashboardItem extends Component { + static template = "awesome_dashboard.DashboardItem"; + static props = { + slots : { + type: Object, + optional: true + }, + size : { + type: Number, + optional: true, + }, + }; + static defaultProps = { + size: 1, + }; +} diff --git a/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml b/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml new file mode 100644 index 00000000000..112fda4d588 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml @@ -0,0 +1,16 @@ + + + + +
+
+ +
+
+ +
+ +
+
+ +
diff --git a/awesome_dashboard/static/src/pie_chart/pie_chart.js b/awesome_dashboard/static/src/pie_chart/pie_chart.js new file mode 100644 index 00000000000..607d408ea37 --- /dev/null +++ b/awesome_dashboard/static/src/pie_chart/pie_chart.js @@ -0,0 +1,32 @@ +import { Component, onWillStart, useRef, onMounted } from "@odoo/owl"; +import { loadJS } from "@web/core/assets"; + +export class PieChart extends Component { + static template = "awesome_dashboard.PieChart"; + static props = { + pieChartData: Object, + } + + setup() { + this.canva = useRef("canva"); + onWillStart(() => loadJS(["/web/static/lib/Chart/Chart.js"])); + onMounted( () => this.renderChart() ); + } + + renderChart() { + const labels = Object.keys(this.props.pieChartData); + const values = Object.values(this.props.pieChartData); + this.myPieChart = new Chart(this.canva.el, { + type: 'pie', + data: { + labels, + datasets: [ + { + data: values, + } + ] + }, + }) + } + +} diff --git a/awesome_dashboard/static/src/pie_chart/pie_chart.xml b/awesome_dashboard/static/src/pie_chart/pie_chart.xml new file mode 100644 index 00000000000..7b73cb45b7a --- /dev/null +++ b/awesome_dashboard/static/src/pie_chart/pie_chart.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/awesome_dashboard/static/src/statistics_service.js b/awesome_dashboard/static/src/statistics_service.js new file mode 100644 index 00000000000..c4a937bb10a --- /dev/null +++ b/awesome_dashboard/static/src/statistics_service.js @@ -0,0 +1,22 @@ +import { registry } from "@web/core/registry"; +import { rpc } from "@web/core/network/rpc"; +import { reactive } from "@odoo/owl"; + +const statisticsService = { + + start() { + const statistics = reactive ( { changed: false } ); + + async function loadStatistics () { + const updates = await rpc("/awesome_dashboard/statistics", {}); + Object.assign(statistics, updates, {changed: true} ); + } + + setInterval(loadStatistics, 1*60*1000); + loadStatistics(); + + return statistics; + } +} + +registry.category("services").add("awesome_dashboard.statistics", statisticsService); \ No newline at end of file diff --git a/awesome_owl/__manifest__.py b/awesome_owl/__manifest__.py index e8ac1cda552..55002ab81de 100644 --- a/awesome_owl/__manifest__.py +++ b/awesome_owl/__manifest__.py @@ -29,8 +29,10 @@ 'assets': { 'awesome_owl.assets_playground': [ ('include', 'web._assets_helpers'), + ('include', 'web._assets_backend_helpers'), 'web/static/src/scss/pre_variables.scss', 'web/static/lib/bootstrap/scss/_variables.scss', + 'web/static/lib/bootstrap/scss/_maps.scss', ('include', 'web._assets_bootstrap'), ('include', 'web._assets_core'), 'web/static/src/libs/fontawesome/css/font-awesome.css', diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js new file mode 100644 index 00000000000..085f730b602 --- /dev/null +++ b/awesome_owl/static/src/card/card.js @@ -0,0 +1,19 @@ +import { useState, Component } from "@odoo/owl"; + +export class Card extends Component { + static template = "awesome_owl.Card"; + + static props = { + title : { type: String }, + slots : { type: Object, optional: true } + } + + setup() { + this.state = useState({ isOpen: true }) + } + + toggle() { + this.state.isOpen = !this.state.isOpen; + } + +} \ No newline at end of file diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml new file mode 100644 index 00000000000..a1514f6e26d --- /dev/null +++ b/awesome_owl/static/src/card/card.xml @@ -0,0 +1,18 @@ + + + + +
+
+
+ + +
+

+ +

+
+
+
+ +
\ No newline at end of file diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js new file mode 100644 index 00000000000..36aa4c24384 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.js @@ -0,0 +1,20 @@ +import { useState, Component } from "@odoo/owl"; + +export class Counter extends Component { + static template = "awesome_owl.Counter"; + static props = { + onChange: { type: Function, optional: true } + } + + setup() { + this.state = useState({ value: 0 }); + } + + increment() { + this.state.value++; + if (this.props.onChange) { + this.props.onChange(); + } + } + +} \ No newline at end of file diff --git a/awesome_owl/static/src/counter/counter.xml b/awesome_owl/static/src/counter/counter.xml new file mode 100644 index 00000000000..ea985e04b64 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.xml @@ -0,0 +1,9 @@ + + + + +

Counter:

+ +
+ +
\ No newline at end of file diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 4ac769b0aa5..ee85129c2ea 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,5 +1,20 @@ -import { Component } from "@odoo/owl"; +import { Component, useState, markup } from "@odoo/owl"; +import { Counter } from "./counter/counter" +import { Card } from "./card/card"; +import { TodoList } from "./todo_list/todo_list"; export class Playground extends Component { - static template = "awesome_owl.playground"; + static template = "awesome_owl.Playground"; + static components = { Counter, Card, TodoList }; + + setup() { + this.value1 = "
test
"; + this.value2 = markup("test2"); + this.state = useState({ sum : 0 }); + } + + implementSum() { + this.state.sum++; + } + } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..0d08ceb5606 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -1,10 +1,34 @@ - +
hello world
+
+ + +
+
+ + + + + + +
+
+ + + +
+
+ The sum is: +
+

+
+ +
diff --git a/awesome_owl/static/src/todo_list/todo_item.js b/awesome_owl/static/src/todo_list/todo_item.js new file mode 100644 index 00000000000..1fadc6905e9 --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_item.js @@ -0,0 +1,21 @@ +import { Component, useState } from "@odoo/owl" + +export class TodoItem extends Component { + static template = "awesome_owl.TodoItem"; + + static props = { + todo : { + id: Number, + description: String, + isCompleted: Boolean }, + onClick : { Type: Function, optional : true } + }; + + toggleState() { + this.props.todo.isCompleted = !this.props.todo.isCompleted; + } + + removeTodo() { + this.props.onClick(this.props.todo.id); + } +} \ No newline at end of file diff --git a/awesome_owl/static/src/todo_list/todo_item.xml b/awesome_owl/static/src/todo_list/todo_item.xml new file mode 100644 index 00000000000..57dff9e3b43 --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_item.xml @@ -0,0 +1,15 @@ + + + + +
+

+ + . + + +

+
+
+ +
\ No newline at end of file diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js new file mode 100644 index 00000000000..a94c6bfe747 --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -0,0 +1,36 @@ +import { Component, useState, useRef } from "@odoo/owl" +import { TodoItem } from "./todo_item" + +export class TodoList extends Component { + static template = "awesome_owl.TodoList"; + static components = { TodoItem }; + + setup() { + this.todos = useState([ + {id: 1, description: "buy bread", isCompleted: false}, + {id: 2, description: "buy milk", isCompleted: false}, + {id: 3, description: "have lunch", isCompleted: true}, + ]); + this.todoCounter = this.todos.length; + this.inputRef = useRef("todo_input") + } + + addTodo(ev) { + if (ev.keyCode === 13) { + const input_text = this.inputRef.el.value.trim(); + if (input_text) { + this.todoCounter++; + this.todos.push({id: this.todoCounter, description: input_text, isCompleted: false}); + this.inputRef.el.value = ""; + } + } + } + + removeTodo(id) { + const index = this.todos.findIndex(todo => todo.id === id); + if (index >= 0) { + this.todos.splice(index, 1); + } + } +} + diff --git a/awesome_owl/static/src/todo_list/todo_list.xml b/awesome_owl/static/src/todo_list/todo_list.xml new file mode 100644 index 00000000000..71874e7757d --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_list.xml @@ -0,0 +1,14 @@ + + + + +
+

Todo List:

+ +

+ +

+
+
+ +
\ 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..29830de4c0c --- /dev/null +++ b/estate/__manifest__.py @@ -0,0 +1,26 @@ +{ + 'name': "Real Estate", + 'version': '1.0', + 'depends': ['base'], + 'author': "taskv", + 'category': 'Tutorials', + 'description': """ + Tutorial Project + """, + '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/estate_menus.xml', + 'views/res_users_views.xml', + 'data/master_data.xml', + ], + 'demo': [ + 'demo/demo_data.xml', + ], + 'installable': True, + 'application': True, + 'license': 'LGPL-3', +} diff --git a/estate/data/master_data.xml b/estate/data/master_data.xml new file mode 100644 index 00000000000..2c5ec77e03c --- /dev/null +++ b/estate/data/master_data.xml @@ -0,0 +1,28 @@ + + + + + + John Johnson + False + + + Steve Stevenson + False + + + + + Residential + + + Commercial + + + Industrial + + + Land + + + \ No newline at end of file diff --git a/estate/demo/demo_data.xml b/estate/demo/demo_data.xml new file mode 100644 index 00000000000..0f73c425b2c --- /dev/null +++ b/estate/demo/demo_data.xml @@ -0,0 +1,97 @@ + + + + + + + Big Villa + new + A nice and big villa + + 12345 + + 1600000 + 6 + 100 + 4 + True + True + 100000 + south + + + + Trailer home + cancelled + Home in a trailer park + + 54321 + + 100000 + 120000 + 1 + 10 + 4 + False + + + + Small apartment + offer_received + Cosy apartment + + 54321 + + 100000 + 1 + 40 + 0 + False + + + + + + 10000 + + + 14 + + + + 1500000 + + + 14 + + + + 1500001 + + + 14 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/estate/models/__init__.py b/estate/models/__init__.py new file mode 100644 index 00000000000..fea9f441d6d --- /dev/null +++ b/estate/models/__init__.py @@ -0,0 +1,5 @@ +from . import estate_property +from . import estate_property_offer +from . import estate_property_tag +from . import estate_property_type +from . import res_users diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py new file mode 100644 index 00000000000..d28108c27d9 --- /dev/null +++ b/estate/models/estate_property.py @@ -0,0 +1,113 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models, api, exceptions +from odoo.tools.float_utils import float_is_zero, float_compare + + +class EstateProperty(models.Model): + _name = 'estate.property' + _description = 'Estate Property' + _order = "id desc" + + name = fields.Char('Title', required=True, default='Unknown', translate='True') + active = fields.Boolean('Active', default=True) + description = fields.Text('Description') + postcode = fields.Char('Postcode') + date_availability = fields.Date('Available From', copy=False, default=fields.Date.add(fields.Date.today(), months=3)) + expected_price = fields.Float('Expected Price', required=True) + selling_price = fields.Float('Selling Price', readonly=True, copy=False) + bedrooms = fields.Integer('Bedrooms', default=2) + living_area = fields.Integer('Living Area (sqm)') + facades = fields.Integer('Facades') + garage = fields.Boolean('Garage') + garden = fields.Boolean('Garden') + garden_area = fields.Integer('Garden Area (sqm)') + 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'), + ], + default='new', + required=True, + copy=False, + ) + property_type_id = fields.Many2one('estate.property.type', string='Property Type') + property_tag_ids = fields.Many2many('estate.property.tag', string='Property Tag') + buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False, + domain=[('is_company', '=', False)]) + salesperson_id = fields.Many2one('res.users', string='Salesperson', + default=lambda self: self.env.user) + offer_ids = fields.One2many('estate.property.offer', 'property_id', string='Offers') + total_area = fields.Integer('Total Area (sqm)', compute='_compute_total_area') + best_offer = fields.Float('Best Offer', compute='_compute_best_offer') + + _check_expected_price = models.Constraint( + 'CHECK(expected_price > 0)', + 'The expected price must be strictly positive', + ) + + _check_selling_price = models.Constraint( + 'CHECK(selling_price >= 0)', + 'The selling price must be positive', + ) + + @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: + record.best_offer = max(record.offer_ids.mapped('price'), default=0.0) + + @api.constrains('selling_price', 'expected_price') + def _check_selling_price(self): + for record in self: + if not float_is_zero(record.selling_price, 4) and float_compare(record.selling_price, + record.expected_price * 0.9, 4) < 0: + raise exceptions.ValidationError("The selling price must be at least 90% of the expected price.") + + @api.onchange('garden') + def _onchange_garden(self): + if self.garden: + self.garden_area = 10 + self.garden_orientation = 'north' + else: + self.garden_area = 0 + self.garden_orientation = '' + + @api.ondelete(at_uninstall=False) + def _unlink_check_state(self): + for record in self: + if record.state not in ('new', 'cancelled'): + raise exceptions.UserError("Only new and cancelled properties can be deleted.") + + def action_property_sold(self): + self.ensure_one() + if self.state != 'cancelled': + self.state = 'sold' + else: + raise exceptions.UserError("Cancelled properties cannot be sold.") + return True + + def action_property_cancelled(self): + self.ensure_one() + if self.state != 'sold': + self.state = 'cancelled' + else: + raise exceptions.UserError("Sold properties cannot be 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..9a907c5b895 --- /dev/null +++ b/estate/models/estate_property_offer.py @@ -0,0 +1,62 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models, api, exceptions, _ +from datetime import date, timedelta + + +class EstatePropertyOffer(models.Model): + _name = 'estate.property.offer' + _description = 'Estate Property Offer' + _order = "price desc" + + price = fields.Float(string='Price') + status = fields.Selection( + string='Status', + copy=False, + selection=[('accepted', 'Accepted'), ('refused', 'Refused')] + ) + partner_id = fields.Many2one('res.partner', string='Customer', required=True) + property_id = fields.Many2one('estate.property', string='Property', required=True) + validity = fields.Integer(string='Validity (days)', default=7) + date_deadline = fields.Date(string='Deadline', compute='_compute_deadline', inverse='_inverse_deadline') + property_type_id = fields.Many2one('estate.property.type', string='Property Type', related="property_id.property_type_id", store=True) + + _check_price = models.Constraint( + 'CHECK(price > 0)', + 'The offer price must be strictly positive', + ) + + @api.depends('validity') + def _compute_deadline(self): + for record in self: + record.date_deadline = (record.create_date if record.create_date else date.today()) + timedelta(days=record.validity) + + def _inverse_deadline(self): + for record in self: + record.validity = (record.date_deadline - (record.create_date.date() if record.create_date else date.today())).days + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get('property_id'): + current_property = self.env['estate.property'].browse(vals['property_id']) + if current_property.best_offer > vals.get('price', 0): + raise exceptions.ValidationError(_("The offer must be higher than %(best_offer)s", best_offer=current_property.best_offer)) + if current_property.state == 'new': + current_property.state = 'offer_received' + return super().create(vals_list) + + def action_accept(self): + self.ensure_one() + if self.property_id.state in ('new', 'offer_received'): + self.property_id.state = 'offer_accepted' + self.status = 'accepted' + self.property_id.selling_price = self.price + self.property_id.buyer_id = self.partner_id + return True + + def action_refuse(self): + self.ensure_one() + if not self.status: + self.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..f6ee0c34844 --- /dev/null +++ b/estate/models/estate_property_tag.py @@ -0,0 +1,15 @@ +from odoo import fields, models + + +class EstatePropertyTag(models.Model): + _name = 'estate.property.tag' + _description = "Estate Property Tag" + _order = 'name' + + name = fields.Char(string='Property Tag', required=True) + color = fields.Integer() + + _tag_name_uniq = models.Constraint( + 'unique(name)', + "The property 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..9f95a4d3f32 --- /dev/null +++ b/estate/models/estate_property_type.py @@ -0,0 +1,23 @@ +from odoo import fields, models, api + + +class EstatePropertyType(models.Model): + _name = 'estate.property.type' + _description = 'Estate Property Type' + _order = "sequence, name" + + name = fields.Char('Property Type', required=True) + property_ids = fields.One2many('estate.property', 'property_type_id', 'Properties') + offer_ids = fields.One2many('estate.property.offer', 'property_type_id', 'Offers') + offer_count = fields.Integer(compute='_compute_offer_count') + sequence = fields.Integer() + + _type_name_uniq = models.Constraint( + 'unique(name)', + "The 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..adc876d247e --- /dev/null +++ b/estate/models/res_users.py @@ -0,0 +1,8 @@ +from odoo import fields, models + + +class Users(models.Model): + _inherit = 'res.users' + + property_ids = fields.One2many('estate.property', 'salesperson_id', string='Estate Property', + domain=[('date_availability', '<=', fields.Date.today())]) diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv new file mode 100644 index 00000000000..49bca99cac8 --- /dev/null +++ b/estate/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1 +access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1 +access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1 +access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1 diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml new file mode 100644 index 00000000000..18b79afccf6 --- /dev/null +++ b/estate/views/estate_menus.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml new file mode 100644 index 00000000000..0d2d0f12888 --- /dev/null +++ b/estate/views/estate_property_offer_views.xml @@ -0,0 +1,49 @@ + + + + estate.property.offer.view.form + estate.property.offer + +
+ + + + + + + + + + + + + +
+
+
+ + + estate.property.offer.view.list + estate.property.offer + + + + + + + + +
+

+ +

+
+ + + + + + + + + + + + + +
+
+ + + estate.property.type.view.list + estate.property.type + + + + + + + + + + Estate Property Type + estate.property.type + list,form + + +
diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml new file mode 100644 index 00000000000..9616a293375 --- /dev/null +++ b/estate/views/estate_property_views.xml @@ -0,0 +1,148 @@ + + + + estate.property.search + estate.property + + + + + + + + + + + + + + + + + + + + + + + + estate.property.view.form + estate.property + +
+
+
+ +
+

+ +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + estate.property.view.list + estate.property + + + + + + + + + + + + + + + + estate.property.view.kanban + estate.property + + + + + +
+ +
+ Expected price: + +
+
+ Best offer: + +
+
+ Selling price: + +
+ +
+
+
+
+
+
+ + + Estate Property + estate.property + list,form,kanban + + {'search_default_filter_available': 1} + + +
diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml new file mode 100644 index 00000000000..6dc864c5665 --- /dev/null +++ b/estate/views/res_users_views.xml @@ -0,0 +1,19 @@ + + + + + + res.users.view.form.inherit.real.estate + res.users + + + + + + + + + + + + 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..7dd0c2c26e4 --- /dev/null +++ b/estate_account/__manifest__.py @@ -0,0 +1,14 @@ + +{ + 'name': "Real Estate Invoicing", + 'version': '1.0', + 'depends': ['estate', 'account'], + 'author': "taskv", + 'category': 'Tutorials', + 'description': """ + Tutorial Project + """, + 'installable': True, + 'application': True, + 'license': 'LGPL-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..7058428ef5e --- /dev/null +++ b/estate_account/models/estate_property.py @@ -0,0 +1,26 @@ +from odoo import models, Command + + +class EstateProperty(models.Model): + _inherit = 'estate.property' + + def action_property_sold(self): + if self.state == 'offer_accepted' and self.buyer_id: + invoice_vals = { + 'move_type': 'out_invoice', + 'partner_id': self.buyer_id.id, + 'invoice_line_ids': [ + Command.create({ + "name": "Commission 6%", + "quantity": 1, + "price_unit": self.selling_price * 0.06, + }), + Command.create({ + "name": "Administrative fees", + "quantity": 1, + "price_unit": 100., + }), + ], + } + self.env['account.move'].sudo().create(invoice_vals) + return super().action_property_sold()