Files
app-odoo/app_sale_order_weight/models/sale_order.py
2018-07-21 01:30:20 +08:00

20 lines
559 B
Python

# -*- 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