Skip to content
Extraits de code Groupes Projets
Valider 7897750b rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

Modifs suite à la recette

parent a13f9f94
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -10,9 +10,11 @@
'hr_expense',
'l10n_fr',
'hr_timesheet',
'cgscop_timesheet',
],
"data": [
"views/hr_expense.xml",
"views/hr_timesheet.xml",
"views/product.xml",
],
'qweb': [
......
# © 2019 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import hr_employee
from . import hr_expense
from . import hr_timesheet
from . import product
......@@ -2,7 +2,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
from odoo.exceptions import RedirectWarning
class CGScopExpense(models.Model):
......@@ -10,8 +9,43 @@ class CGScopExpense(models.Model):
expense_gap = fields.Float(
string="Plafond de dépense",
related='product_id.expense_gap')
related="product_id.expense_gap")
timesheet_id = fields.Many2one(
comodel_name="account.analytic.line",
string="Ligne de Temps",
ondelete="restrict")
analytic_account_id = fields.Many2one(
related="timesheet_id.account_id",
string="Code Activité UR",
store=True)
coop_id = fields.Many2one(
related="timesheet_id.partner_id",
string="Contact",
store=True)
ur_financial_system_id = fields.Many2one(
related="timesheet_id.ur_financial_system_id",
string='Dispositif Financier',
store=True)
expense_formula = fields.Selection(
related='product_id.expense_formula')
quantity_computed = fields.Float(
string="Quantité",
compute="_compute_values")
unit_amount_computed = fields.Float(
string="Prix",
compute="_compute_values")
# ------------------------------------------------------
# Computed Fields
# ------------------------------------------------------
@api.depends('quantity', 'unit_amount')
def _compute_values(self):
self.quantity_computed = self.quantity
self.unit_amount_computed = self.unit_amount
# ------------------------------------------------------
# Onchange Fields
# ------------------------------------------------------
@api.onchange('total_amount')
def onchange_total_amount(self):
for exp in self:
......@@ -20,5 +54,16 @@ class CGScopExpense(models.Model):
return {
'warning': {
'title': "Plafond dépassé",
'message': "Attention, le montant est supérieur au plafond autorisé"}}
'message': "Attention, le montant est supérieur \
au plafond autorisé"}}
@api.onchange('product_id')
def onchange_product_id(self):
if self.product_id.expense_formula == 'fixed_price':
self.unit_amount = self.product_id.standard_price
self.update({
'unit_amount': self.product_id.standard_price
})
elif self.product_id.expense_formula == 'fixed_rate':
self.quantity = 1.0
self.product_id.unit_amount = self.product_id.standard_price
# © 2019 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields
from odoo import models, fields, api
from odoo.exceptions import ValidationError
class CGScopProductTemplate(models.Model):
_inherit = 'product.template'
expense_gap = fields.Float("Plafond de dépense")
expense_formula = fields.Selection([
('free', 'Libre'),
('fixed_rate', 'Forfait'),
('fixed_price', 'Prix fixe')],
string="Type de calcul",
default="free",
help="""
Défini l'option de calcul dans la note de frais :
- Libre : permet à l'utilisateur de définir le prix et la quantité
- Forfait : l'utilisateur n'a pas la possibilité de modifier le
prix ni la quantité égale à 1 par défaut
- Prix fixe : le prix est fixe, mais l'utilisateur peut modifier
la quantité (pour les km par exemple)
""")
class CGScopProductProduct(models.Model):
_inherit = 'product.product'
@api.one
@api.constrains('expense_formula', 'standard_price')
def _check_expense_formula(self):
if self.expense_formula != 'free' and self.standard_price == 0.0:
raise ValidationError(
"Le coût doit être supérieur à 0 si la formule de \
calcul n'est pas Libre")
......@@ -24,18 +24,55 @@
<field name="model">hr.expense</field>
<field name="inherit_id" ref="hr_expense.hr_expense_view_form"/>
<field name="arch" type="xml">
<xpath expr="//widget[@name='attach_document']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//widget[2]" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<field name="reference" position="attributes">
<attribute name="invisible">True</attribute>
</field>
<field name="date" position="attributes">
<attribute name="required">True</attribute>
</field>
<field name="product_id" position="attributes">
<attribute name="options">{'no_open': True}</attribute>
</field>
<field name="employee_id" position="attributes">
<attribute name="options">{'no_open': True}</attribute>
</field>
<field name="unit_amount" position="attributes">
<attribute name="attrs">{'invisible': [('expense_formula', '!=', 'free')]}</attribute>
</field>
<field name="unit_amount" position="after">
<field name="unit_amount_computed" attrs="{'invisible': [('expense_formula', '=', 'free')]}" />
<field name="quantity_computed" attrs="{'invisible': [('expense_formula', '!=', 'fixed_rate')]}" />
</field>
<label for="quantity" position="attributes">
<attribute name="attrs">{'invisible': [('expense_formula', '=', 'fixed_rate')]}</attribute>
</label>
<field name="quantity" position="attributes">
<attribute name="attrs">{'invisible': [('expense_formula', '=', 'fixed_rate')]}</attribute>
</field>
<field name="tax_ids" position="before">
<field name="expense_gap" attrs="{'invisible': [('expense_gap', '=', 0.0)]}" readonly="True" />
<field name="expense_formula" invisible="True" />
</field>
<field name="analytic_account_id" position="before">
<field name="timesheet_id" options="{'no_create_edit': True, 'no_open': True}" />
</field>
<field name="analytic_account_id" position="attributes">
<attribute name="string">Code activité CG</attribute>
<attribute name="string">Code activité UR</attribute>
<attribute name="groups"></attribute>
<attribute name="readonly">True</attribute>
<attribute name="options">{'no_open': True}</attribute>
<attribute name="attrs">{'invisible': [('timesheet_id', '=', False)]}</attribute>
</field>
<field name="analytic_account_id" position="after">
<field name="expense_gap" />
<field name="coop_id" attrs="{'invisible': [('timesheet_id', '=', False)]}" readonly="True" options="{'no_open': True}" />
<field name="ur_financial_system_id" attrs="{'invisible': [('timesheet_id', '=', False)]}" readonly="True" options="{'no_open': True}"/>
</field>
<label for="payment_mode" position="attributes">
<attribute name="invisible">True</attribute>
......
......@@ -5,12 +5,49 @@
<odoo>
<data>
<!-- Produit Note de Frais Form View -->
<record id="view_product_expense_cgscop_kanban_inherited" model="ir.ui.view">
<field name="name">product.product.expense.cgscop.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_kanban_view"/>
<field name="arch" type="xml">
<field name="lst_price" position="after">
<field name="standard_price"/>
<field name="can_be_expensed" />
<field name="expense_formula" />
</field>
<xpath expr="//templates/t/div/div/ul/li" position="replace" >
<t t-if="record.can_be_expensed">
<li><strong>Coût : <field name="standard_price"/></strong></li>
<li><strong><field name="expense_formula"/></strong></li>
</t>
<t t-if="record.sale_ok">
<li><strong>Prix : <field name="lst_price"/></strong></li>
</t>
</xpath>
</field>
</record>
<!-- Produit Note de Frais Form View -->
<record id="view_product_expense_cgscop_form_inherited" model="ir.ui.view">
<field name="name">product.product.expense.cgscop.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="hr_expense.product_product_expense_form_view"/>
<field name="arch" type="xml">
<field name="type" position="attributes">
<attribute name="invisible">True</attribute>
</field>
<field name="type" position="after">
<field name="expense_formula" required="True" />
</field>
<field name="list_price" position="attributes">
<attribute name="invisible">True</attribute>
</field>
<field name="standard_price" position="attributes">
<attribute name="attrs">
{'required': [('expense_formula', '!=', 'free')]}
</attribute>
</field>
<field name="uom_po_id" position="after">
<field name="expense_gap" />
</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