diff --git a/__manifest__.py b/__manifest__.py index 933aba260d9a141b0f219442c4883b2e6c6c792b..2190e2c356074dce219c93bdee72d11daf9cfa81 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -2,7 +2,7 @@ { 'name': 'Le Filament - Training', - 'version': '13.0.1.0.0', + 'version': '14.0.1.0.0', 'summary': 'Training sessions managment', 'license': 'AGPL-3', 'author': 'LE FILAMENT', diff --git a/models/training_training.py b/models/training_training.py index c862e86ccbb80692eec8fa33204a572a7474027b..1667878e9d3b8a52061c324502c190b9bc64ab0c 100644 --- a/models/training_training.py +++ b/models/training_training.py @@ -66,7 +66,8 @@ class Training(models.Model): store=True) rate = fields.Integer( string="Taux horaire", - compute='_compute_costs') + compute='_compute_costs', + default=0) students_count = fields.Integer( string='Nombre de stagiaires', compute='_compute_students_count', @@ -141,23 +142,29 @@ class Training(models.Model): # ------------------------------------------------------ @api.depends('student_ids') 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): - if self.students_count > 0: - self.student_cost = self.cost / self.students_count - if self.hours_total > 0: - self.rate = self.cost / self.hours_total + for record in self: + record.student_cost = 0 + record.rate = 0 + 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') def _compute_sessions(self): - self.session_count = len(self.session_ids) - self.hours = sum(self.session_ids.mapped('date_delay')) + for record in self: + 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): - self.hours_total = self.students_count * self.hours + for record in self: + record.hours_total = record.students_count * record.hours @api.depends('order_ids') def _compute_amount(self): @@ -165,7 +172,8 @@ class Training(models.Model): @api.depends('invoice_ids') 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 diff --git a/report/report_agreement.xml b/report/report_agreement.xml index d31562cd942e79723084b9c5d6fa30e7340eed8b..eb091ef3b7a619f73142b23f1e5ddafa1679f4e1 100644 --- a/report/report_agreement.xml +++ b/report/report_agreement.xml @@ -150,14 +150,15 @@ <field name="dpi">90</field> </record> - <report id="report_agreement_pdf" - name="lefilament_training.qweb_agreement_pdf" - model="training.training" - string="Formation - Convention" - report_type="qweb-pdf" - attachment_use="False" - paperformat="paperformat_a4_training" - /> + <record id="report_agreement_pdf" model="ir.actions.report"> + <field name="name">Formation - Convention</field> + <field name="model">training.training</field> + <field name="report_type">qweb-pdf</field> + <field name="report_name">lefilament_training.qweb_agreement_pdf</field> + <field name="binding_model_id" ref="model_training_training"/> + <field name="binding_type">report</field> + <field name="paperformat_id" ref="paperformat_a4_training"/> + </record> </data> </odoo> \ No newline at end of file diff --git a/report/report_attendance_sheet.xml b/report/report_attendance_sheet.xml index 702d4a90e098d36789fc7da3c34cf4dc013e6347..b8719f6d2ab4bc409bc5ead28488a59a22f0a99e 100644 --- a/report/report_attendance_sheet.xml +++ b/report/report_attendance_sheet.xml @@ -109,14 +109,15 @@ <field name="dpi">90</field> </record> - <report id="report_attendance_sheet_pdf" - name="lefilament_training.qweb_attendance_sheet_pdf" - model="training.training" - string="Formation - Feuille d'émargement" - report_type="qweb-pdf" - paperformat="paperformat_a4_training" - attachment_use="False" - /> + <record id="report_attendance_sheet_pdf" model="ir.actions.report"> + <field name="name">Formation - Feuille d'émargement</field> + <field name="model">training.training</field> + <field name="report_type">qweb-pdf</field> + <field name="report_name">lefilament_training.qweb_attendance_sheet_pdf</field> + <field name="binding_model_id" ref="model_training_training"/> + <field name="binding_type">report</field> + <field name="paperformat_id" ref="paperformat_a4_training"/> + </record> </data> </odoo> \ No newline at end of file diff --git a/report/report_attestation.xml b/report/report_attestation.xml index 5419358e4bd4aa72fc829375d316d193e643117b..e69a4c3d3920bf74c875dd927890c0c02db0c1ef 100644 --- a/report/report_attestation.xml +++ b/report/report_attestation.xml @@ -65,14 +65,15 @@ </t> </template> - <report id="report_attestation_pdf" - name="lefilament_training.qweb_attestation_pdf" - model="training.training" - string="Formation - Attestations" - report_type="qweb-pdf" - attachment_use="False" - paperformat="paperformat_a4_training" - /> + <record id="report_attestation_pdf" model="ir.actions.report"> + <field name="name">Formation - Attestations</field> + <field name="model">training.training</field> + <field name="report_type">qweb-pdf</field> + <field name="report_name">lefilament_training.qweb_attestation_pdf</field> + <field name="binding_model_id" ref="model_training_training"/> + <field name="binding_type">report</field> + <field name="paperformat_id" ref="paperformat_a4_training"/> + </record> </data> </odoo> \ No newline at end of file diff --git a/report/report_program.xml b/report/report_program.xml index 116e86b57f8c7adaefa1a22736b8f22e28b71571..3af3f0ce124cc8dd80c350bd7df9b0995a0474a9 100644 --- a/report/report_program.xml +++ b/report/report_program.xml @@ -78,14 +78,15 @@ </t> </template> - <report id="report_program_pdf" - name="lefilament_training.qweb_program_pdf" - model="training.training" - string="Formation - Programme" - report_type="qweb-pdf" - attachment_use="False" - paperformat="paperformat_a4_training" - /> + <record id="report_program_pdf" model="ir.actions.report"> + <field name="name">Formation - Programme</field> + <field name="model">training.training</field> + <field name="report_type">qweb-pdf</field> + <field name="report_name">lefilament_training.qweb_program_pdf</field> + <field name="binding_model_id" ref="model_training_training"/> + <field name="binding_type">report</field> + <field name="paperformat_id" ref="paperformat_a4_training"/> + </record> </data> </odoo>