Skip to content

Commit 1dad555

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

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: 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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from odoo import fields, 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+
print(record['selling_price'])
18+
if record['selling_price'] == 0:
19+
raise UserError("An offer must be accepted before setting the property as Sold")
20+
self.env['account.move'].create([{
21+
'journal_id': journal.id,
22+
'move_type': 'out_invoice',
23+
'partner_id': record.buyer_id.id,
24+
"line_ids": [
25+
Command.create({
26+
"name": record['name'],
27+
"quantity": 1,
28+
"price_unit": record['selling_price'] * 0.06,
29+
}),
30+
Command.create({
31+
"name": "Admin fees",
32+
"quantity": 1,
33+
"price_unit": 100.00,
34+
}),
35+
],
36+
}])
37+
return super().action_sold()

0 commit comments

Comments
 (0)