From da74f3ffd2ed939d58f90bd4f6ebe71a60a6d91a Mon Sep 17 00:00:00 2001 From: Juliana Date: Tue, 11 May 2021 12:09:26 +0200 Subject: [PATCH] Add info c&c on account + report account --- __init__.py | 3 +- __manifest__.py | 4 +- models/__init__.py | 1 + models/account_invoice.py | 48 +++++++++++++++++ models/sale_order.py | 16 +++++- models/vracoop_point_retrait.py | 20 ++++--- report/account_invoice_template.xml | 15 ++++++ views/account_invoice_views.xml | 22 ++++++++ views/vracoop_retrait_views.xml | 1 + wizard/__init__.py | 4 ++ wizard/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 223 bytes .../sale_make_invoice_advance.cpython-37.pyc | Bin 0 -> 899 bytes wizard/sale_make_invoice_advance.py | 50 ++++++++++++++++++ 13 files changed, 169 insertions(+), 15 deletions(-) create mode 100644 models/account_invoice.py create mode 100644 report/account_invoice_template.xml create mode 100644 views/account_invoice_views.xml create mode 100644 wizard/__init__.py create mode 100644 wizard/__pycache__/__init__.cpython-37.pyc create mode 100644 wizard/__pycache__/sale_make_invoice_advance.cpython-37.pyc create mode 100644 wizard/sale_make_invoice_advance.py diff --git a/__init__.py b/__init__.py index d548d15..83a8b40 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,5 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import models -from . import controllers \ No newline at end of file +from . import controllers +from . import wizard \ No newline at end of file diff --git a/__manifest__.py b/__manifest__.py index f846dce..c3905e2 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -19,6 +19,8 @@ "views/vracoop_sale_retrait_views.xml", "views/vracoop_templates.xml", "views/sale_order.xml", - "views/delivery_views.xml" + "views/delivery_views.xml", + "views/account_invoice_views.xml", + "report/account_invoice_template.xml" ] } diff --git a/models/__init__.py b/models/__init__.py index bf52ecf..52f7c5c 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -5,4 +5,5 @@ from . import vracoop_point_retrait from . import vracoop_retrait_time from . import vracoop_retrait_suivi from . import sale_order +from . import account_invoice from . import delivery \ No newline at end of file diff --git a/models/account_invoice.py b/models/account_invoice.py new file mode 100644 index 0000000..c74e9ff --- /dev/null +++ b/models/account_invoice.py @@ -0,0 +1,48 @@ +# Copyright 2021 Le Filament () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models +from datetime import datetime + + +class AccountInvoice(models.Model): + _inherit = 'account.invoice' + + # ------------------------------------------------------ + # Fields declaration + # ------------------------------------------------------ + vracoop_point_retrait_id = fields.Many2one( + comodel_name='vracoop.point.retrait', + string="Point retrait") + day_retrait = fields.Date("Jour du retrait") + hour_retrait = fields.Float("Heure du retrait") + carrier_point_retrait = fields.Boolean( + string='Est un point retrait') + + # ------------------------------------------------------ + # SQL Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Default methods + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Onchange / Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # CRUD methods (ORM overrides) + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Actions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Business methods + # ------------------------------------------------------ diff --git a/models/sale_order.py b/models/sale_order.py index 7a49fc2..5c40a1f 100644 --- a/models/sale_order.py +++ b/models/sale_order.py @@ -1,7 +1,7 @@ # © 2019 Le Filament () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, fields +from odoo import models, fields, api from datetime import datetime class SaleOrder(models.Model): @@ -42,4 +42,16 @@ class SaleOrder(models.Model): 'day_retrait': day_retrait, 'vracoop_point_retrait_id': retrait.id}) - return True \ No newline at end of file + return True + + @api.multi + def _prepare_invoice(self): + self.ensure_one() + res = super(SaleOrder, self)._prepare_invoice() + res.update({ + 'vracoop_point_retrait_id': self.vracoop_point_retrait_id.id, + 'day_retrait': self.day_retrait, + 'hour_retrait': self.hour_retrait, + 'carrier_point_retrait': self.carrier_point_retrait + }) + return res \ No newline at end of file diff --git a/models/vracoop_point_retrait.py b/models/vracoop_point_retrait.py index 1c01c69..b6d3d5c 100644 --- a/models/vracoop_point_retrait.py +++ b/models/vracoop_point_retrait.py @@ -2,14 +2,8 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models, fields, api -import pytz -# import dateutil.rrule as rrule -# from datetime import date -from dateutil.relativedelta import * -from dateutil.easter import * -from dateutil.rrule import rrule, DAILY, MINUTELY, rruleset -from dateutil.parser import * -# from datetime import * +from dateutil.rrule import rrule, DAILY, MINUTELY +from dateutil.relativedelta import relativedelta from datetime import datetime, timedelta from pytz import timezone @@ -67,6 +61,8 @@ class VracoopPointRetrait(models.Model): "Nombre de retrait max par tranche horaire") nb_day_available = fields.Integer( "Nombre de jours pour commande", default=7) + nb_hours_preparation = fields.Float( + "Nombre d'heures de préparation", default=0.0) @api.multi def slot_calculate(self): @@ -103,10 +99,11 @@ class VracoopPointRetrait(models.Model): # Liste des jours où je peux récupérer la commande # en fonction nombre de jour dispo sur la fiche du point retrait + first_day = datetime.today() + relativedelta(hours=rec.nb_hours_preparation) list_week = list(rrule( DAILY, count=count_day, - dtstart=datetime.today())) + dtstart=first_day)) for week in list_week: # On exclut les jours où la journée @@ -172,7 +169,7 @@ class VracoopPointRetrait(models.Model): # Heure disponible pour un retrait # en fonction du temps de préparation today_hour_available = today_datetime + timedelta( - hours=corresponding_line.preparation_time) + hours=(corresponding_line.preparation_time + rec.nb_hours_preparation)) # Boucle pour les créneaux du matin for slot_elem in list_slot_per_day_morning: @@ -194,7 +191,8 @@ class VracoopPointRetrait(models.Model): last_slot = slot_elem_last.strftime("%H:%M") # Si le jour est égal à la date du jour - if slot_elem.date() == today_datetime.date(): + day_first = today_datetime.date() + relativedelta(hours=rec.nb_hours_preparation) + if slot_elem.date() == day_first: if (slot_elem_last > last_morning_hour_week): if (today_hour_available > last_morning_hour_week): continue diff --git a/report/account_invoice_template.xml b/report/account_invoice_template.xml new file mode 100644 index 0000000..3d9173d --- /dev/null +++ b/report/account_invoice_template.xml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/views/account_invoice_views.xml b/views/account_invoice_views.xml new file mode 100644 index 0000000..49965d2 --- /dev/null +++ b/views/account_invoice_views.xml @@ -0,0 +1,22 @@ + + + + + + account.invoice.form.view.with_retrait + account.invoice + + + + + + + + + > + + + + + + \ No newline at end of file diff --git a/views/vracoop_retrait_views.xml b/views/vracoop_retrait_views.xml index 11b74f1..564826c 100644 --- a/views/vracoop_retrait_views.xml +++ b/views/vracoop_retrait_views.xml @@ -98,6 +98,7 @@ + diff --git a/wizard/__init__.py b/wizard/__init__.py new file mode 100644 index 0000000..91dfca5 --- /dev/null +++ b/wizard/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 Le Filament () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import sale_make_invoice_advance diff --git a/wizard/__pycache__/__init__.cpython-37.pyc b/wizard/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f711a543533a940ce57d39e5f85d14c7cf8411eb GIT binary patch literal 223 zcmXwyF^ebJdM${o^>MhZ*C$C8J~C^)IQn})v2b0loTP+C*})fQf#PHZP13O{t}FLrT|?b h81mklMxEVN2UNhFt^xS1FWt|wBuw6}`l=^eyaAk!J=6dI literal 0 HcmV?d00001 diff --git a/wizard/__pycache__/sale_make_invoice_advance.cpython-37.pyc b/wizard/__pycache__/sale_make_invoice_advance.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d79faca6d487bd6f7280fadc468dc3cc2c30a485 GIT binary patch literal 899 zcmZuv!EV$r5Vd0`o0e_4w5UG-QZ5_8ffGWM3*tb9RJi0~EZe2tCh>NhY_(N56{$bL zp*`|TzH;IhI5Ez4i$GYKm$99h_hvk=cXqZ3E`HvBY9@sIh?~vg=)6MnGXzaEtw}>G z+9Xxdu!=Rj;*`80I??Pa(af-Udc~?t^J7w^KQV?BJTSSiAv>|A);?s7)28-;3Kg$6 zD-y-!pCA}gQBA5u(~22BPp`=d9VzlFT4mRSlWKwlJnSFK+8pYoY?XO0SB+`Ax9#%s zz~k{uuFq$S^~KD#OSPd%kp*idEK)v4=txHga+Ta9109lq-Lfxy;5Tfba}p-s?o zO~3J5O34swOpZ{+!4jl$ZXp)Vww(aefwY~lIy}&Fwb_U1sq5i>x346CHSl*(u@zF^ zFAPA2qQXO=z{t)B)b6Y@A-w?G8HmzDVm0LGz*dC#hD92Fdsp^kL_&a%JjT2-wH_5ef=>(SH;n zwmvr2$7#taPsfv^ViI_4&X^VA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from odoo import api, fields, models, _ + + +class SaleAdvancePaymentInv(models.TransientModel): + _inherit = "sale.advance.payment.inv" + + # ------------------------------------------------------ + # Fields declaration + # ------------------------------------------------------ + @api.multi + def _create_invoice(self, order, so_line, amount): + inv = super(SaleAdvancePaymentInv, self)._create_invoice(order, so_line, amount) + inv.write({ + 'vracoop_point_retrait_id': order.vracoop_point_retrait_id.id, + 'day_retrait': order.day_retrait, + 'hour_retrait': order.hour_retrait, + 'carrier_point_retrait': order.carrier_point_retrait + }) + return inv + # ------------------------------------------------------ + # SQL Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Default methods + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Onchange / Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # CRUD methods (ORM overrides) + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Actions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Business methods + # ------------------------------------------------------