Do not auto-fill target_date for line items (#4275)

* Improve help_text for target_date field on lineitem model(s)

* Don't auto-fill target_date for purchase order line item(s)

* Refactor function to create new sales order line item

* Add migration file

* JS linting
This commit is contained in:
Oliver 2023-01-29 14:24:38 +11:00 committed by GitHub
parent ed9f93a2d6
commit 50eb81f495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 17 deletions

View File

@ -0,0 +1,33 @@
# Generated by Django 3.2.16 on 2023-01-29 01:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('order', '0076_auto_20221111_0153'),
]
operations = [
migrations.AlterField(
model_name='purchaseorderextraline',
name='target_date',
field=models.DateField(blank=True, help_text='Target date for this line item (leave blank to use the target date from the order)', null=True, verbose_name='Target Date'),
),
migrations.AlterField(
model_name='purchaseorderlineitem',
name='target_date',
field=models.DateField(blank=True, help_text='Target date for this line item (leave blank to use the target date from the order)', null=True, verbose_name='Target Date'),
),
migrations.AlterField(
model_name='salesorderextraline',
name='target_date',
field=models.DateField(blank=True, help_text='Target date for this line item (leave blank to use the target date from the order)', null=True, verbose_name='Target Date'),
),
migrations.AlterField(
model_name='salesorderlineitem',
name='target_date',
field=models.DateField(blank=True, help_text='Target date for this line item (leave blank to use the target date from the order)', null=True, verbose_name='Target Date'),
),
]

View File

@ -945,7 +945,7 @@ class OrderLineItem(models.Model):
target_date = models.DateField(
blank=True, null=True,
verbose_name=_('Target Date'),
help_text=_('Target shipping date for this line item'),
help_text=_('Target date for this line item (leave blank to use the target date from the order)'),
)

View File

@ -179,9 +179,6 @@ $('#new-po-line').click(function() {
currency: '{{ order.supplier.currency }}',
{% endif %}
{% endif %}
{% if order.target_date %}
target_date: '{{ order.target_date|date:'Y-m-d' }}',
{% endif %}
onSuccess: function() {
$('#po-line-table').bootstrapTable('refresh');
}

View File

@ -249,21 +249,16 @@
});
$("#new-so-line").click(function() {
var fields = soLineItemFields({
createSalesOrderLineItem({
order: {{ order.pk }},
{% if order.target_date %}
target_date: '{{ order.target_date|date:'Y-m-d' }}',
{% endif %}
});
constructForm('{% url "api-so-line-list" %}', {
fields: fields,
method: 'POST',
title: '{% trans "Add Line Item" %}',
onSuccess: function() {
$("#so-lines-table").bootstrapTable("refresh");
},
}
});
// Create a new SalesOrderLine item
var fields = soLineItemFields({
order: {{ order.pk }},
});
});

View File

@ -30,6 +30,7 @@
createPurchaseOrder,
createPurchaseOrderLineItem,
createSalesOrder,
createSalesOrderLineItem,
createSalesOrderShipment,
duplicatePurchaseOrder,
editPurchaseOrder,
@ -519,7 +520,9 @@ function createSalesOrderShipment(options={}) {
}
// Create a new SalesOrder
/*
* Create a new SalesOrder
*/
function createSalesOrder(options={}) {
constructForm('{% url "api-so-list" %}', {
@ -561,6 +564,24 @@ function createSalesOrder(options={}) {
}
/*
* Launch a modal form to create a new SalesOrderLineItem
*/
function createSalesOrderLineItem(options={}) {
var fields = soLineItemFields(options);
constructForm('{% url "api-so-line-list" %}', {
fields: fields,
method: 'POST',
title: '{% trans "Add Line Item" %}',
onSuccess: function(response) {
handleFormSuccess(response, options);
},
});
}
/*
* Construct a set of fields for a purchase order form
*/