diff --git a/__init__.py b/__init__.py index 5305644df1417bd42ff792a947cf27db51b60943..3616b300222650c0489f67bd5cc6fd9c999496f2 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- -from . import models \ No newline at end of file +from . import models +from . import wizard \ No newline at end of file diff --git a/__manifest__.py b/__manifest__.py index 6dbbdecabb69f58aece9bbf9d9edd18a07bb12f4..126f7fd51eb41b544fea333eff70dd308b8c27aa 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -31,5 +31,6 @@ 'report/employee_report.xml', 'report/impound_report.xml', 'report/judicial_account_report.xml', + 'wizard/impound_notes.xml', ], } \ No newline at end of file diff --git a/models/embargo.py b/models/embargo.py index 1aac7531859084d51bf6fcee6bbf7e989c266f9e..e65b1cd7c21f8a1acd81a4f01a80ba3899f1757c 100644 --- a/models/embargo.py +++ b/models/embargo.py @@ -53,7 +53,9 @@ class Impund(models.Model): state = fields.Selection([ ('draft', 'Draft'), ('in_progress', 'In progress'), - ('done', 'Done')], default='draft') + ('done', 'Done'), + ('cancel', 'Cancel') + ], default='draft') impound_novelties_ids = fields.One2many('impound.balance.lines', 'impounds_id', string='Impound Novelties') @api.onchange('employee') @@ -126,7 +128,14 @@ class Impund(models.Model): for impound in impounds: balance = impound.impound_balance + is_payslip_setted[0].impound_novelties_quantity - q impound.impound_balance = balance - is_payslip_setted.update({"impound_novelties_quantity": q}) + if impound.state == "draft": + impound.write({ + "state": "in_progress" + }) + for payslip in is_payslip_setted: + payslip.update({ + "impound_novelties_quantity": q + }) return date_param = datetime.datetime.strptime(d, '%Y/%m/%d') month = date_param.strftime("%B") @@ -140,3 +149,11 @@ class Impund(models.Model): "payslip_id": payslip_id, }]] impound.impound_balance = balance + impound.write({ + "state": "in_progress" + }) + + def close_impound(self): + return self.write({ + "state": "cancel" + }) diff --git a/views/impound_view.xml b/views/impound_view.xml index 08f6f5701a480e77a56b672cbbbc86baa6f230de..e43872caa72f4720dc2037f69b56da1049e7af14 100644 --- a/views/impound_view.xml +++ b/views/impound_view.xml @@ -7,7 +7,8 @@ <form> <header> <field name="state" widget="statusbar"/> -<!-- <button name="set_impound_balance_2" class="oe_stat_button" type="object" string="Test button 2"/>--> + <button name="close_impound" class="oe_stat_button" type="object" string="Close Impound" + attrs="{'invisible':[('state', '!=', 'in_progress')]}"/> </header> <sheet> <group> @@ -88,6 +89,7 @@ <group col="3"> <group> <field name="bank"/> + <field name="account_number"/> </group> <group> <field name="branch_office_number"/> @@ -106,27 +108,6 @@ <field name="impound_novelties_quantity"/> </tree> </field> - - <!-- <field name="impound_novelties_ids">--> - <!-- <form>--> - <!-- <group>--> - <!-- <group>--> - <!-- <field name="order"/>--> - <!-- <field name="impound_type"/>--> - <!-- </group>--> - <!-- <group>--> - <!-- <field name="invoice_number"/>--> - <!-- <field name="year"/>--> - <!-- </group>--> - <!-- </group>--> - <!-- </form>--> - <!-- <tree>--> - <!-- <field name="start_date" string=""/>--> - <!-- <field name="impound_type"/>--> - <!-- <field name="invoice_number"/>--> - <!-- <field name="year"/>--> - <!-- </tree>--> - <!-- </field>--> </sheet> </form> </field> diff --git a/wizard/__init__.py b/wizard/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..178ab84b3945014bbe9e2990db2d3ce74ef81dc0 --- /dev/null +++ b/wizard/__init__.py @@ -0,0 +1 @@ +from . import impound_notes \ No newline at end of file diff --git a/wizard/impound_notes.py b/wizard/impound_notes.py new file mode 100644 index 0000000000000000000000000000000000000000..95aa595ecb187430bf1d185d54f510b5b71a7b65 --- /dev/null +++ b/wizard/impound_notes.py @@ -0,0 +1,28 @@ +from odoo import models, fields, _, api +from odoo.exceptions import ValidationError + + +class ImpoundNotesWizard(models.TransientModel): + _name = 'impound.notes.wizard' + _description = 'Impound Notes generator' + + impound_note_type = fields.Selection([ + ('type1', 'Type1'), + ('type2', 'Type2'), + ('type3', 'Type3')], default='type1') + impound_month = fields.Date(string="Impund month") + + @api.multi + def generate_impound_report(self): + print("------ WIZARD NOTES GENERATOR ---------") + impounds = self.env["impound.impound"].search([]) + if not self.impound_month: + raise ValidationError(_("You have to pick a date")) + month = self.impound_month.strftime("%B") + impound_lines = [] + for impound in impounds: + for line in impound.impound_novelties_ids: + if line.impound_novelties_month == month: + impound_lines.append(impound) + + diff --git a/wizard/impound_notes.xml b/wizard/impound_notes.xml new file mode 100644 index 0000000000000000000000000000000000000000..9d1dd55fa22d635b2d23321f6449b277f0fb70ce --- /dev/null +++ b/wizard/impound_notes.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + + <record id="impound_notes_wizard" model="ir.ui.view"> + <field name="name">impound notes wizard</field> + <field name="model">impound.notes.wizard</field> + <field name="arch" type="xml"> + <form> + <group> + <field name="impound_note_type"/> + <field name="impound_month"/> + </group> + <footer> + <button name="generate_impound_report" string="Generate Notes" type="object" class="btn-success"/> + </footer> + </form> + </field> + </record> + + + <act_window + id="impound_notes_wizard_action" + src_model="impound.impound" + name="Impound Notes Generator" + res_model="impound.notes.wizard" + view_mode="form" + target="new" + /> + <menuitem + id="impound_notes_wizard_menu_item" + name="Impound Notes Generator" + sequence="10" + parent="embargos_menu_root" + action="impound_notes_wizard_action" + /> +</odoo>