File tree Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ from . import models
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ from . import estate_property_child
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments