Skip to content
Extraits de code Groupes Projets
Valider 559fa7a4 rédigé par Rémi - Le Filament's avatar Rémi - Le Filament
Parcourir les fichiers

[ADD@ color on avancement, store computed sums and readonly subvention

parent 53eb18fd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from datetime import datetime from datetime import datetime
from random import randint
from odoo import _, api, fields, models from odoo import _, api, fields, models
...@@ -43,7 +44,9 @@ class SaleProject(models.Model): ...@@ -43,7 +44,9 @@ class SaleProject(models.Model):
ondelete="cascade", ondelete="cascade",
) )
# Related fields from sale order # Related fields from sale order
state = fields.Selection(related="sale_order_id.state", store=True) state = fields.Selection(
related="sale_order_id.state", store=True, string="État de la commande"
)
partner_id = fields.Many2one( partner_id = fields.Many2one(
"res.partner", related="sale_order_id.partner_id", store=True, string="Client" "res.partner", related="sale_order_id.partner_id", store=True, string="Client"
) )
...@@ -139,26 +142,42 @@ class SaleProject(models.Model): ...@@ -139,26 +142,42 @@ class SaleProject(models.Model):
) )
# Fields computed from list of interventions # Fields computed from list of interventions
intervention_counter = fields.Integer( intervention_counter = fields.Integer(
compute="_compute_intervention_values", string="Nombre d'interventions" compute="_compute_intervention_values",
string="Nombre d'interventions",
compute_sudo="True",
) )
intervention_total_length = fields.Float( intervention_total_length = fields.Float(
compute="_compute_intevention_values", string="Longeur interventions" compute="_compute_intervention_values",
string="Longeur interventions",
group_operator="sum",
store=True,
compute_sudo="True",
) )
intervention_total_surface = fields.Integer( intervention_total_surface = fields.Integer(
compute="_compute_intevention_values", string="Surface interventions" compute="_compute_intervention_values",
string="Surface interventions",
group_operator="sum",
store=True,
compute_sudo="True",
) )
intervention_total_plant_qty = fields.Integer( intervention_total_plant_qty = fields.Integer(
compute="_compute_intevention_values", string="Nb plants interventions" compute="_compute_intervention_values",
string="Nb plants interventions",
group_operator="sum",
store=True,
compute_sudo="True",
) )
intervention_type_ids = fields.Many2many( intervention_type_ids = fields.Many2many(
comodel_name="product.template", comodel_name="product.template",
string="Types d'intervention", string="Types d'intervention",
compute="_compute_intervention_values", compute="_compute_intervention_values",
compute_sudo="True",
) )
intervention_financial_help_ids = fields.Many2many( intervention_financial_help_ids = fields.Many2many(
comodel_name="sale.financial.help", comodel_name="sale.financial.help",
string="Aides financières", string="Aides financières",
compute="_compute_intervention_values", compute="_compute_intervention_values",
compute_sudo="True",
) )
sale_order_line_ids = fields.One2many( sale_order_line_ids = fields.One2many(
...@@ -340,7 +359,11 @@ class SaleProjectAdvancement(models.Model): ...@@ -340,7 +359,11 @@ class SaleProjectAdvancement(models.Model):
_description = "Avancement" _description = "Avancement"
_order = "name" _order = "name"
def _get_default_color(self):
return randint(1, 11)
name = fields.Char(string="Avancement", required=True) name = fields.Char(string="Avancement", required=True)
color = fields.Integer(string="Color Index", default=_get_default_color)
class SaleProjectSaison(models.Model): class SaleProjectSaison(models.Model):
......
...@@ -41,9 +41,14 @@ ...@@ -41,9 +41,14 @@
string="Projets" string="Projets"
> >
<tree editable="bottom"> <tree editable="bottom">
<field name="id" invisible="1" />
<field name="name" optional="show" readonly="True" /> <field name="name" optional="show" readonly="True" />
<field name="state" invisible="1" /> <field name="state" invisible="1" />
<field name="project_subvention_id" optional="show" /> <field
name="project_subvention_id"
optional="show"
attrs="{'readonly': [('id','!=', False)]}"
/>
<field name="user_id" optional="show" /> <field name="user_id" optional="show" />
<field name="admin_state_id" optional="show" /> <field name="admin_state_id" optional="show" />
<field <field
...@@ -130,6 +135,7 @@ ...@@ -130,6 +135,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree editable="top"> <tree editable="top">
<field name="name" /> <field name="name" />
<field name="color" widget="color_picker" />
</tree> </tree>
</field> </field>
</record> </record>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<group name="required_infos" string="Projet"> <group name="required_infos" string="Projet">
<group> <group>
<field name="project_subvention_id" /> <field name="project_subvention_id" readonly="True" />
<field name="geo_sector_id" /> <field name="geo_sector_id" />
<field name="user_id" /> <field name="user_id" />
</group> </group>
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
name="project_subvention_id" name="project_subvention_id"
optional="show" optional="show"
options="{'no_create_edit': True}" options="{'no_create_edit': True}"
readonly="True"
/> />
<field <field
name="user_id" name="user_id"
...@@ -137,14 +138,8 @@ ...@@ -137,14 +138,8 @@
<field <field
name="admin_state_id" name="admin_state_id"
optional="show" optional="show"
options="{'no_create_edit': True}" widget="badge"
/> options="{'color_field': 'color', 'no_create_edit': True}"
<field
name="sale_project_suivi_ids"
optional="hide"
widget="many2many_tags"
domain="[('sale_project_admin_state_id', '=', admin_state_id)]"
options="{'no_create_edit': True}"
/> />
<field <field
name="intervention_type_ids" name="intervention_type_ids"
...@@ -161,16 +156,28 @@ ...@@ -161,16 +156,28 @@
name="sale_project_advancement_ids" name="sale_project_advancement_ids"
optional="hide" optional="hide"
widget="many2many_tags" widget="many2many_tags"
options="{'no_create_edit': True}" options="{'color_field': 'color', 'no_create_edit': True}"
/> />
<field <field
name="intervention_financial_help_ids" name="intervention_financial_help_ids"
optional="hide" optional="hide"
widget="many2many_tags" widget="many2many_tags"
/> />
<field name="intervention_total_length" optional="hide" /> <field
<field name="intervention_total_surface" optional="hide" /> name="intervention_total_length"
<field name="intervention_total_plant_qty" optional="hide" /> sum="Longueur"
optional="hide"
/>
<field
name="intervention_total_surface"
sum="Surface"
optional="hide"
/>
<field
name="intervention_total_plant_qty"
sum="Nb de Plants"
optional="hide"
/>
<button <button
type="object" type="object"
name="action_interventions" name="action_interventions"
...@@ -185,9 +192,25 @@ ...@@ -185,9 +192,25 @@
<field name="model">sale.project</field> <field name="model">sale.project</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<search string="Recherche de Projet de Création"> <search string="Recherche de Projet de Création">
<field name="name" />
<field name="sale_order_id" /> <field name="sale_order_id" />
<field name="project_subvention_id" /> <field name="project_subvention_id" />
<field name="partner_id" />
<field name="partner_geo_sector_id" />
<field name="user_id" />
<field name="sale_user_id" />
<filter
string="Paillage Déroulé"
name="paillage"
domain="[('sale_project_advancement_ids', 'in', %(ap_sale_project.sale_product_advancement_1)d)]"
/>
<group expand="0" string="Group By"> <group expand="0" string="Group By">
<filter
name="group_by_saison"
string="Saison"
domain="[]"
context="{'group_by':'saison_id'}"
/>
<filter <filter
name="group_by_order" name="group_by_order"
string="Devis" string="Devis"
...@@ -205,11 +228,26 @@ ...@@ -205,11 +228,26 @@
name="sale_project_admin_state" name="sale_project_admin_state"
context="{'group_by': 'admin_state_id'}" context="{'group_by': 'admin_state_id'}"
/> />
<filter
string="État de la commande"
name="group_by_state"
context="{'group_by': 'state'}"
/>
<filter <filter
string="Client" string="Client"
name="group_by_partner_id" name="group_by_partner_id"
context="{'group_by': 'partner_id'}" context="{'group_by': 'partner_id'}"
/> />
<filter
string="Référent"
name="group_by_user_id"
context="{'group_by': 'user_id'}"
/>
<filter
string="Vendeur"
name="group_by_sale_user_id"
context="{'group_by': 'sale_user_id'}"
/>
</group> </group>
</search> </search>
</field> </field>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter