[IMP] nfu_ecommerce: Add open packaging filter to webshop
This commit is contained in:
parent
aa31ea501a
commit
847d34c889
6 changed files with 152 additions and 11 deletions
|
|
@ -37,7 +37,7 @@ Changelog
|
|||
|
||||
:0.0.1: Initial module.
|
||||
:1.0.0: Live
|
||||
:1.1.0: Add Open Packagings Filter
|
||||
:1.1.0: Add Open Packagings Filter and fix rounding issue
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
|
|
|||
120
nfu_ecommerce/i18n/de.po
Normal file
120
nfu_ecommerce/i18n/de.po
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * nfu_ecommerce
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-10-04 19:54+0000\n"
|
||||
"PO-Revision-Date: 2024-10-04 19:54+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging
|
||||
msgid "<span>Max Qty</span>"
|
||||
msgstr "<span>Max Menge</span>"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging
|
||||
msgid "Add one"
|
||||
msgstr "Einen hinzufügen"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.o_wsale_offcanvas
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.products_open_packaging
|
||||
msgid "All Products"
|
||||
msgstr "Alle Produkte"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model:ir.model.fields,field_description:nfu_ecommerce.field_sale_order__balance
|
||||
msgid "Balance"
|
||||
msgstr "Guthaben"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.total
|
||||
msgid "Balance:"
|
||||
msgstr "Aktuelles Guthaben:"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_summary_packaging
|
||||
msgid "Max Ordered Quantity:"
|
||||
msgstr "Max Menge"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_summary_packaging
|
||||
msgid "Max Qty"
|
||||
msgstr "Max Menge:"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.total
|
||||
msgid "New balance:"
|
||||
msgstr "Neues Guthaben:"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging
|
||||
msgid "No open package available"
|
||||
msgstr "Keine offenen Gebinde"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_summary_packaging
|
||||
msgid "Open Package:"
|
||||
msgstr "Offenes Gebinde:"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.o_wsale_offcanvas
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.products_open_packaging
|
||||
msgid "Open Packagings"
|
||||
msgstr "Offene Gebinde"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model:ir.model.fields,field_description:nfu_ecommerce.field_sale_order_line__open_qty
|
||||
msgid "Open Qty"
|
||||
msgstr "Offene Menge"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model:ir.model,name:nfu_ecommerce.model_product_template
|
||||
msgid "Product"
|
||||
msgstr "Produkt"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.product_template_tree_view
|
||||
msgid "Publish on Website"
|
||||
msgstr "Veröffentlichen"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging
|
||||
msgid "Remove one"
|
||||
msgstr "Eins entfernen"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model:ir.model,name:nfu_ecommerce.model_sale_order
|
||||
msgid "Sales Order"
|
||||
msgstr "Verkaufsauftrag"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model:ir.model,name:nfu_ecommerce.model_sale_order_line
|
||||
msgid "Sales Order Line"
|
||||
msgstr "Verkaufsauftragszeile"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.product_template_tree_view
|
||||
msgid "Unpublish on Website"
|
||||
msgstr "Von Website entfernen"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model:ir.model.fields,field_description:nfu_ecommerce.field_sale_order__updated_balance
|
||||
msgid "Updated Balance"
|
||||
msgstr "Zukünftiges Guthaben"
|
||||
|
||||
#. module: nfu_ecommerce
|
||||
#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging
|
||||
msgid "Warning"
|
||||
msgstr "Warnung"
|
||||
|
|
@ -1,11 +1,28 @@
|
|||
from odoo import models
|
||||
from odoo import fields, models
|
||||
from odoo.tools import float_is_zero, float_repr, float_round
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
def compute_open_packages(self):
|
||||
self.ensure_one()
|
||||
qty_of_last_pack = self.batch_uom_qty % self.product_packaging_id.qty
|
||||
open_qty = self.product_packaging_id.qty - qty_of_last_pack
|
||||
return open_qty
|
||||
open_qty = fields.Float(compute="_compute_open_qty")
|
||||
|
||||
def _compute_open_qty(self):
|
||||
for line in self:
|
||||
if line.product_packaging_id:
|
||||
precision_rounding = line.product_id.uom_id.rounding
|
||||
precision_digits = len(str(precision_rounding).split(".")[1])
|
||||
qty_of_last_pack = float_round(
|
||||
line.batch_uom_qty % line.product_packaging_id.qty, precision_rounding=precision_rounding
|
||||
)
|
||||
if not float_is_zero(qty_of_last_pack, precision_rounding=precision_rounding):
|
||||
open_qty = float_round(
|
||||
line.product_packaging_id.qty - qty_of_last_pack, precision_rounding=precision_rounding
|
||||
)
|
||||
# somehow float_rounding() does not capture all cases ex. float_rounding(2-1.1)
|
||||
# this is a samll workaround
|
||||
line.open_qty = float(float_repr(open_qty, precision_digits))
|
||||
else:
|
||||
line.open_qty = 0.0
|
||||
else:
|
||||
line.open_qty = 0.0
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
:0.0.1: Initial module.
|
||||
:1.0.0: Live
|
||||
:1.1.0: Add Open Packagings Filter
|
||||
:1.1.0: Add Open Packagings Filter and fix rounding issue
|
||||
|
|
@ -397,7 +397,7 @@ and after the current order.</p>
|
|||
</tr>
|
||||
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body">Live</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body">Add Open Packagings Filter</td>
|
||||
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body">Add Open Packagings Filter and fix rounding issue</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -28,8 +28,12 @@
|
|||
<template id="cart_lines_packaging" inherit_id="website_sale.cart_lines" name="Shopping Cart Lines">
|
||||
<xpath expr="//td[hasclass('td-product_name')]" position="inside">
|
||||
<div t-if="line.product_packaging_id and (line.product_packaging_id.qty != 1)">
|
||||
<span>Open Package: <t t-esc="line.compute_open_packages()"/>/<t t-esc="line.product_packaging_id.qty"/>
|
||||
</span><br/>
|
||||
<span t-if="line.open_qty > 0">Open Package: <t t-esc="line.open_qty"/>/<t
|
||||
t-esc="line.product_packaging_id.qty"
|
||||
/>
|
||||
</span>
|
||||
<span t-else="">No open package available</span>
|
||||
<br/>
|
||||
<span>Max Ordered Quantity: <span
|
||||
t-esc="line.batch_uom_max_qty"
|
||||
t-attf-class="#{'text-danger' if line.batch_uom_max_qty < line.product_packaging_id.qty else ''}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue