File tree Expand file tree Collapse file tree 4 files changed +53
-0
lines changed Expand file tree Collapse file tree 4 files changed +53
-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 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 ()
You can’t perform that action at this time.
0 commit comments