Skip to content

Commit 9c68110

Browse files
author
youness benbraitit (yoben)
committed
[IMP] estate: added invoicing
added invoicing debuged an issue when invoices does not appear
1 parent 360f500 commit 9c68110

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

estate_account/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

estate_account/__manifest__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
'name': 'Estate - Accounting Link',
3+
'summary': 'Link between Real Estate and Accounting',
4+
'version': '1.0',
5+
'category': 'Accounting/Localisation',
6+
'author': 'Odoo S.A.',
7+
'license': 'LGPL-3',
8+
'depends': ['estate', 'account'],
9+
'data': [
10+
],
11+
'installable': True,
12+
'application': False,
13+
}

estate_account/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import estate_property
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from odoo import Command, models
2+
3+
4+
class EstateProperty(models.Model):
5+
_inherit = "estate.property"
6+
7+
def action_sold(self):
8+
res = super(EstateProperty, self).action_sold()
9+
10+
AccountMove = self.env['account.move']
11+
Journal = self.env['account.journal']
12+
for prop in self:
13+
partner = prop.buyer_id
14+
if not partner:
15+
continue
16+
journal = Journal.search([('type', '=', 'sale')], limit=1)
17+
commission_amount = 0.0
18+
if prop.selling_price:
19+
commission_amount = round(0.06 * float(prop.selling_price), 2)
20+
vals = {
21+
'partner_id': partner.id,
22+
'move_type': 'out_invoice',
23+
'invoice_line_ids': [
24+
Command.create({
25+
'name': 'Commission (6%)',
26+
'quantity': 1.0,
27+
'price_unit': commission_amount,
28+
}),
29+
Command.create({
30+
'name': 'Administrative fees',
31+
'quantity': 1.0,
32+
'price_unit': 100.00,
33+
}),
34+
],
35+
}
36+
if journal:
37+
vals['journal_id'] = journal.id
38+
AccountMove.create(vals)
39+
return res

0 commit comments

Comments
 (0)