| @ -0,0 +1,24 @@ | |||
| from odoo import models, fields, api | |||
| from odoo.exceptions import UserError, ValidationError,Warning | |||
| from psycopg2 import sql, DatabaseError | |||
| from werkzeug import utils | |||
| class opendons_accounting_deposit(models.Model): | |||
| _name = 'opendons.accountingdeposit' | |||
| _description = 'manage accounting deposit' | |||
| company_id = fields.Many2one( | |||
| "res.company", | |||
| string="Company", | |||
| ondelete="cascade", | |||
| default=lambda self: self.env.company, | |||
| ) | |||
| payment_batch_ids = fields.One2many( | |||
| 'opendons_payment_batch', | |||
| 'accountingdeposit_id', | |||
| string='Payment batchs', | |||
| readonly=True | |||
| ) | |||
| @ -0,0 +1,24 @@ | |||
| from odoo import models, fields, api | |||
| from odoo.exceptions import UserError, ValidationError,Warning | |||
| from psycopg2 import sql, DatabaseError | |||
| from werkzeug import utils | |||
| class opendons_bank_deposit(models.Model): | |||
| _name = 'opendons.bankdeposit' | |||
| _description = 'manage bank deposit' | |||
| company_id = fields.Many2one( | |||
| "res.company", | |||
| string="Company", | |||
| ondelete="cascade", | |||
| default=lambda self: self.env.company, | |||
| ) | |||
| payment_batch_ids = fields.One2many( | |||
| 'opendons_payment_batch', | |||
| 'bankdeposit_id', | |||
| string='Payment batchs', | |||
| readonly=True | |||
| ) | |||
| @ -0,0 +1,59 @@ | |||
| <odoo> | |||
| <data> | |||
| <record model="ir.ui.view" id="opendons.accounting_deposit_list"> | |||
| <field name="name">opendons_accounting_deposit list</field> | |||
| <field name="model">opendons.accountingdeposit</field> | |||
| <field name="arch" type="xml"> | |||
| <tree> | |||
| <field name="create_date"/> | |||
| <field name="create_uid"/> | |||
| <field name="payment_batch_ids"/> | |||
| </tree> | |||
| </field> | |||
| </record> | |||
| <record model="ir.ui.view" id="opendons.accounting_deposit_form"> | |||
| <field name="name">opendons_payment_batch_accounting Form</field> | |||
| <field name="model">opendons.accountingdeposit</field> | |||
| <field name="arch" type="xml"> | |||
| <form string="accounting_deposit_form"> | |||
| <group name="accounting_deposit"> | |||
| <field name="create_date"/> | |||
| <field name="create_uid"/> | |||
| <field name="payment_batch_ids"> | |||
| <tree> | |||
| <field name="create_date"/> | |||
| <field name="create_uid"/> | |||
| <field name="payment_mode_id"/> | |||
| <field name="amount_total" string="Total"/> | |||
| <field name="payment_count" string="Payments count"/> | |||
| </tree> | |||
| </field> | |||
| </group> | |||
| </form> | |||
| </field> | |||
| </record> | |||
| <record model="ir.actions.act_window" id="accounting_deposit_action"> | |||
| <field name="name">accounting deposits</field> | |||
| <field name="res_model">opendons.accountingdeposit</field> | |||
| <field name="view_mode">tree,form</field> | |||
| </record> | |||
| <menuitem id="accounting_deposit_menu" action="accounting_deposit_action" | |||
| parent="payment_batch_top_menu" sequence="30"/> | |||
| </data> | |||
| </odoo> | |||
| @ -0,0 +1,61 @@ | |||
| <odoo> | |||
| <data> | |||
| <record model="ir.ui.view" id="opendons.bank_deposit_list"> | |||
| <field name="name">opendons_bank_deposit list</field> | |||
| <field name="model">opendons.bankdeposit</field> | |||
| <field name="arch" type="xml"> | |||
| <tree> | |||
| <field name="create_date"/> | |||
| <field name="create_uid"/> | |||
| <field name="payment_batch_ids"/> | |||
| </tree> | |||
| </field> | |||
| </record> | |||
| <record model="ir.ui.view" id="opendons.bank_deposit_form"> | |||
| <field name="name">opendons_payment_batch_bank Form</field> | |||
| <field name="model">opendons.bankdeposit</field> | |||
| <field name="arch" type="xml"> | |||
| <header> | |||
| </header> | |||
| <sheet> | |||
| <form string="bank_deposit_form"> | |||
| <group name="bank_deposit"> | |||
| <field name="create_date"/> | |||
| <field name="create_uid"/> | |||
| <field name="payment_batch_ids"> | |||
| <tree> | |||
| <field name="create_date"/> | |||
| <field name="create_uid"/> | |||
| <field name="payment_mode_id"/> | |||
| <field name="amount_total" string="Total"/> | |||
| <field name="payment_count" string="Payments count"/> | |||
| </tree> | |||
| </field> | |||
| </group> | |||
| </form> | |||
| </sheet> | |||
| </field> | |||
| </record> | |||
| <record model="ir.actions.act_window" id="bank_deposit_action"> | |||
| <field name="name">Bank deposits</field> | |||
| <field name="res_model">opendons.bankdeposit</field> | |||
| <field name="view_mode">tree,form</field> | |||
| </record> | |||
| <menuitem id="bank_deposit_menu" action="bank_deposit_action" | |||
| parent="payment_batch_top_menu" sequence="20"/> | |||
| </data> | |||
| </odoo> | |||
| @ -1,2 +1,4 @@ | |||
| from . import operation_duplicate_wizard | |||
| from . import recurring_donation_wizard | |||
| from . import recurring_donation_wizard | |||
| from . import create_bank_deposit_wizard | |||
| from . import create_accounting_deposit_wizard | |||
| @ -0,0 +1,29 @@ | |||
| from odoo import fields, models, _ | |||
| from odoo.exceptions import UserError, ValidationError,Warning | |||
| class CreateaccountingDeposit(models.TransientModel): | |||
| _name = 'opendons.createaccountingdeposit' | |||
| _description = 'Create a accounting deposit form batchs selected' | |||
| def create_accounting_deposit(self): | |||
| active_ids = self._context.get('active_ids', []) or [] | |||
| if active_ids: | |||
| payments=self.env['opendons_payment_batch'].browse(active_ids) | |||
| for p in payments: | |||
| if p.bank_deposit_date==False: raise Warning('the batch payment selected was not deposited in bank : operation cancelled') | |||
| if p.accounting_deposit_date: raise Warning('the batch payment selected was already deposited in bank : operation cancelled') | |||
| #create accounting deposit | |||
| vals={} | |||
| bd=self.env['opendons.accountingdeposit'].create(vals) | |||
| for p in payments: | |||
| #add payment to accounting deposit | |||
| bd.write({'payment_batch_ids':[(4,p.id)]}) | |||
| #add accounting deposit to payment | |||
| p.accountingdeposit_id=bd.id | |||
| p.state='deposited_in_accounting' | |||
| @ -0,0 +1,29 @@ | |||
| <odoo> | |||
| <record id="create_accounting_deposit_view" model="ir.ui.view"> | |||
| <field name="name">create_accounting_deposit view</field> | |||
| <field name="model">opendons.createaccountingdeposit</field> | |||
| <field name="arch" type="xml"> | |||
| <form> | |||
| <p> | |||
| Are you sure do you want to create a accounting deposit with selected payments ? | |||
| </p> | |||
| <footer> | |||
| <button name="create_accounting_deposit" string="Create a accounting deposit" type="object"/> | |||
| <button string="Cancel" class="btn btn-secondary" special="cancel" /> | |||
| </footer> | |||
| </form> | |||
| </field> | |||
| </record> | |||
| <record id="action_create_new_accounting_deposit" model="ir.actions.act_window"> | |||
| <field name="name">Create an accounting deposit</field> | |||
| <field name="res_model">opendons.createaccountingdeposit</field> | |||
| <field name="view_mode">form</field> | |||
| <field name="target">new</field> | |||
| <field name="binding_model_id" ref="opendons.model_opendons_payment_batch"/> | |||
| </record> | |||
| </odoo> | |||
| @ -0,0 +1,38 @@ | |||
| from odoo import fields, models, _ | |||
| from odoo.exceptions import UserError, ValidationError,Warning | |||
| class CreateBankDeposit(models.TransientModel): | |||
| _name = 'opendons.createbankdeposit' | |||
| _description = 'Create a bank deposit form batchs selected' | |||
| def create_bank_deposit(self): | |||
| active_ids = self._context.get('active_ids', []) or [] | |||
| if active_ids: | |||
| payments=self.env['opendons_payment_batch'].browse(active_ids) | |||
| for p in payments: | |||
| if p.state=='draft': raise Warning('the batch payment selected is not validated : operation cancelled') | |||
| if p.accounting_deposit_date: raise Warning('the batch payment selected was already deposited in accounting : operation cancelled') | |||
| if p.bank_deposit_date: raise Warning('the batch payment selected was already deposited in bank : operation cancelled') | |||
| #create bank deposit | |||
| vals={} | |||
| bd=self.env['opendons.bankdeposit'].create(vals) | |||
| for p in self.env['opendons_payment_batch'].browse(active_ids): | |||
| #add payment to bank deposit | |||
| bd.write({'payment_batch_ids':[(4,p.id)]}) | |||
| #add bank deposit to payment | |||
| p.bankdeposit_id=bd.id | |||
| p.state='deposited_in_bank' | |||
| # #creation de l'opération sans les segments | |||
| # vals={} | |||
| # vals['name']='copy of ' + record.name | |||
| # vals['chanel']=record.chanel | |||
| # vals['user_id']=self._uid | |||
| # vals['state']='draft' | |||
| # dup_operation=super(opendons_operation, self).create(vals) | |||
| @ -0,0 +1,29 @@ | |||
| <odoo> | |||
| <record id="create_bank_deposit_view" model="ir.ui.view"> | |||
| <field name="name">create_bank_deposit view</field> | |||
| <field name="model">opendons.createbankdeposit</field> | |||
| <field name="arch" type="xml"> | |||
| <form> | |||
| <p> | |||
| Are you sure do you want to create a bank deposit with selected payments ? | |||
| </p> | |||
| <footer> | |||
| <button name="create_bank_deposit" string="Create a bank deposit" type="object"/> | |||
| <button string="Cancel" class="btn btn-secondary" special="cancel" /> | |||
| </footer> | |||
| </form> | |||
| </field> | |||
| </record> | |||
| <record id="action_create_new_bank_deposit" model="ir.actions.act_window"> | |||
| <field name="name">Create a bank deposit</field> | |||
| <field name="res_model">opendons.createbankdeposit</field> | |||
| <field name="view_mode">form</field> | |||
| <field name="target">new</field> | |||
| <field name="binding_model_id" ref="opendons.model_opendons_payment_batch"/> | |||
| </record> | |||
| </odoo> | |||