diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js new file mode 100644 index 00000000000..350de94cfc9 --- /dev/null +++ b/awesome_owl/static/src/card/card.js @@ -0,0 +1,20 @@ +import { Component, useState } from "@odoo/owl"; + +export class Card extends Component { + static template = "awesome_owl.Card"; + + setup(){ + this.state = useState({ + isOpen: true, + }); + } + + toggle() { + this.state.isOpen = !this.state.isOpen; + } + + static props = { + title : String, + slots: Object, + } +} diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml new file mode 100644 index 00000000000..65435d111bc --- /dev/null +++ b/awesome_owl/static/src/card/card.xml @@ -0,0 +1,18 @@ + + +
+
+ + +
+ +
+ +
+
+
+
+
diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js new file mode 100644 index 00000000000..1140c493eb4 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.js @@ -0,0 +1,16 @@ +import { Component, useState } from "@odoo/owl"; + +export class Counter extends Component { + static template = "awesome_owl.Counter"; + + setup() { + this.state = useState({ value: 0 }); + } + + increment() { + this.state.value++; + if (this.props.onincrement) { + this.props.onincrement(); + } + } +} diff --git a/awesome_owl/static/src/counter/counter.xml b/awesome_owl/static/src/counter/counter.xml new file mode 100644 index 00000000000..6db9b2fc5bc --- /dev/null +++ b/awesome_owl/static/src/counter/counter.xml @@ -0,0 +1,10 @@ + + +
+ Counter: + +
+
+
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 4ac769b0aa5..4a8ffec4d47 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,5 +1,17 @@ -import { Component } from "@odoo/owl"; +import { Component, useState } from "@odoo/owl"; +import { Counter } from "./counter/counter"; +import { Card } from "./card/card"; +import { TodoList } from "./todo/todo_list"; export class Playground extends Component { static template = "awesome_owl.playground"; + static components = { Counter, Card, TodoList }; + + setup() { + this.sum = useState({ value: 0 }); + } + + incrementSum() { + this.sum.value++; + } } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..1c1c63f2564 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -1,10 +1,15 @@ - - + + +
- hello world + + + "The sum is :" +
+
+
-
diff --git a/awesome_owl/static/src/todo/todoList.xml b/awesome_owl/static/src/todo/todoList.xml new file mode 100644 index 00000000000..b17927f3461 --- /dev/null +++ b/awesome_owl/static/src/todo/todoList.xml @@ -0,0 +1,14 @@ + + Todo Input: +
+ + + +
+
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..ed750cfde13 --- /dev/null +++ b/awesome_owl/static/src/todo/todo_item.js @@ -0,0 +1,21 @@ +import { Component } from "@odoo/owl"; + +export class TodoItem extends Component { + static template = "awesome_owl.TodoItem"; + + static props = { + id: Number, + description: String, + isCompleted: Boolean, + toggleTodo: Function, + removeTodo: Function, + }; + + onToggle() { + this.props.toggleTodo(this.props.id); + } + + onRemove(){ + this.props.removeTodo(this.props.id); + } +} 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..2caf9553de9 --- /dev/null +++ b/awesome_owl/static/src/todo/todo_list.js @@ -0,0 +1,41 @@ +import { Component, useState} from "@odoo/owl"; +import { TodoItem } from "./todo_item"; +import { useAutofocus } from "../utils"; + +export class TodoList extends Component { + static template = "awesome_owl.TodoList"; + static components = { TodoItem }; + + setup(){ + this.inputRef = useAutofocus("InputValue") + this.todos = useState([]); + this.nextId = 1 + this.inputValue = useState({ text: "" }); + this.removeTodo = this.removeTodo.bind(this); + } + + addTodo(ev) + { + if (ev.keyCode != 13) return + this.todos.push({ + id : this.nextId++, + description : this.inputValue.text, + isCompleted : false + }) + this.inputValue.text = "" + } + + toggleTodo = (id) => { + const todo = this.todos.find(t => t.id == id); + if (todo) { + todo.isCompleted = !todo.isCompleted; + } + } + + removeTodo(id) { + const index = this.todos.findIndex(todo => todo.id === id); + if (index !== -1) { + this.todos.splice(index, 1); + } + } +} diff --git a/awesome_owl/static/src/todo/todoitem.xml b/awesome_owl/static/src/todo/todoitem.xml new file mode 100644 index 00000000000..ee3e5838559 --- /dev/null +++ b/awesome_owl/static/src/todo/todoitem.xml @@ -0,0 +1,14 @@ + +
+ + + id: - + description: - + iscompleted: + + +
+
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js new file mode 100644 index 00000000000..46a5a66101c --- /dev/null +++ b/awesome_owl/static/src/utils.js @@ -0,0 +1,11 @@ +import { useRef, onMounted } from "@odoo/owl"; + +export function useAutofocus(refName) { + const ref = useRef(refName); + + onMounted(() => { + ref.el.focus(); + }); + + return ref; +} 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..e8409c57acc --- /dev/null +++ b/estate/__manifest__.py @@ -0,0 +1,26 @@ +{ + 'name': "Estate", + 'version': '0.1', + 'summary': "Real Estate Advertisement", + 'description': """ + This module allows you to manage real estate advertisements, including + properties, agents, and customer inquiries. + """, + 'author': "aykhu", + 'license': 'LGPL-3', + 'website': "https://www.odoo.com/app/estate", + 'category': 'Tutorials', + 'application': True, + 'depends': ['base', 'calendar', 'mail'], + 'data': [ + 'security/ir.model.access.csv', + 'views/estate_property_issue_views.xml', + 'views/estate_property_visit_views.xml', + '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', + ], +} diff --git a/estate/models/__init__.py b/estate/models/__init__.py new file mode 100644 index 00000000000..7be08b9c0b5 --- /dev/null +++ b/estate/models/__init__.py @@ -0,0 +1,7 @@ +from . import estate_property +from . import estate_property_type +from . import estate_property_tag +from . import estate_property_offer +from . import res_users +from . import estate_property_visit +from . import estate_property_issues diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py new file mode 100644 index 00000000000..277e6be3c67 --- /dev/null +++ b/estate/models/estate_property.py @@ -0,0 +1,162 @@ +from dateutil.relativedelta import relativedelta + +from odoo import _, api, fields, models +from odoo.exceptions import UserError, ValidationError +from odoo.tools.float_utils import float_compare, float_is_zero + + +class EstateProperty(models.Model): + _name = 'estate.property' + _description = 'Estate Property' + _order = "id desc" + _inherit = ['mail.thread', 'mail.activity.mixin'] + + name = fields.Char(string='Title', required=True, default='Unknown') + description = fields.Text(string='Description') + postcode = fields.Char(string='Postal Code') + date_availability = fields.Date( + string='Available From', copy=False, default=lambda self: fields.Date.today() + relativedelta(months=3) + ) + expected_price = fields.Float(string='Expected Price', required=True) + selling_price = fields.Float( + string='Selling Price', readonly=True, copy=False + ) + living_area = fields.Integer(string='Living Area (sq m)') + bedrooms = fields.Integer(string='Bedrooms', default=2) + facades = fields.Integer(string='Facades') + has_garage = fields.Boolean(string="Has Garage ?") + has_garden = fields.Boolean(string="Has Garden ?") + garden_area = fields.Integer(string="Garden Area (sq m)") + active = fields.Boolean(string="Is Active ?", default=True) + garden_orientation = fields.Selection( + string="Garden Orientation", + selection=[ + ('north', 'North'), + ('south', 'South'), + ('east', 'East'), + ('west', 'West') + ], + ) + state = fields.Selection( + string="Status", + selection=[ + ("new", "New"), + ("offer_received", "Offer Received"), + ("offer_accepted", "Offer Accepted"), + ("sold", "Sold"), + ("cancelled", "Cancelled") + ], + required=True, default="new", copy=False + ) + property_type_id = fields.Many2one( + "estate.property.type", ondelete='cascade', string="Property Type" + ) + salesperson_id = fields.Many2one( + "res.users", string="Sales Person", default=lambda self: self.env.user + ) + buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False) + property_tags_ids = fields.Many2many( + "estate.property.tag", string="Property Tags" + ) + offer_ids = fields.One2many("estate.property.offer", "property_id") + total_area = fields.Float(compute="_compute_total_area") + best_price = fields.Float( + string="Best Offer", compute="_compute_best_price", store=True + ) + visit_ids = fields.One2many('estate.property.visit', 'property_id') + issue_ids = fields.One2many('estate.property.issue', 'property_id') + issue_count = fields.Integer(compute='_compute_issue_count') + + _check_expected_price = models.Constraint( + 'CHECK(expected_price > 0)', 'Price must be strictly positive' + ) + + @api.depends("living_area", "garden_area") + def _compute_total_area(self): + for record in self: + record.total_area = record.living_area + record.garden_area + + @api.depends("offer_ids.price") + def _compute_best_price(self): + for record in self: + if record.offer_ids: + record.best_price = max(record.offer_ids.mapped("price")) + else: + record.best_price = 0.0 + + @api.depends('visit_ids') + def _compute_issue_count(self): + data = dict(self.env['estate.property.issue']._read_group( + [('property_id', 'in', self.ids)], + groupby=['property_id'], + aggregates=['__count'] + )) + + for record in self: + record.issue_count = data.get(record, 0) + # record.issue_count = len(record.issue_ids) + + @api.onchange('has_garden') + def _onchange_garden(self): + if self.has_garden: + self.garden_area = 10 + self.garden_orientation = 'north' + else: + self.garden_area = None + self.garden_orientation = None + + @api.constrains('selling_price', 'expected_price') + def _check_selling_price(self): + for record in self: + if float_is_zero(record.selling_price, precision_digits=2): + continue + min_price = record.expected_price * 0.9 + if float_compare( + record.selling_price, + min_price, + precision_digits=2 + ) < 0: + raise ValidationError(_( + "The selling price cannot be lower than 90% of the expected price." + )) + + def action_property_sold(self): + if self.state == "cancelled": + raise UserError(_("Cancelled property cannot be set as sold.")) + elif self.issue_ids.priority == '3' and self.issue_ids.state != "resolved": + raise UserError(_("High priority issue is still not resolved")) + else: + self.state = "sold" + return True + + def action_set_sold_rainbow_man(self): + self.action_property_sold() + + return { + 'effect': { + 'fadeout': 'slow', + 'img_url': '/web/static/img/smile.svg', + 'type': 'rainbow_man', + } + } + + def action_property_cancelled(self): + if self.state == "sold": + raise UserError(_("Sold property cannot be set as cancelled")) + else: + self.state = "cancelled" + return True + + def action_accept_best_offer(self): + best_offer = self.offer_ids.filtered_domain( + [('price', '=', self.best_price)]) + best_offer.action_offer_accepted() + return True + + @api.ondelete(at_uninstall=False) + def delete_state_check(self): + for record in self: + if record.state not in ('new', 'cancelled'): + raise UserError( + _("Only New or Cancelled properties can be deleted")) + return True diff --git a/estate/models/estate_property_issues.py b/estate/models/estate_property_issues.py new file mode 100644 index 00000000000..6ec1a6ef11c --- /dev/null +++ b/estate/models/estate_property_issues.py @@ -0,0 +1,88 @@ +from datetime import timedelta + +from odoo import api, fields, models + +AVAILABLE_PRIORITIES = [ + ('1', 'Low'), + ('2', 'Medium'), + ('3', 'High'), +] + + +class EstatePropertyIssues(models.Model): + _name = 'estate.property.issue' + _description = "Raise and Manage issues in properties" + + name = fields.Char(required=True) + property_id = fields.Many2one('estate.property', required=True) + reported_by = fields.Many2one('res.partner') + assigned_to = fields.Many2one('res.users') + issue_type = fields.Selection( + selection=[ + ('plumbing', 'Plumbing'), + ('electrical', 'Electrical'), + ('structural', 'Structural'), + ('other', 'other'), + ], + required=True + ) + state = fields.Selection( + string="Status", + selection=[ + ("new", "New"), + ("in_progress", "In progress"), + ("resolved", "Resolved"), + ("cancelled", "Cancelled") + ], + default="new", + ) + priority = fields.Selection( + AVAILABLE_PRIORITIES, compute="_compute_priority" + ) + resolved_date = fields.Date() + description = fields.Text() + is_overdue = fields.Boolean(compute="_compute_is_overdue", default=False) + + @api.depends('issue_type') + def _compute_priority(self): + for record in self: + if record.issue_type not in ('electrical', 'structural'): + record.priority = '1' + if record.issue_type == 'electrical': + record.priority = '2' + if record.issue_type == 'structural': + record.priority = '3' + + @api.depends('create_date', 'priority', 'resolved_date') + def _compute_is_overdue(self): + priority_days = { + '3': 2, + '2': 5, + '1': 10, + } + + for record in self: + start_date = record.create_date.date() if record.create_date else fields.Date.today() + resolve_date = record.resolved_date or fields.Date.today() + limit_days = priority_days.get(record.priority) + + if (resolve_date - start_date) > timedelta(days=limit_days): + record.is_overdue = True + else: + record.is_overdue = False + + @api.onchange('assigned_to') + def _check_state(self): + for record in self: + if record.assigned_to and record.state == "new": + record.state = "in_progress" + + def action_set_resolved(self): + self.state = 'resolved' + if not self.resolved_date: + self.resolved_date = fields.Date.today() + return True + + def action_set_cancelled(self): + self.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..ebcb794c133 --- /dev/null +++ b/estate/models/estate_property_offer.py @@ -0,0 +1,79 @@ +from dateutil.relativedelta import relativedelta + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class EstatePropertyOffer(models.Model): + _name = "estate.property.offer" + _description = "Estate Property Offer" + _order = "price desc" + + price = fields.Float(string="Offer Price", required=True) + status = fields.Selection( + selection=[ + ("accepted", "Accepted"), + ("refused", "Refused"), + ], + string="Status", + copy=False, + ) + partner_id = fields.Many2one("res.partner", required=True) + property_id = fields.Many2one("estate.property", required=True) + validity = fields.Integer(string="Validity (days)", default=7) + date_deadline = fields.Date( + string="Deadline", compute='_compute_date_deadline', inverse="_inverse_deadline", + ) + property_type_id = fields.Many2one(related="property_id.property_type_id", store=True) + + _check_offer_price = models.Constraint( + 'CHECK (price > 0)', 'Offer price must be strictly positive' + ) + + @api.depends('create_date', 'validity') + def _compute_date_deadline(self): + for record in self: + start_date = ( + record.create_date.date() if record.create_date else fields.Date.today() + ) + record.date_deadline = start_date + relativedelta(days=record.validity) + + def _inverse_deadline(self): + for record in self: + start_date = ( + record.create_date.date() if record.create_date else fields.Date.today() + ) + record.validity = (record.date_deadline - start_date).days + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + current_price = vals.get('price') + property_id = self.env['estate.property'].browse(vals['property_id']) + for offer in property_id.offer_ids: + if current_price < offer.price: + raise UserError(_("Offer Price cannot be less than previous offer prices")) + + offers = super().create(vals_list) + + for offer in offers: + if offer.property_id.state == 'new': + offer.property_id.state = 'offer_received' + + return offers + + def action_offer_accepted(self): + if self.price < self.property_id.best_price: + raise UserError(_("Another higher price offer exists")) + self.status = "accepted" + self.property_id.selling_price = self.price + self.property_id.buyer_id = self.partner_id + self.property_id.state = "offer_accepted" + + offers = self.property_id.offer_ids.filtered(lambda x: x.status != "accepted") + offers.write({'status': 'refused'}) + return True + + def action_offer_refused(self): + 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..2bb729a1af9 --- /dev/null +++ b/estate/models/estate_property_tag.py @@ -0,0 +1,12 @@ +from odoo import fields, models + + +class EstatePropertyTags(models.Model): + _name = "estate.property.tag" + _description = "Estate Property Tag" + _order = "name" + + name = fields.Char(string="Name", required=True) + color = fields.Integer() + + _unique_tag_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..cdbc264d72a --- /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 = "Estate Property Type" + _order = "name" + + name = fields.Char(string="Name", required=True) + property_ids = fields.One2many("estate.property", "property_type_id") + sequence = fields.Integer() + offer_ids = fields.One2many("estate.property.offer", "property_type_id") + offer_count = fields.Integer(compute='_compute_offer_count') + + _unique_type_name = models.Constraint('UNIQUE(name)', "Type name must be unique") + + @api.depends('offer_count') + def _compute_offer_count(self): + for record in self: + record.offer_count = len(record.offer_ids) diff --git a/estate/models/estate_property_visit.py b/estate/models/estate_property_visit.py new file mode 100644 index 00000000000..24f346e3f02 --- /dev/null +++ b/estate/models/estate_property_visit.py @@ -0,0 +1,38 @@ +from datetime import timedelta + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class EstatePropertyVisit(models.Model): + _name = "estate.property.visit" + _description = "Schedule for properties" + + salesperson_id = fields.Many2one(related="property_id.salesperson_id") + customer_name = fields.Many2one('res.partner') + visit_date = fields.Datetime(default=fields.Datetime.now()) + property_id = fields.Many2one('estate.property', required=True) + + @api.model_create_multi + def create(self, vals_list): + + visits = super().create(vals_list) + + for visit in visits: + stop_time = visit.visit_date + timedelta(hours=+1) + self.env['calendar.event'].create({ + 'name': 'Property Visit', + 'start': visit.visit_date, + 'stop': stop_time, + }) + + return visits + + @api.constrains('visit_date', 'property_id') + def _check_visit_time(self): + for record in self: + for visit in record.property_id.visit_ids: + if record.id == visit.id or record.visit_date.date() != visit.visit_date.date(): + continue + if record.visit_date - visit.visit_date < timedelta(hours=1): + raise UserError(_("2 visits cannot have same time")) diff --git a/estate/models/res_users.py b/estate/models/res_users.py new file mode 100644 index 00000000000..a2cc9714f47 --- /dev/null +++ b/estate/models/res_users.py @@ -0,0 +1,10 @@ +from odoo import fields, models + + +class ResUsers(models.Model): + _name = 'res.users' + _inherit = ['res.users'] + + property_ids = fields.One2many( + 'estate.property', 'salesperson_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..662aadba025 --- /dev/null +++ b/estate/security/ir.model.access.csv @@ -0,0 +1,7 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1 +estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1 +estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1 +estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1 +estate.access_estate_visit,access_estate_property_visit,estate.model_estate_property_visit,base.group_user,1,1,1,1 +estate.access_estate_issue,access_estate_property_issue,estate.model_estate_property_issue,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..f2de1677bc3 --- /dev/null +++ b/estate/views/estate_menus.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/estate/views/estate_property_issue_views.xml b/estate/views/estate_property_issue_views.xml new file mode 100644 index 00000000000..ebbfa10dba9 --- /dev/null +++ b/estate/views/estate_property_issue_views.xml @@ -0,0 +1,64 @@ + + + + + Estate Property Issue + estate.property.issue + list,form + [('property_id', '=', active_id)] + + + + estate.property.issue.form + estate.property.issue + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + estate.property.issue.list + estate.property.issue + + + + + + + + + + + + +
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml new file mode 100644 index 00000000000..a3e0898a041 --- /dev/null +++ b/estate/views/estate_property_offer_views.xml @@ -0,0 +1,41 @@ + + + + Offers + estate.property.offer + list,form + [('property_type_id', '=', active_id)] + + + + estate.property.offer.list + estate.property.offer + + + + + + + + + + + + + + + + + + + + + + + + + + + + estate.property.type.list + estate.property.type + + + + + + + + + diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml new file mode 100644 index 00000000000..0311a910d8c --- /dev/null +++ b/estate/views/estate_property_views.xml @@ -0,0 +1,146 @@ + + + + Estate Property + estate.property + list,form,kanban + {'search_default_available_properties':1} + + + + estate.property.list + estate.property + + + + + + + + + + + + + + + + + estate.property.search + estate.property + + + + + + + + + + + + + + + + + + estate.property.form + estate.property + +
+
+
+ +
+ +
+

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + estate.property.kanban + estate.property + + + + + +
+ +
+ +
+ Expected Price : +
+
+ Best Price : +
+
+ Selling Price : +
+ +
+
+
+
+
+
+
+ +
diff --git a/estate/views/estate_property_visit_views.xml b/estate/views/estate_property_visit_views.xml new file mode 100644 index 00000000000..6a6166c76a4 --- /dev/null +++ b/estate/views/estate_property_visit_views.xml @@ -0,0 +1,44 @@ + + + + + Estate Property Visit + estate.property.visit + list,form,calendar + [('property_id', '=', active_id)] + + + + estate.property.visit.list + estate.property.visit + + + + + + + + + + estate.property.visit.form + estate.property.visit + +
+ + + + +
+ + + estate.property.visit.calendar + estate.property.visit + + + + + + + + +
diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml new file mode 100644 index 00000000000..b3fca2a5e0a --- /dev/null +++ b/estate/views/res_users_views.xml @@ -0,0 +1,15 @@ + + + + res.users.form.inherit.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..b4d4ff5cfad --- /dev/null +++ b/estate_account/__manifest__.py @@ -0,0 +1,6 @@ +{ + 'name': 'Estate Account', + 'author': "Ayush Khubchandani (aykhu)", + 'license': 'LGPL-3', + 'depends': ['estate', 'account'] +} 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..38c75f295ef --- /dev/null +++ b/estate_account/models/estate_account.py @@ -0,0 +1,26 @@ +from odoo import Command, models + + +class EstateAccount(models.Model): + _inherit = 'estate.property' + + def action_property_sold(self): + + super().action_property_sold() + + self.env['account.move'].create([{ + 'partner_id': self.salesperson_id.id, + 'move_type': 'out_invoice', + 'invoice_line_ids': [ + Command.create({ + 'name': '6% commision', + 'price_unit': self.selling_price * 0.06, + 'quantity': 1, + }), + Command.create({ + 'name': 'Administrative fees', + 'price_unit': 100, + 'quantity': 1, + }) + ] + }])