mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
20 lines
559 B
Python
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
|
|
|