From 47b0f771b8d114962b13cd438761d22f0dc125fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <remi@le-filament.com>
Date: Wed, 7 Jul 2021 15:39:53 +0200
Subject: [PATCH] =?UTF-8?q?[add]=20Ajout=20modification=20demand=C3=A9es?=
 =?UTF-8?q?=20par=20client?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 README.rst                         | 23 ++++++++++++------
 __init__.py                        |  3 ++-
 __manifest__.py                    |  1 +
 models/__init__.py                 |  1 +
 models/product.py                  |  2 +-
 models/sale_order.py               |  3 +++
 models/stock_move.py               | 17 +++++++++++++
 report/__init__.py                 |  4 +++
 report/product_pricelist_report.py | 10 ++++++++
 report/report_invoice.xml          | 25 +++++++++++++++++++
 report/report_pricelist.xml        | 19 +++++++++++++++
 report/report_saleorder.xml        | 39 ++++++++++++++++++++++++++++++
 views/sale_order.xml               | 25 +++++++++++++++++++
 13 files changed, 163 insertions(+), 9 deletions(-)
 create mode 100644 models/stock_move.py
 create mode 100644 report/__init__.py
 create mode 100644 report/product_pricelist_report.py
 create mode 100644 report/report_pricelist.xml
 create mode 100644 report/report_saleorder.xml

diff --git a/README.rst b/README.rst
index 3a3622c..965e298 100755
--- a/README.rst
+++ b/README.rst
@@ -7,13 +7,22 @@
 Fumaison Occ - Vente
 ====================
 
-- Ce module hérite du module *product* et ajoute un champ EAN7 sur les articles champs au modèle *product.product*
-- Ajout de champs venant de *fumoc_partner* sur *sale_order*
-- Ajout de la note de facturation et de la DLC des lots dans les factures pdf
-- Ajout de la DLC dans la vue détaillée des opérations sur le bon de livraison
-- Modifications mineures du bon de livraison (suppression numéro de téléphone client, remplace Origine par Commande, Force date prévue, Ajout du code-barre article)
-- Calcul la DLC des lots en fonction du numéro de lot
-- Ajout de la DLC, DDM et date d'alerte dans *stock_quant*
+- Articles
+  - Ce module hérite du module *product* et ajoute un champ EAN7 sur les articles champs au modèle *product.product*
+- Commande
+  - Ajout de champs venant de *fumoc_partner* sur *sale_order*
+  - Ajout du type de facturation sur la vue liste
+  - Modifications date (sans heure) sur PDF Bon de Commande
+- Picking
+  - Ajout de la DLC dans la vue détaillée des opérations sur le bon de livraison
+  - Modifications mineures du bon de livraison (suppression numéro de téléphone client, remplace Origine par Commande, Force date prévue, Ajout du code-barre article)
+- Facturation
+  - Ajout de la note de facturation et de la DLC des lots dans les factures pdf
+  - Ajout montants HT et TTC sur chaque ligne des PDF factures + renomme Origine en Commande
+  - Ajout liste des BL sur PDF
+- Lots & Quants
+  - Calcule la DLC des lots en fonction du numéro de lot
+  - Ajout de la DLC, DDM et date d'alerte dans *stock_quant*
 
 Description
 ===========
diff --git a/__init__.py b/__init__.py
index e352eeb..35eec7b 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,4 +1,5 @@
 # Copyright 2021 Le Filament (<http://www.le-filament.com>)
 # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
 
-from . import models
\ No newline at end of file
+from . import models
+from . import report
diff --git a/__manifest__.py b/__manifest__.py
index 116efd8..71f453e 100755
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -10,6 +10,7 @@
         'product_expiry',
         'sale_stock',
         'fumoc_partner',
