Skip to content
Extraits de code Groupes Projets
Valider e5aa1f1d rédigé par Juliana's avatar Juliana
Parcourir les fichiers

[MIG] Migration 14.0

parent 0232cd50
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!1Refactor reports
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{ {
'name': 'Le Filament - Training', 'name': 'Le Filament - Training',
'version': '13.0.1.0.0', 'version': '14.0.1.0.0',
'summary': 'Training sessions managment', 'summary': 'Training sessions managment',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': 'LE FILAMENT', 'author': 'LE FILAMENT',
......
...@@ -66,7 +66,8 @@ class Training(models.Model): ...@@ -66,7 +66,8 @@ class Training(models.Model):
store=True) store=True)
rate = fields.Integer( rate = fields.Integer(
string="Taux horaire", string="Taux horaire",
compute='_compute_costs') compute='_compute_costs',
default=0)
students_count = fields.Integer( students_count = fields.Integer(
string='Nombre de stagiaires', string='Nombre de stagiaires',
compute='_compute_students_count', compute='_compute_students_count',
...@@ -141,23 +142,29 @@ class Training(models.Model): ...@@ -141,23 +142,29 @@ class Training(models.Model):
# ------------------------------------------------------ # ------------------------------------------------------
@api.depends('student_ids') @api.depends('student_ids')
def _compute_students_count(self): def _compute_students_count(self):
self.students_count = len(self.student_ids) for record in self:
record.students_count = len(record.student_ids)
@api.depends('student_ids', 'cost') @api.depends('students_count', 'cost', 'hours_total')
def _compute_costs(self): def _compute_costs(self):
if self.students_count > 0: for record in self:
self.student_cost = self.cost / self.students_count record.student_cost = 0
if self.hours_total > 0: record.rate = 0
self.rate = self.cost / self.hours_total if record.students_count > 0:
record.student_cost = record.cost / record.students_count
if record.hours_total > 0:
record.rate = record.cost / record.hours_total
@api.depends('session_ids') @api.depends('session_ids')
def _compute_sessions(self): def _compute_sessions(self):
self.session_count = len(self.session_ids) for record in self:
self.hours = sum(self.session_ids.mapped('date_delay')) record.session_count = len(record.session_ids)
record.hours = sum(record.session_ids.mapped('date_delay'))
@api.depends('session_ids', 'student_ids') @api.depends('students_count', 'hours')
def _compute_hours_total(self): def _compute_hours_total(self):
self.hours_total = self.students_count * self.hours for record in self:
record.hours_total = record.students_count * record.hours
@api.depends('order_ids') @api.depends('order_ids')
def _compute_amount(self): def _compute_amount(self):
...@@ -165,7 +172,8 @@ class Training(models.Model): ...@@ -165,7 +172,8 @@ class Training(models.Model):
@api.depends('invoice_ids') @api.depends('invoice_ids')
def _compute_invoiced(self): def _compute_invoiced(self):
self.invoiced = sum(self.invoice_ids.mapped('amount_untaxed_signed')) for record in self:
record.invoiced = sum(record.invoice_ids.mapped('amount_untaxed_signed'))
# ------------------------------------------------------ # ------------------------------------------------------
# Buttons # Buttons
......
...@@ -150,14 +150,15 @@ ...@@ -150,14 +150,15 @@
<field name="dpi">90</field> <field name="dpi">90</field>
</record> </record>
<report id="report_agreement_pdf" <record id="report_agreement_pdf" model="ir.actions.report">
name="lefilament_training.qweb_agreement_pdf" <field name="name">Formation - Convention</field>
model="training.training" <field name="model">training.training</field>
string="Formation - Convention" <field name="report_type">qweb-pdf</field>
report_type="qweb-pdf" <field name="report_name">lefilament_training.qweb_agreement_pdf</field>
attachment_use="False" <field name="binding_model_id" ref="model_training_training"/>
paperformat="paperformat_a4_training" <field name="binding_type">report</field>
/> <field name="paperformat_id" ref="paperformat_a4_training"/>
</record>
</data> </data>
</odoo> </odoo>
\ No newline at end of file
...@@ -109,14 +109,15 @@ ...@@ -109,14 +109,15 @@
<field name="dpi">90</field> <field name="dpi">90</field>
</record> </record>
<report id="report_attendance_sheet_pdf" <record id="report_attendance_sheet_pdf" model="ir.actions.report">
name="lefilament_training.qweb_attendance_sheet_pdf" <field name="name">Formation - Feuille d'émargement</field>
model="training.training" <field name="model">training.training</field>
string="Formation - Feuille d'émargement" <field name="report_type">qweb-pdf</field>
report_type="qweb-pdf" <field name="report_name">lefilament_training.qweb_attendance_sheet_pdf</field>
paperformat="paperformat_a4_training" <field name="binding_model_id" ref="model_training_training"/>
attachment_use="False" <field name="binding_type">report</field>
/> <field name="paperformat_id" ref="paperformat_a4_training"/>
</record>
</data> </data>
</odoo> </odoo>
\ No newline at end of file
...@@ -65,14 +65,15 @@ ...@@ -65,14 +65,15 @@
</t> </t>
</template> </template>
<report id="report_attestation_pdf" <record id="report_attestation_pdf" model="ir.actions.report">
name="lefilament_training.qweb_attestation_pdf" <field name="name">Formation - Attestations</field>
model="training.training" <field name="model">training.training</field>
string="Formation - Attestations" <field name="report_type">qweb-pdf</field>
report_type="qweb-pdf" <field name="report_name">lefilament_training.qweb_attestation_pdf</field>
attachment_use="False" <field name="binding_model_id" ref="model_training_training"/>
paperformat="paperformat_a4_training" <field name="binding_type">report</field>
/> <field name="paperformat_id" ref="paperformat_a4_training"/>
</record>
</data> </data>
</odoo> </odoo>
\ No newline at end of file
...@@ -78,14 +78,15 @@ ...@@ -78,14 +78,15 @@
</t> </t>
</template> </template>
<report id="report_program_pdf" <record id="report_program_pdf" model="ir.actions.report">
name="lefilament_training.qweb_program_pdf" <field name="name">Formation - Programme</field>
model="training.training" <field name="model">training.training</field>
string="Formation - Programme" <field name="report_type">qweb-pdf</field>
report_type="qweb-pdf" <field name="report_name">lefilament_training.qweb_program_pdf</field>
attachment_use="False" <field name="binding_model_id" ref="model_training_training"/>
paperformat="paperformat_a4_training" <field name="binding_type">report</field>
/> <field name="paperformat_id" ref="paperformat_a4_training"/>
</record>
</data> </data>
</odoo> </odoo>
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