Skip to content

Commit 09e1f6e

Browse files
committed
[IMP] estate_account: added a module to link estate and invoicing modules
1 parent 4a9112c commit 09e1f6e

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
'name': "estate sales link",
3+
'version': "0.1",
4+
'depends': [
5+
'base',
6+
'estate',
7+
'account'
8+
],
9+
'descritpion': "A module to link estate sales with invoicing",
10+
'author': "yagho",
11+
'application': True,
12+
'installable': True,
13+
'license': "LGPL-3",
14+
'data': []
15+
}

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_child
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from odoo import models, Command
2+
from odoo.exceptions import UserError
3+
4+
5+
class estatePropertyChild(models.Model):
6+
_inherit = 'estate.property'
7+
8+
def _get_default_journal(self):
9+
return self.env['account.journal'].search([
10+
*self.env['account.journal']._check_company_domain(self.env.company),
11+
('type', '=', 'sale'),
12+
], limit=1)
13+
14+
def action_sold(self):
15+
journal = self._get_default_journal()
16+
for record in self:
17+
if record['selling_price'] == 0:
18+
raise UserError("An offer must be accepted before setting the property as Sold")
19+
self.env['account.move'].create([{
20+
'journal_id': journal.id,
21+
'move_type': 'out_invoice',
22+
'partner_id': record.buyer_id.id,
23+
"line_ids": [
24+
Command.create({
25+
"name": record['name'],
26+
"quantity": 1,
27+
"price_unit": record['selling_price'] * 0.06,
28+
}),
29+
Command.create({
30+
"name": "Admin fees",
31+
"quantity": 1,
32+
"price_unit": 100.00,
33+
}),
34+
],
35+
}])
36+
return super().action_sold()

0 commit comments

Comments
 (0)