Skip to content

Commit 198127d

Browse files
committed
[ADD] estate_account: add a module to interact with the module estate
1 parent 432a707 commit 198127d

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
'name': 'Estate Account',
3+
'depends': [
4+
'estate',
5+
'account'
6+
],
7+
'application': True,
8+
'description': '',
9+
'data': [],
10+
'license': 'LGPL-3'
11+
}

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from odoo import Command, exceptions, models
2+
3+
4+
class EstateProperty(models.Model):
5+
_inherit = "estate.property"
6+
7+
def _create_invoices(self):
8+
if not self.env["account.move"].check_access_rights("create", False):
9+
try:
10+
self.check_access_rights("write")
11+
self.check_access_rule("write")
12+
except exceptions.AccessError:
13+
return self.env["account.move"]
14+
15+
invoice_vals_list = [
16+
{"name": "6% for selling price", "quantity": 1, "price_unit": 0.06 * self.selling_price},
17+
{"name": "100 for administration fees", "quantity": 1, "price_unit": 100.}
18+
]
19+
20+
self.ensure_one()
21+
22+
return self.env["account.move"].create({
23+
"partner_id": self.buyer_id.id,
24+
"move_type": "out_invoice",
25+
"invoice_line_ids": [Command.create(val) for val in invoice_vals_list],
26+
"invoice_user_id": self.env.uid,
27+
"invoice_origin": self.name
28+
})
29+
30+
def action_property_sold(self):
31+
self._create_invoices()
32+
return super().action_property_sold()

0 commit comments

Comments
 (0)