[REF][ADD]GOLEM Payement

* Refactor days from m2m to o2m ;
* Allow better flow for filling ;
* Check date coherence.
This commit is contained in:
Fabien BOURGEOIS 2018-08-01 18:10:20 +02:00
parent 00451b4f9f
commit d82babaa25
5 changed files with 159 additions and 27 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: 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
@ -19,8 +19,8 @@
'name': 'GOLEM payment',
'summary': 'Usage of account invoice and account payments',
'description': ''' Ability to create invoice(s) from activity subscriptions
and anticipate multiple payments. Uses GOLEM Activity Registration State. ''',
'version': '10.0.0.1.0',
and anticipate multiple payments. ''',
'version': '10.0.0.2.0',
'category': 'GOLEM',
'author': 'Fabien Bourgeois',
'license': 'AGPL-3',

View File

@ -6,15 +6,24 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-14 23:15+0000\n"
"PO-Revision-Date: 2017-06-14 23:15+0000\n"
"POT-Creation-Date: 2018-08-01 16:06+0000\n"
"PO-Revision-Date: 2018-08-01 18:08+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_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "By month"
msgstr "Par mois"
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "By week"
msgstr "Par semaine"
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_create_uid
@ -34,13 +43,20 @@ msgid "Day"
msgstr "Jour"
#. module: golem_payment
#: code:addons/golem_payment/models/golem_payment.py:27
#: code:addons/golem_payment/models/golem_payment.py:80
#, python-format
msgid "Day %s is out of season period (%s-%s)"
msgstr "Le jour %s est en dehors de la période de la saison (%s-%s)"
#. module: golem_payment
#: code:addons/golem_payment/models/golem_payment.py:36
#: sql_constraint:golem.payment.schedule.day:0
#, python-format
msgid "Day must be unique."
msgstr "Le jour doit être unique."
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_day_display
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_day_ids
msgid "Days"
msgstr "Jours"
@ -51,16 +67,16 @@ msgstr "Jours"
msgid "Display Name"
msgstr "Nom affiché"
#. module: golem_payment
#: model:ir.model,name:golem_payment.model_golem_member
msgid "GOLEM Member"
msgstr "Adhérent"
#. module: golem_payment
#: model:ir.model,name:golem_payment.model_golem_payment_schedule
msgid "GOLEM Payment Schedule"
msgstr "GOLEM : échéancier de paiement"
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "Group By"
msgstr "Grouper par"
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_day_id
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_id
@ -101,8 +117,29 @@ msgstr "Occurences"
msgid "Payment Schedules"
msgstr "Échéanciers de paiements"
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "Payment delayed"
msgstr "Paiement à venir"
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_account_payment_reference
msgid "Payment reference"
msgstr "Référence paiement"
#. module: golem_payment
#: model:ir.model,name:golem_payment.model_account_payment
msgid "Payments"
msgstr "Paiements"
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_day_schedule_id
msgid "Schedule id"
msgstr "Échéancier"
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_season_id
#: model:ir.ui.view,arch_db:golem_payment.golem_payment_schedule_search
msgid "Season"
msgstr "Saison"
@ -111,3 +148,13 @@ msgstr "Saison"
msgid "golem.payment.schedule.day"
msgstr "golem.payment.schedule.day"
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "payment in 30 days"
msgstr "Dans les 30 jours"
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "payment in 7 days"
msgstr "Dans les 7 jours"

View File

@ -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:14+0000\n"
"PO-Revision-Date: 2017-06-14 23:14+0000\n"
"POT-Creation-Date: 2018-08-01 16:06+0000\n"
"PO-Revision-Date: 2018-08-01 16:06+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -15,6 +15,16 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "By month"
msgstr ""
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "By week"
msgstr ""
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_create_uid
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_day_create_uid
@ -33,13 +43,20 @@ msgid "Day"
msgstr ""
#. module: golem_payment
#: code:addons/golem_payment/models/golem_payment.py:27
#: code:addons/golem_payment/models/golem_payment.py:80
#, python-format
msgid "Day %s is out of season period (%s-%s)"
msgstr ""
#. module: golem_payment
#: code:addons/golem_payment/models/golem_payment.py:36
#: sql_constraint:golem.payment.schedule.day:0
#, python-format
msgid "Day must be unique."
msgstr ""
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_day_display
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_day_ids
msgid "Days"
msgstr ""
@ -51,13 +68,13 @@ msgid "Display Name"
msgstr ""
#. module: golem_payment
#: model:ir.model,name:golem_payment.model_golem_member
msgid "GOLEM Member"
#: model:ir.model,name:golem_payment.model_golem_payment_schedule
msgid "GOLEM Payment Schedule"
msgstr ""
#. module: golem_payment
#: model:ir.model,name:golem_payment.model_golem_payment_schedule
msgid "GOLEM Payment Schedule"
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "Group By"
msgstr ""
#. module: golem_payment
@ -100,8 +117,29 @@ msgstr ""
msgid "Payment Schedules"
msgstr ""
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "Payment delayed"
msgstr ""
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_account_payment_reference
msgid "Payment reference"
msgstr ""
#. module: golem_payment
#: model:ir.model,name:golem_payment.model_account_payment
msgid "Payments"
msgstr ""
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_day_schedule_id
msgid "Schedule id"
msgstr ""
#. module: golem_payment
#: model:ir.model.fields,field_description:golem_payment.field_golem_payment_schedule_season_id
#: model:ir.ui.view,arch_db:golem_payment.golem_payment_schedule_search
msgid "Season"
msgstr ""
@ -110,3 +148,13 @@ msgstr ""
msgid "golem.payment.schedule.day"
msgstr ""
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "payment in 30 days"
msgstr ""
#. module: golem_payment
#: model:ir.ui.view,arch_db:golem_payment.account_payment_search
msgid "payment in 7 days"
msgstr ""

View File

@ -1,6 +1,6 @@
# -*- coding: 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
@ -18,6 +18,8 @@
""" GOLEM Payment models """
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo.tools import formatLang
class AccountPayment(models.Model):
""" Add number bank check"""
@ -28,10 +30,14 @@ class GolemPaymentScheduleDay(models.Model):
""" Schedule day simple model """
_name = 'golem.payment.schedule.day'
_rec_name = 'day'
_sql_constraints = [('golem_payment_schedule_day_uniq', 'UNIQUE (day)',
_order = 'schedule_id asc,day asc'
_sql_constraints = [('golem_payment_schedule_day_uniq',
'UNIQUE (day, schedule_id)',
_('Day must be unique.'))]
day = fields.Date(required=True, index=True)
day = fields.Date(required=True)
schedule_id = fields.Many2one('golem.payment.schedule', required=True,
auto_join=True)
class GolemPaymentSchedule(models.Model):
@ -41,12 +47,35 @@ class GolemPaymentSchedule(models.Model):
_order = 'season_id desc'
name = fields.Char(required=True)
day_ids = fields.Many2many('golem.payment.schedule.day', string='Days')
day_ids = fields.One2many('golem.payment.schedule.day', 'schedule_id',
string='Days')
day_display = fields.Char(compute='_compute_day_display', string='Days')
occurences = fields.Integer(compute='_compute_occurences')
season_id = fields.Many2one('golem.season', 'Season', required=True)
@api.depends('day_ids')
def _compute_day_display(self):
""" Computes day display """
for schedule in self:
days = [fields.Date.from_string(d.day).strftime('%d/%m/%Y')
for d in schedule.day_ids]
schedule.day_display = u', '.join(days)
@api.depends('day_ids')
def _compute_occurences(self):
""" Computes number of occurences """
for schedule in self:
schedule.occurences = len(schedule.day_ids)
@api.constrains('day_ids', 'season_id')
def check_dates(self):
""" Check date coherence """
for schedule in self:
if schedule.season_id.date_start:
days = schedule.day_ids.mapped('day')
for day in days:
season = schedule.season_id
if (day < season.date_start or day > season.date_end):
verr = _('Day %s is out of season period (%s-%s)'% \
(day, season.date_start, season.date_end))
raise ValidationError(verr)

View File

@ -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
@ -30,7 +30,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<group>
<field name="name" />
<field name="season_id" options="{'no_open': True, 'no_create': True}" />
<field name="day_ids" widget="many2many_tags" />
<field name="day_ids">
<tree editable="bottom">
<field name="day" />
<field name="schedule_id" invisible="1" />
</tree>
</field>
<field name="occurences" />
</group>
</sheet>
@ -46,7 +51,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tree>
<field name="name" />
<field name="season_id" />
<field name="day_ids" widget="many2many_tags" />
<field name="day_ids" invisible="1" />
<field name="day_display" />
<field name="occurences" />
</tree>
</field>
@ -61,6 +67,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="name" />
<field name="season_id" />
<field name="day_ids" />
<filter name="group_season" string="Season"
context="{'group_by': 'season_id'}" />
</search>
</field>
</record>