mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
add sale_weight
This commit is contained in:
6
app_sale_order_weight/__init__.py
Normal file
6
app_sale_order_weight/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
29
app_sale_order_weight/__manifest__.py
Normal file
29
app_sale_order_weight/__manifest__.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# -*- coding: utf-8 ---*---
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
{
|
||||||
|
'name' : 'App Sales Order Weight',
|
||||||
|
'version' : '11.1.6.17',
|
||||||
|
'summary': 'Add sku weight in Sale Order',
|
||||||
|
'sequence': 10,
|
||||||
|
'license':'LGPL-3',
|
||||||
|
'description': """
|
||||||
|
Add sku weight in Sale Order.
|
||||||
|
Calculates total weight of a sale order, which is the sum of individual weights of each unit of the products in the order
|
||||||
|
""",
|
||||||
|
'category': 'Sales',
|
||||||
|
'author' : 'Sunpop.cn',
|
||||||
|
'website' : 'http://www.sunpop.cn',
|
||||||
|
'images': ['static/description/banner.jpg'],
|
||||||
|
'depends' : ['sale_management'],
|
||||||
|
'data': [
|
||||||
|
'views/sale_order_views.xml',
|
||||||
|
],
|
||||||
|
'demo': [
|
||||||
|
],
|
||||||
|
'qweb': [
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'application': True,
|
||||||
|
'auto_install': False,
|
||||||
|
}
|
||||||
47
app_sale_order_weight/i18n/zh_CN.po
Normal file
47
app_sale_order_weight/i18n/zh_CN.po
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * app_sale_order_weight
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 11.0+e-20180429\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2018-06-17 15:47+0000\n"
|
||||||
|
"PO-Revision-Date: 2018-06-17 15:47+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: app_sale_order_weight
|
||||||
|
#: model:ir.ui.view,arch_db:app_sale_order_weight.sale_weight_line_form
|
||||||
|
msgid "<span> kg</span>"
|
||||||
|
msgstr "<span> kg</span>"
|
||||||
|
|
||||||
|
#. module: app_sale_order_weight
|
||||||
|
#: model:ir.model.fields,field_description:app_sale_order_weight.field_sale_order_line_weight_net
|
||||||
|
msgid "Net Weight(kg)"
|
||||||
|
msgstr "重量(kg)"
|
||||||
|
|
||||||
|
#. module: app_sale_order_weight
|
||||||
|
#: model:ir.model,name:app_sale_order_weight.model_sale_order
|
||||||
|
msgid "Quotation"
|
||||||
|
msgstr "报价单"
|
||||||
|
|
||||||
|
#. module: app_sale_order_weight
|
||||||
|
#: model:ir.model,name:app_sale_order_weight.model_sale_order_line
|
||||||
|
msgid "Sales Order Line"
|
||||||
|
msgstr "销售订单行"
|
||||||
|
|
||||||
|
#. module: app_sale_order_weight
|
||||||
|
#: model:ir.model.fields,field_description:app_sale_order_weight.field_sale_order_total_weight_net
|
||||||
|
msgid "Total Weight (kg)"
|
||||||
|
msgstr "Total Weight (kg)"
|
||||||
|
|
||||||
|
#. module: app_sale_order_weight
|
||||||
|
#: model:ir.ui.view,arch_db:app_sale_order_weight.sale_weight_line_form
|
||||||
|
msgid "Total Weight:"
|
||||||
|
msgstr "Total Weight:"
|
||||||
|
|
||||||
7
app_sale_order_weight/models/__init__.py
Normal file
7
app_sale_order_weight/models/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from . import sale_order
|
||||||
|
from . import sale_order_line
|
||||||
|
|
||||||
|
|
||||||
19
app_sale_order_weight/models/sale_order.py
Normal file
19
app_sale_order_weight/models/sale_order.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
|
||||||
|
from odoo import api, fields, models, _
|
||||||
|
|
||||||
|
class SaleOrder(models.Model):
|
||||||
|
_inherit = "sale.order"
|
||||||
|
|
||||||
|
total_weight = fields.Float(string='Total Weight(kg)', compute='_compute_weight_total')
|
||||||
|
|
||||||
|
def _compute_weight_total(self):
|
||||||
|
for sale in self:
|
||||||
|
weight_tot = 0
|
||||||
|
for line in sale.order_line:
|
||||||
|
if line.product_id:
|
||||||
|
weight_tot += line.weight or 0.0
|
||||||
|
sale.total_weight = weight_tot
|
||||||
|
|
||||||
24
app_sale_order_weight/models/sale_order_line.py
Normal file
24
app_sale_order_weight/models/sale_order_line.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
|
||||||
|
from odoo import api, fields, models, _
|
||||||
|
|
||||||
|
# Record the net weight of the order line
|
||||||
|
class SaleOrderLine(models.Model):
|
||||||
|
_inherit = 'sale.order.line'
|
||||||
|
|
||||||
|
weight = fields.Float(string='Weight(kg)', compute='_compute_weight',
|
||||||
|
inverse='_set_weight', store=True)
|
||||||
|
|
||||||
|
def _compute_weight(self):
|
||||||
|
for line in self:
|
||||||
|
weight = 0
|
||||||
|
if line.product_id and line.product_id.weight:
|
||||||
|
weight += (line.product_id.weight
|
||||||
|
* line.product_uom_qty / line.product_uom.factor)
|
||||||
|
line.weight = weight
|
||||||
|
|
||||||
|
@api.one
|
||||||
|
def _set_weight(self):
|
||||||
|
pass
|
||||||
BIN
app_sale_order_weight/static/description/banner.jpg
Normal file
BIN
app_sale_order_weight/static/description/banner.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
BIN
app_sale_order_weight/static/description/icon.png
Normal file
BIN
app_sale_order_weight/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
43
app_sale_order_weight/static/description/index.html
Normal file
43
app_sale_order_weight/static/description/index.html
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<section class="oe_container oe_dark">
|
||||||
|
<div class="oe_row oe_spaced">
|
||||||
|
<div class="oe_span12">
|
||||||
|
<h2 class="oe_slogan">Sales Order Weight</h2>
|
||||||
|
</div>
|
||||||
|
<p class='oe_mt32'>
|
||||||
|
This module from BroadTech IT Solutions 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_span11">
|
||||||
|
<div class="oe_row_img oe_centered">
|
||||||
|
<img class="oe_picture oe_screenshot" src="sale_weight_product.png">
|
||||||
|
</div>
|
||||||
|
</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_span11">
|
||||||
|
<div class="oe_row_img oe_centered">
|
||||||
|
<img class="oe_picture oe_screenshot" src="sale_weight.png">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class='oe_span12 oe_mt32'>
|
||||||
|
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)
|
||||||
|
<br/>
|
||||||
|
Total_weight = sum(Sale_order_line_net_weight)
|
||||||
|
</p>
|
||||||
|
<br/>
|
||||||
|
<p class='oe_mt32 oe_spaced'>
|
||||||
|
For any assistance please feel free to contact us: contact@broadtech-innovations.com
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
BIN
app_sale_order_weight/static/description/sale_weight.png
Normal file
BIN
app_sale_order_weight/static/description/sale_weight.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
BIN
app_sale_order_weight/static/description/sale_weight_product.png
Normal file
BIN
app_sale_order_weight/static/description/sale_weight_product.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 73 KiB |
52
app_sale_order_weight/views/sale_order_views.xml
Normal file
52
app_sale_order_weight/views/sale_order_views.xml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- Add the total weight to the sale order list -->
|
||||||
|
<record model="ir.ui.view" id="sale_weight_tree">
|
||||||
|
<field name="name">sale.weight.view.tree</field>
|
||||||
|
<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">
|
||||||
|
<field name="total_weight"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="sale_quotation_weight_tree">
|
||||||
|
<field name="name">sale.quotation.weight.view.tree</field>
|
||||||
|
<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">
|
||||||
|
<field name="total_weight"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Add the total weight in sale form and net weight to the order line subform -->
|
||||||
|
<record model="ir.ui.view" id="sale_weight_line_form">
|
||||||
|
<field name="name">sale.weight.view.line.form</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='note']" position="before">
|
||||||
|
<div>
|
||||||
|
<label for="total_weight" name="total_weight" string="Total Weight: " class="oe_inline"/>
|
||||||
|
<field name="total_weight" class="oe_inline"/><span> kg</span>
|
||||||
|
</div>
|
||||||
|
<newline/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='order_line']/tree/field[@name='product_uom']" position="after">
|
||||||
|
<field name="weight"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='order_line']/form/group/group/field[@name='price_unit']" position="before">
|
||||||
|
<field name="weight"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
Reference in New Issue
Block a user