Merge pull request #16 from bakeupboys/80-16.0-livegang

80 16.0 livegang
This commit is contained in:
madmooose 2024-07-30 18:26:37 +02:00 committed by GitHub
commit 67cba5f268
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 63 additions and 18 deletions

View file

@ -36,6 +36,7 @@ Changelog
=========
:0.0.1: Initial module.
:1.0.0: Live
Bug Tracker
===========

View file

@ -4,9 +4,9 @@
"author": "BAKEUP",
"website": "https://www.bakeup.org",
"category": "website",
"version": "16.0.0.0.1",
"version": "16.0.1.0.0",
"depends": ["website_sale", "nfu_sale_order_batch_packaging"],
"data": ["views/templates.xml"],
"data": ["views/product_template_views.xml", "views/templates.xml"],
"assets": {"web.assets_frontend": ["nfu_ecommerce/static/src/js/website_sale.js"]},
"license": "LGPL-3",
}

View file

@ -1,2 +1,3 @@
from . import product_template
from . import sale_order
from . import sale_order_line

View file

@ -0,0 +1,13 @@
from odoo import models
class ProductTemplate(models.Model):
_inherit = "product.template"
def action_publish_on_website(self):
for product in self:
product.is_published = True
def action_unpublish_on_website(self):
for product in self:
product.is_published = False

View file

@ -6,5 +6,6 @@ class SaleOrderLine(models.Model):
def compute_open_packages(self):
self.ensure_one()
open_qty = self.batch_uom_qty % self.product_packaging_id.qty
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

View file

@ -1 +1,2 @@
:0.0.1: Initial module.
:1.0.0: Live

View file

@ -395,6 +395,8 @@ and after the current order.</p>
<tbody valign="top">
<tr class="field"><th class="field-name">0.0.1:</th><td class="field-body">Initial module.</td>
</tr>
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body">Live</td>
</tr>
</tbody>
</table>
</div>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_template_tree_view" model="ir.ui.view">
<field name="name">product.template.product.tree.inherit.website</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<button string="Publish on Website" type="object" name="action_publish_on_website"/>
<button string="Unpublish on Website" type="object" name="action_unpublish_on_website"/>
</xpath>
</field>
</record>
</odoo>

View file

@ -3,10 +3,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"
/><br/></span>
<span>Total Ordered Quantity: <t t-esc="line.batch_uom_qty"/></span>
<span>Open Package: <t t-esc="line.compute_open_packages()"/>/<t t-esc="line.product_packaging_id.qty"/>
</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 &lt; line.product_packaging_id.qty else ''}"
/></span>
</div>
</xpath>
<xpath expr="//th[hasclass('td-qty')]" position="after">
@ -85,10 +87,13 @@
<template id="cart_summary_packaging" inherit_id="website_sale.cart_summary" name="Cart right column">
<xpath expr="//td[hasclass('td-product_name')]" position="inside">
<div>
<span t-if="line.product_packaging_id">Open Package: <t t-esc="line.product_packaging_id.qty"/><br
<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>Max Ordered Quantity: <span
t-esc="line.batch_uom_max_qty"
t-attf-class="#{'text-danger' if line.batch_uom_max_qty &lt; line.product_packaging_id.qty else ''}"
/></span>
<span t-if="line.batch_uom_qty &gt; 0">Ordered Quantity: <t t-esc="line.batch_uom_qty"/></span>
</div>
</xpath>
<xpath expr="//th[hasclass('td-qty')]" position="after">

View file

@ -35,6 +35,7 @@ Changelog
:0.0.1: Initial module.
:1.0.0: rename to nfu_sale_order_batch_packaging
:1.1.0: Live
Bug Tracker
===========

View file

@ -4,7 +4,7 @@
"author": "BAKEUP",
"website": "https://www.bakeup.org",
"category": "Sale",
"version": "16.0.1.0.0",
"version": "16.0.1.1.0",
"depends": ["sale", "sale_order_batch"],
"data": [
"views/sale_order_views.xml",

View file

@ -9,6 +9,7 @@ class SaleOrderLine(models.Model):
product_uom_ordered_qty = fields.Float(string="Ordered Qty", digits="Product Unit of Measure", default=1.0)
product_uom_max_qty = fields.Float(string="Max Qty", digits="Product Unit of Measure")
batch_uom_qty = fields.Float(compute="_compute_batch_uom_qty")
batch_uom_max_qty = fields.Float(compute="_compute_batch_uom_qty")
@api.constrains("product_uom_qty", "product_uom_max_qty")
def _check_product_uom_qty(self):
@ -21,20 +22,21 @@ class SaleOrderLine(models.Model):
)
)
@api.depends("product_uom_qty")
@api.depends("product_uom_qty", "product_uom_max_qty")
def _compute_batch_uom_qty(self):
for line in self:
if line.order_id.batch_id:
batch_id = line.batch_id
product_id = line.product_id
batch_uom_qtys = (
batch_lines = (
self.env["sale.order.line"]
.sudo()
.search([("batch_id", "=", batch_id.id), ("product_id", "=", product_id.id)])
).mapped("product_uom_qty")
line.batch_uom_qty = sum(batch_uom_qtys)
)
line.batch_uom_qty = sum(batch_lines.mapped("product_uom_qty"))
line.batch_uom_max_qty = sum(batch_lines.mapped("product_uom_max_qty"))
else:
line.batch_uom_qty = 0
line.batch_uom_max_qty = line.batch_uom_qty = 0
@api.depends("product_packaging_id", "product_uom", "product_uom_qty", "batch_id")
def _compute_product_packaging_qty(self):

View file

@ -1,2 +1,3 @@
:0.0.1: Initial module.
:1.0.0: rename to nfu_sale_order_batch_packaging
:1.1.0: Live

View file

@ -395,6 +395,8 @@ and adds a packaging default to sale order batch.</p>
</tr>
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body">rename to nfu_sale_order_batch_packaging</td>
</tr>
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body">Live</td>
</tr>
</tbody>
</table>
</div>