Browse Source

Add info c&c on account + report account

12.0
Juliana 4 years ago
parent
commit
da74f3ffd2
  1. 3
      __init__.py
  2. 4
      __manifest__.py
  3. 1
      models/__init__.py
  4. 48
      models/account_invoice.py
  5. 16
      models/sale_order.py
  6. 20
      models/vracoop_point_retrait.py
  7. 15
      report/account_invoice_template.xml
  8. 22
      views/account_invoice_views.xml
  9. 1
      views/vracoop_retrait_views.xml
  10. 4
      wizard/__init__.py
  11. BIN
      wizard/__pycache__/__init__.cpython-37.pyc
  12. BIN
      wizard/__pycache__/sale_make_invoice_advance.cpython-37.pyc
  13. 50
      wizard/sale_make_invoice_advance.py

3
__init__.py

@ -1,4 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models
from . import controllers
from . import controllers
from . import wizard

4
__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"
]
}

1
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

48
models/account_invoice.py

@ -0,0 +1,48 @@
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
# 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
# ------------------------------------------------------

16
models/sale_order.py

@ -1,7 +1,7 @@
# © 2019 Le Filament (<http://www.le-filament.com>)
# 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
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

20
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

15
report/account_invoice_template.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<p t-if="o.reference" position="before">
<p t-if="o.vracoop_point_retrait_id">
Point de retrait: <span t-field="o.vracoop_point_retrait_id"/><br/>
Jour de retrait: <span t-field="o.day_retrait"/><br/>
Heure de retrait: <span t-field="o.hour_retrait" t-options= '{"widget": "float_time"}'/>
</p>
</p>
</template>
</data>
</odoo>

22
views/account_invoice_views.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="invoice_form" model="ir.ui.view">
<field name="name">account.invoice.form.view.with_retrait</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<data>
<field name="payment_term_id" position="after">
<field name="carrier_point_retrait" invisible="1"/>
<field name="vracoop_point_retrait_id" attrs="{'invisible': [('carrier_point_retrait', '=', False)]}"/>
<field name="day_retrait" attrs="{'invisible': [('carrier_point_retrait', '=', False)]}" />
<field name="hour_retrait" widget="float_time" attrs="{'invisible': [('carrier_point_retrait', '=', False)]}"/>
</field>>
</data>
</field>
</record>
</data>
</odoo>

1
views/vracoop_retrait_views.xml

@ -98,6 +98,7 @@
<group>
<field name="nb_max_retrait"/>
<field name="nb_day_available"/>
<field name="nb_hours_preparation"/>
</group>
</group>
<notebook>

4
wizard/__init__.py

@ -0,0 +1,4 @@
# Copyright 2020 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import sale_make_invoice_advance

BIN
wizard/__pycache__/__init__.cpython-37.pyc

BIN
wizard/__pycache__/sale_make_invoice_advance.cpython-37.pyc

50
wizard/sale_make_invoice_advance.py

@ -0,0 +1,50 @@
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
# 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
# ------------------------------------------------------
Loading…
Cancel
Save