Browse Source

[IMP] agreement_sale

pull/257/head
Maxime Chambreuil 6 years ago
parent
commit
2789dfbb8e
  1. 3
      agreement_sale/__init__.py
  2. 7
      agreement_sale/__manifest__.py
  3. 4
      agreement_sale/models/__init__.py
  4. 4
      agreement_sale/models/agreement.py
  5. 13
      agreement_sale/models/product.py
  6. 11
      agreement_sale/models/sale_order.py
  7. 4
      agreement_sale/views/agreement.xml
  8. 25
      agreement_sale/views/product.xml
  9. 4
      agreement_sale/views/sale_order.xml

3
agreement_sale/__init__.py

@ -1,3 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

7
agreement_sale/__manifest__.py

@ -1,5 +1,5 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Agreement - Sale',
@ -15,7 +15,8 @@
],
'data': [
'views/agreement.xml',
'views/sale_order.xml'
'views/product.xml',
'views/sale_order.xml',
],
'installable': True,
'development_status': 'Beta',

4
agreement_sale/models/__init__.py

@ -1,6 +1,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import (
sale_order,
agreement,
product,
)

4
agreement_sale/models/agreement.py

@ -1,5 +1,5 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models

13
agreement_sale/models/product.py

@ -0,0 +1,13 @@
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
is_serviceprofile = fields.Boolean(
string="Create a Service Profile",
help="""If True, this product will create a service profile on the
agreement when the sales order is confirmed.""")

11
agreement_sale/models/sale_order.py

@ -1,5 +1,5 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
# Copyright (C) 2019 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
@ -37,11 +37,8 @@ class SaleOrder(models.Model):
'sale_line_id': line.id,
'uom_id': line.product_uom.id
})
# If the product sold has a BOM, create a service profile
bom = self.env['mrp.bom'].search(
[('product_tmpl_id', '=',
line.product_id.product_tmpl_id.id)])
if bom:
# If the product is a service profile, create one
if line.product_id.product_tmpl_id.is_serviceprofile:
self.env['agreement.serviceprofile'].create({
'name': line.name,
'agreement_id': order.agreement_id.id,

4
agreement_sale/views/agreement.xml

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<odoo>
<!-- Copyright 2018 Open Source Integrators
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<!-- Copyright 2019 Open Source Integrators
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<!-- Agreement Form View -->
<record id="agreement_sale_form_view" model="ir.ui.view">

25
agreement_sale/views/product.xml

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<odoo>
<!-- Copyright 2019 Open Source Integrators
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<!-- Product Template Form View -->
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.form.view</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page id="agreement" string="Agreement">
<group>
<group id="agreement-left">
<field name="is_serviceprofile"/>
</group>
<group id="agreement-right"/>
</group>
</page>
</xpath>
</field>
</record>
</odoo>

4
agreement_sale/views/sale_order.xml

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<odoo>
<!-- Copyright 2018 Open Source Integrators
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<!-- Copyright 2019 Open Source Integrators
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<!-- Agreement Form View -->
<record id="sale_order_agreement_form_view" model="ir.ui.view">

Loading…
Cancel
Save