Use untaxed amount in name_get of purchase orders

Add sum for qty in operation lines
This commit is contained in:
Alexis de Lattre
2018-07-12 23:53:26 +02:00
parent d4e673103e
commit 21d1454ab9
2 changed files with 22 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
from odoo.tools.misc import formatLang
class PurchaseOrder(models.Model):
@@ -54,6 +55,20 @@ class PurchaseOrder(models.Model):
self, 'purchase.report_purchaseorder')
return action
# Re-write native name_get() to use amount_untaxed instead of amount_total
@api.multi
@api.depends('name', 'partner_ref')
def name_get(self):
result = []
for po in self:
name = po.name
if po.partner_ref:
name += ' ('+po.partner_ref+')'
if po.amount_untaxed:
name += ': ' + formatLang(self.env, po.amount_untaxed, currency_obj=po.currency_id)
result.append((po.id, name))
return result
class StockPicking(models.Model):
_inherit = 'stock.picking'

View File

@@ -32,6 +32,13 @@
<button name="action_cancel" type="object" position="attributes">
<attribute name="confirm">Are you sure you want to cancel this picking?</attribute>
</button>
<!-- This sum is useful to check the 'number of items' to transfer... -->
<xpath expr="//field[@name='pack_operation_product_ids']/tree/field[@name='product_qty']" position="attributes">
<attribute name="sum">1</attribute>
</xpath>
<xpath expr="//field[@name='pack_operation_product_ids']/tree/field[@name='qty_done']" position="attributes">
<attribute name="sum">1</attribute>
</xpath>
</field>
</record>