-
-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import contract | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import api, models | ||
|
||
|
||
class ContractContract(models.Model): | ||
_inherit = 'contract.contract' | ||
|
||
@api.multi | ||
def _prepare_recurring_invoices_values(self, date_ref=False): | ||
invoices_values = super(ContractContract, self).\ | ||
_prepare_recurring_invoices_values(date_ref=date_ref) | ||
return invoices_values | ||
|
||
@api.depends('contract_line_ids') | ||
def _compute_sale_order_count(self): | ||
super(ContractContract, self)._compute_sale_order_count() | ||
contract_count = len( | ||
self.contract_line_ids. | ||
mapped('sale_order_line_id.order_id.contract_id')) or 0 | ||
self.sale_order_count += contract_count | ||
|
||
@api.multi | ||
def action_view_sales_orders(self): | ||
res = super(ContractContract, self).action_view_sales_orders() | ||
contracts = self.contract_line_ids.mapped( | ||
'sale_order_line_id.order_id.contract_id' | ||
) | ||
res.get('domain')[0][2].extend(contracts) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import api, fields, models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = 'sale.order' | ||
|
||
contract_id = fields.Many2one( | ||
comodel_name="contract.contract", | ||
string="Contract", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="view_order_form_form_view" model="ir.ui.view"> | ||
<field name="name">sale.order.form.view</field> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale.view_order_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="partner_id" position="after"> | ||
<field name="contract_id" domain="[('partner_id', '=', partner_id)]"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |