Merge remote-tracking branch 'inventree/master'

This commit is contained in:
Oliver Walters 2021-05-06 09:07:39 +10:00
commit 33ac3cdd95
23 changed files with 4387 additions and 3761 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -223,7 +223,7 @@ class PurchaseOrder(Order):
return reverse('po-detail', kwargs={'pk': self.id})
@transaction.atomic
def add_line_item(self, supplier_part, quantity, group=True, reference=''):
def add_line_item(self, supplier_part, quantity, group=True, reference='', purchase_price=None):
""" Add a new line item to this purchase order.
This function will check that:
@ -254,7 +254,12 @@ class PurchaseOrder(Order):
if matches.count() > 0:
line = matches.first()
line.quantity += quantity
# update quantity and price
quantity_new = line.quantity + quantity
line.quantity = quantity_new
supplier_price = supplier_part.get_price(quantity_new)
if line.purchase_price and supplier_price:
line.purchase_price = supplier_price / quantity_new
line.save()
return
@ -263,7 +268,9 @@ class PurchaseOrder(Order):
order=self,
part=supplier_part,
quantity=quantity,
reference=reference)
reference=reference,
purchase_price=purchase_price,
)
line.save()
@ -329,7 +336,7 @@ class PurchaseOrder(Order):
return self.pending_line_items().count() == 0
@transaction.atomic
def receive_line_item(self, line, location, quantity, user, status=StockStatus.OK):
def receive_line_item(self, line, location, quantity, user, status=StockStatus.OK, purchase_price=None):
""" Receive a line item (or partial line item) against this PO
"""
@ -353,7 +360,8 @@ class PurchaseOrder(Order):
location=location,
quantity=quantity,
purchase_order=self,
status=status
status=status,
purchase_price=purchase_price,
)
stock.save()

View File

@ -776,6 +776,7 @@ class PurchaseOrderReceive(AjaxUpdateView):
line.receive_quantity,
self.request.user,
status=line.status_code,
purchase_price=line.purchase_price,
)
@ -996,6 +997,14 @@ class OrderParts(AjaxView):
part.order_supplier = supplier_part.id if supplier_part else None
part.order_quantity = quantity
# set supplier-price
if supplier_part:
supplier_price = supplier_part.get_price(quantity)
if supplier_price:
part.purchase_price = supplier_price / quantity
if not hasattr(part, 'purchase_price'):
part.purchase_price = None
self.parts.append(part)
if supplier_part is None:
@ -1095,7 +1104,10 @@ class OrderParts(AjaxView):
sp=item.order_supplier))
continue
order.add_line_item(supplier_part, quantity)
# get purchase price
purchase_price = item.purchase_price
order.add_line_item(supplier_part, quantity, purchase_price=purchase_price)
class POLineItemCreate(AjaxCreateView):

View File

@ -91,7 +91,7 @@
{% if part.salable and roles.sales_order.view %}
<li class='list-group-item {% if tab == "sales-prices" %}active{% endif %}' title='{% trans "Sales Price Information" %}'>
<a href='{% url "part-sale-prices" part.id %}'>
<span class='menu-tab-icon fas fa-dollar-sign'></span>
<span class='menu-tab-icon fas fa-dollar-sign' style='width: 20px;'></span>
{% trans "Sale Price" %}
</a>
</li>

View File

@ -2,7 +2,7 @@
{% load static %}
{% load i18n %}
{% block menubar %}}
{% block menubar %}
{% include 'part/navbar.html' with tab='sales-prices' %}
{% endblock %}

View File

@ -65,7 +65,7 @@ def manage(c, cmd, pty=False):
cmd - django command to run
"""
c.run('cd {path} && python3 manage.py {cmd}'.format(
c.run('cd "{path}" && python3 manage.py {cmd}'.format(
path=managePyDir(),
cmd=cmd
), pty=pty)
@ -185,7 +185,7 @@ def translate(c):
"""
# Translate applicable .py / .html / .js files
manage(c, "makemessages --all -e py,html,js")
manage(c, "makemessages --all -e py,html,js --no-wrap")
manage(c, "compilemessages")
path = os.path.join('InvenTree', 'script', 'translation_stats.py')