diff --git a/__init__.py b/__init__.py
index 980c01c..1f2b419 100644
--- a/__init__.py
+++ b/__init__.py
@@ -3,10 +3,12 @@
from trytond.pool import Pool
from . import purchase
+from . import product
def register():
Pool.register(
+ product.Product,
purchase.Configuration,
purchase.Purchase,
purchase.Line,
diff --git a/product.py b/product.py
new file mode 100644
index 0000000..db39134
--- /dev/null
+++ b/product.py
@@ -0,0 +1,24 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+from decimal import Decimal
+from trytond.model import fields
+from trytond.pool import PoolMeta, Pool
+from trytond.modules.product import price_digits
+
+class Product(metaclass=PoolMeta):
+ __name__ = 'product.product'
+ last_cost = fields.Function(fields.Numeric('Last Cost', digits=price_digits,
+ help='Last purchase price'), 'get_last_cost')
+
+ def get_last_cost(self, name=None):
+ res = self.cost_price
+ InvoiceLine = Pool().get('account.invoice.line')
+ products = InvoiceLine.search_read([
+ ('product', '=', self.id),
+ ('invoice.state', 'in', ['posted', 'paid']),
+ ('invoice.type', '=', 'in'),
+ ], fields_names=['unit_price'], order=[('invoice.invoice_date', 'DESC')], limit=1)
+ if products:
+ res = products[0]['unit_price']
+ return res
+
diff --git a/product.xml b/product.xml
new file mode 100644
index 0000000..be2241e
--- /dev/null
+++ b/product.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ product.product
+
+ product_form_simple
+
+
+
\ No newline at end of file
diff --git a/tryton.cfg b/tryton.cfg
index bf29ebb..51ab75b 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,8 +1,9 @@
[tryton]
-version=6.0.3
+version=6.0.4
depends:
product
purchase
account_col
xml:
purchase.xml
+ product.xml
diff --git a/view/product_form_simple.xml b/view/product_form_simple.xml
new file mode 100644
index 0000000..3442954
--- /dev/null
+++ b/view/product_form_simple.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+