warnings cleanup and bug fixes for equipment & applications
This commit is contained in:
parent
87a1cb8860
commit
0a6f048708
7 changed files with 23 additions and 10 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class PartnerApplicationSpecification(models.Model):
|
||||
|
|
@ -12,7 +13,7 @@ class PartnerApplicationSpecification(models.Model):
|
|||
tracking=1,
|
||||
ondelete="restrict",
|
||||
domain="[('id', 'in', allowed_specification_keys)]",
|
||||
string="Name",
|
||||
string="Specification Name",
|
||||
required=True,
|
||||
)
|
||||
name = fields.Char(
|
||||
|
|
@ -29,3 +30,13 @@ class PartnerApplicationSpecification(models.Model):
|
|||
allowed_specification_keys = fields.Many2many(
|
||||
related="application_id.application_type_id.allowed_specification_keys",
|
||||
)
|
||||
|
||||
@api.constrains("key_id")
|
||||
def _constrain_key_id(self):
|
||||
for rec in self:
|
||||
if rec.key_id not in rec.allowed_specification_keys:
|
||||
raise ValidationError(
|
||||
_(
|
||||
f"Key '{rec.key_id.name}' is not allowed for this application type."
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<button name="%(action_view_partner_applications_by_type)d"
|
||||
type="action"
|
||||
class="oe_stat_button"
|
||||
context="{'application_type_id': active_id}"
|
||||
context="{'application_type_id': id}"
|
||||
icon="fa-gears"
|
||||
>
|
||||
<field name="applications_count" string="Applications"
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
<field name="specification_ids">
|
||||
<tree editable="bottom">
|
||||
<field name="allowed_specification_keys" column_invisible="1"/>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="key_id" />
|
||||
<field name="value"/>
|
||||
</tree>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
type="action"
|
||||
class="oe_stat_button"
|
||||
icon="fa-cogs"
|
||||
context="{'partner_id': active_id}"
|
||||
context="{'partner_id': id}"
|
||||
>
|
||||
<field string="Applications" name="applications_count"
|
||||
widget="statinfo"/>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ class Equipment(models.Model):
|
|||
comodel_name="res.partner",
|
||||
string="Physical Address",
|
||||
tracking=True,
|
||||
ondelete="cascade",
|
||||
ondelete="restrict",
|
||||
required=True,
|
||||
)
|
||||
|
||||
location_notes = fields.Text(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ class PartnerApplication(models.Model):
|
|||
for application in self:
|
||||
if len(application.equipment_ids.partner_id) > 1:
|
||||
raise ValidationError(
|
||||
"An application can only be linked to one partner."
|
||||
_("An application can only be linked to one partner.")
|
||||
)
|
||||
|
||||
@api.depends("equipment_ids")
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
<field name="name">Partner Equipments</field>
|
||||
<field name="res_model">fsm.equipment</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'default_application_id': active_id}</field>
|
||||
<field name="domain">[('application_id', '=', active_id)]</field>
|
||||
<field name="context">{'default_application_id': context.get("application_id")}</field>
|
||||
<field name="domain">[('application_id', '=', context.get("application_id"))]</field>
|
||||
</record>
|
||||
<record id="view_partner_application_search" model="ir.ui.view">
|
||||
<field name="name">partner.application.search</field>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
type="action"
|
||||
class="oe_stat_button"
|
||||
icon="fa-tachometer"
|
||||
context="{'application_id': active_id}"
|
||||
context="{'application_id': id}"
|
||||
>
|
||||
<field string="Equipments" name="equipment_count" widget="statinfo"/>
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue