Browse Source

Merge PR #373 into 12.0

Signed-off-by max3903
pull/376/head
OCA-git-bot 5 years ago
parent
commit
f11b9f3c2f
  1. 1
      agreement_legal_sale/__manifest__.py
  2. 1
      agreement_legal_sale/models/__init__.py
  3. 3
      agreement_legal_sale/models/sale_order.py
  4. 2
      agreement_legal_sale/readme/USAGE.rst
  5. 3
      agreement_serviceprofile/__manifest__.py
  6. 1
      agreement_serviceprofile/models/__init__.py
  7. 3
      agreement_serviceprofile/models/agreement_serviceprofile.py
  8. 9
      agreement_serviceprofile/models/product.py
  9. 7
      agreement_serviceprofile/views/product.xml

1
agreement_legal_sale/__manifest__.py

@ -15,7 +15,6 @@
], ],
'data': [ 'data': [
'views/agreement.xml', 'views/agreement.xml',
'views/product.xml',
'views/sale_order.xml', 'views/sale_order.xml',
], ],
'installable': True, 'installable': True,

1
agreement_legal_sale/models/__init__.py

@ -3,5 +3,4 @@
from . import ( from . import (
sale_order, sale_order,
agreement, agreement,
product,
) )

3
agreement_legal_sale/models/sale_order.py

@ -36,10 +36,11 @@ class SaleOrder(models.Model):
'sale_line_id': line.id, 'sale_line_id': line.id,
'uom_id': line.product_uom.id 'uom_id': line.product_uom.id
}) })
# If the product is a service profile, create one
# If the product creates service profiles, create one
if line.product_id.product_tmpl_id.is_serviceprofile: if line.product_id.product_tmpl_id.is_serviceprofile:
self.env['agreement.serviceprofile'].create({ self.env['agreement.serviceprofile'].create({
'name': line.name, 'name': line.name,
'product_id': line.product_id.product_tmpl_id.id,
'agreement_id': order.agreement_id.id, 'agreement_id': order.agreement_id.id,
}) })
return res return res

2
agreement_legal_sale/readme/USAGE.rst

@ -8,7 +8,7 @@ To use this module:
* the agreement template is copied into an agreement with a copy of the * the agreement template is copied into an agreement with a copy of the
sections, clauses, recitals and appendices sections, clauses, recitals and appendices
* all the sales order lines are added as agreement lines * all the sales order lines are added as agreement lines
* the products on the SO with BOM are added as service profile on the agreement
* the service products (with is_serviceprofile = True) on the SO are added as service profile on the agreement
* the customer information is set from the sales order * the customer information is set from the sales order
* the eventual analytic account linked to the sales order is set on the agreement * the eventual analytic account linked to the sales order is set on the agreement
* the agreement is linked to the sales order and vice versa * the agreement is linked to the sales order and vice versa

3
agreement_serviceprofile/__manifest__.py

@ -15,8 +15,9 @@
'data': [ 'data': [
'data/serviceprofile_stage.xml', 'data/serviceprofile_stage.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'views/product.xml',
'views/agreement_serviceprofile.xml', 'views/agreement_serviceprofile.xml',
'views/agreement.xml'
'views/agreement.xml',
], ],
'development_status': 'Beta', 'development_status': 'Beta',
'maintainers': [ 'maintainers': [

1
agreement_serviceprofile/models/__init__.py

@ -1,3 +1,4 @@
from . import agreement_serviceprofile from . import agreement_serviceprofile
from . import agreement from . import agreement
from . import agreement_stage from . import agreement_stage
from . import product

3
agreement_serviceprofile/models/agreement_serviceprofile.py

@ -26,7 +26,8 @@ class AgreementServiceProfile(models.Model):
notes = fields.Text(string="Notes") notes = fields.Text(string="Notes")
product_id = fields.Many2one('product.template', 'Service Product', product_id = fields.Many2one('product.template', 'Service Product',
domain="[('type', '=', 'service')]",
domain="[('is_serviceprofile', '=', True), "
"('type', '=', 'service')]",
required=True) required=True)
partner_id = fields.Many2one(related='agreement_id.partner_id', partner_id = fields.Many2one(related='agreement_id.partner_id',
string='Partner') string='Partner')

9
agreement_legal_sale/models/product.py → agreement_serviceprofile/models/product.py

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

7
agreement_legal_sale/views/product.xml → agreement_serviceprofile/views/product.xml

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 Open Source Integrators
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo> <odoo>
<!-- Copyright 2019 Open Source Integrators
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<!-- Product Template Form View --> <!-- Product Template Form View -->
<record id="product_template_form_view" model="ir.ui.view"> <record id="product_template_form_view" model="ir.ui.view">
@ -10,7 +9,7 @@
<field name="inherit_id" ref="product.product_template_form_view"/> <field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//notebook" position="inside"> <xpath expr="//notebook" position="inside">
<page id="agreement" string="Agreement">
<page id="agreement" string="Service">
<group> <group>
<group id="agreement_left"> <group id="agreement_left">
<field name="is_serviceprofile"/> <field name="is_serviceprofile"/>
Loading…
Cancel
Save