[IMP] Product Variant on Serviceprofile

[IMP] Allow Product Variant Serviceprofile

[IMP] Add Variant To Tree/Form View

[IMP] Boolean First
This commit is contained in:
scampbell
2020-09-21 10:57:42 -07:00
committed by Patrick Wilson
parent c97aece70f
commit 9d1251caf6
5 changed files with 49 additions and 4 deletions

View File

@@ -28,8 +28,11 @@ class AgreementServiceProfile(models.Model):
notes = fields.Text(string="Notes")
product_id = fields.Many2one('product.template', 'Service Product',
domain="[('is_serviceprofile', '=', True), "
"('type', '=', 'service')]",
required=True)
"('type', '=', 'service')]")
product_variant_id = fields.Many2one('product.product', 'Service Product Variant',
domain="[('is_serviceprofile', '=', True), "
"('type', '=', 'service')]")
use_product_variant = fields.Boolean('Use Product Variant', default=False)
partner_id = fields.Many2one(related='agreement_id.partner_id',
string='Partner')

View File

@@ -16,3 +16,17 @@ class ProductTemplate(models.Model):
def onchange_type(self):
if self.is_serviceprofile:
self.type = 'service'
class ProductProduct(models.Model):
_inherit = 'product.product'
is_serviceprofile = fields.Boolean(
string="Create Service Profiles",
help="""If True, this product will create a service profile on the
agreement when the sales order is confirmed.""")
@api.onchange('is_serviceprofile')
def onchange_type(self):
if self.is_serviceprofile:
self.type = 'service'

View File

@@ -12,6 +12,7 @@
<tree>
<field name="name"/>
<field name="product_id"/>
<field name="product_variant_id"/>
</tree>
<form>
<group>
@@ -19,7 +20,9 @@
<field name="name"/>
</group>
<group>
<field name="product_id"/>
<field name="use_product_variant"/>
<field name="product_variant_id" attrs="{'invisible': [('use_product_variant', '=', False)], 'required': [('use_product_variant','!=', False)]}"/>
<field name="product_id" attrs="{'invisible': [('use_product_variant', '!=', False)], 'required': [('use_product_variant','=', False)]}"/>
</group>
</group>
<group string="Notes">

View File

@@ -11,6 +11,7 @@
<field name="agreement_id"/>
<field name="partner_id"/>
<field name="product_id"/>
<field name="product_variant_id"/>
<field name="active" invisible="1"/>
</tree>
</field>
@@ -47,7 +48,9 @@
<field name="agreement_id"/>
</group>
<group>
<field name="product_id"/>
<field name="product_id" attrs="{'invisible': [('use_product_variant', '!=', False)], 'required': [('use_product_variant','=', False)]}"/>
<field name="product_variant_id" attrs="{'invisible': [('use_product_variant', '=', False)], 'required': [('use_product_variant','!=', False)]}"/>
<field name="use_product_variant"/>
</group>
</group>
<group string="Notes">
@@ -96,6 +99,9 @@
<filter string="Product" name="group_product"
icon="terp-product"
context="{'group_by': 'product_id'}"/>
<filter string="Product Variant" name="group_product"
icon="terp-product"
context="{'group_by': 'product_variant_id'}"/>
</search>
</field>
</record>

View File

@@ -21,4 +21,23 @@
</field>
</record>
<!-- Product Template Form View -->
<record id="product_product_form_view" model="ir.ui.view">
<field name="name">product.product.form.view</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page id="agreement" string="Service">
<group>
<group id="agreement_left">
<field name="is_serviceprofile"/>
</group>
<group id="agreement_right"/>
</group>
</page>
</xpath>
</field>
</record>
</odoo>