forked from Yaltik/golem
[ADD]GOLEM Activity Registration State : add generated invoice and payments
Add generated invoice and payments on wizard. Allow to see them with navigation buttons.
This commit is contained in:
parent
3fd0b457c3
commit
06618da5f1
@ -19,7 +19,7 @@
|
||||
'name': 'GOLEM Activity Session Member Registrations States',
|
||||
'summary': 'GOLEM Activities Session Member Registration states',
|
||||
'description': 'GOLEM Activities Session Member Registration states',
|
||||
'version': '10.0.1.1.0',
|
||||
'version': '10.0.1.2.0',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -6,15 +6,14 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-06-14 23:16+0000\n"
|
||||
"PO-Revision-Date: 2017-06-14 23:16+0000\n"
|
||||
"POT-Creation-Date: 2018-07-17 09:11+0000\n"
|
||||
"PO-Revision-Date: 2018-07-17 11:31+0200\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Language: fr\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_line_ids
|
||||
@ -46,6 +45,11 @@ msgstr "Annulé"
|
||||
msgid "Confirmed"
|
||||
msgstr "Confirmé"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.ui.view,arch_db:golem_activity_registration_state.invoicing_form
|
||||
msgid "Congratulations, activities had been confirmed and invoiced."
|
||||
msgstr "Félicitations, les activités ont été confirmées et facturées."
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_create_uid
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_line_create_uid
|
||||
@ -64,6 +68,16 @@ msgstr "Créé le"
|
||||
msgid "Display Name"
|
||||
msgstr "Nom affiché"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.ui.view,arch_db:golem_activity_registration_state.invoicing_form
|
||||
msgid "Display invoice"
|
||||
msgstr "Afficher la facture"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.ui.view,arch_db:golem_activity_registration_state.invoicing_form
|
||||
msgid "Display payments"
|
||||
msgstr "Afficher les paiements"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: selection:golem.activity.registration,state:0
|
||||
msgid "Draft"
|
||||
@ -89,6 +103,20 @@ msgstr "GOLEM Activity Registration Invoicing Wizard"
|
||||
msgid "GOLEM Member"
|
||||
msgstr "Adhérent"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: code:addons/golem_activity_registration_state/wizard/golem_activity_registration_invoicing.py:147
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_invoice_id
|
||||
#, python-format
|
||||
msgid "Generated invoice"
|
||||
msgstr "Facture générée"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: code:addons/golem_activity_registration_state/wizard/golem_activity_registration_invoicing.py:162
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_payment_ids
|
||||
#, python-format
|
||||
msgid "Generated payments"
|
||||
msgstr "Paiements générés"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_member_has_draft_registrations
|
||||
msgid "Has draft registrations ?"
|
||||
@ -191,10 +219,23 @@ msgid "Season"
|
||||
msgstr "Saison"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_state
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_state
|
||||
msgid "State"
|
||||
msgstr "État"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: code:addons/golem_activity_registration_state/wizard/golem_activity_registration_invoicing.py:143
|
||||
#, python-format
|
||||
msgid "There is no generated invoice."
|
||||
msgstr "Il n'y a pas de facture générée."
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: code:addons/golem_activity_registration_state/wizard/golem_activity_registration_invoicing.py:158
|
||||
#, python-format
|
||||
msgid "There is no generated payments."
|
||||
msgstr "Il n'y a pas de paiement généré."
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.ui.view,arch_db:golem_activity_registration_state.invoicing_form
|
||||
msgid "Total"
|
||||
@ -210,8 +251,18 @@ msgstr "Valider"
|
||||
msgid "Validate all draft registrations"
|
||||
msgstr "Valider toutes les inscriptions"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: selection:golem.activity.registration.invoicing,state:0
|
||||
msgid "final"
|
||||
msgstr "final"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.model,name:golem_activity_registration_state.model_golem_activity_registration_invoicing_line
|
||||
msgid "golem.activity.registration.invoicing.line"
|
||||
msgstr "golem.activity.registration.invoicing.line"
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: selection:golem.activity.registration.invoicing,state:0
|
||||
msgid "init"
|
||||
msgstr "init"
|
||||
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-06-14 23:16+0000\n"
|
||||
"PO-Revision-Date: 2017-06-14 23:16+0000\n"
|
||||
"POT-Creation-Date: 2018-07-17 09:11+0000\n"
|
||||
"PO-Revision-Date: 2018-07-17 09:11+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -45,6 +45,11 @@ msgstr ""
|
||||
msgid "Confirmed"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.ui.view,arch_db:golem_activity_registration_state.invoicing_form
|
||||
msgid "Congratulations, activities had been confirmed and invoiced."
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_create_uid
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_line_create_uid
|
||||
@ -63,6 +68,16 @@ msgstr ""
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.ui.view,arch_db:golem_activity_registration_state.invoicing_form
|
||||
msgid "Display invoice"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.ui.view,arch_db:golem_activity_registration_state.invoicing_form
|
||||
msgid "Display payments"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: selection:golem.activity.registration,state:0
|
||||
msgid "Draft"
|
||||
@ -88,6 +103,20 @@ msgstr ""
|
||||
msgid "GOLEM Member"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: code:addons/golem_activity_registration_state/wizard/golem_activity_registration_invoicing.py:147
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_invoice_id
|
||||
#, python-format
|
||||
msgid "Generated invoice"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: code:addons/golem_activity_registration_state/wizard/golem_activity_registration_invoicing.py:162
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_payment_ids
|
||||
#, python-format
|
||||
msgid "Generated payments"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_member_has_draft_registrations
|
||||
msgid "Has draft registrations ?"
|
||||
@ -190,10 +219,23 @@ msgid "Season"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_state
|
||||
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_state
|
||||
msgid "State"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: code:addons/golem_activity_registration_state/wizard/golem_activity_registration_invoicing.py:143
|
||||
#, python-format
|
||||
msgid "There is no generated invoice."
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: code:addons/golem_activity_registration_state/wizard/golem_activity_registration_invoicing.py:158
|
||||
#, python-format
|
||||
msgid "There is no generated payments."
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.ui.view,arch_db:golem_activity_registration_state.invoicing_form
|
||||
msgid "Total"
|
||||
@ -209,8 +251,18 @@ msgstr ""
|
||||
msgid "Validate all draft registrations"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: selection:golem.activity.registration.invoicing,state:0
|
||||
msgid "final"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: model:ir.model,name:golem_activity_registration_state.model_golem_activity_registration_invoicing_line
|
||||
msgid "golem.activity.registration.invoicing.line"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_registration_state
|
||||
#: selection:golem.activity.registration.invoicing,state:0
|
||||
msgid "init"
|
||||
msgstr ""
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
|
||||
import logging
|
||||
from math import ceil
|
||||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class GolemActivityRegistrationInvoicingLine(models.TransientModel):
|
||||
@ -39,17 +40,26 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
|
||||
_name = 'golem.activity.registration.invoicing'
|
||||
_description = 'GOLEM Activity Registration Invoicing Wizard'
|
||||
|
||||
season_id = fields.Many2one('golem.season', 'Season', required=True)
|
||||
member_id = fields.Many2one('golem.member', 'Member', required=True)
|
||||
state = fields.Selection([('init', 'init'), ('final', 'final')],
|
||||
default='init', required=True)
|
||||
season_id = fields.Many2one('golem.season', 'Season', required=True,
|
||||
ondelete='cascade')
|
||||
member_id = fields.Many2one('golem.member', 'Member', required=True,
|
||||
ondelete='cascade')
|
||||
line_ids = fields.One2many('golem.activity.registration.invoicing.line',
|
||||
'invoicing_id', string='Activities')
|
||||
schedule_id = fields.Many2one('golem.payment.schedule', 'Payment schedule',
|
||||
domain='[("season_id", "=", season_id)]',
|
||||
ondelete='cascade',
|
||||
help='If no schedule is selected, only the '
|
||||
'invoice will be create. Otherwise, draft '
|
||||
'payments will be generated.')
|
||||
journal_id = fields.Many2one('account.journal', 'Journal',
|
||||
domain=[('type', 'in', ('bank', 'cash'))])
|
||||
domain=[('type', 'in', ('bank', 'cash'))],
|
||||
ondelete='cascade')
|
||||
invoice_id = fields.Many2one('account.invoice', string='Generated invoice',
|
||||
ondelete='cascade')
|
||||
payment_ids = fields.Many2many('account.payment', string='Generated payments')
|
||||
|
||||
@api.multi
|
||||
def _create_invoice(self):
|
||||
@ -81,6 +91,7 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
|
||||
def _create_payments(self, invoice):
|
||||
""" Create payment if schedule has been chosen """
|
||||
self.ensure_one()
|
||||
payments = self.env['account.payment']
|
||||
if self.schedule_id and self.schedule_id.occurences > 0:
|
||||
amount = invoice.amount_total
|
||||
amount_per_occurence = ceil(amount / self.schedule_id.occurences)
|
||||
@ -101,6 +112,8 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
|
||||
payment_values = dict(payment._cache)
|
||||
payment = self.env['account.payment'].create(payment_values)
|
||||
payment.invoice_ids = [(4, invoice.id, False)]
|
||||
payments |= payment
|
||||
return payments
|
||||
|
||||
@api.multi
|
||||
def validate(self):
|
||||
@ -110,4 +123,44 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
|
||||
lambda r: r.state == 'draft')
|
||||
draft_registrations.write({'state': 'confirmed'})
|
||||
invoice = self._create_invoice()
|
||||
self._create_payments(invoice)
|
||||
self.invoice_id = invoice
|
||||
payments = self._create_payments(invoice)
|
||||
self.payment_ids |= payments
|
||||
self.write({'state': 'final'})
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': self._name,
|
||||
'res_id': self[0].id,
|
||||
'target': 'new'
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def go_invoice(self):
|
||||
""" Navigate to generated invoice """
|
||||
self.ensure_one()
|
||||
if not self.invoice_id:
|
||||
uerr = _('There is no generated invoice.')
|
||||
raise UserError(uerr)
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': _('Generated invoice'),
|
||||
'view_mode': 'form,tree',
|
||||
'res_model': 'account.invoice',
|
||||
'res_id': self[0].invoice_id.id
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def go_payments(self):
|
||||
""" Navigate to generated payments """
|
||||
self.ensure_one()
|
||||
if not self.payment_ids:
|
||||
uerr = _('There is no generated payments.')
|
||||
raise UserError(uerr)
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': _('Generated payments'),
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.payment',
|
||||
'domain': [('id', 'in', self.payment_ids.ids)]
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
|
||||
Copyright 2017-2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
@ -26,8 +26,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="model">golem.activity.registration.invoicing</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Registration invoicing">
|
||||
<p class="oe_grey">Please confirm activity prices and choose a payment schedule if needed.</p>
|
||||
<group>
|
||||
<field name="state" invisible="1" />
|
||||
<p states="init" class="oe_grey">
|
||||
Please confirm activity prices and choose a payment schedule if needed.
|
||||
</p>
|
||||
<group states="init">
|
||||
<field name="season_id" readonly="1" />
|
||||
<field name="member_id" readonly="1" />
|
||||
<field name="line_ids" string="Activities and Prices">
|
||||
@ -41,9 +44,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
attrs="{'invisible': [('schedule_id', '=', False)],
|
||||
'required': [('schedule_id', '!=', False)]}" />
|
||||
</group>
|
||||
<p states="final">
|
||||
Congratulations, activities had been confirmed and invoiced.
|
||||
</p>
|
||||
<group states="final">
|
||||
<field name="invoice_id" readonly="1" />
|
||||
<field name="payment_ids" readonly="1" />
|
||||
</group>
|
||||
<footer>
|
||||
<button name="validate" string="Validate" type="object"
|
||||
class="oe_highlight" />
|
||||
states="init" class="oe_highlight" />
|
||||
<button name="go_invoice" string="Display invoice" type="object"
|
||||
states="final" class="oe_highlight" />
|
||||
<button name="go_payments" string="Display payments" type="object"
|
||||
states="final" />
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user