mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
purchase order weight
This commit is contained in:
@@ -3,13 +3,14 @@
|
||||
|
||||
{
|
||||
'name': 'App Product Weight in Sales Order',
|
||||
'version': '12.0.11.26',
|
||||
'summary': 'Add Product sku weight in Sale Order, product weight, sale weight, total weight',
|
||||
'version': '12.19.01.02',
|
||||
'summary': 'Add Product sku weight in Sale Order, product weight, sale weight, sale order weight, total weight, kg kg(s) lb lb(s) support',
|
||||
'sequence': 10,
|
||||
'license': 'LGPL-3',
|
||||
'description': """
|
||||
Add product sku weight in Sale Order. Unit of measure auto weight.
|
||||
Calculates total weight of a sale order, which is the sum of individual weights of each unit of the products in the order
|
||||
Add product sku weight in Sale Order. Unit of measure auto weight, kg kg(s) lb lb(s) support.
|
||||
Calculates total weight of a sale order, which is the sum of individual weights of each unit of the products in the order。
|
||||
Support kg(s) or lb(s)
|
||||
""",
|
||||
'category': 'Sales',
|
||||
'author': 'Sunpop.cn',
|
||||
|
||||
@@ -7,13 +7,23 @@ from odoo import api, fields, models, _
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
weight_total = fields.Float(string='Total Weight(kg)', compute='_compute_weight_total')
|
||||
def _get_default_weight_uom_name(self):
|
||||
get_param = self.env['ir.config_parameter'].sudo().get_param
|
||||
product_weight_in_lbs_param = get_param('product.weight_in_lbs')
|
||||
if product_weight_in_lbs_param == '1':
|
||||
return self.env.ref('uom.product_uom_lb').name
|
||||
else:
|
||||
return self.env.ref('uom.product_uom_kgm').name
|
||||
|
||||
weight_total = fields.Float(string='Total Weight', compute='_compute_weight_total')
|
||||
# 重量显示的单位
|
||||
weight_uom_name = fields.Char(string='Weight Measure', default=_get_default_weight_uom_name, readonly=True)
|
||||
|
||||
def _compute_weight_total(self):
|
||||
for sale in self:
|
||||
for rec in self:
|
||||
weight_tot = 0
|
||||
for line in sale.order_line:
|
||||
for line in rec.order_line:
|
||||
if line.product_id:
|
||||
weight_tot += line.weight_subtotal or 0.0
|
||||
sale.weight_total = weight_tot
|
||||
rec.weight_total = weight_tot
|
||||
|
||||
|
||||
@@ -11,17 +11,19 @@ class SaleOrderLine(models.Model):
|
||||
|
||||
# 显示的单位,影响性能暂时不使用
|
||||
# weight_uom_name = fields.Char(string='Weight Measure', related='product_id.weight_uom_id.name', readonly=True)
|
||||
weight = fields.Float(string='Weight', related='product_id.weight', store=True, readonly=True)
|
||||
weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight_subtotal',
|
||||
inverse='_set_weight_subtotal', store=True)
|
||||
weight = fields.Float(string='Weight', compute='_compute_weight', readonly=True)
|
||||
weight_subtotal = fields.Float(string='Weight Subtotal', compute='_compute_weight', store=True)
|
||||
|
||||
@api.multi
|
||||
@api.depends('product_id', 'weight', 'product_uom', 'product_uom_qty')
|
||||
def _compute_weight_subtotal(self):
|
||||
@api.depends('product_id', 'product_uom', 'product_qty')
|
||||
def _compute_weight(self):
|
||||
for line in self:
|
||||
weight = 0
|
||||
weight_subtotal = 0
|
||||
if line.product_id and line.product_id.weight:
|
||||
weight_subtotal += (line.product_id.weight * line.product_uom_qty / line.product_uom.factor)
|
||||
weight = line.product_id.weight / line.product_uom.factor
|
||||
weight_subtotal += (weight * line.product_qty)
|
||||
line.weight = weight
|
||||
line.weight_subtotal = weight_subtotal
|
||||
|
||||
@api.one
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 78 KiB |
BIN
app_product_weight_sale/static/description/banner.png
Normal file
BIN
app_product_weight_sale/static/description/banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 287 KiB |
BIN
app_product_weight_sale/static/description/demo1.jpg
Normal file
BIN
app_product_weight_sale/static/description/demo1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
@@ -3,32 +3,46 @@
|
||||
<div class="oe_span12">
|
||||
<h2 class="oe_slogan">Sales Order Weight</h2>
|
||||
</div>
|
||||
<div class="alert alert-info" style="padding:8px;font-weight: 300; font-size: 20px;">
|
||||
<i class="fa fa-hand-o-right"></i><b> Key features: </b>
|
||||
<ul class="list-unstyled">
|
||||
<li>
|
||||
<i class="fa fa-check-square-o text-primary"></i>
|
||||
Add product sku weight in Sale Order line.
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-check-square-o text-primary"></i>
|
||||
Calculates total weight of a sale order, which is the sum of individual weights of each unit of the products in the order.
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-check-square-o text-primary"></i>
|
||||
Support kg(s) or lb(s)
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<p class='oe_mt32'>
|
||||
This module from Sunpop.cn manages to calculate total weight of a sale order, which is the sum of individual weights of each unit of the products in the order.
|
||||
</p>
|
||||
<p class='oe_mt32'>
|
||||
The product form has a field 'Weight', which stores the weight of the product in Kg.
|
||||
</p>
|
||||
<div class="oe_demo oe_screenshot">
|
||||
<img class="oe_picture oe_screenshot" src="product_weight.jpg">
|
||||
<h3 class='oe_mt32'>
|
||||
Setup product weight.
|
||||
</h3>
|
||||
<img class="oe_screenshot" src="product_weight.jpg">
|
||||
</div>
|
||||
|
||||
|
||||
<p class='oe_span12 oe_mt32'>
|
||||
The module adds a field 'Net Weight' in sale order line, which calculates the Order line weight based on Order line Quantity and Unit of Measure. The new field 'Total Weight' in Sale Order would be the sum of sale order line weights.
|
||||
</p>
|
||||
|
||||
<div class="oe_demo oe_screenshot">
|
||||
<img class="oe_picture oe_screenshot" src="banner.jpg">
|
||||
<h3 class='oe_mt32'>
|
||||
Get product weight and total weight in order.
|
||||
</h3>
|
||||
<img class="oe_screenshot" src="demo1.jpg">
|
||||
</div>
|
||||
|
||||
<p class='oe_span12 oe_mt32'>
|
||||
The calculation uses the following formula:
|
||||
</p>
|
||||
The calculation uses the following formula:
|
||||
</p>
|
||||
<p class='oe_mt32'>
|
||||
Sale_order_line_net_weight = (line_product_weight * line_product_uom_qty / line_product_uom_factor)
|
||||
order_line_net_weight = (line_product_weight / line_product_uom_factor)
|
||||
<br/>
|
||||
weight_total = sum(Sale_order_line_net_weight)
|
||||
weight_total = sum(order_line_net_weight)
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='state']" position="after">
|
||||
<xpath expr="//field[@name='amount_total']" position="before">
|
||||
<field name="weight_total"/>
|
||||
</xpath>
|
||||
</field>
|
||||
@@ -19,7 +19,7 @@
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_quotation_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='state']" position="after">
|
||||
<xpath expr="//field[@name='amount_total']" position="before">
|
||||
<field name="weight_total"/>
|
||||
</xpath>
|
||||
</field>
|
||||
@@ -35,7 +35,7 @@
|
||||
<xpath expr="//field[@name='note']" position="before">
|
||||
<div>
|
||||
<label for="weight_total" name="weight_total" string="Total Weight: " class="oe_inline"/>
|
||||
<field name="weight_total" class="oe_inline"/><span> kg</span>
|
||||
<field name="weight_total" class="oe_inline"/><span> <field name="weight_uom_name" class="oe_inline"/></span>
|
||||
</div>
|
||||
<newline/>
|
||||
</xpath>
|
||||
@@ -43,7 +43,7 @@
|
||||
<field name="weight"/>
|
||||
<field name="weight_subtotal"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']/form/group/group/field[@name='price_unit']" position="before">
|
||||
<xpath expr="//field[@name='order_line']/form//field[@name='price_unit']" position="before">
|
||||
<field name="weight"/>
|
||||
<field name="weight_subtotal"/>
|
||||
</xpath>
|
||||
|
||||
@@ -28,9 +28,6 @@ sheet全宽
|
||||
.o_form_view .o_form_sheet_bg > .o_form_sheet {
|
||||
max-width: 98% !important;
|
||||
}
|
||||
.o_content .o_view_controller > .o_form_view {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
.o_form_view .o_form_sheet_bg > .o_form_sheet {
|
||||
|
||||
Reference in New Issue
Block a user