+        'stock_picking_invoice_link',
     ],
     'data': [
         # datas
diff --git a/models/__init__.py b/models/__init__.py
index 63655f2..d9e7130 100644
--- a/models/__init__.py
+++ b/models/__init__.py
@@ -6,6 +6,7 @@ from . import product
 from . import res_company
 from . import res_config_settings
 from . import sale_order
+from . import stock_move
 from . import stock_picking
 from . import stock_production_lot
 from . import stock_quant
diff --git a/models/product.py b/models/product.py
index faaa98d..2ec2101 100644
--- a/models/product.py
+++ b/models/product.py
@@ -1,7 +1,7 @@
 # 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, api
+from odoo import fields, models
 
 
 class ProductTemplate(models.Model):
diff --git a/models/sale_order.py b/models/sale_order.py
index df5bf34..e5a041c 100644
--- a/models/sale_order.py
+++ b/models/sale_order.py
@@ -16,3 +16,6 @@ class FumocSaleOrder(models.Model):
     packaging_id = fields.Many2one(
         string="Emballage",
         related='partner_id.packaging_id')
+    billing_type_id = fields.Many2one(
+        string="Type de facturation",
+        related='partner_id.billing_type_id')
diff --git a/models/stock_move.py b/models/stock_move.py
new file mode 100644
index 0000000..458d3ec
--- /dev/null
+++ b/models/stock_move.py
@@ -0,0 +1,17 @@
+# 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 models
+
+
+class StockMove(models.Model):
+    _inherit = 'stock.move'
+
+    def _prepare_move_line_vals(self, quantity=None, reserved_quant=None):
+        vals = self.super()._prepare_move_line_vals(self, quantity=None, reserved_quant=None)
+        if reserved_quant:
+            vals = dict(
+                vals,
+                expiration_date=reserved_quant.lot_id.expiration_date,
+            )
+        return vals
diff --git a/report/__init__.py b/report/__init__.py
new file mode 100644
index 0000000..5376788
--- /dev/null
+++ b/report/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import product_pricelist_report
diff --git a/report/product_pricelist_report.py b/report/product_pricelist_report.py
new file mode 100644
index 0000000..d9c6c9e
--- /dev/null
+++ b/report/product_pricelist_report.py
@@ -0,0 +1,10 @@
+# Copyright 2021 Le Filament (<http://www.le-filament.com>)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+class report_product_pricelist(models.AbstractModel):
+     _inherit = 'report.product.report_pricelist'
+
+    def _get_product_data(self, is_product_tmpl, product, pricelist, quantities):
+        data = super()._get_product_data(is_product_tmpl, product, pricelist, quantities)
+        data['barcode'] = product.barcode
+        return data
diff --git a/report/report_invoice.xml b/report/report_invoice.xml
index 0fa4b6a..45a3e71 100644
--- a/report/report_invoice.xml
+++ b/report/report_invoice.xml
@@ -5,6 +5,31 @@
 
     <template id="fumoc_sale_stock_report_invoice_document" inherit_id="sale_stock.sale_stock_report_invoice_document">
 
+        <xpath expr="//div[@name='origin']" position="replace">
+            <div class="col-auto col-3 mw-100 mb-2" t-if="o.invoice_origin" name="origin">
+                <strong>Commande :</strong>
+                <p class="m-0" t-field="o.invoice_origin"/>
+            </div>
+            <div class="col-auto col-3 mw-100 mb-2" t-if="o.picking_ids" name="origin">
+                <strong>Livraison(s) :</strong>
+                <p t-esc="'%s' % ', '.join(o.picking_ids.mapped('name'))"/>
+            </div>
+        </xpath>
+
+        <xpath expr="//th[@name='th_subtotal']" position="replace">
+            <th name="th_subtotal" class="text-right">
+                <span>Montant HT</span>
+                <span>Montant TTC</span>
+            </th>
+        </xpath>
+
+        <xpath expr="//table//tbody//t[@name='account_invoice_line_accountable']//td[hasclass('o_price_total')]" position="replace">
+            <td class="text-right o_price_total">
+                <span class="text-nowrap" t-field="line.price_subtotal"/>
+                <span class="text-nowrap" t-field="line.price_total"/>
+            </td>
+        </xpath>
+
         <xpath expr="//table[@name='invoice_snln_table']" position="attributes">
             <attribute name="style">width: 65%;</attribute>
         </xpath>
diff --git a/report/report_pricelist.xml b/report/report_pricelist.xml
new file mode 100644
index 0000000..d301d3e
--- /dev/null
+++ b/report/report_pricelist.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2021 Le Filament
+     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
+<odoo>
+
+    <template id="fumoc_sale_report_pricelist_page" inherit_id="product.report_pricelist_page">
+
+        <xpath expr="//table/thead/tr/th[1]" position="after">
+            <th>Codes Barre</th>
+        </xpath>
+        <xpath expr="//table/tbody/t/tr/td[1]" position="after">
+          <td class="text-right">
+              <t t-esc="product['list_price']"/>
+          </td>
+        </xpath>
+
+    </template>
+
+</odoo>
diff --git a/report/report_saleorder.xml b/report/report_saleorder.xml
new file mode 100644
index 0000000..37d6e6a
--- /dev/null
+++ b/report/report_saleorder.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2021 Le Filament
+     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
+<odoo>
+
+    <template id="fumoc_sale_report_saleorder_document" inherit_id="sale_stock.report_saleorder_document_inherit_sale_stock">
+
+        <xpath expr="//div[@id='informations']" position="replace">
+            <div class="row mt32 mb32" id="informations">
+                <div t-if="doc.client_order_ref" class="col-auto col-3 mw-100 mb-2">
+                    <strong>Your Reference:</strong>
+                    <p class="m-0" t-field="doc.client_order_ref"/>
+                </div>
+                <div t-if="doc.date_order and doc.state not in ['draft','sent']" class="col-auto col-3 mw-100 mb-2">
+                    <strong>Order Date:</strong>
+                    <p class="m-0" t-field="doc.date_order" t-options="{&quot;widget&quot;: &quot;date&quot;}"/>
+                </div>
+                <div t-if="doc.date_order and doc.state in ['draft','sent']" class="col-auto col-3 mw-100 mb-2">
+                    <strong>Quotation Date:</strong>
+                    <p class="m-0" t-field="doc.date_order" t-options="{&quot;widget&quot;: &quot;date&quot;}"/>
+                </div>
+                <div t-if="doc.validity_date and doc.state in ['draft', 'sent']" class="col-auto col-3 mw-100 mb-2" name="expiration_date">
+                    <strong>Expiration:</strong>
+                    <p class="m-0" t-field="doc.validity_date" t-options="{&quot;widget&quot;: &quot;date&quot;}"/>
+                </div>
+                <div class="col-3" t-if="doc.incoterm" groups="sale_stock.group_display_incoterm">
+                    <strong>Incoterm:</strong>
+                    <p t-field="doc.incoterm.code"/>
+                </div>
+                <div t-if="doc.user_id.name" class="col-auto col-3 mw-100 mb-2">
+                    <strong>Salesperson:</strong>
+                    <p class="m-0" t-field="doc.user_id"/>
+                </div>
+            </div>
+        </xpath>
+
+    </template>
+
+</odoo>
diff --git a/views/sale_order.xml b/views/sale_order.xml
index a2a32de..574bf07 100644
--- a/views/sale_order.xml
+++ b/views/sale_order.xml
@@ -14,6 +14,31 @@
                     <field name="departure_day_ids" widget="many2many_tags"/>
                     <field name="res_transporter_id"/>
                     <field name="packaging_id"/>
+                    <field name="billing_type_id"/>
+                </xpath>
+            </field>
+        </record>
+
+        <record id="fumoc_sale_order_tree_inherit" model="ir.ui.view">
+            <field name="name">fumoc_sale.sale.order.tree</field>
+            <field name="model">sale.order</field>
+            <field name="inherit_id" ref="	sale.view_order_tree"/>
+            <field name="priority" eval="8"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='partner_id']" position="after">
+                    <field name="billing_type_id" optional="show"/>
+                </xpath>
+            </field>
+        </record>
+
+        <record id="fumoc_sale_quotation_tree_inherit" model="ir.ui.view">
+            <field name="name">fumoc_sale.sale.quotation.tree</field>
+            <field name="model">sale.order</field>
+            <field name="inherit_id" ref="	sale.view_quotation_tree"/>
+            <field name="priority" eval="8"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='partner_id']" position="after">
+                    <field name="billing_type_id" optional="show"/>
                 </xpath>
             </field>
         </record>
-- 
GitLab