Skip to content

Commit

Permalink
Merge 54dd83f into 7694b30
Browse files Browse the repository at this point in the history
  • Loading branch information
nikul-serpentcs committed Dec 17, 2019
2 parents 7694b30 + 54dd83f commit 199d735
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 1 deletion.
4 changes: 4 additions & 0 deletions contract_sale/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Contributors

* Levent Karakaş
* Bejaoui Souheil <souheil.bejaoui@acsone.eu>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>

* Nikul Chaudhary <nikul.chaudhary.serpentcs@gmail.com>


Maintainers
~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions contract_sale/__init__.py
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
3 changes: 2 additions & 1 deletion contract_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/contract',
'depends': [
'sale',
'sale_management',
'contract',
],
'data': [
Expand All @@ -20,6 +20,7 @@
'views/contract_line.xml',
'views/contract_template.xml',
'views/res_partner_view.xml',
'views/sale_order.xml',
],
'license': 'AGPL-3',
'installable': True,
Expand Down
4 changes: 4 additions & 0 deletions contract_sale/models/__init__.py
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
29 changes: 29 additions & 0 deletions contract_sale/models/contract.py
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
11 changes: 11 additions & 0 deletions contract_sale/models/sale_order.py
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",
)
15 changes: 15 additions & 0 deletions contract_sale/views/sale_order.xml
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>

0 comments on commit 199d735

Please sign in to comment.