Skip to content

Commit

Permalink
[ADD] estate_account: Chapter 14-link module estate and accounting
Browse files Browse the repository at this point in the history
Override the sold action of the estate module to create an invoice
when a property is sold.
The invoice is a 6% down payement with a 100€ admin fees.
  • Loading branch information
Clement-Cardot committed Mar 22, 2024
1 parent d83235a commit 22f74cc
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions estate_account/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions estate_account/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
'name': "estate_account",
'version': '1.0',
'depends': ['estate', 'account'],
'author': "Clément Cardot (cacl)",
'license': "LGPL-3",
'description': """
A link module to create invoices from property sales
""",

'data': [

],

'application': False,
}
3 changes: 3 additions & 0 deletions estate_account/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import estate_property
27 changes: 27 additions & 0 deletions estate_account/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import models, Command

class EstateProperty(models.Model):
_inherit = "estate.property"

def action_sold(self):
values = {
'move_type': 'out_invoice',
'partner_id': self.buyer_id.id,
#'journal_id': self.env['account.journal'].search([('type', '=', 'sale')], limit=1).id
'invoice_line_ids': [
Command.create({
'name': self.name + ' - 6% down payment',
'quantity': 1,
'price_unit': self.selling_price * 0.06,
}),
Command.create({
'name': 'administrative fees',
'quantity': 1,
'price_unit': 100.00,
}),
]
}
self.env['account.move'].create(values)
return super().action_sold()

0 comments on commit 22f74cc

Please sign in to comment.