From 3aae0fa0259dd7f046b5203ae7b30fe415ecb269 Mon Sep 17 00:00:00 2001 From: odoo-pda Date: Fri, 13 Mar 2020 16:27:33 +0100 Subject: [PATCH] [ADD] macavrac_base module. (+ small cleans on beesdoo_website_shift) --- .../{__openerp__.py => __manifest__.py} | 0 beesdoo_website_shift/controllers/main.py | 13 ++--- .../data/res_config_data.xml | 8 ++- beesdoo_website_shift/models/res_config.py | 2 +- .../views/my_shift_website_templates.xml | 4 +- .../views/res_config_views.xml | 4 +- .../models/cooperative_status.py | 2 +- macavrac_base/__init__.py | 1 + macavrac_base/__manifest__.py | 23 +++++++++ macavrac_base/models/__init__.py | 1 + macavrac_base/models/res_partner.py | 49 +++++++++++++++++++ macavrac_base/views/res_partner.xml | 31 ++++++++++++ 12 files changed, 124 insertions(+), 14 deletions(-) rename beesdoo_website_shift/{__openerp__.py => __manifest__.py} (100%) create mode 100644 macavrac_base/__init__.py create mode 100644 macavrac_base/__manifest__.py create mode 100644 macavrac_base/models/__init__.py create mode 100644 macavrac_base/models/res_partner.py create mode 100644 macavrac_base/views/res_partner.xml diff --git a/beesdoo_website_shift/__openerp__.py b/beesdoo_website_shift/__manifest__.py similarity index 100% rename from beesdoo_website_shift/__openerp__.py rename to beesdoo_website_shift/__manifest__.py diff --git a/beesdoo_website_shift/controllers/main.py b/beesdoo_website_shift/controllers/main.py index 4123f02..aa92173 100644 --- a/beesdoo_website_shift/controllers/main.py +++ b/beesdoo_website_shift/controllers/main.py @@ -9,11 +9,10 @@ from datetime import datetime, timedelta from itertools import groupby from pytz import timezone, utc -from openerp import http, fields -from openerp.http import request +from odoo import http, fields +from odoo.http import request -from openerp.addons.beesdoo_shift.models.planning import float_to_time -from openerp.addons.beesdoo_shift.models.cooperative_status import PERIOD +from odoo.addons.beesdoo_shift.models.planning import float_to_time class WebsiteShiftController(http.Controller): @@ -408,6 +407,8 @@ class WebsiteShiftController(http.Controller): # Get config regular_next_shift_limit = int(request.env['ir.config_parameter'].get_param( 'beesdoo_website_shift.regular_next_shift_limit')) + shift_period = int(request.env['ir.config_parameter'].get_param( + 'beesdoo_website_shift.shift_period')) for i in range(nb_subscribed_shifts, regular_next_shift_limit): # Create the fictive shift @@ -426,11 +427,11 @@ class WebsiteShiftController(http.Controller): # Set new date shift.start_time = self.add_days( fields.Datetime.from_string(main_shift.start_time), - days=i * PERIOD + days=i * shift_period ) shift.end_time = self.add_days( fields.Datetime.from_string(main_shift.end_time), - days=i * PERIOD + days=i * shift_period ) # Add the fictive shift to the list of shift subscribed_shifts.append(shift) diff --git a/beesdoo_website_shift/data/res_config_data.xml b/beesdoo_website_shift/data/res_config_data.xml index d75440d..f84681e 100644 --- a/beesdoo_website_shift/data/res_config_data.xml +++ b/beesdoo_website_shift/data/res_config_data.xml @@ -3,7 +3,7 @@ Copyright 2017-2018 Rémy Taymans License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + beesdoo_website_shift.irregular_shift_limit @@ -37,5 +37,9 @@ beesdoo_website_shift.regular_highlight_rule 20 + + beesdoo_website_shift.shift_period + 28 + - + diff --git a/beesdoo_website_shift/models/res_config.py b/beesdoo_website_shift/models/res_config.py index 04e31c2..f4e408b 100644 --- a/beesdoo_website_shift/models/res_config.py +++ b/beesdoo_website_shift/models/res_config.py @@ -4,7 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from ast import literal_eval -from openerp import fields, models, api +from odoo import fields, models, api PARAMS = [ ('irregular_shift_limit', 'beesdoo_website_shift.irregular_shift_limit'), diff --git a/beesdoo_website_shift/views/my_shift_website_templates.xml b/beesdoo_website_shift/views/my_shift_website_templates.xml index 33fa0f3..ed5b8e6 100644 --- a/beesdoo_website_shift/views/my_shift_website_templates.xml +++ b/beesdoo_website_shift/views/my_shift_website_templates.xml @@ -3,7 +3,7 @@ Copyright 2017-2018 Rémy Taymans License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + - + diff --git a/beesdoo_website_shift/views/res_config_views.xml b/beesdoo_website_shift/views/res_config_views.xml index 9968a90..62ba035 100644 --- a/beesdoo_website_shift/views/res_config_views.xml +++ b/beesdoo_website_shift/views/res_config_views.xml @@ -3,7 +3,7 @@ Copyright 2017-2018 Rémy Taymans License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - + @@ -101,4 +101,4 @@ sequence="10"/> - + diff --git a/beesdoo_worker_status/models/cooperative_status.py b/beesdoo_worker_status/models/cooperative_status.py index 0a05e88..433a281 100644 --- a/beesdoo_worker_status/models/cooperative_status.py +++ b/beesdoo_worker_status/models/cooperative_status.py @@ -253,7 +253,7 @@ class ResPartner(models.Model): Override is_worker definition You need have subscribe to a A Share """ - is_worker = fields.Boolean(compute="_is_worker", search="_search_worker") + is_worker = fields.Boolean(compute="_is_worker", search="_search_worker", readonly=True, related="") def _is_worker(self): for rec in self: diff --git a/macavrac_base/__init__.py b/macavrac_base/__init__.py new file mode 100644 index 0000000..9a7e03e --- /dev/null +++ b/macavrac_base/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/macavrac_base/__manifest__.py b/macavrac_base/__manifest__.py new file mode 100644 index 0000000..05fdcc5 --- /dev/null +++ b/macavrac_base/__manifest__.py @@ -0,0 +1,23 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + 'name': "Macavrac Base Module", + + 'summary': """ + Module with basic customizations for the Macavrac cooperative. + """, + + 'description': """ + """, + + 'author': "Patricia Daloze", + + 'category': 'Sales', + 'version': '12.0.1.0.0', + + 'depends': ['beesdoo_shift', 'contacts'], + + 'data': [ + 'views/res_partner.xml', + ], + 'installable': True, +} diff --git a/macavrac_base/models/__init__.py b/macavrac_base/models/__init__.py new file mode 100644 index 0000000..4c58886 --- /dev/null +++ b/macavrac_base/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner \ No newline at end of file diff --git a/macavrac_base/models/res_partner.py b/macavrac_base/models/res_partner.py new file mode 100644 index 0000000..0c5e4e2 --- /dev/null +++ b/macavrac_base/models/res_partner.py @@ -0,0 +1,49 @@ +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + +class Partner(models.Model): + + _inherit = 'res.partner' + + date_stamp = fields.Date(string="Timestamp", help="Date de remplissage du formulaire") + birthdate = fields.Date(string="Date d'anniversaire") + payment_date = fields.Date(string="Date de paiement") + certificate_sent_date = fields.Date(string="Certificat envoyé le") + fiscal_certificate_sent_date = fields.Date(string="Attestation fiscale envoyée le") + + coop_number = fields.Integer(string="Coop N°") + share_qty = fields.Integer(string="Nombre de part") + + share_amount = fields.Float(string="Montant", compute="_compute_share_amount") + + gender = fields.Selection([('female','Féminin'),('male','Masculin'),('other','Autre')], string="Genre") + cooperator_type = fields.Selection([('share_a', 'Part A'), ('share_b', 'Part B'), ('share_c', 'Part C'), ('share_d', 'Part D')], string="Type de Part") + state_request = fields.Selection([('ok',"En ordre"),('waiting_payment','En attente de paiement'), + ('certificate_to_send', 'Certificat à envoyer'), ('resigning', 'Parts revendues')]) #TODO should we use the cooperative.status model instead? + + national_register_number = fields.Char(string="Numéro de registre national") #TODO add constraint / check consistancy + share_numbers = fields.Char(string="Numéro de parts") + payment_details = fields.Char(string="Détail de paiement") + iban = fields.Char(string="IBAN") #TODO remove. Temp for import purpose. + comment_request = fields.Char(string="Commentaire") + + email_sent = fields.Boolean(string="Email envoyé") + is_worker = fields.Boolean(compute="_compute_is_worker", search="_search_is_worker", string="is Worker", readonly=True, related="") + + + @api.depends('share_qty') + def _compute_share_amount(self): + for rec in self: + rec.share_amount = rec.share_qty * 25.0 #TODO add ir.config_parameter to make this amount editable + + + @api.depends('cooperator_type') + def _compute_is_worker(self): + for rec in self: + rec.is_worker = rec.cooperator_type == 'share_b' + + def _search_is_worker(self, operator, value): + if (operator == '=' and value) or (operator == '!=' and not value): + return [('cooperator_type', '=', 'share_b')] + else: + return [('cooperator_type', '!=', 'share_b')] diff --git a/macavrac_base/views/res_partner.xml b/macavrac_base/views/res_partner.xml new file mode 100644 index 0000000..f3e34c5 --- /dev/null +++ b/macavrac_base/views/res_partner.xml @@ -0,0 +1,31 @@ + + + Macavrac Coop + res.partner + + 99 + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file